From 28f39862a8a673d5d162121b8c432a5b82883d3d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 24 Jun 2023 18:03:20 +0000 Subject: [PATCH 01/18] use Const::eval instead of QueryNormalize in error reporting --- .../src/traits/error_reporting/mod.rs | 48 +++++++++---------- tests/ui/consts/missing-larger-array-impl.rs | 9 ++++ .../consts/missing-larger-array-impl.stderr | 20 ++++++++ 3 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 tests/ui/consts/missing-larger-array-impl.rs create mode 100644 tests/ui/consts/missing-larger-array-impl.stderr diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 67745f04641ab..5c16363015455 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -11,7 +11,6 @@ use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCod use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::{self, InferCtxt}; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; -use crate::traits::query::normalize::QueryNormalizeExt as _; use crate::traits::specialize::to_pretty_impl_header; use crate::traits::NormalizeExt; use on_unimplemented::{AppendConstMessage, OnUnimplementedNote, TypeErrCtxtExt as _}; @@ -31,7 +30,7 @@ use rustc_middle::traits::select::OverflowError; use rustc_middle::traits::SelectionOutputTypeParameterMismatch; use rustc_middle::ty::abstract_const::NotConstEvaluatable; use rustc_middle::ty::error::{ExpectedFound, TypeError}; -use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::print::{with_forced_trimmed_paths, FmtPrinter, Print}; use rustc_middle::ty::{ self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, @@ -60,7 +59,7 @@ pub enum CandidateSimilarity { Fuzzy { ignoring_lifetimes: bool }, } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ImplCandidate<'tcx> { pub trait_ref: ty::TraitRef<'tcx>, pub similarity: CandidateSimilarity, @@ -1992,7 +1991,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // Mentioning implementers of `Copy`, `Debug` and friends is not useful. return false; } - let normalized_impl_candidates: Vec<_> = self + let impl_candidates: Vec<_> = self .tcx .all_impls(def_id) // Ignore automatically derived impls and `!Trait` impls. @@ -2019,7 +2018,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } }) .collect(); - return report(normalized_impl_candidates, err); + return report(impl_candidates, err); } // Sort impl candidates so that ordering is consistent for UI tests. @@ -2028,27 +2027,26 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // // Prefer more similar candidates first, then sort lexicographically // by their normalized string representation. - let mut normalized_impl_candidates_and_similarities = impl_candidates - .iter() - .copied() - .map(|ImplCandidate { trait_ref, similarity }| { - // FIXME(compiler-errors): This should be using `NormalizeExt::normalize` - let normalized = self - .at(&ObligationCause::dummy(), ty::ParamEnv::empty()) - .query_normalize(trait_ref) - .map_or(trait_ref, |normalized| normalized.value); - (similarity, normalized) - }) - .collect::>(); - normalized_impl_candidates_and_similarities.sort(); - normalized_impl_candidates_and_similarities.dedup(); + let mut impl_candidates = impl_candidates.to_vec(); + impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref)); + impl_candidates.dedup(); - let normalized_impl_candidates = normalized_impl_candidates_and_similarities - .into_iter() - .map(|(_, normalized)| normalized) - .collect::>(); - - report(normalized_impl_candidates, err) + report( + impl_candidates + .into_iter() + .map(|cand| { + // Fold the const so that it shows up as, e.g., `10` + // instead of `core::::array::{impl#30}::{constant#0}`. + cand.trait_ref.fold_with(&mut BottomUpFolder { + tcx: self.tcx, + ty_op: |ty| ty, + lt_op: |lt| lt, + ct_op: |ct| ct.eval(self.tcx, ty::ParamEnv::empty()), + }) + }) + .collect(), + err, + ) } fn report_similar_impl_candidates_for_root_obligation( diff --git a/tests/ui/consts/missing-larger-array-impl.rs b/tests/ui/consts/missing-larger-array-impl.rs new file mode 100644 index 0000000000000..e6c879c8ebdab --- /dev/null +++ b/tests/ui/consts/missing-larger-array-impl.rs @@ -0,0 +1,9 @@ +struct X; + +// Make sure that we show the impl trait refs in the help message with +// their evaluated constants, rather than `core::::array::{impl#30}::{constant#0}` + +fn main() { + <[X; 35] as Default>::default(); + //~^ ERROR the trait bound `[X; 35]: Default` is not satisfied +} diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr new file mode 100644 index 0000000000000..fad5c53f712e7 --- /dev/null +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `[X; 35]: Default` is not satisfied + --> $DIR/missing-larger-array-impl.rs:7:5 + | +LL | <[X; 35] as Default>::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` + | + = help: the following other types implement trait `Default`: + &[T] + &mut [T] + [T; 0] + [T; 10] + [T; 11] + [T; 12] + [T; 13] + [T; 14] + and 27 others + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From 30c61eece4ce212e8b0b6c384b3abc9d24201d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Mon, 26 Jun 2023 13:33:53 -0300 Subject: [PATCH 02/18] std: edit [T]::swap docs Add a note telling that no elements change when arguments are equal --- library/core/src/slice/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 5d6e7dcfcee87..e2a2428fbc244 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -851,6 +851,8 @@ impl [T] { /// Swaps two elements in the slice. /// + /// If `a` equals to `b`, it's guaranteed that elements won't change value. + /// /// # Arguments /// /// * a - The index of the first element From 2c33dfea7657467b419956a7331c8d6f66c119b5 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 27 Jun 2023 23:31:06 +0000 Subject: [PATCH 03/18] Don't sort strings right after we just sorted by types --- .../src/traits/error_reporting/mod.rs | 58 ++++++++------- tests/ui/binop/binop-mul-i32-f32.stderr | 4 +- tests/ui/binop/shift-various-bad-types.stderr | 48 ++++++------- .../ui/const-generics/exhaustive-value.stderr | 14 ++-- .../generic_arg_infer/issue-91614.stderr | 4 +- .../issues/issue-67185-2.stderr | 12 ++-- .../const-eval/const-eval-overflow-3b.stderr | 4 +- .../const-eval/const-eval-overflow-4b.stderr | 4 +- .../consts/missing-larger-array-impl.stderr | 14 ++-- tests/ui/consts/too_generic_eval_ice.stderr | 12 ++-- tests/ui/deriving/issue-103157.stderr | 10 +-- ...e-21659-show-relevant-trait-impls-2.stderr | 4 +- .../issue-39802-show-5-trait-impls.stderr | 4 +- ...de-confusable-in-float-literal-expt.stderr | 16 ++--- tests/ui/fmt/ifmt-unimpl.stderr | 16 ++--- tests/ui/impl-trait/equality.stderr | 4 +- tests/ui/issues/issue-11771.stderr | 32 ++++----- tests/ui/issues/issue-24352.stderr | 4 +- tests/ui/issues/issue-32709.stderr | 2 +- tests/ui/issues/issue-50582.stderr | 16 ++--- ...valid-iterator-chain-with-int-infer.stderr | 2 +- .../iterators/invalid-iterator-chain.stderr | 10 +-- tests/ui/mismatched_types/binops.stderr | 72 +++++++++---------- ...diverging-fallback-no-leak.fallback.stderr | 2 +- tests/ui/never_type/issue-13352.stderr | 4 +- .../not-suggest-float-literal.stderr | 50 ++++++------- .../suggest-float-literal.stderr | 32 ++++----- .../ui/on-unimplemented/multiple-impls.stderr | 18 ++--- tests/ui/on-unimplemented/slice-index.stderr | 2 +- tests/ui/on-unimplemented/sum.stderr | 4 +- tests/ui/range/range-1.stderr | 8 +-- tests/ui/span/multiline-span-simple.stderr | 4 +- ...mpl-trait-return-trailing-semicolon.stderr | 2 +- tests/ui/suggestions/into-str.stderr | 8 +-- .../issue-71394-no-from-impl.stderr | 8 +-- .../assoc-fn-bound-root-obligation.stderr | 6 +- tests/ui/try-trait/bad-interconversion.stderr | 6 +- tests/ui/try-trait/option-to-result.stderr | 2 +- tests/ui/try-trait/try-on-option.stderr | 2 +- .../nested-tait-inference2.stderr | 2 +- tests/ui/type/type-check-defaults.stderr | 4 +- tests/ui/typeck/issue-81293.stderr | 4 +- tests/ui/typeck/issue-90101.stderr | 2 +- tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr | 8 +-- 44 files changed, 274 insertions(+), 270 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 5c16363015455..810e6bbe77a86 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1926,10 +1926,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { other: bool, ) -> bool { let other = if other { "other " } else { "" }; - let report = |mut candidates: Vec>, err: &mut Diagnostic| { - candidates.sort(); - candidates.dedup(); - let len = candidates.len(); + let report = |candidates: Vec>, err: &mut Diagnostic| { if candidates.is_empty() { return false; } @@ -1958,11 +1955,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect(); traits.sort(); traits.dedup(); + // FIXME: this could use a better heuristic, like just checking + // that substs[1..] is the same. + let all_traits_equal = traits.len() == 1; - let mut candidates: Vec = candidates + let candidates: Vec = candidates .into_iter() .map(|c| { - if traits.len() == 1 { + if all_traits_equal { format!("\n {}", c.self_ty()) } else { format!("\n {}", c) @@ -1970,14 +1970,16 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { }) .collect(); - candidates.sort(); - candidates.dedup(); let end = if candidates.len() <= 9 { candidates.len() } else { 8 }; err.help(format!( "the following {other}types implement trait `{}`:{}{}", trait_ref.print_only_trait_path(), candidates[..end].join(""), - if len > 9 { format!("\nand {} others", len - 8) } else { String::new() } + if candidates.len() > 9 { + format!("\nand {} others", candidates.len() - 8) + } else { + String::new() + } )); true }; @@ -1991,7 +1993,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // Mentioning implementers of `Copy`, `Debug` and friends is not useful. return false; } - let impl_candidates: Vec<_> = self + let mut impl_candidates: Vec<_> = self .tcx .all_impls(def_id) // Ignore automatically derived impls and `!Trait` impls. @@ -2018,6 +2020,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } }) .collect(); + + impl_candidates.sort(); + impl_candidates.dedup(); return report(impl_candidates, err); } @@ -2027,26 +2032,25 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // // Prefer more similar candidates first, then sort lexicographically // by their normalized string representation. - let mut impl_candidates = impl_candidates.to_vec(); + let mut impl_candidates: Vec<_> = impl_candidates + .iter() + .cloned() + .map(|mut cand| { + // Fold the consts so that they shows up as, e.g., `10` + // instead of `core::::array::{impl#30}::{constant#0}`. + cand.trait_ref = cand.trait_ref.fold_with(&mut BottomUpFolder { + tcx: self.tcx, + ty_op: |ty| ty, + lt_op: |lt| lt, + ct_op: |ct| ct.eval(self.tcx, ty::ParamEnv::empty()), + }); + cand + }) + .collect(); impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref)); impl_candidates.dedup(); - report( - impl_candidates - .into_iter() - .map(|cand| { - // Fold the const so that it shows up as, e.g., `10` - // instead of `core::::array::{impl#30}::{constant#0}`. - cand.trait_ref.fold_with(&mut BottomUpFolder { - tcx: self.tcx, - ty_op: |ty| ty, - lt_op: |lt| lt, - ct_op: |ct| ct.eval(self.tcx, ty::ParamEnv::empty()), - }) - }) - .collect(), - err, - ) + report(impl_candidates.into_iter().map(|cand| cand.trait_ref).collect(), err) } fn report_similar_impl_candidates_for_root_obligation( diff --git a/tests/ui/binop/binop-mul-i32-f32.stderr b/tests/ui/binop/binop-mul-i32-f32.stderr index c986bc3fd1e3e..115e700061981 100644 --- a/tests/ui/binop/binop-mul-i32-f32.stderr +++ b/tests/ui/binop/binop-mul-i32-f32.stderr @@ -6,10 +6,10 @@ LL | x * y | = help: the trait `Mul` is not implemented for `i32` = help: the following other types implement trait `Mul`: + + > <&'a i32 as Mul> <&i32 as Mul<&i32>> - > - error: aborting due to previous error diff --git a/tests/ui/binop/shift-various-bad-types.stderr b/tests/ui/binop/shift-various-bad-types.stderr index 38db66f86b461..b43672ef3b568 100644 --- a/tests/ui/binop/shift-various-bad-types.stderr +++ b/tests/ui/binop/shift-various-bad-types.stderr @@ -6,14 +6,14 @@ LL | 22 >> p.char; | = help: the trait `Shr` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0277]: no implementation for `{integer} >> &str` @@ -24,14 +24,14 @@ LL | 22 >> p.str; | = help: the trait `Shr<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` @@ -42,14 +42,14 @@ LL | 22 >> p; | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0308]: mismatched types diff --git a/tests/ui/const-generics/exhaustive-value.stderr b/tests/ui/const-generics/exhaustive-value.stderr index 76a83ba67ce79..4a26e09772dc4 100644 --- a/tests/ui/const-generics/exhaustive-value.stderr +++ b/tests/ui/const-generics/exhaustive-value.stderr @@ -6,13 +6,13 @@ LL | <() as Foo>::test() | = help: the following other types implement trait `Foo`: <() as Foo<0>> - <() as Foo<100>> - <() as Foo<101>> - <() as Foo<102>> - <() as Foo<103>> - <() as Foo<104>> - <() as Foo<105>> - <() as Foo<106>> + <() as Foo<1>> + <() as Foo<2>> + <() as Foo<3>> + <() as Foo<4>> + <() as Foo<5>> + <() as Foo<6>> + <() as Foo<7>> and 248 others error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr index 13ea4a295afd7..0096d4ee23d11 100644 --- a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr +++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr @@ -6,11 +6,11 @@ LL | let y = Mask::<_, _>::splat(false); | = note: cannot satisfy `_: MaskElement` = help: the following types implement trait `MaskElement`: + isize + i8 i16 i32 i64 - i8 - isize note: required by a bound in `Mask::::splat` --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL help: consider giving `y` an explicit type, where the type for type parameter `T` is specified diff --git a/tests/ui/const-generics/issues/issue-67185-2.stderr b/tests/ui/const-generics/issues/issue-67185-2.stderr index 032b0c41047fc..a2e5b8053688b 100644 --- a/tests/ui/const-generics/issues/issue-67185-2.stderr +++ b/tests/ui/const-generics/issues/issue-67185-2.stderr @@ -5,8 +5,8 @@ LL | ::Quaks: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -17,8 +17,8 @@ LL | [::Quaks; 2]: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -29,8 +29,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | @@ -47,8 +47,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -65,8 +65,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -83,8 +83,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr index 05f33c33946a8..06e398edca9af 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -12,10 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | = help: the trait `Add` is not implemented for `i8` = help: the following other types implement trait `Add`: + + > <&'a i8 as Add> <&i8 as Add<&i8>> - > - error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr index d019f5920b517..07ef2ac090f7b 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -12,10 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | = help: the trait `Add` is not implemented for `i8` = help: the following other types implement trait `Add`: + + > <&'a i8 as Add> <&i8 as Add<&i8>> - > - error[E0604]: only `u8` can be cast as `char`, not `i8` --> $DIR/const-eval-overflow-4b.rs:22:13 diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr index fad5c53f712e7..b8f6cb5ef9772 100644 --- a/tests/ui/consts/missing-larger-array-impl.stderr +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -5,14 +5,14 @@ LL | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: - &[T] - &mut [T] [T; 0] - [T; 10] - [T; 11] - [T; 12] - [T; 13] - [T; 14] + [T; 1] + [T; 2] + [T; 3] + [T; 4] + [T; 5] + [T; 6] + [T; 7] and 27 others error: aborting due to previous error diff --git a/tests/ui/consts/too_generic_eval_ice.stderr b/tests/ui/consts/too_generic_eval_ice.stderr index 5af82a3e34bf5..843d6d9e04ba7 100644 --- a/tests/ui/consts/too_generic_eval_ice.stderr +++ b/tests/ui/consts/too_generic_eval_ice.stderr @@ -22,14 +22,14 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]` = help: the following other types implement trait `PartialEq`: - <&[B] as PartialEq<[A; N]>> - <&[T] as PartialEq>> - <&mut [B] as PartialEq<[A; N]>> - <&mut [T] as PartialEq>> - <[A; N] as PartialEq<&[B]>> - <[A; N] as PartialEq<&mut [B]>> <[A; N] as PartialEq<[B; N]>> <[A; N] as PartialEq<[B]>> + <[A; N] as PartialEq<&[B]>> + <[A; N] as PartialEq<&mut [B]>> + <[T] as PartialEq>> + <[A] as PartialEq<[B]>> + <[B] as PartialEq<[A; N]>> + <&[T] as PartialEq>> and 3 others error: aborting due to 3 previous errors diff --git a/tests/ui/deriving/issue-103157.stderr b/tests/ui/deriving/issue-103157.stderr index b18e1e5098b34..01cce2a397ab3 100644 --- a/tests/ui/deriving/issue-103157.stderr +++ b/tests/ui/deriving/issue-103157.stderr @@ -8,14 +8,14 @@ LL | Float(Option), | ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64` | = help: the following other types implement trait `Eq`: - i128 + isize + i8 i16 i32 i64 - i8 - isize - u128 - u16 + i128 + usize + u8 and 4 others = note: required for `Option` to implement `Eq` note: required by a bound in `AssertParamIsEq` diff --git a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index 5e0e4a0115a0e..2d50c09645d7c 100644 --- a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -7,12 +7,12 @@ LL | f1.foo(1usize); | required by a bound introduced by this call | = help: the following other types implement trait `Foo`: + > > > - > + > > > - > error: aborting due to previous error diff --git a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 7229b9ac986ac..ae15e054f6288 100644 --- a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -8,10 +8,10 @@ LL | Foo::::bar(&1i8); | = help: the following other types implement trait `Foo`: > + > > > > - > error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -38,10 +38,10 @@ LL | Foo::::bar(&true); = help: the following other types implement trait `Foo`: > > + > > > > - > error: aborting due to 3 previous errors diff --git a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 26986684f0c0a..44bdbb93ff51c 100644 --- a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -23,14 +23,14 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ | = help: the trait `Sub<{integer}>` is not implemented for `{float}` = help: the following other types implement trait `Sub`: - <&'a f32 as Sub> - <&'a f64 as Sub> - <&'a i128 as Sub> - <&'a i16 as Sub> - <&'a i32 as Sub> - <&'a i64 as Sub> - <&'a i8 as Sub> - <&'a isize as Sub> + + > + + > + + > + + > and 48 others error: aborting due to 3 previous errors diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index b0dddd3b1e8d0..4c0ac52865d77 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -7,14 +7,14 @@ LL | format!("{:X}", "3"); | required by a bound introduced by this call | = help: the following other types implement trait `UpperHex`: - &T - &mut T - NonZeroI128 - NonZeroI16 - NonZeroI32 - NonZeroI64 - NonZeroI8 - NonZeroIsize + isize + i8 + i16 + i32 + i64 + i128 + usize + u8 and 20 others = note: required for `&str` to implement `UpperHex` note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex` diff --git a/tests/ui/impl-trait/equality.stderr b/tests/ui/impl-trait/equality.stderr index 69f4cbbbf4294..9b8bff215e027 100644 --- a/tests/ui/impl-trait/equality.stderr +++ b/tests/ui/impl-trait/equality.stderr @@ -30,10 +30,10 @@ LL | n + sum_to(n - 1) | = help: the trait `Add` is not implemented for `u32` = help: the following other types implement trait `Add`: + + > <&'a u32 as Add> <&u32 as Add<&u32>> - > - error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/issues/issue-11771.stderr b/tests/ui/issues/issue-11771.stderr index 161fce4b0315c..b37140f60f9c1 100644 --- a/tests/ui/issues/issue-11771.stderr +++ b/tests/ui/issues/issue-11771.stderr @@ -6,14 +6,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error[E0277]: cannot add `()` to `{integer}` @@ -24,14 +24,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-24352.stderr b/tests/ui/issues/issue-24352.stderr index 1f51b6e29050c..f1c3891b87000 100644 --- a/tests/ui/issues/issue-24352.stderr +++ b/tests/ui/issues/issue-24352.stderr @@ -6,10 +6,10 @@ LL | 1.0f64 - 1 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | 1.0f64 - 1.0 diff --git a/tests/ui/issues/issue-32709.stderr b/tests/ui/issues/issue-32709.stderr index a4ba5da4d8724..94e8f9295fdd5 100644 --- a/tests/ui/issues/issue-32709.stderr +++ b/tests/ui/issues/issue-32709.stderr @@ -8,6 +8,7 @@ LL | Err(5)?; | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From`: + <(T,) as From<[T; 1]>> <(T, T) as From<[T; 2]>> <(T, T, T) as From<[T; 3]>> <(T, T, T, T) as From<[T; 4]>> @@ -15,7 +16,6 @@ LL | Err(5)?; <(T, T, T, T, T, T) as From<[T; 6]>> <(T, T, T, T, T, T, T) as From<[T; 7]>> <(T, T, T, T, T, T, T, T) as From<[T; 8]>> - <(T, T, T, T, T, T, T, T, T) as From<[T; 9]>> and 4 others = note: required for `Result` to implement `FromResidual>` diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/issues/issue-50582.stderr index 3d527eb6b4e4a..9eafd7ab4f0fa 100644 --- a/tests/ui/issues/issue-50582.stderr +++ b/tests/ui/issues/issue-50582.stderr @@ -15,14 +15,14 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr index 3cb5e44c71101..7f1b9c38e6798 100644 --- a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr @@ -6,8 +6,8 @@ LL | let x = Some(()).iter().map(|()| 1).sum::(); | = help: the trait `Sum<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-with-int-infer.rs:2:29 | diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index f3dceca7e4139..a2688107d10db 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -24,8 +24,8 @@ LL | println!("{}", scores.sum::()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:12:10 | @@ -49,8 +49,8 @@ LL | .sum::(), | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:25:14 | @@ -81,8 +81,8 @@ LL | .sum::(), | = help: the trait `Sum` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:33:14 | @@ -109,8 +109,8 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:38:38 | @@ -130,8 +130,8 @@ LL | println!("{}", vec![(), ()].iter().sum::()); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:39:33 | diff --git a/tests/ui/mismatched_types/binops.stderr b/tests/ui/mismatched_types/binops.stderr index 3585587ed4c02..b18ab7f7608d5 100644 --- a/tests/ui/mismatched_types/binops.stderr +++ b/tests/ui/mismatched_types/binops.stderr @@ -6,14 +6,14 @@ LL | 1 + Some(1); | = help: the trait `Add>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error[E0277]: cannot subtract `Option<{integer}>` from `usize` @@ -24,10 +24,10 @@ LL | 2 as usize - Some(1); | = help: the trait `Sub>` is not implemented for `usize` = help: the following other types implement trait `Sub`: + + > <&'a usize as Sub> <&usize as Sub<&usize>> - > - error[E0277]: cannot multiply `{integer}` by `()` --> $DIR/binops.rs:4:7 @@ -37,14 +37,14 @@ LL | 3 * (); | = help: the trait `Mul<()>` is not implemented for `{integer}` = help: the following other types implement trait `Mul`: - <&'a f32 as Mul> - <&'a f64 as Mul> - <&'a i128 as Mul> - <&'a i16 as Mul> - <&'a i32 as Mul> - <&'a i64 as Mul> - <&'a i8 as Mul> - <&'a isize as Mul> + + > + + > + + > + + > and 49 others error[E0277]: cannot divide `{integer}` by `&str` @@ -55,14 +55,14 @@ LL | 4 / ""; | = help: the trait `Div<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Div`: - <&'a f32 as Div> - <&'a f64 as Div> - <&'a i128 as Div> - <&'a i16 as Div> - <&'a i32 as Div> - <&'a i64 as Div> - <&'a i8 as Div> - <&'a isize as Div> + + > + + > + + > + + > and 54 others error[E0277]: can't compare `{integer}` with `String` @@ -73,14 +73,14 @@ LL | 5 < String::new(); | = help: the trait `PartialOrd` is not implemented for `{integer}` = help: the following other types implement trait `PartialOrd`: - f32 - f64 - i128 + isize + i8 i16 i32 i64 - i8 - isize + i128 + usize + u8 and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` @@ -91,14 +91,14 @@ LL | 6 == Ok(1); | = help: the trait `PartialEq>` is not implemented for `{integer}` = help: the following other types implement trait `PartialEq`: - f32 - f64 - i128 + isize + i8 i16 i32 i64 - i8 - isize + i128 + usize + u8 and 6 others error: aborting due to 6 previous errors diff --git a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr index 3215c4669d5e3..df29fe227135d 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -7,8 +7,8 @@ LL | unconstrained_arg(return); | required by a bound introduced by this call | = help: the following other types implement trait `Test`: - () i32 + () = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) = help: did you intend to use the type `()` here instead? note: required by a bound in `unconstrained_arg` diff --git a/tests/ui/never_type/issue-13352.stderr b/tests/ui/never_type/issue-13352.stderr index 2d22da0b420e0..406785bfea0e2 100644 --- a/tests/ui/never_type/issue-13352.stderr +++ b/tests/ui/never_type/issue-13352.stderr @@ -6,10 +6,10 @@ LL | 2_usize + (loop {}); | = help: the trait `Add<()>` is not implemented for `usize` = help: the following other types implement trait `Add`: + + > <&'a usize as Add> <&usize as Add<&usize>> - > - error: aborting due to previous error diff --git a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr index 8f0eef237cfe2..e1825eb5b541d 100644 --- a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100.0 | = help: the trait `Add<{float}>` is not implemented for `u8` = help: the following other types implement trait `Add`: + + > <&'a u8 as Add> <&u8 as Add<&u8>> - > - error[E0277]: cannot add `&str` to `f64` --> $DIR/not-suggest-float-literal.rs:6:7 @@ -19,10 +19,10 @@ LL | x + "foo" | = help: the trait `Add<&str>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - error[E0277]: cannot add `{integer}` to `f64` --> $DIR/not-suggest-float-literal.rs:11:7 @@ -32,10 +32,10 @@ LL | x + y | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - error[E0277]: cannot subtract `{float}` from `u8` --> $DIR/not-suggest-float-literal.rs:15:7 @@ -45,10 +45,10 @@ LL | x - 100.0 | = help: the trait `Sub<{float}>` is not implemented for `u8` = help: the following other types implement trait `Sub`: + + > <&'a u8 as Sub> <&u8 as Sub<&u8>> - > - error[E0277]: cannot subtract `&str` from `f64` --> $DIR/not-suggest-float-literal.rs:19:7 @@ -58,10 +58,10 @@ LL | x - "foo" | = help: the trait `Sub<&str>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - error[E0277]: cannot subtract `{integer}` from `f64` --> $DIR/not-suggest-float-literal.rs:24:7 @@ -71,10 +71,10 @@ LL | x - y | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - error[E0277]: cannot multiply `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:28:7 @@ -84,10 +84,10 @@ LL | x * 100.0 | = help: the trait `Mul<{float}>` is not implemented for `u8` = help: the following other types implement trait `Mul`: + + > <&'a u8 as Mul> <&u8 as Mul<&u8>> - > - error[E0277]: cannot multiply `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:32:7 @@ -97,10 +97,10 @@ LL | x * "foo" | = help: the trait `Mul<&str>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - error[E0277]: cannot multiply `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:37:7 @@ -110,10 +110,10 @@ LL | x * y | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - error[E0277]: cannot divide `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:41:7 @@ -123,11 +123,11 @@ LL | x / 100.0 | = help: the trait `Div<{float}>` is not implemented for `u8` = help: the following other types implement trait `Div`: + + > + > <&'a u8 as Div> <&u8 as Div<&u8>> - > - > - error[E0277]: cannot divide `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:45:7 @@ -137,10 +137,10 @@ LL | x / "foo" | = help: the trait `Div<&str>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - error[E0277]: cannot divide `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:50:7 @@ -150,10 +150,10 @@ LL | x / y | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - error: aborting due to 12 previous errors diff --git a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr index 03779d356371a..929a9e3b5954d 100644 --- a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Add`: + + > <&'a f32 as Add> <&f32 as Add<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -23,10 +23,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -40,10 +40,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sub`: + + > <&'a f32 as Sub> <&f32 as Sub<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -57,10 +57,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -74,10 +74,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Mul`: + + > <&'a f32 as Mul> <&f32 as Mul<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -91,10 +91,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -108,10 +108,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Div`: + + > <&'a f32 as Div> <&f32 as Div<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 @@ -125,10 +125,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 diff --git a/tests/ui/on-unimplemented/multiple-impls.stderr b/tests/ui/on-unimplemented/multiple-impls.stderr index d628b159a66d2..3d0e36db75215 100644 --- a/tests/ui/on-unimplemented/multiple-impls.stderr +++ b/tests/ui/on-unimplemented/multiple-impls.stderr @@ -8,8 +8,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -19,8 +19,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:33 @@ -32,8 +32,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:5 @@ -43,8 +43,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:33 @@ -56,8 +56,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:5 @@ -67,8 +67,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -78,8 +78,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:5 @@ -89,8 +89,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:5 @@ -100,8 +100,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error: aborting due to 9 previous errors diff --git a/tests/ui/on-unimplemented/slice-index.stderr b/tests/ui/on-unimplemented/slice-index.stderr index a7ec3bda85eca..b9bca211f438b 100644 --- a/tests/ui/on-unimplemented/slice-index.stderr +++ b/tests/ui/on-unimplemented/slice-index.stderr @@ -16,8 +16,8 @@ LL | x[..1i32]; | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo` = help: the following other types implement trait `SliceIndex`: - as SliceIndex<[T]>> as SliceIndex> + as SliceIndex<[T]>> = note: required for `[i32]` to implement `Index>` error: aborting due to 2 previous errors diff --git a/tests/ui/on-unimplemented/sum.stderr b/tests/ui/on-unimplemented/sum.stderr index 2a316dba778fe..a2357e49b07e8 100644 --- a/tests/ui/on-unimplemented/sum.stderr +++ b/tests/ui/on-unimplemented/sum.stderr @@ -6,8 +6,8 @@ LL | vec![(), ()].iter().sum::(); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:4:18 | @@ -26,8 +26,8 @@ LL | vec![(), ()].iter().product::(); | = help: the trait `Product<&()>` is not implemented for `i32` = help: the following other types implement trait `Product`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:7:18 | diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr index 3956390368f7f..277d9b2682d8b 100644 --- a/tests/ui/range/range-1.stderr +++ b/tests/ui/range/range-1.stderr @@ -12,13 +12,13 @@ LL | for i in false..true {} | = help: the following other types implement trait `Step`: char - i128 + isize + i8 i16 i32 i64 - i8 - isize - u128 + i128 + usize and 5 others = note: required for `std::ops::Range` to implement `Iterator` = note: required for `std::ops::Range` to implement `IntoIterator` diff --git a/tests/ui/span/multiline-span-simple.stderr b/tests/ui/span/multiline-span-simple.stderr index b44df962a9ba7..b6052a209bf50 100644 --- a/tests/ui/span/multiline-span-simple.stderr +++ b/tests/ui/span/multiline-span-simple.stderr @@ -6,10 +6,10 @@ LL | foo(1 as u32 + | = help: the trait `Add<()>` is not implemented for `u32` = help: the following other types implement trait `Add`: + + > <&'a u32 as Add> <&u32 as Add<&u32>> - > - error: aborting due to previous error diff --git a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index e74c2c4214fe2..6465eeb8bc62d 100644 --- a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -16,8 +16,8 @@ LL | fn bar() -> impl Bar { | ^^^^^^^^ the trait `Bar` is not implemented for `()` | = help: the following other types implement trait `Bar`: - Qux i32 + Qux error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/into-str.stderr b/tests/ui/suggestions/into-str.stderr index a56a2a188cb3f..7e24150e7f447 100644 --- a/tests/ui/suggestions/into-str.stderr +++ b/tests/ui/suggestions/into-str.stderr @@ -8,12 +8,12 @@ LL | foo(String::new()); | = note: to coerce a `String` into a `&str`, use `&*` as a prefix = help: the following other types implement trait `From`: - > - > - > + > >> >> - > + > + > + > = note: required for `String` to implement `Into<&str>` note: required by a bound in `foo` --> $DIR/into-str.rs:1:31 diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index ea57992b48326..004f1c1622b6f 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -5,14 +5,14 @@ LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | = help: the following other types implement trait `From`: - <&'input [u8] as From>> - <[T; 10] as From<(T, T, T, T, T, T, T, T, T, T)>> - <[T; 11] as From<(T, T, T, T, T, T, T, T, T, T, T)>> - <[T; 12] as From<(T, T, T, T, T, T, T, T, T, T, T, T)>> + <[bool; LANES] as From>> + <[T; N] as From>> <[T; 1] as From<(T,)>> <[T; 2] as From<(T, T)>> <[T; 3] as From<(T, T, T)>> <[T; 4] as From<(T, T, T, T)>> + <[T; 5] as From<(T, T, T, T, T)>> + <[T; 6] as From<(T, T, T, T, T, T)>> and 7 others = note: required for `&[u8]` to implement `Into<&[i8]>` diff --git a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr index ce9ab2d811ae1..b1c683e4729ea 100644 --- a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr +++ b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr @@ -6,13 +6,13 @@ LL | s.strip_suffix(b'\n').unwrap_or(s) | = help: the trait `FnMut<(char,)>` is not implemented for `u8` = help: the following other types implement trait `Pattern<'a>`: + char + [char; N] &'b String &'b [char; N] &'b [char] - &'b str &'c &'b str - [char; N] - char + &'b str = note: required for `u8` to implement `Pattern<'_>` error: aborting due to previous error diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index a49630adb9538..7eb392faa66b3 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -8,8 +8,8 @@ LL | Ok(Err(123_i32)?) | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From`: - > > + > = note: required for `Result` to implement `FromResidual>` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` @@ -22,8 +22,8 @@ LL | Some(3)?; | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:17:31 @@ -35,8 +35,8 @@ LL | Ok(ControlFlow::Break(123)?) | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:22:22 diff --git a/tests/ui/try-trait/option-to-result.stderr b/tests/ui/try-trait/option-to-result.stderr index fabc1ff2c762e..1c4d718f1eeb4 100644 --- a/tests/ui/try-trait/option-to-result.stderr +++ b/tests/ui/try-trait/option-to-result.stderr @@ -9,8 +9,8 @@ LL | a?; | = help: the trait `FromResidual>` is not implemented for `Result<(), ()>` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 diff --git a/tests/ui/try-trait/try-on-option.stderr b/tests/ui/try-trait/try-on-option.stderr index fad6a1fe8237b..eeb0439df298c 100644 --- a/tests/ui/try-trait/try-on-option.stderr +++ b/tests/ui/try-trait/try-on-option.stderr @@ -9,8 +9,8 @@ LL | x?; | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr index f4d96038d9109..dccf84362f0f8 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -8,8 +8,8 @@ LL | () | -- return type was inferred to be `()` here | = help: the following other types implement trait `Foo`: - <() as Foo<()>> <() as Foo> + <() as Foo<()>> error: aborting due to previous error diff --git a/tests/ui/type/type-check-defaults.stderr b/tests/ui/type/type-check-defaults.stderr index 9ba63ffe9c93f..10d600cbfccce 100644 --- a/tests/ui/type/type-check-defaults.stderr +++ b/tests/ui/type/type-check-defaults.stderr @@ -66,10 +66,10 @@ LL | trait ProjectionPred> where T::Item : Add {} | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error: aborting due to 7 previous errors diff --git a/tests/ui/typeck/issue-81293.stderr b/tests/ui/typeck/issue-81293.stderr index 6976be71135c2..292c63070ae44 100644 --- a/tests/ui/typeck/issue-81293.stderr +++ b/tests/ui/typeck/issue-81293.stderr @@ -21,10 +21,10 @@ LL | a = c + b * 5; | = help: the trait `Add` is not implemented for `usize` = help: the following other types implement trait `Add`: + + > <&'a usize as Add> <&usize as Add<&usize>> - > - error: aborting due to 3 previous errors diff --git a/tests/ui/typeck/issue-90101.stderr b/tests/ui/typeck/issue-90101.stderr index d2729d853547b..484089f9e87e3 100644 --- a/tests/ui/typeck/issue-90101.stderr +++ b/tests/ui/typeck/issue-90101.stderr @@ -7,11 +7,11 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world") | required by a bound introduced by this call | = help: the following other types implement trait `From`: - > >> >> > > + > = note: required for `Cow<'_, str>` to implement `Into` note: required by a bound in `func` --> $DIR/issue-90101.rs:3:20 diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 96ac4321689f3..85adf7751392f 100644 --- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -8,10 +8,10 @@ LL | >::add(1, 2); | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 @@ -65,10 +65,10 @@ LL | >::add(1, 2); | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error: aborting due to 4 previous errors From 13fcd8dd58cd51de9303c0f27ee35a59b12d5755 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 28 Jun 2023 14:28:37 -0700 Subject: [PATCH 04/18] Add release notes for 1.71.0 --- RELEASES.md | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index fa95df685aaa4..423bf2e7bd1d2 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,141 @@ +Version 1.71.0 (2023-07-13) +========================== + + + +Language +-------- + +- [Remove misleading target feature aliases, inappropriately connected to AVX-512.](https://github.com/rust-lang/rust/pull/107707/) +- [Stabilize `raw-dylib`, `link_ordinal`, `import_name_type` and `-Cdlltool`.](https://github.com/rust-lang/rust/pull/109677/) +- [Uplift `clippy::{drop,forget}_{ref,copy}` lints.](https://github.com/rust-lang/rust/pull/109732/) +- [Type inference is more conservative around constrained vars.](https://github.com/rust-lang/rust/pull/110100/) +- [Use fulfillment to check `Drop` impl compatibility](https://github.com/rust-lang/rust/pull/110577/) + + + +Compiler +-------- + +- [Evaluate place expression in `PlaceMention`](https://github.com/rust-lang/rust/pull/104844/), + making `let _ =` patterns more consistent with respect to the borrow checker. +- [Add `--print deployment-target` flag for Apple targets.](https://github.com/rust-lang/rust/pull/105354/) +- [Stabilize `extern "C-unwind"` and friends.](https://github.com/rust-lang/rust/pull/106075/) + The existing `extern "C"` etc. may change behavior for cross-language unwinding in a future release. +- [Update the version of musl used on `*-linux-musl` targets to 1.2.3](https://github.com/rust-lang/rust/pull/107129/), + enabling [time64](https://musl.libc.org/time64.html) on 32-bit systems. +- [Stabilize `debugger_visualizer`](https://github.com/rust-lang/rust/pull/108668/) + for embedding metadata like Microsoft's Natvis. +- [Enable flatten-format-args by default.](https://github.com/rust-lang/rust/pull/109999/) +- [Make `Self` respect tuple constructor privacy.](https://github.com/rust-lang/rust/pull/111245/) +- [Improve niche placement by trying two strategies and picking the better result.](https://github.com/rust-lang/rust/pull/108106/) +- [Use `apple-m1` as the target CPU for `aarch64-apple-darwin`.](https://github.com/rust-lang/rust/pull/109899/) +- [Add Tier 3 support for the `x86_64h-apple-darwin` target.](https://github.com/rust-lang/rust/pull/108795/) +- [Promote `loongarch64-unknown-linux-gnu` to Tier 2 with host tools.](https://github.com/rust-lang/rust/pull/110936/) + +Refer to Rust's [platform support page][platform-support-doc] +for more information on Rust's tiered platform support. + + + +Libraries +--------- +- [Remove structural match from `TypeId`.](https://github.com/rust-lang/rust/pull/103291/) +- [Loosen `From<&[T]> for Box<[T]>` bound to `T: Clone`.](https://github.com/rust-lang/rust/pull/103406/) +- [Remove unnecessary `T: Send` bound](https://github.com/rust-lang/rust/pull/111134/) + in `Error for mpsc::SendError` and `TrySendError`. +- [Fix docs for `alloc::realloc`](https://github.com/rust-lang/rust/pull/108630/) + to match `Layout` requirements that the size must not exceed `isize::MAX`. +- [Document `const {}` syntax for `std::thread_local`.](https://github.com/rust-lang/rust/pull/110620/) + This syntax was stabilized in Rust 1.59, but not previously mentioned in release notes. + + + +Stabilized APIs +--------------- + +- [`CStr::is_empty`](https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.is_empty) +- [`BuildHasher::hash_one`](https://doc.rust-lang.org/stable/std/hash/trait.BuildHasher.html#method.hash_one) +- [`NonZeroI*::is_positive`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.is_positive) +- [`NonZeroI*::is_negative`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.is_negative) +- [`NonZeroI*::checked_neg`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.checked_neg) +- [`NonZeroI*::overflowing_neg`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.overflowing_neg) +- [`NonZeroI*::saturating_neg`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.saturating_neg) +- [`NonZeroI*::wrapping_neg`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#method.wrapping_neg) +- [`Neg for NonZeroI*`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#impl-Neg-for-NonZeroI32) +- [`Neg for &NonZeroI*`](https://doc.rust-lang.org/stable/std/num/struct.NonZeroI32.html#impl-Neg-for-%26NonZeroI32) +- [`From<[T; N]> for (T...)`](https://doc.rust-lang.org/stable/std/primitive.array.html#impl-From%3C%5BT;+1%5D%3E-for-(T,)) + (array to N-tuple for N in 1..=12) +- [`From<(T...)> for [T; N]`](https://doc.rust-lang.org/stable/std/primitive.array.html#impl-From%3C(T,)%3E-for-%5BT;+1%5D) + (N-tuple to array for N in 1..=12) +- [`windows::io::AsHandle for Box`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsHandle.html#impl-AsHandle-for-Box%3CT%3E) +- [`windows::io::AsHandle for Rc`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsHandle.html#impl-AsHandle-for-Rc%3CT%3E) +- [`windows::io::AsHandle for Arc`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsHandle.html#impl-AsHandle-for-Arc%3CT%3E) +- [`windows::io::AsSocket for Box`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsSocket.html#impl-AsSocket-for-Box%3CT%3E) +- [`windows::io::AsSocket for Rc`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsSocket.html#impl-AsSocket-for-Rc%3CT%3E) +- [`windows::io::AsSocket for Arc`](https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsSocket.html#impl-AsSocket-for-Arc%3CT%3E) + +These APIs are now stable in const contexts: + +- [`<*const T>::read`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.read) +- [`<*const T>::read_unaligned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.read_unaligned) +- [`<*mut T>::read`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.read-1) +- [`<*mut T>::read_unaligned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.read_unaligned-1) +- [`ptr::read`](https://doc.rust-lang.org/stable/std/ptr/fn.read.html) +- [`ptr::read_unaligned`](https://doc.rust-lang.org/stable/std/ptr/fn.read_unaligned.html) +- [`<[T]>::split_at`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_at) + + + +Cargo +----- +- [Allow named debuginfo options in `Cargo.toml`.](https://github.com/rust-lang/cargo/pull/11958/) +- [Add `workspace_default_members` to the output of `cargo metadata`.](https://github.com/rust-lang/cargo/pull/11978/) +- [`cargo add` now considers `rust-version` when selecting packages.](https://github.com/rust-lang/cargo/pull/12078/) +- [Automatically inherit workspace fields when running `cargo new`/`cargo init`.](https://github.com/rust-lang/cargo/pull/12069/) + + + +Rustdoc +------- + +- [Add a new `rustdoc::unescaped_backticks` lint for broken inline code.](https://github.com/rust-lang/rust/pull/105848/) +- [Support strikethrough with single tildes.](https://github.com/rust-lang/rust/pull/111152/) (`~~old~~` vs. `~new~`) + + + +Misc +---- + + + +Compatibility Notes +------------------- + +- [Add a `sysroot` crate to represent the standard library crates.](https://github.com/rust-lang/rust/pull/108865/) + This does not affect stable users, but may require adjustment in tools that build their own standard library. +- [Cargo optimizes its usage under `rustup`.](https://github.com/rust-lang/cargo/pull/11917/) When + Cargo detects it will run `rustc` pointing to a rustup proxy, it'll try bypassing the proxy and + use the underlying binary directly. There are assumptions around the interaction with rustup and + `RUSTUP_TOOLCHAIN`. However, it's not expected to affect normal users. +- [When querying a package, Cargo tries only the original name, all hyphens, and all underscores to + handle misspellings.](https://github.com/rust-lang/cargo/pull/12083/) Previously, Cargo tried each + combination of hyphens and underscores, causing excessive requests to crates.io. +- Cargo now [disallows `RUSTUP_HOME`](https://github.com/rust-lang/cargo/pull/12101/) and + [`RUSTUP_TOOLCHAIN`](https://github.com/rust-lang/cargo/pull/12107/) in the `[env]` configuration + table. This is considered to be not a use case Cargo would like to support, since it will likely + cause problems or lead to confusion. + + + +Internal Changes +---------------- + +These changes do not affect any public interfaces of Rust, but they represent +significant improvements to the performance or internals of rustc and related +tools. + + Version 1.70.0 (2023-06-01) ========================== From 281e072d8026ddc36f8bac8f138eb6544fdb845a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 29 Jun 2023 11:38:43 -0700 Subject: [PATCH 05/18] Remove target feature note These are still unstable through `avx512_target_feature`. Co-authored-by: Taiki Endo --- RELEASES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 423bf2e7bd1d2..95cc36e242a20 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6,7 +6,6 @@ Version 1.71.0 (2023-07-13) Language -------- -- [Remove misleading target feature aliases, inappropriately connected to AVX-512.](https://github.com/rust-lang/rust/pull/107707/) - [Stabilize `raw-dylib`, `link_ordinal`, `import_name_type` and `-Cdlltool`.](https://github.com/rust-lang/rust/pull/109677/) - [Uplift `clippy::{drop,forget}_{ref,copy}` lints.](https://github.com/rust-lang/rust/pull/109732/) - [Type inference is more conservative around constrained vars.](https://github.com/rust-lang/rust/pull/110100/) From 43f4fa4bf12b05e07001b1a80fa136845d49ec6c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 29 Jun 2023 11:52:31 -0700 Subject: [PATCH 06/18] Move the TypeId change to Compatibility Notes --- RELEASES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 95cc36e242a20..0bb535ff14ab8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -39,7 +39,6 @@ for more information on Rust's tiered platform support. Libraries --------- -- [Remove structural match from `TypeId`.](https://github.com/rust-lang/rust/pull/103291/) - [Loosen `From<&[T]> for Box<[T]>` bound to `T: Clone`.](https://github.com/rust-lang/rust/pull/103406/) - [Remove unnecessary `T: Send` bound](https://github.com/rust-lang/rust/pull/111134/) in `Error for mpsc::SendError` and `TrySendError`. @@ -111,6 +110,10 @@ Misc Compatibility Notes ------------------- +- [Remove structural match from `TypeId`.](https://github.com/rust-lang/rust/pull/103291/) + Code that uses a constant `TypeId` in a pattern will potentially be broken. + Known cases have already been fixed -- in particular, users of the `log` + crate's `kv_unstable` feature should update to `log v0.4.18` or later. - [Add a `sysroot` crate to represent the standard library crates.](https://github.com/rust-lang/rust/pull/108865/) This does not affect stable users, but may require adjustment in tools that build their own standard library. - [Cargo optimizes its usage under `rustup`.](https://github.com/rust-lang/cargo/pull/11917/) When From a30f797437eefb9322d8ea87b70d8714f4761332 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 29 Jun 2023 12:20:30 -0700 Subject: [PATCH 07/18] Add a release note about recursive panics --- RELEASES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 0bb535ff14ab8..419c20b9071bf 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -39,6 +39,9 @@ for more information on Rust's tiered platform support. Libraries --------- +- [Rework handling of recursive panics.](https://github.com/rust-lang/rust/pull/110975/) + Additional panics are allowed while unwinding, as long as they are caught before escaping + a `Drop` implementation, but panicking within a panic hook is now an immediate abort. - [Loosen `From<&[T]> for Box<[T]>` bound to `T: Clone`.](https://github.com/rust-lang/rust/pull/103406/) - [Remove unnecessary `T: Send` bound](https://github.com/rust-lang/rust/pull/111134/) in `Error for mpsc::SendError` and `TrySendError`. From 76a7772759247e00365a90be936504289c359165 Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Fri, 30 Jun 2023 08:26:56 -0400 Subject: [PATCH 08/18] resolve typerelative ctors to adt --- compiler/rustc_mir_build/src/thir/cx/expr.rs | 39 +++++++++++++------ .../user-annotations/normalization-2.stderr | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 791c10c1748d9..26192c8e3c609 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -351,19 +351,34 @@ impl<'tcx> Cx<'tcx> { }); } } - let adt_data = - if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = fun.kind { + let adt_data = if let hir::ExprKind::Path(qpath) = fun.kind { + match qpath { // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. - expr_ty.ty_adt_def().and_then(|adt_def| match path.res { - Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_id) => { - Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) - } - Res::SelfCtor(..) => Some((adt_def, FIRST_VARIANT)), - _ => None, - }) - } else { - None - }; + hir::QPath::Resolved(_, ref path) => { + expr_ty.ty_adt_def().and_then(|adt_def| match path.res { + Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_id) => { + Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) + } + Res::SelfCtor(..) => Some((adt_def, FIRST_VARIANT)), + _ => None, + }) + } + hir::QPath::TypeRelative(_ty, _) => { + expr_ty.ty_adt_def().and_then(|adt_def| { + if let Some((DefKind::Ctor(_, CtorKind::Fn), ctor_id)) = + self.typeck_results().type_dependent_def(fun.hir_id) + { + Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) + } else { + None + } + }) + } + _ => None, + } + } else { + None + }; if let Some((adt_def, index)) = adt_data { let substs = self.typeck_results().node_substs(fun.hir_id); let user_provided_types = self.typeck_results().user_provided_types(); diff --git a/tests/ui/nll/user-annotations/normalization-2.stderr b/tests/ui/nll/user-annotations/normalization-2.stderr index 5299282ea151e..6b0dcb414aea5 100644 --- a/tests/ui/nll/user-annotations/normalization-2.stderr +++ b/tests/ui/nll/user-annotations/normalization-2.stderr @@ -147,7 +147,7 @@ LL | fn test_variants<'a, 'b, 'c>() { | -- lifetime `'b` defined here ... LL | >::Tuple(); - | ^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | ^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: lifetime may not live long enough --> $DIR/normalization-2.rs:93:5 From 7dfb9eda25d1973fd8b70f95174e31c1443dde6a Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Sat, 1 Jul 2023 02:28:15 -0400 Subject: [PATCH 09/18] add regression test --- tests/ui/pattern/issue-110508.rs | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/ui/pattern/issue-110508.rs diff --git a/tests/ui/pattern/issue-110508.rs b/tests/ui/pattern/issue-110508.rs new file mode 100644 index 0000000000000..1024ff05578ef --- /dev/null +++ b/tests/ui/pattern/issue-110508.rs @@ -0,0 +1,38 @@ +// run-pass + +#[derive(PartialEq, Eq)] +pub enum Foo { + FooA(()), + FooB(Vec<()>), +} + +impl Foo { + const A1: Foo = Foo::FooA(()); + const A2: Foo = Self::FooA(()); + const A3: Self = Foo::FooA(()); + const A4: Self = Self::FooA(()); +} + +fn main() { + let foo = Foo::FooA(()); + + match foo { + Foo::A1 => {}, + _ => {}, + } + + match foo { + Foo::A2 => {}, + _ => {}, + } + + match foo { + Foo::A3 => {}, + _ => {}, + } + + match foo { + Foo::A4 => {}, + _ => {}, + } +} From b9e991a105f36060a7ed501aa7f5897cc43685ae Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Sat, 1 Jul 2023 15:15:22 -0400 Subject: [PATCH 10/18] add thir-print test --- .../ui/thir-print/thir-flat-const-variant.rs | 18 + .../thir-print/thir-flat-const-variant.stdout | 399 ++++++++++++++++++ 2 files changed, 417 insertions(+) create mode 100644 tests/ui/thir-print/thir-flat-const-variant.rs create mode 100644 tests/ui/thir-print/thir-flat-const-variant.stdout diff --git a/tests/ui/thir-print/thir-flat-const-variant.rs b/tests/ui/thir-print/thir-flat-const-variant.rs new file mode 100644 index 0000000000000..2cd87a5cbb2af --- /dev/null +++ b/tests/ui/thir-print/thir-flat-const-variant.rs @@ -0,0 +1,18 @@ +// compile-flags: -Z unpretty=thir-flat +// check-pass + +// Previously, the constants with `Self::Bar(())` would be `Call`s instead of +// `Adt`s in THIR. + +pub enum Foo { + Bar(()), +} + +impl Foo { + const BAR1: Foo = Foo::Bar(()); + const BAR2: Foo = Self::Bar(()); + const BAR3: Self = Foo::Bar(()); + const BAR4: Self = Self::Bar(()); +} + +fn main() {} diff --git a/tests/ui/thir-print/thir-flat-const-variant.stdout b/tests/ui/thir-print/thir-flat-const-variant.stdout new file mode 100644 index 0000000000000..1b76f07c31889 --- /dev/null +++ b/tests/ui/thir-print/thir-flat-const-variant.stdout @@ -0,0 +1,399 @@ +DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(7), + lint_level: Explicit( + HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).7), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(8), + lint_level: Explicit( + HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).8), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(7), + lint_level: Explicit( + HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).7), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(8), + lint_level: Explicit( + HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).8), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:12 ~ thir_flat_const_variant[1f54]::main): +Thir { + body_type: Fn( + fn(), + ), + arms: [], + blocks: [ + Block { + targeted_by_break: false, + region_scope: Node(1), + opt_destruction_scope: None, + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + stmts: [], + expr: None, + safety_mode: Safe, + }, + ], + exprs: [ + Expr { + kind: Block { + block: b0, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(2), + lint_level: Explicit( + HirId(DefId(0:12 ~ thir_flat_const_variant[1f54]::main).2), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(2), + lint_level: Inherited, + value: e1, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + ], + stmts: [], + params: [], +} + From 7bb9de87f669affafb7aa4c2e4c18b36f0b2238d Mon Sep 17 00:00:00 2001 From: Alex Touchet Date: Sat, 1 Jul 2023 21:14:20 -0700 Subject: [PATCH 11/18] Use consistent formatting in Readme --- README.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 901213d2ca977..8a6c559b0b312 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,9 @@ Read ["Installation"] from [The Book]. The Rust build system uses a Python script called `x.py` to build the compiler, which manages the bootstrapping process. It lives at the root of the project. -It also uses a file named `config.toml` to determine various configuration settings for the build. -You can see a full list of options in `config.example.toml`. +It also uses a file named `config.toml` to determine various configuration +settings for the build. You can see a full list of options in +`config.example.toml`. The `x.py` command can be run directly on most Unix systems in the following format: @@ -33,7 +34,8 @@ format: ``` This is how the documentation and examples assume you are running `x.py`. -See the [rustc dev guide][rustcguidebuild] if this does not work on your platform. +See the [rustc dev guide][rustcguidebuild] if this does not work on your +platform. More information about `x.py` can be found by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. @@ -105,24 +107,26 @@ See [the rustc-dev-guide for more info][sysllvm]. When complete, `./x.py install` will place several programs into `$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the - API-documentation tool. By default, it will also include [Cargo], Rust's package manager. - You can disable this behavior by passing `--set build.extended=false` to `./configure`. + API-documentation tool. By default, it will also include [Cargo], Rust's + package manager. You can disable this behavior by passing + `--set build.extended=false` to `./configure`. [Cargo]: https://github.com/rust-lang/cargo #### Configure and Make -This project provides a configure script and makefile (the latter of which just invokes `x.py`). -`./configure` is the recommended way to programatically generate a `config.toml`. `make` is not -recommended (we suggest using `x.py` directly), but it is supported and we try not to break it -unnecessarily. +This project provides a configure script and makefile (the latter of which just +invokes `x.py`). `./configure` is the recommended way to programatically +generate a `config.toml`. `make` is not recommended (we suggest using `x.py` +directly), but it is supported and we try not to break it unnecessarily. ```sh ./configure make && sudo make install ``` -`configure` generates a `config.toml` which can also be used with normal `x.py` invocations. +`configure` generates a `config.toml` which can also be used with normal `x.py` +invocations. ### Building on Windows @@ -193,7 +197,7 @@ toolchain. #### MSVC MSVC builds of Rust additionally require an installation of Visual Studio 2017 -(or later) so `rustc` can use its linker. The simplest way is to get +(or later) so `rustc` can use its linker. The simplest way is to get [Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload. [Visual Studio]: https://visualstudio.microsoft.com/downloads/ @@ -234,7 +238,8 @@ Windows build triples are: The build triple can be specified by either specifying `--build=` when invoking `x.py` commands, or by creating a `config.toml` file (as described in -[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing `--set build.build=` to `./configure`. +[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing +`--set build.build=` to `./configure`. ## Building Documentation From 07b1912acc54949b4077138b6f1adac376b94e92 Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Sun, 2 Jul 2023 18:44:26 -0400 Subject: [PATCH 12/18] refactor --- compiler/rustc_mir_build/src/thir/cx/expr.rs | 36 +++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 26192c8e3c609..dc1c0966fe7f7 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -208,17 +208,18 @@ impl<'tcx> Cx<'tcx> { // so we wouldn't have to compute and store the actual value let hir::ExprKind::Path(ref qpath) = source.kind else { - return ExprKind::Cast { source: self.mirror_expr(source)}; + return ExprKind::Cast { source: self.mirror_expr(source) }; }; let res = self.typeck_results().qpath_res(qpath, source.hir_id); let ty = self.typeck_results().node_type(source.hir_id); let ty::Adt(adt_def, substs) = ty.kind() else { - return ExprKind::Cast { source: self.mirror_expr(source)}; + return ExprKind::Cast { source: self.mirror_expr(source) }; }; - let Res::Def(DefKind::Ctor(CtorOf::Variant, CtorKind::Const), variant_ctor_id) = res else { - return ExprKind::Cast { source: self.mirror_expr(source)}; + let Res::Def(DefKind::Ctor(CtorOf::Variant, CtorKind::Const), variant_ctor_id) = res + else { + return ExprKind::Cast { source: self.mirror_expr(source) }; }; let idx = adt_def.variant_index_with_ctor_id(variant_ctor_id); @@ -351,28 +352,29 @@ impl<'tcx> Cx<'tcx> { }); } } - let adt_data = if let hir::ExprKind::Path(qpath) = fun.kind { + + // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. + let adt_data = if let hir::ExprKind::Path(ref qpath) = fun.kind + && let Some(adt_def) = expr_ty.ty_adt_def() { match qpath { - // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. hir::QPath::Resolved(_, ref path) => { - expr_ty.ty_adt_def().and_then(|adt_def| match path.res { + match path.res { Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_id) => { Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) } Res::SelfCtor(..) => Some((adt_def, FIRST_VARIANT)), _ => None, - }) + } } hir::QPath::TypeRelative(_ty, _) => { - expr_ty.ty_adt_def().and_then(|adt_def| { - if let Some((DefKind::Ctor(_, CtorKind::Fn), ctor_id)) = - self.typeck_results().type_dependent_def(fun.hir_id) - { - Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) - } else { - None - } - }) + if let Some((DefKind::Ctor(_, CtorKind::Fn), ctor_id)) = + self.typeck_results().type_dependent_def(fun.hir_id) + { + Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))) + } else { + None + } + } _ => None, } From afccc444022f17fea184c65758827f9d5e64922b Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Wed, 5 Jul 2023 02:19:44 +0000 Subject: [PATCH 13/18] add mir dump test --- tests/mir-opt/building/issue_110508.rs | 13 +++++++++++++ .../issue_110508.{impl#0}-BAR1.built.after.mir | 14 ++++++++++++++ .../issue_110508.{impl#0}-BAR2.built.after.mir | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/mir-opt/building/issue_110508.rs create mode 100644 tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir create mode 100644 tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir diff --git a/tests/mir-opt/building/issue_110508.rs b/tests/mir-opt/building/issue_110508.rs new file mode 100644 index 0000000000000..120b026a70f13 --- /dev/null +++ b/tests/mir-opt/building/issue_110508.rs @@ -0,0 +1,13 @@ +// EMIT_MIR issue_110508.{impl#0}-BAR1.built.after.mir +// EMIT_MIR issue_110508.{impl#0}-BAR2.built.after.mir + +enum Foo { + Bar(()), +} + +impl Foo { + const BAR1: Foo = Foo::Bar(()); + const BAR2: Foo = Self::Bar(()); +} + +fn main() {} diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir new file mode 100644 index 0000000000000..6adcdcae76265 --- /dev/null +++ b/tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir @@ -0,0 +1,14 @@ +// MIR for `::BAR1` after built + +const ::BAR1: Foo = { + let mut _0: Foo; + let mut _1: (); + + bb0: { + StorageLive(_1); + _1 = (); + _0 = Foo::Bar(move _1); + StorageDead(_1); + return; + } +} diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir new file mode 100644 index 0000000000000..d1bd45fba2688 --- /dev/null +++ b/tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir @@ -0,0 +1,14 @@ +// MIR for `::BAR2` after built + +const ::BAR2: Foo = { + let mut _0: Foo; + let mut _1: (); + + bb0: { + StorageLive(_1); + _1 = (); + _0 = Foo::Bar(move _1); + StorageDead(_1); + return; + } +} From 261c0231232287dec32329ceb67d61249ffc8d5e Mon Sep 17 00:00:00 2001 From: Eric Mark Martin Date: Wed, 5 Jul 2023 04:28:45 +0000 Subject: [PATCH 14/18] rename constants in mir dump test --- tests/mir-opt/building/issue_110508.rs | 8 ++++---- ...fter.mir => issue_110508.{impl#0}-BAR.built.after.mir} | 4 ++-- ...mir => issue_110508.{impl#0}-SELF_BAR.built.after.mir} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename tests/mir-opt/building/{issue_110508.{impl#0}-BAR1.built.after.mir => issue_110508.{impl#0}-BAR.built.after.mir} (57%) rename tests/mir-opt/building/{issue_110508.{impl#0}-BAR2.built.after.mir => issue_110508.{impl#0}-SELF_BAR.built.after.mir} (55%) diff --git a/tests/mir-opt/building/issue_110508.rs b/tests/mir-opt/building/issue_110508.rs index 120b026a70f13..bcbb1c2983090 100644 --- a/tests/mir-opt/building/issue_110508.rs +++ b/tests/mir-opt/building/issue_110508.rs @@ -1,13 +1,13 @@ -// EMIT_MIR issue_110508.{impl#0}-BAR1.built.after.mir -// EMIT_MIR issue_110508.{impl#0}-BAR2.built.after.mir +// EMIT_MIR issue_110508.{impl#0}-BAR.built.after.mir +// EMIT_MIR issue_110508.{impl#0}-SELF_BAR.built.after.mir enum Foo { Bar(()), } impl Foo { - const BAR1: Foo = Foo::Bar(()); - const BAR2: Foo = Self::Bar(()); + const BAR: Foo = Foo::Bar(()); + const SELF_BAR: Foo = Self::Bar(()); } fn main() {} diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir similarity index 57% rename from tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir rename to tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir index 6adcdcae76265..5fc6d911af354 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-BAR1.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `::BAR1` after built +// MIR for `::BAR` after built -const ::BAR1: Foo = { +const ::BAR: Foo = { let mut _0: Foo; let mut _1: (); diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir similarity index 55% rename from tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir rename to tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir index d1bd45fba2688..1a8925599717e 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-BAR2.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `::BAR2` after built +// MIR for `::SELF_BAR` after built -const ::BAR2: Foo = { +const ::SELF_BAR: Foo = { let mut _0: Foo; let mut _1: (); From 0ba1e0f0febcde615a70d271572c2054e14965dc Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Tue, 20 Jun 2023 10:32:12 -0700 Subject: [PATCH 15/18] Fix standalone build Add extern declarations and optional dependencies to fix build done directly via `cargo build`. --- Cargo.lock | 1 + compiler/rustc_smir/Cargo.toml | 6 +++++- compiler/rustc_smir/rust-toolchain.toml | 2 +- compiler/rustc_smir/src/lib.rs | 10 ++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c936ca40e167..e0446fb28f2ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3949,6 +3949,7 @@ dependencies = [ "rustc_middle", "rustc_span", "scoped-tls", + "rustc_target", "tracing", ] diff --git a/compiler/rustc_smir/Cargo.toml b/compiler/rustc_smir/Cargo.toml index a6e6de5f785a2..80d4e7ed02fe2 100644 --- a/compiler/rustc_smir/Cargo.toml +++ b/compiler/rustc_smir/Cargo.toml @@ -4,14 +4,18 @@ version = "0.0.0" edition = "2021" [dependencies] -rustc_hir = { path = "../rustc_hir" } +# Use optional dependencies for rustc_* in order to support building this crate separately. +rustc_hir = { path = "../rustc_hir", optional = true } rustc_middle = { path = "../rustc_middle", optional = true } rustc_span = { path = "../rustc_span", optional = true } +rustc_target = { path = "../rustc_target", optional = true } tracing = "0.1" scoped-tls = "1.0" [features] default = [ + "rustc_hir", "rustc_middle", "rustc_span", + "rustc_target", ] diff --git a/compiler/rustc_smir/rust-toolchain.toml b/compiler/rustc_smir/rust-toolchain.toml index 157dfd620ee1b..d75e8e33b1c56 100644 --- a/compiler/rustc_smir/rust-toolchain.toml +++ b/compiler/rustc_smir/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-02-28" +channel = "nightly-2023-06-14" components = [ "rustfmt", "rustc-dev" ] diff --git a/compiler/rustc_smir/src/lib.rs b/compiler/rustc_smir/src/lib.rs index fb03633b99b31..21c72f3aaa18a 100644 --- a/compiler/rustc_smir/src/lib.rs +++ b/compiler/rustc_smir/src/lib.rs @@ -14,6 +14,16 @@ #![feature(local_key_cell_methods)] #![feature(ptr_metadata)] +// Declare extern rustc_* crates to enable building this crate separately from the compiler. +#[cfg(not(feature = "default"))] +extern crate rustc_hir; +#[cfg(not(feature = "default"))] +extern crate rustc_middle; +#[cfg(not(feature = "default"))] +extern crate rustc_span; +#[cfg(not(feature = "default"))] +extern crate rustc_target; + pub mod rustc_internal; pub mod stable_mir; From a6632f189ec52f8385e7e185d389df60ba777267 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Tue, 20 Jun 2023 10:40:23 -0700 Subject: [PATCH 16/18] Implement Stable for AssertMessage --- compiler/rustc_smir/src/rustc_smir/mod.rs | 67 +++++++++++++---------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 874e34bef60f0..788daf6728c47 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -119,8 +119,11 @@ fn smir_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> stable_mir::Crate { stable_mir::Crate { id: crate_num.into(), name: crate_name, is_local } } -pub trait Stable { +/// Trait used to convert between an internal MIR type to a Stable MIR type. +pub(crate) trait Stable { + /// The stable representation of the type implementing Stable. type T; + /// Converts an object to the equivalent Stable MIR representation. fn stable(&self) -> Self::T; } @@ -211,34 +214,38 @@ impl Stable for mir::UnwindAction { } } -fn rustc_assert_msg_to_msg<'tcx>( - assert_message: &rustc_middle::mir::AssertMessage<'tcx>, -) -> stable_mir::mir::AssertMessage { - use rustc_middle::mir::AssertKind; - match assert_message { - AssertKind::BoundsCheck { len, index } => { - stable_mir::mir::AssertMessage::BoundsCheck { len: len.stable(), index: index.stable() } - } - AssertKind::Overflow(bin_op, op1, op2) => { - stable_mir::mir::AssertMessage::Overflow(bin_op.stable(), op1.stable(), op2.stable()) - } - AssertKind::OverflowNeg(op) => stable_mir::mir::AssertMessage::OverflowNeg(op.stable()), - AssertKind::DivisionByZero(op) => { - stable_mir::mir::AssertMessage::DivisionByZero(op.stable()) - } - AssertKind::RemainderByZero(op) => { - stable_mir::mir::AssertMessage::RemainderByZero(op.stable()) - } - AssertKind::ResumedAfterReturn(generator) => { - stable_mir::mir::AssertMessage::ResumedAfterReturn(generator.stable()) - } - AssertKind::ResumedAfterPanic(generator) => { - stable_mir::mir::AssertMessage::ResumedAfterPanic(generator.stable()) - } - AssertKind::MisalignedPointerDereference { required, found } => { - stable_mir::mir::AssertMessage::MisalignedPointerDereference { - required: required.stable(), - found: found.stable(), +impl<'tcx> Stable for mir::AssertMessage<'tcx> { + type T = stable_mir::mir::AssertMessage; + fn stable(&self) -> Self::T { + use rustc_middle::mir::AssertKind; + match self { + AssertKind::BoundsCheck { len, index } => stable_mir::mir::AssertMessage::BoundsCheck { + len: len.stable(), + index: index.stable(), + }, + AssertKind::Overflow(bin_op, op1, op2) => stable_mir::mir::AssertMessage::Overflow( + bin_op.stable(), + op1.stable(), + op2.stable(), + ), + AssertKind::OverflowNeg(op) => stable_mir::mir::AssertMessage::OverflowNeg(op.stable()), + AssertKind::DivisionByZero(op) => { + stable_mir::mir::AssertMessage::DivisionByZero(op.stable()) + } + AssertKind::RemainderByZero(op) => { + stable_mir::mir::AssertMessage::RemainderByZero(op.stable()) + } + AssertKind::ResumedAfterReturn(generator) => { + stable_mir::mir::AssertMessage::ResumedAfterReturn(generator.stable()) + } + AssertKind::ResumedAfterPanic(generator) => { + stable_mir::mir::AssertMessage::ResumedAfterPanic(generator.stable()) + } + AssertKind::MisalignedPointerDereference { required, found } => { + stable_mir::mir::AssertMessage::MisalignedPointerDereference { + required: required.stable(), + found: found.stable(), + } } } } @@ -363,7 +370,7 @@ impl<'tcx> Stable for mir::Terminator<'tcx> { Assert { cond, expected, msg, target, unwind } => Terminator::Assert { cond: cond.stable(), expected: *expected, - msg: rustc_assert_msg_to_msg(msg), + msg: msg.stable(), target: target.as_usize(), unwind: unwind.stable(), }, From 633c0222d0c9296c6a7dbb57e99a44ce8088f667 Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Tue, 13 Jun 2023 15:08:14 -0700 Subject: [PATCH 17/18] Implement a few more rvalue translation to smir - Introduce an Opaque type for adding information that is still internal to the compiler. --- Cargo.lock | 2 +- compiler/rustc_smir/src/lib.rs | 1 + compiler/rustc_smir/src/rustc_internal/mod.rs | 10 + compiler/rustc_smir/src/rustc_smir/mod.rs | 132 ++++++++++++- .../rustc_smir/src/stable_mir/mir/body.rs | 181 +++++++++++++++++- 5 files changed, 316 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0446fb28f2ab..48512ffd9db86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3948,8 +3948,8 @@ dependencies = [ "rustc_hir", "rustc_middle", "rustc_span", - "scoped-tls", "rustc_target", + "scoped-tls", "tracing", ] diff --git a/compiler/rustc_smir/src/lib.rs b/compiler/rustc_smir/src/lib.rs index 21c72f3aaa18a..8450bb7311996 100644 --- a/compiler/rustc_smir/src/lib.rs +++ b/compiler/rustc_smir/src/lib.rs @@ -13,6 +13,7 @@ #![cfg_attr(not(feature = "default"), feature(rustc_private))] #![feature(local_key_cell_methods)] #![feature(ptr_metadata)] +#![feature(type_alias_impl_trait)] // Used to define opaque types. // Declare extern rustc_* crates to enable building this crate separately from the compiler. #[cfg(not(feature = "default"))] diff --git a/compiler/rustc_smir/src/rustc_internal/mod.rs b/compiler/rustc_smir/src/rustc_internal/mod.rs index 609a04d263c96..87e0b211556b9 100644 --- a/compiler/rustc_smir/src/rustc_internal/mod.rs +++ b/compiler/rustc_smir/src/rustc_internal/mod.rs @@ -3,6 +3,9 @@ //! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs //! until stable MIR is complete. +use std::fmt::Debug; +use std::string::ToString; + use crate::{ rustc_smir::Tables, stable_mir::{self, with}, @@ -49,3 +52,10 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum { pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) { crate::stable_mir::run(Tables { tcx, def_ids: vec![], types: vec![] }, f); } + +/// A type that provides internal information but that can still be used for debug purpose. +pub type Opaque = impl Debug + ToString + Clone; + +pub(crate) fn opaque(value: &T) -> Opaque { + format!("{value:?}") +} diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index 788daf6728c47..95e940c6c4449 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -7,10 +7,12 @@ //! //! For now, we are developing everything inside `rustc`, thus, we keep this module private. +use crate::rustc_internal::{self, opaque}; use crate::stable_mir::{self, ty::TyKind, Context}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use rustc_target::abi::FieldIdx; use tracing::debug; impl<'tcx> Context for Tables<'tcx> { @@ -127,6 +129,13 @@ pub(crate) trait Stable { fn stable(&self) -> Self::T; } +impl Stable for DefId { + type T = stable_mir::CrateItem; + fn stable(&self) -> Self::T { + rustc_internal::crate_item(*self) + } +} + impl<'tcx> Stable for mir::Statement<'tcx> { type T = stable_mir::mir::Statement; fn stable(&self) -> Self::T { @@ -158,12 +167,18 @@ impl<'tcx> Stable for mir::Rvalue<'tcx> { match self { Use(op) => stable_mir::mir::Rvalue::Use(op.stable()), Repeat(_, _) => todo!(), - Ref(_, _, _) => todo!(), - ThreadLocalRef(_) => todo!(), - AddressOf(_, _) => todo!(), - Len(_) => todo!(), + Ref(region, kind, place) => { + stable_mir::mir::Rvalue::Ref(opaque(region), kind.stable(), place.stable()) + } + ThreadLocalRef(def_id) => stable_mir::mir::Rvalue::ThreadLocalRef(def_id.stable()), + AddressOf(mutability, place) => { + stable_mir::mir::Rvalue::AddressOf(mutability.stable(), place.stable()) + } + Len(place) => stable_mir::mir::Rvalue::Len(place.stable()), Cast(_, _, _) => todo!(), - BinaryOp(_, _) => todo!(), + BinaryOp(bin_op, ops) => { + stable_mir::mir::Rvalue::BinaryOp(bin_op.stable(), ops.0.stable(), ops.1.stable()) + } CheckedBinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::CheckedBinaryOp( bin_op.stable(), ops.0.stable(), @@ -171,14 +186,117 @@ impl<'tcx> Stable for mir::Rvalue<'tcx> { ), NullaryOp(_, _) => todo!(), UnaryOp(un_op, op) => stable_mir::mir::Rvalue::UnaryOp(un_op.stable(), op.stable()), - Discriminant(_) => todo!(), + Discriminant(place) => stable_mir::mir::Rvalue::Discriminant(place.stable()), Aggregate(_, _) => todo!(), ShallowInitBox(_, _) => todo!(), - CopyForDeref(_) => todo!(), + CopyForDeref(place) => stable_mir::mir::Rvalue::CopyForDeref(place.stable()), + } + } +} + +impl Stable for mir::Mutability { + type T = stable_mir::mir::Mutability; + fn stable(&self) -> Self::T { + use mir::Mutability::*; + match *self { + Not => stable_mir::mir::Mutability::Not, + Mut => stable_mir::mir::Mutability::Mut, + } + } +} + +impl Stable for mir::BorrowKind { + type T = stable_mir::mir::BorrowKind; + fn stable(&self) -> Self::T { + use mir::BorrowKind::*; + match *self { + Shared => stable_mir::mir::BorrowKind::Shared, + Shallow => stable_mir::mir::BorrowKind::Shallow, + Mut { kind } => stable_mir::mir::BorrowKind::Mut { kind: kind.stable() }, + } + } +} + +impl Stable for mir::MutBorrowKind { + type T = stable_mir::mir::MutBorrowKind; + fn stable(&self) -> Self::T { + use mir::MutBorrowKind::*; + match *self { + Default => stable_mir::mir::MutBorrowKind::Default, + TwoPhaseBorrow => stable_mir::mir::MutBorrowKind::TwoPhaseBorrow, + ClosureCapture => stable_mir::mir::MutBorrowKind::ClosureCapture, + } + } +} + +impl<'tcx> Stable for mir::NullOp<'tcx> { + type T = stable_mir::mir::NullOp; + fn stable(&self) -> Self::T { + use mir::NullOp::*; + match self { + SizeOf => stable_mir::mir::NullOp::SizeOf, + AlignOf => stable_mir::mir::NullOp::AlignOf, + OffsetOf(indices) => { + stable_mir::mir::NullOp::OffsetOf(indices.iter().map(|idx| idx.stable()).collect()) + } + } + } +} + +impl Stable for mir::CastKind { + type T = stable_mir::mir::CastKind; + fn stable(&self) -> Self::T { + use mir::CastKind::*; + match self { + PointerExposeAddress => stable_mir::mir::CastKind::PointerExposeAddress, + PointerFromExposedAddress => stable_mir::mir::CastKind::PointerFromExposedAddress, + Pointer(cast) => stable_mir::mir::CastKind::Pointer(cast.stable()), + DynStar => stable_mir::mir::CastKind::DynStar, + IntToInt => stable_mir::mir::CastKind::IntToInt, + FloatToInt => stable_mir::mir::CastKind::FloatToInt, + FloatToFloat => stable_mir::mir::CastKind::FloatToFloat, + IntToFloat => stable_mir::mir::CastKind::IntToFloat, + PtrToPtr => stable_mir::mir::CastKind::PtrToPtr, + FnPtrToPtr => stable_mir::mir::CastKind::FnPtrToPtr, + Transmute => stable_mir::mir::CastKind::Transmute, + } + } +} + +impl Stable for ty::adjustment::PointerCast { + type T = stable_mir::mir::PointerCast; + fn stable(&self) -> Self::T { + use ty::adjustment::PointerCast; + match self { + PointerCast::ReifyFnPointer => stable_mir::mir::PointerCast::ReifyFnPointer, + PointerCast::UnsafeFnPointer => stable_mir::mir::PointerCast::UnsafeFnPointer, + PointerCast::ClosureFnPointer(unsafety) => { + stable_mir::mir::PointerCast::ClosureFnPointer(unsafety.stable()) + } + PointerCast::MutToConstPointer => stable_mir::mir::PointerCast::MutToConstPointer, + PointerCast::ArrayToPointer => stable_mir::mir::PointerCast::ArrayToPointer, + PointerCast::Unsize => stable_mir::mir::PointerCast::Unsize, } } } +impl Stable for rustc_hir::Unsafety { + type T = stable_mir::mir::Safety; + fn stable(&self) -> Self::T { + match self { + rustc_hir::Unsafety::Unsafe => stable_mir::mir::Safety::Unsafe, + rustc_hir::Unsafety::Normal => stable_mir::mir::Safety::Normal, + } + } +} + +impl Stable for FieldIdx { + type T = usize; + fn stable(&self) -> Self::T { + self.as_usize() + } +} + impl<'tcx> Stable for mir::Operand<'tcx> { type T = stable_mir::mir::Operand; fn stable(&self) -> Self::T { diff --git a/compiler/rustc_smir/src/stable_mir/mir/body.rs b/compiler/rustc_smir/src/stable_mir/mir/body.rs index 468e915d1a073..b1d1dbf0190cb 100644 --- a/compiler/rustc_smir/src/stable_mir/mir/body.rs +++ b/compiler/rustc_smir/src/stable_mir/mir/body.rs @@ -1,4 +1,5 @@ -use crate::stable_mir::ty::Ty; +use crate::rustc_internal::Opaque; +use crate::stable_mir::{self, ty::Ty}; #[derive(Clone, Debug)] pub struct Body { @@ -136,12 +137,98 @@ pub enum Statement { Nop, } +type Region = Opaque; + // FIXME this is incomplete #[derive(Clone, Debug)] pub enum Rvalue { - Use(Operand), + /// Creates a pointer with the indicated mutability to the place. + /// + /// This is generated by pointer casts like `&v as *const _` or raw address of expressions like + /// `&raw v` or `addr_of!(v)`. + AddressOf(Mutability, Place), + + /// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second + /// parameter may be a `usize` as well. + /// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats, + /// raw pointers, or function pointers and return a `bool`. The types of the operands must be + /// matching, up to the usual caveat of the lifetimes in function pointers. + /// * Left and right shift operations accept signed or unsigned integers not necessarily of the + /// same type and return a value of the same type as their LHS. Like in Rust, the RHS is + /// truncated as needed. + /// * The `Bit*` operations accept signed integers, unsigned integers, or bools with matching + /// types and return a value of that type. + /// * The remaining operations accept signed integers, unsigned integers, or floats with + /// matching types and return a value of that type. + BinaryOp(BinOp, Operand, Operand), + + /// Performs essentially all of the casts that can be performed via `as`. + /// + /// This allows for casts from/to a variety of types. + Cast(CastKind, Operand, Ty), + + /// Same as `BinaryOp`, but yields `(T, bool)` with a `bool` indicating an error condition. + /// + /// For addition, subtraction, and multiplication on integers the error condition is set when + /// the infinite precision result would not be equal to the actual result. CheckedBinaryOp(BinOp, Operand, Operand), + + /// A CopyForDeref is equivalent to a read from a place. + /// When such a read happens, it is guaranteed that the only use of the returned value is a + /// deref operation, immediately followed by one or more projections. + CopyForDeref(Place), + + /// Computes the discriminant of the place, returning it as an integer of type + /// [`discriminant_ty`]. Returns zero for types without discriminant. + /// + /// The validity requirements for the underlying value are undecided for this rvalue, see + /// [#91095]. Note too that the value of the discriminant is not the same thing as the + /// variant index; use [`discriminant_for_variant`] to convert. + /// + /// [`discriminant_ty`]: crate::ty::Ty::discriminant_ty + /// [#91095]: https://github.com/rust-lang/rust/issues/91095 + /// [`discriminant_for_variant`]: crate::ty::Ty::discriminant_for_variant + Discriminant(Place), + + /// Yields the length of the place, as a `usize`. + /// + /// If the type of the place is an array, this is the array length. For slices (`[T]`, not + /// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is + /// ill-formed for places of other types. + Len(Place), + + /// Creates a reference to the place. + Ref(Region, BorrowKind, Place), + + /// Transmutes a `*mut u8` into shallow-initialized `Box`. + /// + /// This is different from a normal transmute because dataflow analysis will treat the box as + /// initialized but its content as uninitialized. Like other pointer casts, this in general + /// affects alias analysis. + ShallowInitBox(Operand, Ty), + + /// Creates a pointer/reference to the given thread local. + /// + /// The yielded type is a `*mut T` if the static is mutable, otherwise if the static is extern a + /// `*const T`, and if neither of those apply a `&T`. + /// + /// **Note:** This is a runtime operation that actually executes code and is in this sense more + /// like a function call. Also, eliminating dead stores of this rvalue causes `fn main() {}` to + /// SIGILL for some reason that I (JakobDegen) never got a chance to look into. + /// + /// **Needs clarification**: Are there weird additional semantics here related to the runtime + /// nature of this operation? + ThreadLocalRef(stable_mir::CrateItem), + + /// Exactly like `BinaryOp`, but less operands. + /// + /// Also does two's-complement arithmetic. Negation requires a signed integer or a float; + /// bitwise not requires a signed integer, unsigned integer, or bool. Both operation kinds + /// return a value with the same type as their operand. UnaryOp(UnOp, Operand), + + /// Yields the operand unchanged + Use(Operand), } #[derive(Clone, Debug)] @@ -157,8 +244,98 @@ pub struct Place { pub projection: String, } +type FieldIdx = usize; + #[derive(Clone, Debug)] pub struct SwitchTarget { pub value: u128, pub target: usize, } + +#[derive(Clone, Debug)] +pub enum BorrowKind { + /// Data must be immutable and is aliasable. + Shared, + + /// The immediately borrowed place must be immutable, but projections from + /// it don't need to be. For example, a shallow borrow of `a.b` doesn't + /// conflict with a mutable borrow of `a.b.c`. + Shallow, + + /// Data is mutable and not aliasable. + Mut { + /// `true` if this borrow arose from method-call auto-ref + kind: MutBorrowKind, + }, +} + +#[derive(Clone, Debug)] +pub enum MutBorrowKind { + Default, + TwoPhaseBorrow, + ClosureCapture, +} + +#[derive(Clone, Debug)] +pub enum Mutability { + Not, + Mut, +} + +#[derive(Clone, Debug)] +pub enum Safety { + Unsafe, + Normal, +} + +#[derive(Clone, Debug)] +pub enum PointerCast { + /// Go from a fn-item type to a fn-pointer type. + ReifyFnPointer, + + /// Go from a safe fn pointer to an unsafe fn pointer. + UnsafeFnPointer, + + /// Go from a non-capturing closure to an fn pointer or an unsafe fn pointer. + /// It cannot convert a closure that requires unsafe. + ClosureFnPointer(Safety), + + /// Go from a mut raw pointer to a const raw pointer. + MutToConstPointer, + + /// Go from `*const [T; N]` to `*const T` + ArrayToPointer, + + /// Unsize a pointer/reference value, e.g., `&[T; n]` to + /// `&[T]`. Note that the source could be a thin or fat pointer. + /// This will do things like convert thin pointers to fat + /// pointers, or convert structs containing thin pointers to + /// structs containing fat pointers, or convert between fat + /// pointers. + Unsize, +} + +#[derive(Clone, Debug)] +pub enum CastKind { + PointerExposeAddress, + PointerFromExposedAddress, + Pointer(PointerCast), + DynStar, + IntToInt, + FloatToInt, + FloatToFloat, + IntToFloat, + PtrToPtr, + FnPtrToPtr, + Transmute, +} + +#[derive(Clone, Debug)] +pub enum NullOp { + /// Returns the size of a value of that type. + SizeOf, + /// Returns the minimum alignment of a type. + AlignOf, + /// Returns the offset of a field. + OffsetOf(Vec), +} From 50b4d1f4134f91354ed71e6e08d91f21015a626b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 8 Jul 2023 14:55:50 +0200 Subject: [PATCH 18/18] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/sidebar-source-code.goml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 520b2c59b0f89..2cb888178847f 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -25,24 +25,24 @@ call-function: ( "check-colors", { "theme": "ayu", - "color": "rgb(197, 197, 197)", - "background_color": "rgb(20, 25, 31)", + "color": "#c5c5c5", + "background_color": "#14191f", } ) call-function: ( "check-colors", { "theme": "dark", - "color": "rgb(221, 221, 221)", - "background_color": "rgb(80, 80, 80)", + "color": "#ddd", + "background_color": "#505050", } ) call-function: ( "check-colors", { "theme": "light", - "color": "rgb(0, 0, 0)", - "background_color": "rgb(245, 245, 245)", + "color": "black", + "background_color": "#F5F5F5", } )