From 1fc8068ed1e1891e3d29f5bfa0dd37a29842071f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 29 Nov 2021 12:08:36 -0500 Subject: [PATCH 1/4] Cherry-pick release notes --- RELEASES.md | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 59d4d4507ffce..4b9b20f4cba60 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,117 @@ +Version 1.57.0 (2021-12-02) +========================== + +Language +-------- + +- [Macro attributes may follow `#[derive]` and will see the original (pre-`cfg`) input.][87220] +- [Accept curly-brace macros in expressions, like `m!{ .. }.method()` and `m!{ .. }?`.][88690] +- [Allow panicking in constant evaluation.][89508] + +Compiler +-------- + +- [Create more accurate debuginfo for vtables.][89597] +- [Add `armv6k-nintendo-3ds` at Tier 3\*.][88529] +- [Add `armv7-unknown-linux-uclibceabihf` at Tier 3\*.][88952] +- [Add `m68k-unknown-linux-gnu` at Tier 3\*.][88321] +- [Add SOLID targets at Tier 3\*:][86191] `aarch64-kmc-solid_asp3`, `armv7a-kmc-solid_asp3-eabi`, `armv7a-kmc-solid_asp3-eabihf` + +\* Refer to Rust's [platform support page][platform-support-doc] for more + information on Rust's tiered platform support. + +Libraries +--------- + +- [Avoid allocations and copying in `Vec::leak`][89337] +- [Add `#[repr(i8)]` to `Ordering`][89507] +- [Optimize `File::read_to_end` and `read_to_string`][89582] +- [Update to Unicode 14.0][89614] +- [Many more functions are marked `#[must_use]`][89692], producing a warning + when ignoring their return value. This helps catch mistakes such as expecting + a function to mutate a value in place rather than return a new value. + +Stabilised APIs +--------------- + +- [`[T; N]::as_mut_slice`][`array::as_mut_slice`] +- [`[T; N]::as_slice`][`array::as_slice`] +- [`collections::TryReserveError`] +- [`HashMap::try_reserve`] +- [`HashSet::try_reserve`] +- [`String::try_reserve`] +- [`String::try_reserve_exact`] +- [`Vec::try_reserve`] +- [`Vec::try_reserve_exact`] +- [`VecDeque::try_reserve`] +- [`VecDeque::try_reserve_exact`] +- [`Iterator::map_while`] +- [`iter::MapWhile`] +- [`proc_macro::is_available`] +- [`Command::get_program`] +- [`Command::get_args`] +- [`Command::get_envs`] +- [`Command::get_current_dir`] +- [`CommandArgs`] +- [`CommandEnvs`] + +These APIs are now usable in const contexts: + +- [`hint::unreachable_unchecked`] + +Cargo +----- + +- [Stabilize custom profiles][cargo/9943] + +Compatibility notes +------------------- + +Internal changes +---------------- +These changes provide no direct user facing benefits, but represent significant +improvements to the internals and overall performance of rustc +and related tools. + +- [Added an experimental backend for codegen with `libgccjit`.][87260] + +[86191]: https://github.com/rust-lang/rust/pull/86191/ +[87220]: https://github.com/rust-lang/rust/pull/87220/ +[87260]: https://github.com/rust-lang/rust/pull/87260/ +[88243]: https://github.com/rust-lang/rust/pull/88243/ +[88321]: https://github.com/rust-lang/rust/pull/88321/ +[88529]: https://github.com/rust-lang/rust/pull/88529/ +[88690]: https://github.com/rust-lang/rust/pull/88690/ +[88952]: https://github.com/rust-lang/rust/pull/88952/ +[89337]: https://github.com/rust-lang/rust/pull/89337/ +[89507]: https://github.com/rust-lang/rust/pull/89507/ +[89508]: https://github.com/rust-lang/rust/pull/89508/ +[89582]: https://github.com/rust-lang/rust/pull/89582/ +[89597]: https://github.com/rust-lang/rust/pull/89597/ +[89614]: https://github.com/rust-lang/rust/pull/89614/ +[89692]: https://github.com/rust-lang/rust/issues/89692/ +[cargo/9943]: https://github.com/rust-lang/cargo/pull/9943/ +[`array::as_mut_slice`]: https://doc.rust-lang.org/std/primitive.array.html#method.as_mut_slice +[`array::as_slice`]: https://doc.rust-lang.org/std/primitive.array.html#method.as_slice +[`collections::TryReserveError`]: https://doc.rust-lang.org/std/collections/struct.TryReserveError.html +[`HashMap::try_reserve`]: https://doc.rust-lang.org/std/collections/hash_map/struct.HashMap.html#method.try_reserve +[`HashSet::try_reserve`]: https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.try_reserve +[`String::try_reserve`]: https://doc.rust-lang.org/alloc/string/struct.String.html#method.try_reserve +[`String::try_reserve_exact`]: https://doc.rust-lang.org/alloc/string/struct.String.html#method.try_reserve_exact +[`Vec::try_reserve`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.try_reserve +[`Vec::try_reserve_exact`]: https://doc.rust-lang.org/std/vec/struct.Vec.html#method.try_reserve_exact +[`VecDeque::try_reserve`]: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.try_reserve +[`VecDeque::try_reserve_exact`]: https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.try_reserve_exact +[`Iterator::map_while`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.map_while +[`iter::MapWhile`]: https://doc.rust-lang.org/std/iter/struct.MapWhile.html +[`proc_macro::is_available`]: https://doc.rust-lang.org/proc_macro/fn.is_available.html +[`Command::get_program`]: https://doc.rust-lang.org/std/process/struct.Command.html#method.get_program +[`Command::get_args`]: https://doc.rust-lang.org/std/process/struct.Command.html#method.get_args +[`Command::get_envs`]: https://doc.rust-lang.org/std/process/struct.Command.html#method.get_envs +[`Command::get_current_dir`]: https://doc.rust-lang.org/std/process/struct.Command.html#method.get_current_dir +[`CommandArgs`]: https://doc.rust-lang.org/std/process/struct.CommandArgs.html +[`CommandEnvs`]: https://doc.rust-lang.org/std/process/struct.CommandEnvs.html + Version 1.56.1 (2021-11-01) =========================== @@ -85,7 +199,7 @@ Cargo - [Cargo supports specifying a minimum supported Rust version in Cargo.toml.][`rust-version`] This has no effect at present on dependency version selection. We encourage crates to specify their minimum supported Rust version, and we encourage CI systems - that support Rust code to include a crate's specified minimum version in the text matrix for that + that support Rust code to include a crate's specified minimum version in the test matrix for that crate by default. Compatibility notes From fd046c334c2f861bb4f7e434125ab21c23a5940d Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 29 Nov 2021 12:08:55 -0500 Subject: [PATCH 2/4] Bump to stable channel --- src/ci/channel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/channel b/src/ci/channel index 65b2df87f7df3..2bf5ad0447d33 100644 --- a/src/ci/channel +++ b/src/ci/channel @@ -1 +1 @@ -beta +stable From 7f56b9a50925c3d03db6357e87be7de91cf3da7b Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Wed, 24 Nov 2021 21:22:42 +0100 Subject: [PATCH 3/4] Disable outline atomics to aarch64-unknown-linux-musl. This is a functionally equivalent, minimally invasive backport of #90044, which fixes the problem that compiling any binary with the target aarch64-unknown-linux-musl fails unless lld is used for linking (#89626). I have tested this backport by building aarch64-unknown-linux-gnu, installing the std libraries for the -musl and -gnu variants in rustc-beta-aarch64-unknown-linux-gnu/rustc/lib/rustlib and running helloworld successfully for both targets on arm64 hardware. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index b15efcd0dc2b1..c2136f16120ac 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -417,7 +417,10 @@ pub fn llvm_global_features(sess: &Session) -> Vec { features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter)); // FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12. - if get_version() >= (12, 0, 0) && sess.target.llvm_target.contains("aarch64-unknown-linux") { + if get_version() >= (12, 0, 0) + && sess.target.llvm_target.contains("aarch64-unknown-linux") + && sess.target.llvm_target != "aarch64-unknown-linux-musl" + { features.push("+outline-atomics".to_string()); } From a9174cf94e72378d7aa8c5eb4fb9d85f392c00df Mon Sep 17 00:00:00 2001 From: jackh726 Date: Thu, 25 Nov 2021 21:16:27 -0500 Subject: [PATCH 4/4] Don't treat unnormalized function arguments as well-formed --- .../src/type_check/free_region_relations.rs | 6 ++-- .../rustc_typeck/src/check/compare_method.rs | 7 +---- compiler/rustc_typeck/src/check/mod.rs | 1 - compiler/rustc_typeck/src/check/wfcheck.rs | 5 ---- ...d-bounds-unnorm-associated-type.nll.stderr | 14 +++++++++ .../implied-bounds-unnorm-associated-type.rs | 22 ++++++++++++++ ...plied-bounds-unnorm-associated-type.stderr | 13 ++++++++ .../generic-associated-types/issue-87748.rs | 30 ------------------- 8 files changed, 52 insertions(+), 46 deletions(-) create mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr create mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type.rs create mode 100644 src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-87748.rs diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 70c74940d6235..84fa9bbca85ad 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -258,7 +258,6 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> { debug!("build: input_or_output={:?}", ty); // We add implied bounds from both the unnormalized and normalized ty // See issue #87748 - let constraints_implied_1 = self.add_implied_bounds(ty); let TypeOpOutput { output: norm_ty, constraints: constraints1, .. } = self .param_env .and(type_op::normalize::Normalize::new(ty)) @@ -286,10 +285,9 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> { // } // ``` // Both &Self::Bar and &() are WF - let constraints_implied_2 = - if ty != norm_ty { self.add_implied_bounds(norm_ty) } else { None }; + let constraints_implied = self.add_implied_bounds(norm_ty); normalized_inputs_and_output.push(norm_ty); - constraints1.into_iter().chain(constraints_implied_1).chain(constraints_implied_2) + constraints1.into_iter().chain(constraints_implied) }) .collect(); diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index d5b631df058ae..5e12497f3493b 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -266,14 +266,9 @@ fn compare_predicate_entailment<'tcx>( // First liberate late bound regions and subst placeholders let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, tcx.fn_sig(trait_m.def_id)); let trait_sig = trait_sig.subst(tcx, trait_to_placeholder_substs); - // Next, add all inputs and output as well-formed tys. Importantly, - // we have to do this before normalization, since the normalized ty may - // not contain the input parameters. See issue #87748. - wf_tys.extend(trait_sig.inputs_and_output.iter()); let trait_sig = inh.normalize_associated_types_in(impl_m_span, impl_m_hir_id, param_env, trait_sig); - // Also add the resulting inputs and output as well-formed. - // This probably isn't strictly necessary. + // Add the resulting inputs and output as well-formed. wf_tys.extend(trait_sig.inputs_and_output.iter()); let trait_fty = tcx.mk_fn_ptr(ty::Binder::dummy(trait_sig)); diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 7450b4a4ef1c3..a037bb6647825 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -391,7 +391,6 @@ fn typeck_with_fallback<'tcx>( let mut wf_tys = FxHashSet::default(); // Compute the fty from point of view of inside the fn. let fn_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), fn_sig); - wf_tys.extend(fn_sig.inputs_and_output.iter()); let fn_sig = inh.normalize_associated_types_in( body.value.span, body_id.hir_id, diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 30aab38b1eb85..d737fe9ac86e4 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -960,11 +960,6 @@ fn check_fn_or_method<'fcx, 'tcx>( ) { let sig = fcx.tcx.liberate_late_bound_regions(def_id, sig); - // Unnormalized types in signature are WF too - implied_bounds.extend(sig.inputs()); - // FIXME(#27579) return types should not be implied bounds - implied_bounds.insert(sig.output()); - // Normalize the input and output types one at a time, using a different // `WellFormedLoc` for each. We cannot call `normalize_associated_types` // on the entire `FnSig`, since this would use the same `WellFormedLoc` diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr new file mode 100644 index 0000000000000..e37ec7f26651c --- /dev/null +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.nll.stderr @@ -0,0 +1,14 @@ +error: lifetime may not live long enough + --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + | +LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | s + | ^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + +error: aborting due to previous error + diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs new file mode 100644 index 0000000000000..2e5ac7d7398eb --- /dev/null +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.rs @@ -0,0 +1,22 @@ +// check-fail +// See issue #91068. Types in the substs of an associated type can't be implied +// to be WF, since they don't actually have to be constructed. + +trait Trait { + type Type; +} + +impl Trait for T { + type Type = (); +} + +fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { + s //~ ERROR lifetime mismatch [E0623] +} + +fn main() { + let x = String::from("Hello World!"); + let y = f(&x, ()); + drop(x); + println!("{}", y); +} diff --git a/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr b/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr new file mode 100644 index 0000000000000..93ab5dceee947 --- /dev/null +++ b/src/test/ui/fn/implied-bounds-unnorm-associated-type.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/implied-bounds-unnorm-associated-type.rs:14:5 + | +LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str { + | ------- ---------- + | | + | these two types are declared with different lifetimes... +LL | s + | ^ ...but data from `s` flows here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/generic-associated-types/issue-87748.rs b/src/test/ui/generic-associated-types/issue-87748.rs deleted file mode 100644 index 93c3b3937cb81..0000000000000 --- a/src/test/ui/generic-associated-types/issue-87748.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Checks that we properly add implied bounds from unnormalized projections in -// inputs when typechecking functions. - -// check-pass - -#![feature(generic_associated_types)] - -trait MyTrait { - type Assoc<'a, 'b> where 'b: 'a; - fn do_sth(arg: Self::Assoc<'_, '_>); -} - -struct A; -struct B; -struct C; - -impl MyTrait for A { - type Assoc<'a, 'b> where 'b: 'a = u32; - fn do_sth(_: u32) {} -} -impl MyTrait for B { - type Assoc<'a, 'b> where 'b: 'a = u32; - fn do_sth(_: Self::Assoc<'_, '_>) {} -} -impl MyTrait for C { - type Assoc<'a, 'b> where 'b: 'a = u32; - fn do_sth(_: Self::Assoc<'static, 'static>) {} -} - -fn main () {}