New upstream version 1.48.0+dfsg1

This commit is contained in:
Ximin Luo 2020-12-01 19:18:35 +00:00
parent 1b1a35ee97
commit 2a31497206
41 changed files with 520 additions and 215 deletions

104
Cargo.lock generated
View File

@ -1926,6 +1926,17 @@ dependencies = [
"rustc-hash",
]
[[package]]
name = "measureme"
version = "9.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22bf8d885d073610aee20e7fa205c4341ed32a761dbde96da5fd96301a8d3e82"
dependencies = [
"parking_lot 0.11.0",
"rustc-hash",
"smallvec 1.4.2",
]
[[package]]
name = "memchr"
version = "2.3.3"
@ -2636,9 +2647,9 @@ dependencies = [
[[package]]
name = "racer"
version = "2.1.39"
version = "2.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9424b4650b9c1134d0a1b34dab82319691e1c95fa8af1658fc640deb1b6823c"
checksum = "68c5fb83bc092c10e12ca863ab8922b1833382d5d248aaafca779886d3396a44"
dependencies = [
"bitflags",
"clap",
@ -2963,19 +2974,18 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_arena"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8e941a8fc3878a111d2bbfe78e39522d884136f0b412b12592195f26f653476"
checksum = "477085eefed2f12085c68577cc3827c8c39a31a4a750978aacb9af10f7903174"
dependencies = [
"rustc-ap-rustc_data_structures",
"smallvec 1.4.2",
]
[[package]]
name = "rustc-ap-rustc_ast"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b58b6b035710df7f339a2bf86f6dafa876efd95439540970e24609e33598ca6"
checksum = "4d4ad5ec25f6b3d122354595be0d1b513f37fca3299d9b448b1db28f4a9e4b12"
dependencies = [
"bitflags",
"rustc-ap-rustc_data_structures",
@ -2990,9 +3000,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_ast_passes"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d379a900d6a1f098490d92ab83e87487dcee2e4ec3f04c3ac4512b5117b64e2"
checksum = "0c6d8635298d7736decdb3c6e92e784d3eccde557462a9c10ac11a34fec3d756"
dependencies = [
"itertools 0.9.0",
"rustc-ap-rustc_ast",
@ -3009,9 +3019,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_ast_pretty"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658d925c0da9e3c5cddc5e54f4fa8c03b41aff1fc6dc5e41837c1118ad010ac0"
checksum = "7a61bdb5252e1a95b7715038949e10f07ce770a436fcd497cdd9bc7255471de9"
dependencies = [
"rustc-ap-rustc_ast",
"rustc-ap-rustc_span",
@ -3021,9 +3031,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_attr"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f387037534f34c148aed753622677500e42d190a095670e7ac3fffc09811a59"
checksum = "84520a16cb61bd31e9c27e87eca5d933a9c94ac84f25649bddcc19989275ab2a"
dependencies = [
"rustc-ap-rustc_ast",
"rustc-ap-rustc_ast_pretty",
@ -3040,10 +3050,11 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_data_structures"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14ffd17a37e00d77926a0713f191c59ff3aeb2b551a024c7cfffce14bab79be8"
checksum = "b1cb2b6a38759cf7c0c1434c8b4cbfcab9cd24970d05f960f2ca01226ddb4d68"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if",
"crossbeam-utils 0.7.2",
@ -3051,7 +3062,7 @@ dependencies = [
"indexmap",
"jobserver",
"libc",
"measureme",
"measureme 9.0.0",
"parking_lot 0.11.0",
"rustc-ap-rustc_graphviz",
"rustc-ap-rustc_index",
@ -3070,9 +3081,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_errors"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b3263ddcfa9eb911e54a4e8088878dd9fd10e00d8b99b01033ba4a2733fe91d"
checksum = "46cfb19536426bf9252827a78552d635be207a4be74f4e92832aad82d7f2135c"
dependencies = [
"annotate-snippets 0.8.0",
"atty",
@ -3089,9 +3100,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_expand"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1ab7e68cede8a2273fd8b8623002ce9dc832e061dfc3330e9bcc1fc2a722d73"
checksum = "6273e60042a0ef31f6cfe783c519873993eb426f055be2bc058a48b6ca3934d0"
dependencies = [
"rustc-ap-rustc_ast",
"rustc-ap-rustc_ast_passes",
@ -3112,9 +3123,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_feature"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eea2dc95421bc19bbd4d939399833a882c46b684283b4267ad1fcf982fc043d9"
checksum = "2936e8346157e2848305e509f38aa3ed4e97697975ef68027587f5db6a38703f"
dependencies = [
"rustc-ap-rustc_data_structures",
"rustc-ap-rustc_span",
@ -3122,21 +3133,21 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_fs_util"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e44c1804f09635f83f6cf1e04c2e92f8aeb7b4e850ac6c53d373dab02c13053"
checksum = "9b4c3ae17776b5a5aa441ca510a650f75805e1f5569edd231caa8378552195a4"
[[package]]
name = "rustc-ap-rustc_graphviz"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc491f2b9be6e928f6df6b287549b8d50c48e8eff8638345155f40fa2cfb785d"
checksum = "5611bf0ac0ac49c2a22c959c7d8b17f85f69959293f0e8c4f753eca832fe7ad0"
[[package]]
name = "rustc-ap-rustc_index"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa73f3fed413cdb6290738a10267da17b9ae8e02087334778b9a8c9491c5efc0"
checksum = "ca67cf37c427057192e451c7f912e94ae9a8ca5ad69fd481c011fad3f86982cb"
dependencies = [
"arrayvec",
"rustc-ap-rustc_macros",
@ -3145,18 +3156,18 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_lexer"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e993881244a92f3b44cf43c8f22ae2ca5cefe4f55a34e2b65b72ee66fe5ad077"
checksum = "a5b04cd2159495584d976d501c5394498470c2e94e4f0cebb8186562d407a678"
dependencies = [
"unicode-xid",
]
[[package]]
name = "rustc-ap-rustc_macros"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4effe366556e1d75344764adf4d54cba7c2fad33dbd07588e96d0853831ddc7c"
checksum = "61ec6d623853449acd3c65050d249d3674edab5f6e4d9f074c7bac183269f9c8"
dependencies = [
"proc-macro2",
"quote",
@ -3166,9 +3177,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_parse"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0342675835251571471d3dca9ea1576a853a8dfa1f4b0084db283c861223cb60"
checksum = "ca524bafce4b04d2b49fee2d40b4b26c3ebab9f1a4f731fdf561f00617862f02"
dependencies = [
"bitflags",
"rustc-ap-rustc_ast",
@ -3186,9 +3197,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_serialize"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "438255ed968d73bf6573aa18d3b8d33c0a85ecdfd14160ef09ff813938e0606c"
checksum = "c67920561e58f98c4de864407c92b2dd05ace5d5e5301e17444f10f742c005b7"
dependencies = [
"indexmap",
"smallvec 1.4.2",
@ -3196,9 +3207,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_session"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d61ff76dede8eb827f6805754900d1097a7046f938f950231b62b448f55bf78"
checksum = "0762fd855792e06ef639327237898e4e092ad68150e6a8e19aeb7dc06276ad7a"
dependencies = [
"bitflags",
"getopts",
@ -3217,9 +3228,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_span"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c267f15c3cfc82a8a441d2bf86bcccf299d1eb625822468e3d8ee6f7c5a1c89"
checksum = "0bf3db7b4ca5d21c14c45475df155e5e020c9a3760346945a662c9a9053b49c8"
dependencies = [
"cfg-if",
"md-5",
@ -3236,9 +3247,9 @@ dependencies = [
[[package]]
name = "rustc-ap-rustc_target"
version = "679.0.0"
version = "686.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1b4b266c4d44aac0f7f83b6741d8f0545b03d1ce32f3b5254f2014225cb96c"
checksum = "3aa6560bb9742b276064d67ab9edb5766ecb303f8ae3854835ad3fad4b432188"
dependencies = [
"bitflags",
"rustc-ap-rustc_data_structures",
@ -3323,6 +3334,7 @@ dependencies = [
name = "rustc-workspace-hack"
version = "1.0.0"
dependencies = [
"byteorder",
"crossbeam-utils 0.7.2",
"proc-macro2",
"quote",
@ -3454,7 +3466,7 @@ version = "0.0.0"
dependencies = [
"bitflags",
"libc",
"measureme",
"measureme 0.7.1",
"rustc-demangle",
"rustc_ast",
"rustc_attr",
@ -3520,7 +3532,7 @@ dependencies = [
"indexmap",
"jobserver",
"libc",
"measureme",
"measureme 0.7.1",
"parking_lot 0.11.0",
"rustc-hash",
"rustc-rayon",
@ -3824,7 +3836,7 @@ version = "0.0.0"
dependencies = [
"bitflags",
"chalk-ir",
"measureme",
"measureme 0.7.1",
"polonius-engine",
"rustc-rayon-core",
"rustc_apfloat",
@ -4255,7 +4267,7 @@ dependencies = [
[[package]]
name = "rustfmt-nightly"
version = "1.4.22"
version = "1.4.24"
dependencies = [
"annotate-snippets 0.6.1",
"anyhow",

View File

@ -1,3 +1,143 @@
Version 1.48.0 (2020-11-19)
==========================
Language
--------
- [The `unsafe` keyword is now syntactically permitted on modules.][75857] This
is still rejected *semantically*, but can now be parsed by procedural macros.
Compiler
--------
- [Stabilised the `-C link-self-contained=<yes|no>` compiler flag.][76158] This tells
`rustc` whether to link its own C runtime and libraries or to rely on a external
linker to find them. (Supported only on `windows-gnu`, `linux-musl`, and `wasi` platforms.)
- [You can now use `-C target-feature=+crt-static` on `linux-gnu` targets.][77386]
Note: If you're using cargo you must explicitly pass the `--target` flag.
- [Added tier 2\* support for `aarch64-unknown-linux-musl`.][76420]
\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
Libraries
---------
- [`io::Write` is now implemented for `&ChildStdin` `&Sink`, `&Stdout`,
and `&Stderr`.][76275]
- [All arrays of any length now implement `TryFrom<Vec<T>>`.][76310]
- [The `matches!` macro now supports having a trailing comma.][74880]
- [`Vec<A>` now implements `PartialEq<[B]>` where `A: PartialEq<B>`.][74194]
- [The `RefCell::{replace, replace_with, clone}` methods now all use `#[track_caller]`.][77055]
Stabilized APIs
---------------
- [`slice::as_ptr_range`]
- [`slice::as_mut_ptr_range`]
- [`VecDeque::make_contiguous`]
- [`future::pending`]
- [`future::ready`]
The following previously stable methods are now `const fn`'s:
- [`Option::is_some`]
- [`Option::is_none`]
- [`Option::as_ref`]
- [`Result::is_ok`]
- [`Result::is_err`]
- [`Result::as_ref`]
- [`Ordering::reverse`]
- [`Ordering::then`]
Cargo
-----
Rustdoc
-------
- [You can now link to items in `rustdoc` using the intra-doc link
syntax.][74430] E.g. ``/// Uses [`std::future`]`` will automatically generate
a link to `std::future`'s documentation. See ["Linking to items by
name"][intradoc-links] for more information.
- [You can now specify `#[doc(alias = "<alias>")]` on items to add search aliases
when searching through `rustdoc`'s UI.][75740]
Compatibility Notes
-------------------
- [Promotion of references to `'static` lifetime inside `const fn` now follows the
same rules as inside a `fn` body.][75502] In particular, `&foo()` will not be
promoted to `'static` lifetime any more inside `const fn`s.
- [Associated type bindings on trait objects are now verified to meet the bounds
declared on the trait when checking that they implement the trait.][27675]
- [When trait bounds on associated types or opaque types are ambiguous, the
compiler no longer makes an arbitrary choice on which bound to use.][54121]
- [Fixed recursive nonterminals not being expanded in macros during
pretty-print/reparse check.][77153] This may cause errors if your macro wasn't
correctly handling recursive nonterminal tokens.
- [`&mut` references to non zero-sized types are no longer promoted.][75585]
- [`rustc` will now warn if you use attributes like `#[link_name]` or `#[cold]`
in places where they have no effect.][73461]
- [Updated `_mm256_extract_epi8` and `_mm256_extract_epi16` signatures in
`arch::{x86, x86_64}` to return `i32` to match the vendor signatures.][73166]
- [`mem::uninitialized` will now panic if any inner types inside a struct or enum
disallow zero-initialization.][71274]
- [`#[target_feature]` will now error if used in a place where it has no effect.][78143]
- [Foreign exceptions are now caught by `catch_unwind` and will cause an abort.][70212]
Note: This behaviour is not guaranteed and is still considered undefined behaviour,
see the [`catch_unwind`] documentation for further information.
Internal Only
-------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc and
related tools.
- [Building `rustc` from source now uses `ninja` by default over `make`.][74922]
You can continue building with `make` by setting `ninja=false` in
your `config.toml`.
- [cg_llvm: `fewer_names` in `uncached_llvm_type`][76030]
- [Made `ensure_sufficient_stack()` non-generic][76680]
[78143]: https://github.com/rust-lang/rust/issues/78143
[76680]: https://github.com/rust-lang/rust/pull/76680/
[76030]: https://github.com/rust-lang/rust/pull/76030/
[70212]: https://github.com/rust-lang/rust/pull/70212/
[27675]: https://github.com/rust-lang/rust/issues/27675/
[54121]: https://github.com/rust-lang/rust/issues/54121/
[71274]: https://github.com/rust-lang/rust/pull/71274/
[77386]: https://github.com/rust-lang/rust/pull/77386/
[77153]: https://github.com/rust-lang/rust/pull/77153/
[77055]: https://github.com/rust-lang/rust/pull/77055/
[76275]: https://github.com/rust-lang/rust/pull/76275/
[76310]: https://github.com/rust-lang/rust/pull/76310/
[76420]: https://github.com/rust-lang/rust/pull/76420/
[76158]: https://github.com/rust-lang/rust/pull/76158/
[75857]: https://github.com/rust-lang/rust/pull/75857/
[75585]: https://github.com/rust-lang/rust/pull/75585/
[75740]: https://github.com/rust-lang/rust/pull/75740/
[75502]: https://github.com/rust-lang/rust/pull/75502/
[74880]: https://github.com/rust-lang/rust/pull/74880/
[74922]: https://github.com/rust-lang/rust/pull/74922/
[74430]: https://github.com/rust-lang/rust/pull/74430/
[74194]: https://github.com/rust-lang/rust/pull/74194/
[73461]: https://github.com/rust-lang/rust/pull/73461/
[73166]: https://github.com/rust-lang/rust/pull/73166/
[intradoc-links]: https://doc.rust-lang.org/rustdoc/linking-to-items-by-name.html
[`catch_unwind`]: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
[`Option::is_some`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.is_some
[`Option::is_none`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.is_none
[`Option::as_ref`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_ref
[`Result::is_ok`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.is_ok
[`Result::is_err`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.is_err
[`Result::as_ref`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.as_ref
[`Ordering::reverse`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.reverse
[`Ordering::then`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.then
[`slice::as_ptr_range`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_ptr_range
[`slice::as_mut_ptr_range`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_mut_ptr_range
[`VecDeque::make_contiguous`]: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.make_contiguous
[`future::pending`]: https://doc.rust-lang.org/std/future/fn.pending.html
[`future::ready`]: https://doc.rust-lang.org/std/future/fn.ready.html
Version 1.47.0 (2020-10-08)
==========================
@ -90,7 +230,8 @@ Compatibility Notes
Internal Only
--------
- [Improved default settings for bootstrapping in `x.py`.][73964] You can read details about this change in the ["Changes To `x.py` Defaults"](https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html) post on the Inside Rust blog.
- [Improved default settings for bootstrapping in `x.py`.][73964] You can read details about this change in the ["Changes to `x.py` defaults"](https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html) post on the Inside Rust blog.
[1.47.0-cfg]: https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
[75048]: https://github.com/rust-lang/rust/pull/75048/
@ -297,6 +438,7 @@ Compiler
- [Added the `tiny` value to the `code-model` codegen flag.][72397]
- [Added tier 3 support\* for the `mipsel-sony-psp` target.][72062]
- [Added tier 3 support for the `thumbv7a-uwp-windows-msvc` target.][72133]
- [Upgraded to LLVM 10.][67759]
\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
@ -396,6 +538,7 @@ Internals Only
[72062]: https://github.com/rust-lang/rust/pull/72062/
[72094]: https://github.com/rust-lang/rust/pull/72094/
[72133]: https://github.com/rust-lang/rust/pull/72133/
[67759]: https://github.com/rust-lang/rust/pull/67759/
[71900]: https://github.com/rust-lang/rust/pull/71900/
[71928]: https://github.com/rust-lang/rust/pull/71928/
[71662]: https://github.com/rust-lang/rust/pull/71662/
@ -1270,6 +1413,7 @@ Compiler
`armv7-unknown-linux-musleabi` targets.][63107]
- [Added tier 3 support for the `hexagon-unknown-linux-musl` target.][62814]
- [Added tier 3 support for the `riscv32i-unknown-none-elf` target.][62784]
- [Upgraded to LLVM 9.][62592]
\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
@ -1336,6 +1480,7 @@ Compatibility Notes
[62735]: https://github.com/rust-lang/rust/pull/62735/
[62766]: https://github.com/rust-lang/rust/pull/62766/
[62784]: https://github.com/rust-lang/rust/pull/62784/
[62592]: https://github.com/rust-lang/rust/pull/62592/
[62785]: https://github.com/rust-lang/rust/issues/62785/
[62814]: https://github.com/rust-lang/rust/pull/62814/
[62896]: https://github.com/rust-lang/rust/issues/62896/
@ -2431,6 +2576,7 @@ Compiler
--------
- [Added the `riscv32imc-unknown-none-elf` target.][53822]
- [Added the `aarch64-unknown-netbsd` target][53165]
- [Upgraded to LLVM 8.][53611]
Libraries
---------
@ -2479,6 +2625,7 @@ Misc
[53033]: https://github.com/rust-lang/rust/pull/53033/
[53044]: https://github.com/rust-lang/rust/pull/53044/
[53165]: https://github.com/rust-lang/rust/pull/53165/
[53611]: https://github.com/rust-lang/rust/pull/53611/
[53213]: https://github.com/rust-lang/rust/pull/53213/
[53236]: https://github.com/rust-lang/rust/pull/53236/
[53272]: https://github.com/rust-lang/rust/pull/53272/
@ -2537,6 +2684,7 @@ Compiler
- [Bumped minimum LLVM version to 5.0.][51899]
- [Added `powerpc64le-unknown-linux-musl` target.][51619]
- [Added `aarch64-unknown-hermit` and `x86_64-unknown-hermit` targets.][52861]
- [Upgraded to LLVM 7.][51966]
Libraries
---------
@ -2588,6 +2736,7 @@ Compatibility Notes
[53893]: https://github.com/rust-lang/rust/pull/53893/
[52861]: https://github.com/rust-lang/rust/pull/52861/
[51966]: https://github.com/rust-lang/rust/pull/51966/
[52656]: https://github.com/rust-lang/rust/pull/52656/
[52239]: https://github.com/rust-lang/rust/pull/52239/
[52330]: https://github.com/rust-lang/rust/pull/52330/

View File

@ -1,6 +1,7 @@
use super::{DirectedGraph, WithNumNodes, WithStartNode, WithSuccessors};
use rustc_index::bit_set::BitSet;
use rustc_index::vec::IndexVec;
use std::ops::ControlFlow;
#[cfg(test)]
mod tests;
@ -86,10 +87,6 @@ where
}
}
/// Allows searches to terminate early with a value.
// FIXME (#75744): remove the alias once the generics are in a better order and `C=()`.
pub type ControlFlow<T> = std::ops::ControlFlow<(), T>;
/// The status of a node in the depth-first search.
///
/// See the documentation of `TriColorDepthFirstSearch` to see how a node's status is updated

View File

@ -134,9 +134,52 @@ pub fn diagnostics_registry() -> Registry {
Registry::new(&rustc_error_codes::DIAGNOSTICS)
}
pub struct RunCompiler<'a, 'b> {
at_args: &'a [String],
callbacks: &'b mut (dyn Callbacks + Send),
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
emitter: Option<Box<dyn Write + Send>>,
make_codegen_backend:
Option<Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>>,
}
impl<'a, 'b> RunCompiler<'a, 'b> {
pub fn new(at_args: &'a [String], callbacks: &'b mut (dyn Callbacks + Send)) -> Self {
Self { at_args, callbacks, file_loader: None, emitter: None, make_codegen_backend: None }
}
pub fn set_make_codegen_backend(
&mut self,
make_codegen_backend: Option<
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
>,
) -> &mut Self {
self.make_codegen_backend = make_codegen_backend;
self
}
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self {
self.emitter = emitter;
self
}
pub fn set_file_loader(
&mut self,
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
) -> &mut Self {
self.file_loader = file_loader;
self
}
pub fn run(self) -> interface::Result<()> {
run_compiler(
self.at_args,
self.callbacks,
self.file_loader,
self.emitter,
self.make_codegen_backend,
)
}
}
// Parse args and run the compiler. This is the primary entry point for rustc.
// The FileLoader provides a way to load files from sources other than the file system.
pub fn run_compiler(
fn run_compiler(
at_args: &[String],
callbacks: &mut (dyn Callbacks + Send),
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
@ -1275,7 +1318,7 @@ pub fn main() -> ! {
})
})
.collect::<Vec<_>>();
run_compiler(&args, &mut callbacks, None, None, None)
RunCompiler::new(&args, &mut callbacks).run()
});
// The extra `\t` is necessary to align this label with the others.
print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed());

View File

@ -1,5 +1,5 @@
use rustc_data_structures::graph::iterate::{
ControlFlow, NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
};
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::FnKind;
@ -9,6 +9,7 @@ use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION;
use rustc_span::Span;
use std::ops::ControlFlow;
crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: LocalDefId) {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);

View File

@ -875,6 +875,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// consolidate multiple unresolved import errors into a single diagnostic.
fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImportError> {
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
let orig_unusable_binding = match &import.kind {
ImportKind::Single { target_bindings, .. } => {
Some(mem::replace(&mut self.r.unusable_binding, target_bindings[TypeNS].get()))
}
_ => None,
};
let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
let path_res = self.r.resolve_path(
&import.module_path,
@ -885,6 +891,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
import.crate_lint(),
);
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
if let Some(orig_unusable_binding) = orig_unusable_binding {
self.r.unusable_binding = orig_unusable_binding;
}
import.vis.set(orig_vis);
if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
// Consider erroneous imports used to avoid duplicate diagnostics.
@ -895,8 +904,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
// Consistency checks, analogous to `finalize_macro_resolutions`.
if let Some(initial_module) = import.imported_module.get() {
if !ModuleOrUniformRoot::same_def(module, initial_module) && no_ambiguity {
let msg = "inconsistent resolution for an import";
self.r.session.span_err(import.span, msg);
span_bug!(import.span, "inconsistent resolution for an import");
}
} else {
if self.r.privacy_errors.is_empty() {
@ -918,6 +926,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
}
PathResult::Failed { is_error_from_last_segment: true, span, label, suggestion } => {
if no_ambiguity {
assert!(import.imported_module.get().is_none());
let err = match self.make_path_suggestion(
span,
import.module_path.clone(),

View File

@ -1 +1 @@
1219014599fd873fcb640b675d8a662150c74e40
7eac88abb2e57e752f3302f02be5f3ce3d7adfb4

View File

@ -1280,7 +1280,7 @@ where
#[inline]
fn find<T, B>(
f: &mut impl FnMut(T) -> Option<B>,
) -> impl FnMut((), T) -> ControlFlow<(), B> + '_ {
) -> impl FnMut((), T) -> ControlFlow<B> + '_ {
move |(), x| match f(x) {
Some(x) => ControlFlow::Break(x),
None => ControlFlow::CONTINUE,
@ -2059,7 +2059,7 @@ where
flag: &'a mut bool,
p: &'a mut impl FnMut(&T) -> bool,
mut fold: impl FnMut(Acc, T) -> R + 'a,
) -> impl FnMut(Acc, T) -> ControlFlow<Acc, R> + 'a {
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> + 'a {
move |acc, x| {
if p(&x) {
ControlFlow::from_try(fold(acc, x))
@ -2372,7 +2372,7 @@ where
fn check<T, Acc, R: Try<Ok = Acc>>(
mut n: usize,
mut fold: impl FnMut(Acc, T) -> R,
) -> impl FnMut(Acc, T) -> ControlFlow<Acc, R> {
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> {
move |acc, x| {
n -= 1;
let r = fold(acc, x);
@ -2500,7 +2500,7 @@ where
fn check<'a, T, Acc, R: Try<Ok = Acc>>(
n: &'a mut usize,
mut fold: impl FnMut(Acc, T) -> R + 'a,
) -> impl FnMut(Acc, T) -> ControlFlow<Acc, R> + 'a {
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> + 'a {
move |acc, x| {
*n -= 1;
let r = fold(acc, x);
@ -2685,7 +2685,7 @@ where
state: &'a mut St,
f: &'a mut impl FnMut(&mut St, T) -> Option<B>,
mut fold: impl FnMut(Acc, B) -> R + 'a,
) -> impl FnMut(Acc, T) -> ControlFlow<Acc, R> + 'a {
) -> impl FnMut(Acc, T) -> ControlFlow<R, Acc> + 'a {
move |acc, x| match f(state, x) {
None => ControlFlow::Break(Try::from_ok(acc)),
Some(x) => ControlFlow::from_try(fold(acc, x)),

View File

@ -336,9 +336,7 @@ pub trait DoubleEndedIterator: Iterator {
P: FnMut(&Self::Item) -> bool,
{
#[inline]
fn check<T>(
mut predicate: impl FnMut(&T) -> bool,
) -> impl FnMut((), T) -> ControlFlow<(), T> {
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut((), T) -> ControlFlow<T> {
move |(), x| {
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::CONTINUE }
}

View File

@ -2109,7 +2109,7 @@ pub trait Iterator {
F: FnMut(Self::Item) -> bool,
{
#[inline]
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<(), ()> {
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<()> {
move |(), x| {
if f(x) { ControlFlow::CONTINUE } else { ControlFlow::BREAK }
}
@ -2162,7 +2162,7 @@ pub trait Iterator {
F: FnMut(Self::Item) -> bool,
{
#[inline]
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<(), ()> {
fn check<T>(mut f: impl FnMut(T) -> bool) -> impl FnMut((), T) -> ControlFlow<()> {
move |(), x| {
if f(x) { ControlFlow::BREAK } else { ControlFlow::CONTINUE }
}
@ -2222,9 +2222,7 @@ pub trait Iterator {
P: FnMut(&Self::Item) -> bool,
{
#[inline]
fn check<T>(
mut predicate: impl FnMut(&T) -> bool,
) -> impl FnMut((), T) -> ControlFlow<(), T> {
fn check<T>(mut predicate: impl FnMut(&T) -> bool) -> impl FnMut((), T) -> ControlFlow<T> {
move |(), x| {
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::CONTINUE }
}
@ -2255,9 +2253,7 @@ pub trait Iterator {
F: FnMut(Self::Item) -> Option<B>,
{
#[inline]
fn check<T, B>(
mut f: impl FnMut(T) -> Option<B>,
) -> impl FnMut((), T) -> ControlFlow<(), B> {
fn check<T, B>(mut f: impl FnMut(T) -> Option<B>) -> impl FnMut((), T) -> ControlFlow<B> {
move |(), x| match f(x) {
Some(x) => ControlFlow::Break(x),
None => ControlFlow::CONTINUE,
@ -2296,7 +2292,7 @@ pub trait Iterator {
R: Try<Ok = bool>,
{
#[inline]
fn check<F, T, R>(mut f: F) -> impl FnMut((), T) -> ControlFlow<(), Result<T, R::Error>>
fn check<F, T, R>(mut f: F) -> impl FnMut((), T) -> ControlFlow<Result<T, R::Error>>
where
F: FnMut(&T) -> R,
R: Try<Ok = bool>,

View File

@ -3,7 +3,7 @@ use crate::ops::Try;
/// Used to make try_fold closures more like normal loops
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ControlFlow<C, B> {
pub enum ControlFlow<B, C = ()> {
/// Continue in the loop, using the given value for the next iteration
Continue(C),
/// Exit the loop, yielding the given value
@ -11,7 +11,7 @@ pub enum ControlFlow<C, B> {
}
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
impl<C, B> Try for ControlFlow<C, B> {
impl<B, C> Try for ControlFlow<B, C> {
type Ok = C;
type Error = B;
#[inline]
@ -31,7 +31,21 @@ impl<C, B> Try for ControlFlow<C, B> {
}
}
impl<C, B> ControlFlow<C, B> {
impl<B, C> ControlFlow<B, C> {
/// Returns `true` if this is a `Break` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_break(&self) -> bool {
matches!(*self, ControlFlow::Break(_))
}
/// Returns `true` if this is a `Continue` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_continue(&self) -> bool {
matches!(*self, ControlFlow::Continue(_))
}
/// Converts the `ControlFlow` into an `Option` which is `Some` if the
/// `ControlFlow` was `Break` and `None` otherwise.
#[inline]
@ -44,7 +58,7 @@ impl<C, B> ControlFlow<C, B> {
}
}
impl<R: Try> ControlFlow<R::Ok, R> {
impl<R: Try> ControlFlow<R, R::Ok> {
/// Create a `ControlFlow` from any type implementing `Try`.
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[inline]
@ -66,7 +80,7 @@ impl<R: Try> ControlFlow<R::Ok, R> {
}
}
impl<B> ControlFlow<(), B> {
impl<B> ControlFlow<B, ()> {
/// It's frequently the case that there's no value needed with `Continue`,
/// so this provides a way to avoid typing `(())`, if you prefer it.
///
@ -88,7 +102,7 @@ impl<B> ControlFlow<(), B> {
pub const CONTINUE: Self = ControlFlow::Continue(());
}
impl<C> ControlFlow<C, ()> {
impl<C> ControlFlow<(), C> {
/// APIs like `try_for_each` don't need values with `Break`,
/// so this provides a way to avoid typing `(())`, if you prefer it.
///

View File

@ -781,6 +781,34 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
}
}
impl<T: ?Sized> Pin<&'static T> {
/// Get a pinned reference from a static reference.
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
// SAFETY: The 'static borrow guarantees the data will not be
// moved/invalidated until it gets dropped (which is never).
unsafe { Pin::new_unchecked(r) }
}
}
impl<T: ?Sized> Pin<&'static mut T> {
/// Get a pinned mutable reference from a static mutable reference.
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
// SAFETY: The 'static borrow guarantees the data will not be
// moved/invalidated until it gets dropped (which is never).
unsafe { Pin::new_unchecked(r) }
}
}
#[stable(feature = "pin", since = "1.33.0")]
impl<P: Deref> Deref for Pin<P> {
type Target = P::Target;

View File

@ -9,6 +9,7 @@ use crate::cell::RefCell;
use crate::fmt;
use crate::io::{self, BufReader, Initializer, IoSlice, IoSliceMut, LineWriter};
use crate::lazy::SyncOnceCell;
use crate::pin::Pin;
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{Mutex, MutexGuard};
use crate::sys::stdio;
@ -488,7 +489,7 @@ pub struct Stdout {
// FIXME: this should be LineWriter or BufWriter depending on the state of
// stdout (tty or not). Note that if this is not line buffered it
// should also flush-on-panic or some form of flush-on-abort.
inner: &'static ReentrantMutex<RefCell<LineWriter<StdoutRaw>>>,
inner: Pin<&'static ReentrantMutex<RefCell<LineWriter<StdoutRaw>>>>,
}
/// A locked reference to the `Stdout` handle.
@ -548,25 +549,29 @@ pub struct StdoutLock<'a> {
pub fn stdout() -> Stdout {
static INSTANCE: SyncOnceCell<ReentrantMutex<RefCell<LineWriter<StdoutRaw>>>> =
SyncOnceCell::new();
fn cleanup() {
if let Some(instance) = INSTANCE.get() {
// Flush the data and disable buffering during shutdown
// by replacing the line writer by one with zero
// buffering capacity.
// We use try_lock() instead of lock(), because someone
// might have leaked a StdoutLock, which would
// otherwise cause a deadlock here.
if let Some(lock) = Pin::static_ref(instance).try_lock() {
*lock.borrow_mut() = LineWriter::with_capacity(0, stdout_raw());
}
}
}
Stdout {
inner: INSTANCE.get_or_init(|| unsafe {
let _ = sys_common::at_exit(|| {
if let Some(instance) = INSTANCE.get() {
// Flush the data and disable buffering during shutdown
// by replacing the line writer by one with zero
// buffering capacity.
// We use try_lock() instead of lock(), because someone
// might have leaked a StdoutLock, which would
// otherwise cause a deadlock here.
if let Some(lock) = instance.try_lock() {
*lock.borrow_mut() = LineWriter::with_capacity(0, stdout_raw());
}
}
});
let r = ReentrantMutex::new(RefCell::new(LineWriter::new(stdout_raw())));
r.init();
r
}),
inner: Pin::static_ref(&INSTANCE).get_or_init_pin(
|| unsafe {
let _ = sys_common::at_exit(cleanup);
ReentrantMutex::new(RefCell::new(LineWriter::new(stdout_raw())))
},
|mutex| unsafe { mutex.init() },
),
}
}
@ -698,7 +703,7 @@ impl fmt::Debug for StdoutLock<'_> {
/// an error.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Stderr {
inner: &'static ReentrantMutex<RefCell<StderrRaw>>,
inner: Pin<&'static ReentrantMutex<RefCell<StderrRaw>>>,
}
/// A locked reference to the `Stderr` handle.
@ -754,21 +759,16 @@ pub struct StderrLock<'a> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stderr() -> Stderr {
// Note that unlike `stdout()` we don't use `Lazy` here which registers a
// destructor. Stderr is not buffered nor does the `stderr_raw` type consume
// any owned resources, so there's no need to run any destructors at some
// point in the future.
//
// This has the added benefit of allowing `stderr` to be usable during
// process shutdown as well!
// Note that unlike `stdout()` we don't use `at_exit` here to register a
// destructor. Stderr is not buffered , so there's no need to run a
// destructor for flushing the buffer
static INSTANCE: SyncOnceCell<ReentrantMutex<RefCell<StderrRaw>>> = SyncOnceCell::new();
Stderr {
inner: INSTANCE.get_or_init(|| unsafe {
let r = ReentrantMutex::new(RefCell::new(stderr_raw()));
r.init();
r
}),
inner: Pin::static_ref(&INSTANCE).get_or_init_pin(
|| unsafe { ReentrantMutex::new(RefCell::new(stderr_raw())) },
|mutex| unsafe { mutex.init() },
),
}
}

View File

@ -10,6 +10,7 @@ use crate::{
mem::MaybeUninit,
ops::{Deref, Drop},
panic::{RefUnwindSafe, UnwindSafe},
pin::Pin,
sync::Once,
};
@ -297,6 +298,60 @@ impl<T> SyncOnceCell<T> {
Ok(unsafe { self.get_unchecked() })
}
/// Internal-only API that gets the contents of the cell, initializing it
/// in two steps with `f` and `g` if the cell was empty.
///
/// `f` is called to construct the value, which is then moved into the cell
/// and given as a (pinned) mutable reference to `g` to finish
/// initialization.
///
/// This allows `g` to inspect an manipulate the value after it has been
/// moved into its final place in the cell, but before the cell is
/// considered initialized.
///
/// # Panics
///
/// If `f` or `g` panics, the panic is propagated to the caller, and the
/// cell remains uninitialized.
///
/// With the current implementation, if `g` panics, the value from `f` will
/// not be dropped. This should probably be fixed if this is ever used for
/// a type where this matters.
///
/// It is an error to reentrantly initialize the cell from `f`. The exact
/// outcome is unspecified. Current implementation deadlocks, but this may
/// be changed to a panic in the future.
pub(crate) fn get_or_init_pin<F, G>(self: Pin<&Self>, f: F, g: G) -> Pin<&T>
where
F: FnOnce() -> T,
G: FnOnce(Pin<&mut T>),
{
if let Some(value) = self.get_ref().get() {
// SAFETY: The inner value was already initialized, and will not be
// moved anymore.
return unsafe { Pin::new_unchecked(value) };
}
let slot = &self.value;
// Ignore poisoning from other threads
// If another thread panics, then we'll be able to run our closure
self.once.call_once_force(|_| {
let value = f();
// SAFETY: We use the Once (self.once) to guarantee unique access
// to the UnsafeCell (slot).
let value: &mut T = unsafe { (&mut *slot.get()).write(value) };
// SAFETY: The value has been written to its final place in
// self.value. We do not to move it anymore, which we promise here
// with a Pin<&mut T>.
g(unsafe { Pin::new_unchecked(value) });
});
// SAFETY: The inner value has been initialized, and will not be moved
// anymore.
unsafe { Pin::new_unchecked(self.get_ref().get_unchecked()) }
}
/// Consumes the `SyncOnceCell`, returning the wrapped value. Returns
/// `None` if the cell was empty.
///

View File

@ -264,6 +264,7 @@
#![feature(format_args_nl)]
#![feature(gen_future)]
#![feature(generator_trait)]
#![feature(get_mut_unchecked)]
#![feature(global_asm)]
#![feature(hashmap_internals)]
#![feature(int_error_internals)]
@ -290,6 +291,7 @@
#![feature(panic_info_message)]
#![feature(panic_internals)]
#![feature(panic_unwind)]
#![feature(pin_static_ref)]
#![feature(prelude_import)]
#![feature(ptr_internals)]
#![feature(raw)]

View File

@ -1126,7 +1126,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
// Kernel prior to 4.5 don't have copy_file_range
// We store the availability in a global to avoid unnecessary syscalls
static HAS_COPY_FILE_RANGE: AtomicBool = AtomicBool::new(true);
static HAS_COPY_FILE_RANGE: AtomicBool = AtomicBool::new(false);
unsafe fn copy_file_range(
fd_in: libc::c_int,

View File

@ -1,10 +1,10 @@
#[cfg(all(test, not(target_os = "emscripten")))]
mod tests;
use crate::fmt;
use crate::marker;
use crate::marker::PhantomPinned;
use crate::ops::Deref;
use crate::panic::{RefUnwindSafe, UnwindSafe};
use crate::pin::Pin;
use crate::sys::mutex as sys;
/// A re-entrant mutual exclusion
@ -15,6 +15,7 @@ use crate::sys::mutex as sys;
pub struct ReentrantMutex<T> {
inner: sys::ReentrantMutex,
data: T,
_pinned: PhantomPinned,
}
unsafe impl<T: Send> Send for ReentrantMutex<T> {}
@ -37,10 +38,10 @@ impl<T> RefUnwindSafe for ReentrantMutex<T> {}
/// guarded data.
#[must_use = "if unused the ReentrantMutex will immediately unlock"]
pub struct ReentrantMutexGuard<'a, T: 'a> {
lock: &'a ReentrantMutex<T>,
lock: Pin<&'a ReentrantMutex<T>>,
}
impl<T> !marker::Send for ReentrantMutexGuard<'_, T> {}
impl<T> !Send for ReentrantMutexGuard<'_, T> {}
impl<T> ReentrantMutex<T> {
/// Creates a new reentrant mutex in an unlocked state.
@ -51,7 +52,11 @@ impl<T> ReentrantMutex<T> {
/// once this mutex is in its final resting place, and only then are the
/// lock/unlock methods safe.
pub const unsafe fn new(t: T) -> ReentrantMutex<T> {
ReentrantMutex { inner: sys::ReentrantMutex::uninitialized(), data: t }
ReentrantMutex {
inner: sys::ReentrantMutex::uninitialized(),
data: t,
_pinned: PhantomPinned,
}
}
/// Initializes this mutex so it's ready for use.
@ -60,8 +65,8 @@ impl<T> ReentrantMutex<T> {
///
/// Unsafe to call more than once, and must be called after this will no
/// longer move in memory.
pub unsafe fn init(&self) {
self.inner.init();
pub unsafe fn init(self: Pin<&mut Self>) {
self.get_unchecked_mut().inner.init()
}
/// Acquires a mutex, blocking the current thread until it is able to do so.
@ -76,9 +81,9 @@ impl<T> ReentrantMutex<T> {
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return failure if the mutex would otherwise be
/// acquired.
pub fn lock(&self) -> ReentrantMutexGuard<'_, T> {
pub fn lock(self: Pin<&Self>) -> ReentrantMutexGuard<'_, T> {
unsafe { self.inner.lock() }
ReentrantMutexGuard::new(&self)
ReentrantMutexGuard { lock: self }
}
/// Attempts to acquire this lock.
@ -93,8 +98,12 @@ impl<T> ReentrantMutex<T> {
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return failure if the mutex would otherwise be
/// acquired.
pub fn try_lock(&self) -> Option<ReentrantMutexGuard<'_, T>> {
if unsafe { self.inner.try_lock() } { Some(ReentrantMutexGuard::new(&self)) } else { None }
pub fn try_lock(self: Pin<&Self>) -> Option<ReentrantMutexGuard<'_, T>> {
if unsafe { self.inner.try_lock() } {
Some(ReentrantMutexGuard { lock: self })
} else {
None
}
}
}
@ -107,30 +116,6 @@ impl<T> Drop for ReentrantMutex<T> {
}
}
impl<T: fmt::Debug + 'static> fmt::Debug for ReentrantMutex<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.try_lock() {
Some(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(),
None => {
struct LockedPlaceholder;
impl fmt::Debug for LockedPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("<locked>")
}
}
f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish()
}
}
}
}
impl<'mutex, T> ReentrantMutexGuard<'mutex, T> {
fn new(lock: &'mutex ReentrantMutex<T>) -> ReentrantMutexGuard<'mutex, T> {
ReentrantMutexGuard { lock }
}
}
impl<T> Deref for ReentrantMutexGuard<'_, T> {
type Target = T;

View File

@ -1,4 +1,6 @@
use crate::boxed::Box;
use crate::cell::RefCell;
use crate::pin::Pin;
use crate::sync::Arc;
use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
use crate::thread;
@ -6,10 +8,11 @@ use crate::thread;
#[test]
fn smoke() {
let m = unsafe {
let m = ReentrantMutex::new(());
m.init();
let mut m = Box::pin(ReentrantMutex::new(()));
m.as_mut().init();
m
};
let m = m.as_ref();
{
let a = m.lock();
{
@ -27,18 +30,19 @@ fn smoke() {
#[test]
fn is_mutex() {
let m = unsafe {
let m = Arc::new(ReentrantMutex::new(RefCell::new(0)));
m.init();
m
// FIXME: Simplify this if Arc gets a Arc::get_pin_mut.
let mut m = Arc::new(ReentrantMutex::new(RefCell::new(0)));
Pin::new_unchecked(Arc::get_mut_unchecked(&mut m)).init();
Pin::new_unchecked(m)
};
let m2 = m.clone();
let lock = m.lock();
let lock = m.as_ref().lock();
let child = thread::spawn(move || {
let lock = m2.lock();
let lock = m2.as_ref().lock();
assert_eq!(*lock.borrow(), 4950);
});
for i in 0..100 {
let lock = m.lock();
let lock = m.as_ref().lock();
*lock.borrow_mut() += i;
}
drop(lock);
@ -48,20 +52,21 @@ fn is_mutex() {
#[test]
fn trylock_works() {
let m = unsafe {
let m = Arc::new(ReentrantMutex::new(()));
m.init();
m
// FIXME: Simplify this if Arc gets a Arc::get_pin_mut.
let mut m = Arc::new(ReentrantMutex::new(()));
Pin::new_unchecked(Arc::get_mut_unchecked(&mut m)).init();
Pin::new_unchecked(m)
};
let m2 = m.clone();
let _lock = m.try_lock();
let _lock2 = m.try_lock();
let _lock = m.as_ref().try_lock();
let _lock2 = m.as_ref().try_lock();
thread::spawn(move || {
let lock = m2.try_lock();
let lock = m2.as_ref().try_lock();
assert!(lock.is_none());
})
.join()
.unwrap();
let _lock3 = m.try_lock();
let _lock3 = m.as_ref().try_lock();
}
pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell<u32>>);

View File

@ -1575,13 +1575,13 @@ impl Step for Miri {
let miri = builder
.ensure(tool::Miri { compiler, target, extra_features: Vec::new() })
.or_else(|| {
missing_tool("miri", builder.build.config.missing_tools);
missing_tool("miri", true);
None
})?;
let cargomiri = builder
.ensure(tool::CargoMiri { compiler, target, extra_features: Vec::new() })
.or_else(|| {
missing_tool("cargo miri", builder.build.config.missing_tools);
missing_tool("cargo miri", true);
None
})?;
@ -2377,6 +2377,25 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
return;
}
if let Some(config) = builder.config.target_config.get(&target) {
if config.llvm_config.is_some() && !builder.config.llvm_from_ci {
// If the LLVM was externally provided, then we don't currently copy
// artifacts into the sysroot. This is not necessarily the right
// choice (in particular, it will require the LLVM dylib to be in
// the linker's load path at runtime), but the common use case for
// external LLVMs is distribution provided LLVMs, and in that case
// they're usually in the standard search path (e.g., /usr/lib) and
// copying them here is going to cause problems as we may end up
// with the wrong files and isn't what distributions want.
//
// This behavior may be revisited in the future though.
//
// If the LLVM is coming from ourselves (just from CI) though, we
// still want to install it, as it otherwise won't be available.
return;
}
}
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib
// instead of libLLVM-11-rust-....dylib, as on linux. It's not entirely
// clear why this is the case, though. llvm-config will emit the versioned

View File

@ -63,7 +63,7 @@ fi
#
# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
# either automatically or manually.
export RUST_RELEASE_CHANNEL=beta
export RUST_RELEASE_CHANNEL=stable
# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting

View File

@ -46,7 +46,9 @@ fn write_header(out: &mut String, class: Option<&str>) {
}
fn write_code(out: &mut String, src: &str) {
Classifier::new(src).highlight(&mut |highlight| {
// This replace allows to fix how the code source with DOS backline characters is displayed.
let src = src.replace("\r\n", "\n");
Classifier::new(&src).highlight(&mut |highlight| {
match highlight {
Highlight::Token { text, class } => string(out, Escape(text), class),
Highlight::EnterSpan { class } => enter_span(out, class),

View File

@ -0,0 +1,3 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">foo</span>() {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;foo&quot;</span>);
}

View File

@ -1,17 +1,6 @@
use super::write_code;
use expect_test::expect_file;
#[test]
fn test_html_highlighting() {
let src = include_str!("fixtures/sample.rs");
let html = {
let mut out = String::new();
write_code(&mut out, src);
format!("{}<pre><code>{}</code></pre>\n", STYLE, out)
};
expect_file!["fixtures/sample.html"].assert_eq(&html);
}
const STYLE: &str = r#"
<style>
.kw { color: #8959A8; }
@ -23,3 +12,24 @@ const STYLE: &str = r#"
.question-mark { color: #ff9011; }
</style>
"#;
#[test]
fn test_html_highlighting() {
let src = include_str!("fixtures/sample.rs");
let html = {
let mut out = String::new();
write_code(&mut out, src);
format!("{}<pre><code>{}</code></pre>\n", STYLE, out)
};
expect_file!["fixtures/sample.html"].assert_eq(&html);
}
#[test]
fn test_dos_backline() {
let src = "pub fn foo() {\r\n\
println!(\"foo\");\r\n\
}\r\n";
let mut html = String::new();
write_code(&mut html, src);
expect_file!["fixtures/dos_line.html"].assert_eq(&html);
}

View File

@ -26,13 +26,8 @@ fn main() {
let mut count = 1;
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
rustc_driver::catch_fatal_errors(|| {
rustc_driver::run_compiler(
&args,
&mut TestCalls { count: &mut count },
None,
None,
None,
).ok();
}).ok();
rustc_driver::RunCompiler::new(&args, &mut TestCalls { count: &mut count }).run().ok();
})
.ok();
assert_eq!(count, 2);
}

View File

@ -1,3 +1,5 @@
// check-pass
// Minimized case from #62767.
mod m {
pub enum Same {
@ -9,7 +11,7 @@ use m::*;
// The variant `Same` introduced by this import is also considered when resolving the prefix
// `Same::` during import validation to avoid effects similar to time travel (#74556).
use Same::Same; //~ ERROR unresolved import `Same`
use Same::Same;
// Case from #74556.
mod foo {
@ -21,8 +23,8 @@ mod foo {
}
use foo::*;
use bar::bar; //~ ERROR unresolved import `bar::bar`
//~| ERROR inconsistent resolution for an import
use bar::bar;
use bar::foobar;
fn main() {}

View File

@ -1,21 +0,0 @@
error: inconsistent resolution for an import
--> $DIR/issue-62767.rs:24:5
|
LL | use bar::bar;
| ^^^^^^^^
error[E0432]: unresolved import `Same`
--> $DIR/issue-62767.rs:12:5
|
LL | use Same::Same;
| ^^^^ `Same` is a variant, not a module
error[E0432]: unresolved import `bar::bar`
--> $DIR/issue-62767.rs:24:5
|
LL | use bar::bar;
| ^^^^^^^^ no `bar` in `foo::bar::bar`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0432`.

View File

@ -7,7 +7,6 @@ use std::path::{Path, PathBuf};
use tar::Archive;
const DEFAULT_TARGET: &str = "x86_64-unknown-linux-gnu";
const RUSTC_VERSION: &str = include_str!("../../../version");
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
pub(crate) enum PkgType {
@ -172,10 +171,10 @@ impl Versions {
) -> Result<String, Error> {
let component_name = package.tarball_component_name();
let version = match self.channel.as_str() {
"stable" => RUSTC_VERSION.into(),
"stable" => self.rustc_version().into(),
"beta" => "beta".into(),
"nightly" => "nightly".into(),
_ => format!("{}-dev", RUSTC_VERSION),
_ => format!("{}-dev", self.rustc_version()),
};
if package.target_independent() {
@ -186,6 +185,7 @@ impl Versions {
}
pub(crate) fn rustc_version(&self) -> &str {
RUSTC_VERSION
const RUSTC_VERSION: &str = include_str!("../../../version");
RUSTC_VERSION.trim()
}
}

View File

@ -61,6 +61,7 @@ features = [
]
[dependencies]
byteorder = { version = "1", features = ['default', 'std'] }
curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true }
crossbeam-utils = { version = "0.7.2", features = ["nightly"] }
proc-macro2 = { version = "1", features = ["default"] }

View File

@ -1 +1 @@
1.48.0-beta.8 (121901459 2020-11-08)
1.48.0 (7eac88abb 2020-11-16)