diff --git a/compiler/rustc_attr_ir/src/attribute_docs.rs b/compiler/rustc_attr_ir/src/attribute_docs.rs index cc6e3d849d6b1..cb42c7a7bd742 100644 --- a/compiler/rustc_attr_ir/src/attribute_docs.rs +++ b/compiler/rustc_attr_ir/src/attribute_docs.rs @@ -425,11 +425,11 @@ const _: () = (); /// positional and listed parameters are not accepted. /// The following parameter names are valid: /// - `Self` and all generic parameters of the trait. -/// - `This`: the name of the trait the attribute is on, without generics. -/// - `This:path`: the full path of the trait the attribute is on, with unresolved generics. -/// - `This:resolved`: the full path of the trait the attribute is on, with resolved generics. +/// - `this`: the name of the trait the attribute is on, without generics. +/// - `this:path`: the full path of the trait the attribute is on, with unresolved generics. +/// - `this:resolved`: the full path of the trait the attribute is on, with resolved generics. /// Additionally, this will "sugar" the `Fn(...)` traits. -/// - `ItemContext`: the kind of `hir::Node` we're in, things like `"an async block"`, +/// - `item_context`: the kind of `hir::Node` we're in, things like `"an async block"`, /// `"a function"`, `"an async function"`, etc. /// #[doc = include_example!("rustc_on_unimplemented_format")] diff --git a/compiler/rustc_attr_ir/src/diagnostic.rs b/compiler/rustc_attr_ir/src/diagnostic.rs index ead8fbb89dfbd..bfbeb3fc54555 100644 --- a/compiler/rustc_attr_ir/src/diagnostic.rs +++ b/compiler/rustc_attr_ir/src/diagnostic.rs @@ -237,22 +237,22 @@ pub enum FormatArg { }, // `{Self}` SelfUpper, - /// `{This}` and `{This:name}`. + /// `{this}` and `{this:name}`. This, - /// The sugared form: `{This:sugared}`. + /// The sugared form: `{this:resolved}`. ThisResolved, - /// The full path: `{This:path}`. + /// The full path: `{this:path}`. ThisPath, - /// what we're in, like a function, method, closure etc. + /// What we're in, like a function, method, closure etc. Used via `{item_context}`. ItemContext, - /// What the user typed, if it doesn't match anything we can use. - AsIs(Symbol), - /// {Found} in diagnostic::on_type_error + /// {found} in diagnostic::on_type_error Found, - /// {Expected} in diagnostic::on_type_error + /// {expected} in diagnostic::on_type_error Expected, - /// {Unresolved} in diagnostic::on_unknown + /// {unresolved} in diagnostic::on_unknown Unresolved, + /// What the user typed, if it doesn't match anything we can use. + AsIs(Symbol), } /// Represents the `on` filter in `#[rustc_on_unimplemented]`. diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index 53114d0ca9d8a..96dabe6ae46dd 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -174,13 +174,13 @@ impl Mode { "only `Self` and generics of the implementation are allowed as a format argument" } Self::DiagnosticOnMove => { - "only `This`, `Self` and generics of the type are allowed as a format argument" + "only `this`, `Self` and generics of the type are allowed as a format argument" } Self::DiagnosticOnUnknown => { - "only `This` is allowed as a format argument, referring to the failed import" + "only `this` is allowed as a format argument, referring to the failed import" } Self::DiagnosticOnUnmatchedArgs => { - "only `This` is allowed as a format argument, referring to the macro's name" + "only `this` is allowed as a format argument, referring to the macro's name" } Self::DiagnosticOnTypeError => { "only `note` is allowed as option for `diagnostic::on_type_error`" @@ -515,10 +515,10 @@ fn parse_arg( let ret = match arg.position { // Something like "hello {name}" Position::ArgumentNamed(name) => match (mode, Symbol::intern(name)) { - (Mode::RustcOnUnimplemented, sym::ItemContext) => FormatArg::ItemContext, + (Mode::RustcOnUnimplemented, sym::item_context) => FormatArg::ItemContext, - // `{This:ty}` - (Mode::RustcOnUnimplemented, sym::This) => match arg.format.ty { + // `{this:ty}` + (Mode::RustcOnUnimplemented, sym::this) => match arg.format.ty { "resolved" => { check_format = false; FormatArg::ThisResolved @@ -530,11 +530,11 @@ fn parse_arg( _ => FormatArg::This, }, - (Mode::DiagnosticOnTypeError, sym::Found) => FormatArg::Found, - (Mode::DiagnosticOnTypeError, sym::Expected) => FormatArg::Expected, - (Mode::DiagnosticOnUnknown, sym::Unresolved) => FormatArg::Unresolved, + (Mode::DiagnosticOnTypeError, sym::found) => FormatArg::Found, + (Mode::DiagnosticOnTypeError, sym::expected) => FormatArg::Expected, + (Mode::DiagnosticOnUnknown, sym::unresolved) => FormatArg::Unresolved, - // Some diagnostic attributes can use `{This}` to refer to the annotated item. + // Some diagnostic attributes can use `{this}` to refer to the annotated item. // For those that don't, we continue and maybe use it as a generic parameter. // // FIXME(mejrs) `DiagnosticOnUnimplemented` is intentionally not here; @@ -544,13 +544,13 @@ fn parse_arg( | Mode::DiagnosticOnMove | Mode::DiagnosticOnUnmatchedArgs | Mode::DiagnosticOnTypeError, - sym::This, + sym::this, ) => FormatArg::This, // `{Self}`; the self type. // - For trait declaration attributes that's the type that does not implement it. // - for trait impl attributes, the implemented for type. - // - For ADT attributes, that's the type (which will be identical to `{This}`) + // - For ADT attributes, that's the type (which will be identical to `{this}`) // - For everything else it doesn't make sense. ( Mode::RustcOnUnimplemented diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index cb60a97eea053..311f1f5b9162c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1361,18 +1361,21 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { ); let func = with_no_trimmed_paths!(tcx.def_path_str(method_did)); + let mut span: MultiSpan = self_arg.span.into(); + span.push_span_context(tcx.def_span(method_did).shrink_to_lo()); + span.push_span_context(tcx.def_span(tcx.parent(method_did)).shrink_to_lo()); if let Some((kind, _)) = desugaring { err.subdiagnostic(CaptureReasonNote::DesugaringFuncTakeSelf { func, desugar_name: kind.name(), place_name: place_name.clone(), - span: self_arg.span, + span, }); } else { err.subdiagnostic(CaptureReasonNote::FuncTakeSelf { func, place_name: place_name.clone(), - span: self_arg.span, + span, }); } } diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index 8935aed1e7e00..39c07c6ea6668 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -528,7 +528,7 @@ pub(crate) enum CaptureReasonNote { func: String, place_name: String, #[primary_span] - span: Span, + span: MultiSpan, }, #[note( "the {$desugar_name} is desugared into a call to `{$func}`, which takes ownership of the \ @@ -539,7 +539,7 @@ pub(crate) enum CaptureReasonNote { func: String, place_name: String, #[primary_span] - span: Span, + span: MultiSpan, }, } diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 0599f036848c5..2074213c167b2 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1125,6 +1125,7 @@ pub(crate) fn check_trait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err E0714, "marker traits cannot have associated items", ) + .with_span_context(tcx.def_span(def_id)) .emit(); } } diff --git a/compiler/rustc_hir_analysis/src/diagnostics.rs b/compiler/rustc_hir_analysis/src/diagnostics.rs index 0f4d7b9c7d2e4..3b50bf59012eb 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics.rs @@ -50,7 +50,7 @@ pub(crate) struct AssocKindMismatch { pub expected_because_label: Option, pub assoc_kind: &'static str, #[note("the associated {$assoc_kind} is defined here")] - pub def_span: Span, + pub def_span: MultiSpan, #[label("bounds are not allowed on associated constants")] pub bound_on_assoc_const_label: Option, #[subdiagnostic] diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index b21f80925aa05..e1e84f8079bac 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -393,6 +393,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } else { (ident.span, None, assoc_tag, assoc_item.tag()) }; + let mut def_span: MultiSpan = tcx.def_span(assoc_item.def_id).into(); + def_span.push_span_context(tcx.def_span(tcx.parent(assoc_item.def_id))); let def_kind = tcx.def_kind(self.item_def_id()); let item_span = tcx.def_span(self.item_def_id()).shrink_to_lo(); @@ -423,7 +425,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { got: assoc_tag_str(got), expected_because_label, assoc_kind: assoc_tag_str(assoc_item.tag()), - def_span: tcx.def_span(assoc_item.def_id), + def_span, bound_on_assoc_const_label, wrap_in_braces_sugg, }) diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index b431e9951a87e..085122da3c7fb 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -732,9 +732,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call_expr.span, ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)), ); + // FIXME: This needs to happen in a `probe` as the `sup` + // call can currently guide type inference. if self - .at(&cause, self.param_env) - .sup(DefineOpaqueTypes::Yes, formal_input_tys[0], adjusted_arg_type) + .sup_raw( + &cause, + self.param_env, + DefineOpaqueTypes::Yes, + formal_input_tys[0], + adjusted_arg_type, + ) .is_err() { return do_check(); diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 1f55fd49fc86b..068ec3424d91d 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -170,7 +170,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let res = if self.use_lub { at.lub(b, a) } else { - at.sup(DefineOpaqueTypes::Yes, b, a) + self.sup_raw(&self.cause, self.param_env, DefineOpaqueTypes::Yes, b, a) .map(|InferOk { value: (), obligations }| InferOk { value: b, obligations }) }; diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 36e0a22c76133..2f4f2a99cc218 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -190,8 +190,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, actual: Ty<'tcx>, ) -> Result<(), Diag<'a>> { - self.at(cause, self.param_env) - .sup(DefineOpaqueTypes::Yes, expected, actual) + self.sup_raw(cause, self.param_env, DefineOpaqueTypes::Yes, expected, actual) .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) .map_err(|e| { self.err_ctxt().report_mismatched_types(cause, self.param_env, expected, actual, e) diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 3e05f5019eccb..9901f980792f5 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -24,7 +24,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{ExprKind, HirId, QPath, is_range_literal}; use rustc_hir_analysis::diagnostics::{NoFieldOnType, NoVariantNamed}; use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _; -use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, RegionVariableOrigin}; +use rustc_infer::infer::{self, RegionVariableOrigin}; use rustc_infer::traits::WellFormedLoc; use rustc_infer::traits::query::NoSolution; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; @@ -2118,27 +2118,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(_) = remaining_fields.remove(&ident) { let target_ty = self.field_ty(base_expr.span, f, args); let cause = self.misc(base_expr.span); - match self.at(&cause, self.param_env).sup( - // We're already using inference variables for any params, - // and don't allow converting between different structs, - // so there is no way this ever actually defines an opaque - // type. Thus choosing `Yes` is fine. - DefineOpaqueTypes::Yes, - target_ty, - fru_ty, - ) { - Ok(InferOk { obligations, value: () }) => { - self.register_predicates(obligations) - } - Err(_) => { - span_bug!( - cause.span, - "subtyping remaining fields of type changing FRU \ - failed: {target_ty} != {fru_ty}: {}::{}", - variant.name, - ident.name, - ); - } + if let Err(diag) = + self.demand_suptype_diag(cause.span, target_ty, fru_ty) + { + diag.delay_as_bug(); } } self.deeply_resolve_ignoring_regions(fru_ty) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 68eb349bab8f0..c31f0d31ac532 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -3263,9 +3263,14 @@ impl<'a, 'tcx> ArgMatchingCtxt<'a, 'tcx> { // Using probe here, since we don't want this subtyping to affect inference. let subtyping_error = self.probe(|_| { - self.at(&self.misc(arg_span), self.param_env) - .sup(DefineOpaqueTypes::Yes, formal_input_ty, coerced_ty) - .err() + self.sup_raw( + &self.misc(arg_span), + self.param_env, + DefineOpaqueTypes::Yes, + formal_input_ty, + coerced_ty, + ) + .err() }); // Same as above: if either the coerce type or the checked type is an error type, diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 721e9a38fc50c..2b340cf1b6d49 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -561,7 +561,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self_ty, method_self_ty, self.span, pick ); let cause = self.cause(self.self_expr.span, ObligationCauseCode::Misc); - match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, method_self_ty, self_ty) { + match self.sup_raw(&cause, self.param_env, DefineOpaqueTypes::Yes, method_self_ty, self_ty) + { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); } diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index c74047590331c..fee295aa0e149 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1971,7 +1971,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self.xform_self_ty(candidate.item, trait_ref.self_ty(), trait_ref.args); // Guide the trait selection to show impls that have methods whose type matches // up with the `self` parameter of the method. - let _ = self.at(&ObligationCause::dummy(), self.param_env).sup( + let _ = self.sup_raw( + &ObligationCause::dummy(), + self.param_env, DefineOpaqueTypes::Yes, xform_self_ty, self_ty, diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 16c6fed9e9a42..8eabbc0dcb06f 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -133,7 +133,7 @@ impl<'tcx> InferCtxt<'tcx> { /// If possible, prefer the wrapper methods on `ObligationCtxt`, /// `FnCtxt`, or `TypeChecker`. pub fn sup_raw( - self, + &self, cause: &ObligationCause<'tcx>, param_env: ParamEnv<'tcx>, define_opaque_types: DefineOpaqueTypes, @@ -143,7 +143,27 @@ impl<'tcx> InferCtxt<'tcx> { where T: ToTrace<'tcx>, { - self.at(cause, param_env).sup(define_opaque_types, expected, actual) + if self.next_trait_solver { + NextSolverRelate::relate( + self, + param_env, + expected, + ty::Contravariant, + actual, + cause.span, + ) + .map(|goals| self.goals_to_obligations(cause, goals)) + } else { + let mut op = TypeRelating::new( + &self, + ToTrace::to_trace(cause, expected, actual), + param_env, + define_opaque_types, + ty::Contravariant, + ); + op.relate(expected, actual)?; + Ok(InferOk { value: (), obligations: op.into_obligations() }) + } } /// Makes `expected <: actual`. @@ -268,44 +288,6 @@ pub trait ToTrace<'tcx>: Relate> + Copy { } impl<'a, 'tcx> At<'a, 'tcx> { - /// Makes `actual <: expected`. For example, if type-checking a - /// call like `foo(x)`, where `foo: fn(i32)`, you might have - /// `sup(i32, x)`, since the "expected" type is the type that - /// appears in the signature. - /// - /// FIXME: To be removed in favor of the [`InferCtxt::sup_raw`] method instead. - pub fn sup( - self, - define_opaque_types: DefineOpaqueTypes, - expected: T, - actual: T, - ) -> InferResult<'tcx, ()> - where - T: ToTrace<'tcx>, - { - if self.infcx.next_trait_solver { - NextSolverRelate::relate( - self.infcx, - self.param_env, - expected, - ty::Contravariant, - actual, - self.cause.span, - ) - .map(|goals| self.goals_to_obligations(goals)) - } else { - let mut op = TypeRelating::new( - self.infcx, - ToTrace::to_trace(self.cause, expected, actual), - self.param_env, - define_opaque_types, - ty::Contravariant, - ); - op.relate(expected, actual)?; - Ok(InferOk { value: (), obligations: op.into_obligations() }) - } - } - /// Makes `expected <: actual`. /// /// FIXME: To be removed in favor of the [`InferCtxt::sub_raw`] method instead. @@ -411,7 +393,13 @@ impl<'a, 'tcx> At<'a, 'tcx> { match variance { ty::Covariant => self.sub(define_opaque_types, expected, actual), ty::Invariant => self.eq(define_opaque_types, expected, actual), - ty::Contravariant => self.sup(define_opaque_types, expected, actual), + ty::Contravariant => self.infcx.sup_raw( + self.cause, + self.param_env, + define_opaque_types, + expected, + actual, + ), // We could make this make sense but it's not readily // exposed and I don't feel like dealing with it. Note diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index c45c5e44aaa31..c7d64e9a63998 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -891,7 +891,7 @@ impl<'tcx> InferCtxt<'tcx> { if a_is_expected { Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b)) } else { - Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a)) + Ok(self.sup_raw(cause, param_env, DefineOpaqueTypes::Yes, b, a)) } }) } @@ -1567,7 +1567,7 @@ impl<'tcx> InferCtxt<'tcx> { args: Vec>, } - impl<'tcx> BoundVarReplacerDelegate<'tcx> for ToFreshVars<'tcx> { + impl<'tcx> BoundVarReplacerDelegate> for ToFreshVars<'tcx> { fn replace_region(&mut self, br: ty::BoundRegion<'tcx>) -> ty::Region<'tcx> { self.args[br.var.index()].expect_region() } diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index ea266e0032add..760d5b115acd6 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -910,8 +910,7 @@ impl<'tcx> TyCtxt<'tcx> { self.hir_opt_name(id).unwrap_or_else(|| bug!("no name for {}", self.hir_id_to_string(id))) } - /// Given a node ID, gets a list of attributes associated with the AST - /// corresponding to the node-ID. + /// Retrieves the attributes associated with this hir ID. pub fn hir_attrs(self, id: HirId) -> &'tcx [Attribute] { self.hir_attr_map(id.owner).get(id.local_id) } diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 83f62ee65025c..95fbe87a4519a 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -105,10 +105,7 @@ impl ConstValue { typing_env: ty::TypingEnv<'tcx>, ty: Ty<'tcx>, ) -> Option { - let size = tcx - .layout_of(typing_env.with_post_analysis_normalized(tcx).as_query_input(ty)) - .ok()? - .size; + let size = tcx.layout_of(typing_env.as_query_input(ty)).ok()?.size; self.try_to_bits(size) } @@ -381,10 +378,7 @@ impl<'tcx> Const<'tcx> { typing_env: ty::TypingEnv<'tcx>, ) -> Option { let int = self.try_eval_scalar_int(tcx, typing_env)?; - let size = tcx - .layout_of(typing_env.with_post_analysis_normalized(tcx).as_query_input(self.ty())) - .ok()? - .size; + let size = tcx.layout_of(typing_env.as_query_input(self.ty())).ok()?.size; Some(int.to_bits(size)) } diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs index 5b3ff0506201c..264c826109af9 100644 --- a/compiler/rustc_middle/src/mir/interpret/queries.rs +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs @@ -113,7 +113,14 @@ impl<'tcx> TyCtxt<'tcx> { | ty::AliasConstKind::Anon { def_id } => def_id, }; - let cid = match ty::Instance::try_resolve(self, typing_env, def_id, ct.args) { + // We need to use post analysis mode for instance resolving to succeed. + // Otherwise we often bail due to impl candidate not being final. + // Revealing opaques here should be fine as we proved the trait ref + // with rigid opaques in typeck. + let ty::PseudoCanonicalInput { typing_env, value: args } = + typing_env.with_post_analysis_normalized_invalidating_rigid_aliases(self, ct.args); + + let cid = match ty::Instance::try_resolve(self, typing_env, def_id, args) { Ok(Some(instance)) => GlobalId { instance, promoted: None }, // For errors during resolution, we deliberately do not point at the usage site of the constant, // since for these errors the place the constant is used shouldn't matter. @@ -136,7 +143,7 @@ impl<'tcx> TyCtxt<'tcx> { // here does feel somewhat sensible. let def_id = cid.instance.def_id(); if !self.features().generic_const_exprs() - && ct.args.has_non_region_param() + && args.has_non_region_param() // We only FCW for anon consts as repeat expr counts with anon consts are the only place // that we have a back compat hack for. We don't need to check this is a const argument // as only anon consts as const args should get evaluated "for the type system". @@ -184,7 +191,7 @@ impl<'tcx> TyCtxt<'tcx> { // Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should // improve caching of queries. let inputs = self.erase_and_anonymize_regions( - typing_env.with_post_analysis_normalized(self).as_query_input(cid), + typing_env.with_post_analysis_normalized_invalidating_rigid_aliases(self, cid), ); if !span.is_dummy() { // The query doesn't know where it is being invoked, so we need to fix the span. @@ -205,7 +212,7 @@ impl<'tcx> TyCtxt<'tcx> { // Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should // improve caching of queries. let inputs = self.erase_and_anonymize_regions( - typing_env.with_post_analysis_normalized(self).as_query_input(cid), + typing_env.with_post_analysis_normalized_invalidating_rigid_aliases(self, cid), ); debug!(?inputs); let res = if !span.is_dummy() { diff --git a/compiler/rustc_middle/src/ty/consts/valtree.rs b/compiler/rustc_middle/src/ty/consts/valtree.rs index 2ccb05094a71b..2b88785a67973 100644 --- a/compiler/rustc_middle/src/ty/consts/valtree.rs +++ b/compiler/rustc_middle/src/ty/consts/valtree.rs @@ -115,7 +115,7 @@ impl<'tcx> Value<'tcx> { return None; }; let scalar = self.try_to_leaf()?; - let input = typing_env.with_post_analysis_normalized(tcx).as_query_input(self.ty); + let input = typing_env.as_query_input(self.ty); let size = tcx.layout_of(input).ok()?.size; Some(scalar.to_bits(size)) } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index ffa88f7a2fcd2..3d560a9f18815 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -1,13 +1,9 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::DefId; use rustc_span::bug; -use rustc_type_ir::PredicateProxy; -use rustc_type_ir::data_structures::DelayedMap; +use rustc_type_ir::{BoundVarReplacerDelegate, FnMutDelegate}; -use crate::ty::{ - self, Binder, BoundTy, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, - TypeVisitableExt, -}; +use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable}; /////////////////////////////////////////////////////////////////////////// // Some sample folders @@ -51,146 +47,6 @@ where } } -/////////////////////////////////////////////////////////////////////////// -// Bound vars replacer - -/// A delegate used when instantiating bound vars. -/// -/// Any implementation must make sure that each bound variable always -/// gets mapped to the same result. `BoundVarReplacer` caches by using -/// a `DelayedMap` which does not cache the first few types it encounters. -pub trait BoundVarReplacerDelegate<'tcx> { - fn replace_region(&mut self, br: ty::BoundRegion<'tcx>) -> ty::Region<'tcx>; - fn replace_ty(&mut self, bt: ty::BoundTy<'tcx>) -> Ty<'tcx>; - fn replace_const(&mut self, bc: ty::BoundConst<'tcx>) -> ty::Const<'tcx>; -} - -/// A simple delegate taking 3 mutable functions. The used functions must -/// always return the same result for each bound variable, no matter how -/// frequently they are called. -pub struct FnMutDelegate<'a, 'tcx> { - pub regions: &'a mut (dyn FnMut(ty::BoundRegion<'tcx>) -> ty::Region<'tcx> + 'a), - pub types: &'a mut (dyn FnMut(ty::BoundTy<'tcx>) -> Ty<'tcx> + 'a), - pub consts: &'a mut (dyn FnMut(ty::BoundConst<'tcx>) -> ty::Const<'tcx> + 'a), -} - -impl<'a, 'tcx> BoundVarReplacerDelegate<'tcx> for FnMutDelegate<'a, 'tcx> { - fn replace_region(&mut self, br: ty::BoundRegion<'tcx>) -> ty::Region<'tcx> { - (self.regions)(br) - } - fn replace_ty(&mut self, bt: ty::BoundTy<'tcx>) -> Ty<'tcx> { - (self.types)(bt) - } - fn replace_const(&mut self, bc: ty::BoundConst<'tcx>) -> ty::Const<'tcx> { - (self.consts)(bc) - } -} - -/// Replaces the escaping bound vars (late bound regions or bound types) in a type. -struct BoundVarReplacer<'tcx, D> { - tcx: TyCtxt<'tcx>, - - /// As with `RegionFolder`, represents the index of a binder *just outside* - /// the ones we have visited. - current_index: ty::DebruijnIndex, - - delegate: D, - - /// This cache only tracks the `DebruijnIndex` and assumes that it does not matter - /// for the delegate how often its methods get used. - cache: DelayedMap<(ty::DebruijnIndex, Ty<'tcx>), Ty<'tcx>>, -} - -impl<'tcx, D: BoundVarReplacerDelegate<'tcx>> BoundVarReplacer<'tcx, D> { - fn new(tcx: TyCtxt<'tcx>, delegate: D) -> Self { - BoundVarReplacer { tcx, current_index: ty::INNERMOST, delegate, cache: Default::default() } - } -} - -impl<'tcx, D> TypeFolder> for BoundVarReplacer<'tcx, D> -where - D: BoundVarReplacerDelegate<'tcx>, -{ - fn cx(&self) -> TyCtxt<'tcx> { - self.tcx - } - - fn fold_binder>>( - &mut self, - t: ty::Binder<'tcx, T>, - ) -> ty::Binder<'tcx, T> { - self.current_index.shift_in(1); - let t = t.super_fold_with(self); - self.current_index.shift_out(1); - t - } - - fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - match *t.kind() { - ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_ty) - if debruijn == self.current_index => - { - let ty = self.delegate.replace_ty(bound_ty); - debug_assert!(!ty.has_vars_bound_above(ty::INNERMOST)); - ty::shift_vars(self.tcx, ty, self.current_index.as_u32()) - } - _ => { - if !t.has_vars_bound_at_or_above(self.current_index) { - t - } else if let Some(&t) = self.cache.get(&(self.current_index, t)) { - t - } else { - let res = t.super_fold_with(self); - assert!(self.cache.insert((self.current_index, t), res)); - res - } - } - } - } - - fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - match r.kind() { - ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn), br) - if debruijn == self.current_index => - { - let region = self.delegate.replace_region(br); - if let ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn1), br) = region.kind() { - // If the callback returns a bound region, - // that region should always use the INNERMOST - // debruijn index. Then we adjust it to the - // correct depth. - assert_eq!(debruijn1, ty::INNERMOST); - ty::Region::new_bound(self.tcx, debruijn, br) - } else { - region - } - } - _ => r, - } - } - - fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { - match ct.kind() { - ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_const) - if debruijn == self.current_index => - { - let ct = self.delegate.replace_const(bound_const); - debug_assert!(!ct.has_vars_bound_above(ty::INNERMOST)); - ty::shift_vars(self.tcx, ct, self.current_index.as_u32()) - } - _ => ct.super_fold_with(self), - } - } - - fn fold_predicate>>(&mut self, p: P) -> P { - if p.has_vars_bound_at_or_above(self.current_index) { p.super_fold_with(self) } else { p } - } - - fn fold_clauses(&mut self, c: ty::Clauses<'tcx>) -> ty::Clauses<'tcx> { - if c.has_vars_bound_at_or_above(self.current_index) { c.super_fold_with(self) } else { c } - } -} - impl<'tcx> TyCtxt<'tcx> { /// Replaces all regions bound by the given `Binder` with the /// results returned by the closure; the closure is expected to @@ -230,43 +86,28 @@ impl<'tcx> TyCtxt<'tcx> { F: FnMut(ty::BoundRegion<'tcx>) -> ty::Region<'tcx>, T: TypeFoldable>, { - let value = value.skip_binder(); - if !value.has_escaping_bound_vars() { - value - } else { - let delegate = FnMutDelegate { - regions: &mut replace_regions, - types: &mut |b| bug!("unexpected bound ty in binder: {b:?}"), - consts: &mut |b| bug!("unexpected bound ct in binder: {b:?}"), - }; - let mut replacer = BoundVarReplacer::new(self, delegate); - value.fold_with(&mut replacer) - } + let delegate = FnMutDelegate { + regions: &mut replace_regions, + types: &mut |b| bug!("unexpected bound ty in binder: {b:?}"), + consts: &mut |b| bug!("unexpected bound ct in binder: {b:?}"), + }; + rustc_type_ir::replace_escaping_bound_vars_uncached(self, value.skip_binder(), delegate) } - /// Replaces all escaping bound vars. The `fld_r` closure replaces escaping - /// bound regions; the `fld_t` closure replaces escaping bound types and the `fld_c` - /// closure replaces escaping bound consts. + /// Replaces escaping bound vars using `delegate`. pub fn replace_escaping_bound_vars_uncached>>( self, value: T, - delegate: impl BoundVarReplacerDelegate<'tcx>, + delegate: impl BoundVarReplacerDelegate>, ) -> T { - if !value.has_escaping_bound_vars() { - value - } else { - let mut replacer = BoundVarReplacer::new(self, delegate); - value.fold_with(&mut replacer) - } + rustc_type_ir::replace_escaping_bound_vars_uncached(self, value, delegate) } - /// Replaces all types or regions bound by the given `Binder`. The `fld_r` - /// closure replaces bound regions, the `fld_t` closure replaces bound - /// types, and `fld_c` replaces bound constants. + /// Replaces the variables bound by `value` using `delegate`. pub fn replace_bound_vars_uncached>>( self, value: Binder<'tcx, T>, - delegate: impl BoundVarReplacerDelegate<'tcx>, + delegate: impl BoundVarReplacerDelegate>, ) -> T { self.replace_escaping_bound_vars_uncached(value.skip_binder(), delegate) } @@ -291,29 +132,7 @@ impl<'tcx> TyCtxt<'tcx> { where T: TypeFoldable>, { - let shift_bv = |bv: ty::BoundVar| bv + bound_vars; - self.replace_escaping_bound_vars_uncached( - value, - FnMutDelegate { - regions: &mut |r: ty::BoundRegion<'tcx>| { - ty::Region::new_bound( - self, - ty::INNERMOST, - ty::BoundRegion { var: shift_bv(r.var), kind: r.kind }, - ) - }, - types: &mut |t: ty::BoundTy<'tcx>| { - Ty::new_bound( - self, - ty::INNERMOST, - ty::BoundTy { var: shift_bv(t.var), kind: t.kind }, - ) - }, - consts: &mut |c| { - ty::Const::new_bound(self, ty::INNERMOST, ty::BoundConst::new(shift_bv(c.var))) - }, - }, - ) + rustc_type_ir::shift_bound_var_indices(self, bound_vars, value) } /// Replaces any late-bound regions bound in `value` with `'erased`. Useful in codegen but also @@ -334,7 +153,7 @@ impl<'tcx> TyCtxt<'tcx> { tcx: TyCtxt<'tcx>, map: &'a mut FxIndexMap>, } - impl<'tcx> BoundVarReplacerDelegate<'tcx> for Anonymize<'_, 'tcx> { + impl<'tcx> BoundVarReplacerDelegate> for Anonymize<'_, 'tcx> { fn replace_region(&mut self, br: ty::BoundRegion<'tcx>) -> ty::Region<'tcx> { let entry = self.map.entry(br.var); let index = entry.index(); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 149c5f6e91592..a4d22ea9923f2 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1188,7 +1188,23 @@ impl<'tcx> TypingEnv<'tcx> { /// Modify the `typing_mode` to `PostAnalysis` or `Codegen` and eagerly reveal all opaque types /// in the `param_env`. - pub fn with_post_analysis_normalized(self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> { + /// + /// Changing the typing_mode to `PostAnalysis` can result in aliases now being normalizeable, + /// so we need to explicitly renormalize them. This mainly affects opaque types which were + /// previously treated as rigid but can now be normalized to their underlying type, as well as + /// aliases with opaque args. + /// Values that contain types/consts from the previous typing env and that will be used in the + /// new `PostAnalysis` typing env should be folded by this method to allow renormalization. + /// + /// FIXME: we might want to return `Unnormalized` since we force the value to be non-rigid. + pub fn with_post_analysis_normalized_invalidating_rigid_aliases( + self, + tcx: TyCtxt<'tcx>, + value: T, + ) -> PseudoCanonicalInput<'tcx, T> + where + T: TypeFoldable>, + { let TypingEnv { typing_mode, param_env } = self; match typing_mode.0.assert_not_erased() { TypingMode::Coherence @@ -1196,16 +1212,24 @@ impl<'tcx> TypingEnv<'tcx> { | TypingMode::Typeck { .. } | TypingMode::PostTypeckUntilBorrowck { .. } | TypingMode::PostBorrowck { .. } => {} - TypingMode::PostAnalysis | TypingMode::Codegen => return self, + TypingMode::PostAnalysis | TypingMode::Codegen => return self.as_query_input(value), } let param_env = param_env.with_normalized(tcx); - TypingEnv::new(param_env, TypingMode::PostAnalysis) + let value = ty::set_aliases_to_non_rigid(tcx, value).skip_norm_wip(); + TypingEnv::new(param_env, TypingMode::PostAnalysis).as_query_input(value) } - /// Modify the `typing_mode` to `PostAnalysis` or `Codegen` and eagerly reveal all opaque types - /// in the `param_env`. - pub fn with_codegen_normalized(self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> { + /// Same as `with_post_analysis_normalized_invalidating_rigid_aliases` except that we use + /// the `Codegen` typing mode. + pub fn with_codegen_normalized_invalidating_rigid_aliases( + self, + tcx: TyCtxt<'tcx>, + value: T, + ) -> PseudoCanonicalInput<'tcx, T> + where + T: TypeFoldable>, + { let TypingEnv { typing_mode, param_env } = self; match typing_mode.0.assert_not_erased() { TypingMode::Coherence @@ -1214,11 +1238,12 @@ impl<'tcx> TypingEnv<'tcx> { | TypingMode::PostTypeckUntilBorrowck { .. } | TypingMode::PostBorrowck { .. } | TypingMode::PostAnalysis => {} - TypingMode::Codegen => return self, + TypingMode::Codegen => return self.as_query_input(value), } let param_env = param_env.with_normalized(tcx); - TypingEnv::new(param_env, TypingMode::Codegen) + let value = ty::set_aliases_to_non_rigid(tcx, value).skip_norm_wip(); + TypingEnv::new(param_env, TypingMode::Codegen).as_query_input(value) } /// Combine this typing environment with the given `value` to be used by diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 61ba4a70b5f17..e6e29fe7eac70 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -288,7 +288,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { f(value.as_ref().skip_binder(), self) } - /// Prints comma-separated elements. + /// Prints comma-separated elements. If `comma_sep_has_space` is `true`, there is a space after + /// each comma. fn comma_sep(&mut self, mut elems: impl Iterator) -> Result<(), PrintError> where T: Print, @@ -296,13 +297,21 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if let Some(first) = elems.next() { first.print(self)?; for elem in elems { - self.write_str(", ")?; + if self.comma_sep_has_space() { + self.write_str(", ")?; + } else { + self.write_str(",")?; + } elem.print(self)?; } } Ok(()) } + fn comma_sep_has_space(&self) -> bool { + true + } + /// Prints `{f: t}` or `{f as t}` depending on the `cast` argument fn typed_value( &mut self, @@ -1503,14 +1512,26 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { let splatted_arg_index = splatted.map(usize::from); let mut input_iter = inputs.iter().copied(); if let Some(index) = splatted_arg_index { - self.comma_sep((&mut input_iter).take(usize::from(index)))?; - write!(self, ", #[rustc_splat]")?; + self.comma_sep((&mut input_iter).take(index))?; + // Splitting the comma-separated list can miss a comma, but we only need that comma if + // there are arguments before the splat. + // FIXME(splat): if splatting becomes part of the type, we can remove this hack + if index > 0 { + if self.comma_sep_has_space() { + write!(self, ", ")?; + } else { + write!(self, ",")?; + } + } + write!(self, "#[rustc_splat] ")?; self.comma_sep(input_iter)?; } else { self.comma_sep(input_iter)?; } if c_variadic { if !inputs.is_empty() { + // In legacy mangling, most comma-separated lists have no spaces. But here we print + // a space before the `...` for readability. write!(self, ", ")?; } write!(self, "...")?; @@ -1967,6 +1988,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { let mut first = true; for (field_def, field) in iter::zip(&variant_def.fields, fields) { if !first { + // FIXME(legacy mangling): if this appears, should we enable + // spaces depending on `comma_sep_has_space`? write!(self, ", ")?; } write!(self, "{}: ", field_def.name)?; diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index f9a91878a47c2..4b97f13f35fef 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -102,11 +102,6 @@ impl<'tcx> ConstToPat<'tcx> { // not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even // during typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821). // As a result we always use a revealed env when resolving the instance to evaluate. - // - // FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself - // instead of having this logic here - let typing_env = - self.tcx.erase_and_anonymize_regions(self.typing_env).with_codegen_normalized(self.tcx); let alias_const = self.tcx.erase_and_anonymize_regions(alias_const); let mk_too_generic_err = || { @@ -163,47 +158,50 @@ impl<'tcx> ConstToPat<'tcx> { } else { // try to resolve e.g. associated constants to their definition on an impl, and then // evaluate the const. - let valtree = - match self.tcx.const_eval_resolve_for_typeck(typing_env, alias_const, self.span) { - Ok(Ok(c)) => c, - Err(ErrorHandled::Reported(_, _)) => { - // Let's tell the use where this failing const occurs. - let mut err = - self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span }); - // We've emitted an error on the original const, it would be redundant to complain - // on its use as well. - if let ty::ConstKind::Alias(_, alias_const) = self.c.kind() - && let ty::AliasConstKind::Projection { .. } - | ty::AliasConstKind::InherentSelf { .. } - | ty::AliasConstKind::InherentImpl { .. } - | ty::AliasConstKind::Free { .. } = alias_const.kind - { - err.downgrade_to_delayed_bug(); - } - return self.mk_err(err, ty); - } - Err(ErrorHandled::TooGeneric(_)) => { - return mk_too_generic_err(); - } - Ok(Err(bad_ty)) => { - // The pattern cannot be turned into a valtree. - let e = match bad_ty.kind() { - ty::Adt(def, ..) => { - assert!(def.is_union()); - self.tcx.dcx().create_err(UnionPattern { span: self.span }) - } - ty::FnPtr(..) | ty::RawPtr(..) => { - self.tcx.dcx().create_err(PointerPattern { span: self.span }) - } - _ => self.tcx.dcx().create_err(InvalidPattern { - span: self.span, - non_sm_ty: bad_ty, - prefix: bad_ty.prefix_string(self.tcx).to_string(), - }), - }; - return self.mk_err(e, ty); + let valtree = match self.tcx.const_eval_resolve_for_typeck( + self.typing_env, + alias_const, + self.span, + ) { + Ok(Ok(c)) => c, + Err(ErrorHandled::Reported(_, _)) => { + // Let's tell the use where this failing const occurs. + let mut err = + self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span }); + // We've emitted an error on the original const, it would be redundant to complain + // on its use as well. + if let ty::ConstKind::Alias(_, alias_const) = self.c.kind() + && let ty::AliasConstKind::Projection { .. } + | ty::AliasConstKind::InherentSelf { .. } + | ty::AliasConstKind::InherentImpl { .. } + | ty::AliasConstKind::Free { .. } = alias_const.kind + { + err.downgrade_to_delayed_bug(); } - }; + return self.mk_err(err, ty); + } + Err(ErrorHandled::TooGeneric(_)) => { + return mk_too_generic_err(); + } + Ok(Err(bad_ty)) => { + // The pattern cannot be turned into a valtree. + let e = match bad_ty.kind() { + ty::Adt(def, ..) => { + assert!(def.is_union()); + self.tcx.dcx().create_err(UnionPattern { span: self.span }) + } + ty::FnPtr(..) | ty::RawPtr(..) => { + self.tcx.dcx().create_err(PointerPattern { span: self.span }) + } + _ => self.tcx.dcx().create_err(InvalidPattern { + span: self.span, + non_sm_ty: bad_ty, + prefix: bad_ty.prefix_string(self.tcx).to_string(), + }), + }; + return self.mk_err(e, ty); + } + }; // Lower the valtree to a THIR pattern. ty::Value { ty, valtree } @@ -215,9 +213,9 @@ impl<'tcx> ConstToPat<'tcx> { if !thir_pat.references_error() { // Always check for `PartialEq` if we had no other errors yet. - if !type_has_partial_eq_impl(self.tcx, typing_env, ty).has_impl { + if !type_has_partial_eq_impl(self.tcx, self.typing_env, ty).has_impl { let mut err = self.tcx.dcx().create_err(TypeNotPartialEq { span: self.span, ty }); - extend_type_not_partial_eq(self.tcx, typing_env, ty, &mut err); + extend_type_not_partial_eq(self.tcx, self.typing_env, ty, &mut err); return self.mk_err(err, ty); } } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index af61cca62122a..698289c3b5dba 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -721,7 +721,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } }); - let is_allowed = argument_name == sym::Expected || argument_name == sym::Found; + let is_allowed = argument_name == sym::expected || argument_name == sym::found; if !(has_generic | is_allowed) { self.tcx.emit_node_span_lint( MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, diff --git a/compiler/rustc_passes/src/diagnostics.rs b/compiler/rustc_passes/src/diagnostics.rs index 9ec4e10c5fa64..57c6cc4f6513f 100644 --- a/compiler/rustc_passes/src/diagnostics.rs +++ b/compiler/rustc_passes/src/diagnostics.rs @@ -1030,7 +1030,7 @@ pub(crate) struct GlobOrListDelegationUnusedTargetExpr { #[derive(Diagnostic)] #[diag("unknown parameter `{$name}`")] -#[help(r#"expect either a generic argument name, {"`{This}`"}, {"`{Expected}`"} or {"`{Found}`"} as format argument"#)] +#[help(r#"expect either a generic argument name, {"`{this}`"}, {"`{expected}`"} or {"`{found}`"} as format argument"#)] pub(crate) struct OnTypeErrorMalformedFormatLiterals { pub name: Symbol, } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 0f6a0b7012ad7..22d453df065c9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -219,7 +219,6 @@ symbols! { Equal, Err, ExitCode, - Expected, ExternC, ExternRust, Float, @@ -233,7 +232,6 @@ symbols! { FnPtrToPtr, Formatter, Forward, - Found, From, FromIterator, FromResidual, @@ -257,7 +255,6 @@ symbols! { IoBufReader, IrTyKind, Item, - ItemContext, Iterator, IteratorItem, IteratorMap, @@ -361,7 +358,6 @@ symbols! { Type, TypeVisitable, Union, - Unresolved, Unsafe, UnsafeFnPointer, Unsize, @@ -1051,6 +1047,7 @@ symbols! { format_macro, format_placeholder, format_unsafe_arg, + found, fp, fpregs, framework, @@ -1205,6 +1202,7 @@ symbols! { issue_5723_bootstrap, issue_tracker_base_url, item, + item_context, item_like_imports, iter, iter_mut, @@ -2175,6 +2173,7 @@ symbols! { test_removed_feature, test_runner, test_unstable_lint, + this, thread, thread_local, threadptr, @@ -2323,6 +2322,7 @@ symbols! { unreachable_code, unreachable_display, unreachable_macro, + unresolved, unrestricted_attribute_tokens, unsafe_attributes, unsafe_binders, @@ -3008,9 +3008,19 @@ pub mod kw { /// /// Given that `sym` is imported, use them like `sym::symbol_name`. /// For example `sym::rustfmt` or `sym::u8`. -#[diagnostic::on_unknown( - label = "`{Unresolved}` is not a pre-interned symbol", - note = "consider adding `{Unresolved}` to the `symbols!` invocation in compiler/rustc_span/src/symbol.rs" +#[cfg_attr( + bootstrap, + diagnostic::on_unknown( + label = "`{Unresolved}` is not a pre-interned symbol", + note = "consider adding `{Unresolved}` to the `symbols!` invocation in compiler/rustc_span/src/symbol.rs" + ) +)] +#[cfg_attr( + not(bootstrap), + diagnostic::on_unknown( + label = "`{unresolved}` is not a pre-interned symbol", + note = "consider adding `{unresolved}` to the `symbols!` invocation in compiler/rustc_span/src/symbol.rs" + ) )] pub mod sym { use super::Symbol; diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index e2be87e6b271f..b95082d9dbe71 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -487,19 +487,9 @@ impl<'tcx> PrettyPrinter<'tcx> for LegacySymbolMangler<'tcx> { false } - // Identical to `PrettyPrinter::comma_sep` except there is no space after each comma. - fn comma_sep(&mut self, mut elems: impl Iterator) -> Result<(), PrintError> - where - T: Print, - { - if let Some(first) = elems.next() { - first.print(self)?; - for elem in elems { - self.write_str(",")?; - elem.print(self)?; - } - } - Ok(()) + // In symbol mangling, there is no space after the commas in a comma-separated list. + fn comma_sep_has_space(&self) -> bool { + false } fn generic_delimiters( diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs index 7b5bd350fe8f9..e7ac4f36e2571 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs @@ -957,14 +957,15 @@ fn foo(&self) -> Self::T { String::new() } { let msg = match assoc_item.container { ty::AssocContainer::Trait => { - "associated type defaults can't be assumed inside the \ - trait defining them" + "associated type defaults can't be assumed inside the trait defining \ + them" } ty::AssocContainer::InherentImpl | ty::AssocContainer::TraitImpl(_) => { "associated type is `default` and may be overridden" } }; - diag.span_label(tcx.def_span(assoc_item.def_id), msg); + diag.span_context(tcx.def_span(tcx.parent(assoc_item.def_id))); + diag.span_label(tcx.def_span(assoc_item.def_id).into(), msg); return true; } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 5d508c73086f9..bc39af3dc1c6e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -6338,8 +6338,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let Some(fn_def_id) = fn_def_id.as_local() else { // If it's not local, we can at least mention that the method is async, if it is. if self.tcx.asyncness(fn_def_id).is_async() { + let mut span: MultiSpan = self.tcx.def_span(fn_def_id).into(); + span.push_span_context(self.tcx.def_span(self.tcx.parent(fn_def_id))); err.span_note( - self.tcx.def_span(fn_def_id), + span, format!( "`{}::{}` is an `async fn` in trait, which does not \ automatically imply that its future is `{auto_trait}`", diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 3e6d14625c6b2..8f57c3c222d6a 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -283,8 +283,7 @@ where actual: T, ) -> Result<(), TypeError<'tcx>> { self.infcx - .at(cause, param_env) - .sup(DefineOpaqueTypes::Yes, expected, actual) + .sup_raw(cause, param_env, DefineOpaqueTypes::Yes, expected, actual) .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) } diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index aa676dab91bbc..370a8d0c115c0 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -685,9 +685,11 @@ pub fn try_evaluate_const<'tcx, E: Debug>( tcx, alias_const.args, ); - let typing_env = infcx + let ty::PseudoCanonicalInput { typing_env, value: args } = infcx .typing_env(tcx.erase_and_anonymize_regions(param_env)) - .with_post_analysis_normalized(tcx); + .with_post_analysis_normalized_invalidating_rigid_aliases( + tcx, args, + ); (args, typing_env) } } @@ -698,10 +700,13 @@ pub fn try_evaluate_const<'tcx, E: Debug>( } } } else { - let typing_env = infcx + let ty::PseudoCanonicalInput { typing_env, value: args } = infcx .typing_env(tcx.erase_and_anonymize_regions(param_env)) - .with_post_analysis_normalized(tcx); - (alias_const.args, typing_env) + .with_post_analysis_normalized_invalidating_rigid_aliases( + tcx, + alias_const.args, + ); + (args, typing_env) } } Some((def_id, ty::AnonConstKind::RepeatExprCount)) => { diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 6d5cddde61076..1fb8c84176fac 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -1033,8 +1033,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // only the **lifetime bound** is changed. let InferOk { mut obligations, .. } = self .infcx - .at(&obligation.cause, obligation.param_env) - .sup(DefineOpaqueTypes::Yes, target, source_trait) + .sup_raw( + &obligation.cause, + obligation.param_env, + DefineOpaqueTypes::Yes, + target, + source_trait, + ) .map_err(|_| SelectionError::Unimplemented)?; // Register one obligation for 'a: 'b. diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 9a41caafc6da6..1a868ba4b8cee 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -175,7 +175,8 @@ fn resolve_associated_item<'tcx>( return Ok(None); } - let typing_env = typing_env.with_post_analysis_normalized(tcx); + let PseudoCanonicalInput { typing_env, value: rcvr_args } = + typing_env.with_post_analysis_normalized_invalidating_rigid_aliases(tcx, rcvr_args); let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env); let args = rcvr_args.rebase_onto(tcx, trait_def_id, impl_data.args); let args = translate_args( diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 4ecfcde6cc364..bcae974daab7e 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -41,20 +41,18 @@ fn layout_of<'tcx>( tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, ) -> Result, &'tcx LayoutError<'tcx>> { - let PseudoCanonicalInput { typing_env: original_typing_env, value: original_ty } = query; + let PseudoCanonicalInput { typing_env, value: original_ty } = query; debug!(?original_ty); // Optimization: We convert to TypingMode::PostAnalysis and convert opaque types in // the where bounds to their hidden types. This reduces overall uncached invocations // of `layout_of` and is thus a small performance improvement. - let typing_env = original_typing_env.with_post_analysis_normalized(tcx); + // // Switching to `PostAnalysis` typing mode will reveal opaque types that's marked // as rigid in the original typing env. - let unnormalized_ty = if typing_env != original_typing_env { - ty::set_aliases_to_non_rigid(tcx, original_ty) - } else { - ty::Unnormalized::new_wip(original_ty) - }; + let PseudoCanonicalInput { typing_env, value: unnormalized_ty } = + typing_env.with_post_analysis_normalized_invalidating_rigid_aliases(tcx, original_ty); + let unnormalized_ty = ty::Unnormalized::new_wip(unnormalized_ty); // FIXME: We might want to have two different versions of `layout_of`: // One that can be called after typecheck has completed and can use diff --git a/compiler/rustc_type_ir/src/fold.rs b/compiler/rustc_type_ir/src/fold.rs index 388796732c2cb..37dfd9b921285 100644 --- a/compiler/rustc_type_ir/src/fold.rs +++ b/compiler/rustc_type_ir/src/fold.rs @@ -53,6 +53,7 @@ use rustc_index::{Idx, IndexVec}; use thin_vec::ThinVec; use tracing::{debug, instrument}; +use crate::data_structures::DelayedMap; use crate::inherent::*; use crate::visit::{TypeVisitable, TypeVisitableExt as _}; use crate::{ @@ -490,6 +491,180 @@ where } } +/////////////////////////////////////////////////////////////////////////// +// Bound variable replacer + +/// A delegate used when instantiating bound vars. +/// +/// Each bound variable must always map to the same result. `BoundVarReplacer` +/// caches folded types and may not call the delegate on every visit. +pub trait BoundVarReplacerDelegate { + fn replace_region(&mut self, br: ty::BoundRegion) -> Region; + fn replace_ty(&mut self, bt: ty::BoundTy) -> I::Ty; + fn replace_const(&mut self, bc: ty::BoundConst) -> Const; +} + +/// A simple delegate taking three mutable functions. +pub struct FnMutDelegate<'a, I: Interner> { + pub regions: &'a mut (dyn FnMut(ty::BoundRegion) -> Region + 'a), + pub types: &'a mut (dyn FnMut(ty::BoundTy) -> I::Ty + 'a), + pub consts: &'a mut (dyn FnMut(ty::BoundConst) -> Const + 'a), +} + +impl BoundVarReplacerDelegate for FnMutDelegate<'_, I> { + fn replace_region(&mut self, br: ty::BoundRegion) -> Region { + (self.regions)(br) + } + + fn replace_ty(&mut self, bt: ty::BoundTy) -> I::Ty { + (self.types)(bt) + } + + fn replace_const(&mut self, bc: ty::BoundConst) -> Const { + (self.consts)(bc) + } +} + +/// Replaces escaping bound vars in a value. +pub struct BoundVarReplacer { + cx: I, + /// As with `RegionFolder`, represents the index of a binder *just outside* + /// the ones we have visited. + current_index: ty::DebruijnIndex, + delegate: D, + // Types can appear at different binder depths, so include the depth + // in the cache key. + cache: DelayedMap<(ty::DebruijnIndex, I::Ty), I::Ty>, +} + +impl> BoundVarReplacer { + pub fn new(cx: I, delegate: D) -> Self { + Self { cx, current_index: ty::INNERMOST, delegate, cache: Default::default() } + } +} + +impl> TypeFolder for BoundVarReplacer { + fn cx(&self) -> I { + self.cx + } + + fn fold_binder>(&mut self, t: ty::Binder) -> ty::Binder { + self.current_index.shift_in(1); + let t = t.super_fold_with(self); + self.current_index.shift_out(1); + t + } + + fn fold_ty(&mut self, t: I::Ty) -> I::Ty { + match t.kind() { + ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_ty) + if debruijn == self.current_index => + { + let ty = self.delegate.replace_ty(bound_ty); + debug_assert!(!ty.has_vars_bound_above(ty::INNERMOST)); + shift_vars(self.cx, ty, self.current_index.as_u32()) + } + _ => { + if !t.has_vars_bound_at_or_above(self.current_index) { + t + } else if let Some(&t) = self.cache.get(&(self.current_index, t)) { + t + } else { + let res = t.super_fold_with(self); + assert!(self.cache.insert((self.current_index, t), res)); + res + } + } + } + } + + fn fold_region(&mut self, r: Region) -> Region { + match r.kind() { + ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn), br) + if debruijn == self.current_index => + { + let region = self.delegate.replace_region(br); + if let ty::ReBound(ty::BoundVarIndexKind::Bound(inner), br) = region.kind() { + // Bound regions returned by the delegate use INNERMOST. + // Adjust them to the current binder depth. + assert_eq!(inner, ty::INNERMOST); + Region::new_bound(self.cx, debruijn, br) + } else { + region + } + } + _ => r, + } + } + + fn fold_const(&mut self, ct: Const) -> Const { + match ct.kind() { + ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), bound_const) + if debruijn == self.current_index => + { + let ct = self.delegate.replace_const(bound_const); + debug_assert!(!ct.has_vars_bound_above(ty::INNERMOST)); + shift_vars(self.cx, ct, self.current_index.as_u32()) + } + _ => ct.super_fold_with(self), + } + } + + fn fold_predicate>(&mut self, p: P) -> P { + if p.has_vars_bound_at_or_above(self.current_index) { p.super_fold_with(self) } else { p } + } + + fn fold_clauses(&mut self, c: I::Clauses) -> I::Clauses { + if c.has_vars_bound_at_or_above(self.current_index) { c.super_fold_with(self) } else { c } + } +} + +/// Replaces escaping bound vars using `delegate`. +pub fn replace_escaping_bound_vars_uncached>( + cx: I, + value: T, + delegate: impl BoundVarReplacerDelegate, +) -> T { + if !value.has_escaping_bound_vars() { + value + } else { + value.fold_with(&mut BoundVarReplacer::new(cx, delegate)) + } +} + +/// Shifts escaping bound-variable indices by `bound_vars` without changing +/// their De Bruijn depth. +pub fn shift_bound_var_indices>( + cx: I, + bound_vars: usize, + value: T, +) -> T { + if bound_vars == 0 || !value.has_escaping_bound_vars() { + return value; + } + + let shift_bv = |bv: ty::BoundVar| bv + bound_vars; + replace_escaping_bound_vars_uncached( + cx, + value, + FnMutDelegate { + regions: &mut |r: ty::BoundRegion| { + Region::new_bound( + cx, + ty::INNERMOST, + ty::BoundRegion { var: shift_bv(r.var), kind: r.kind }, + ) + }, + types: &mut |t: ty::BoundTy| { + Ty::new_bound(cx, ty::INNERMOST, ty::BoundTy { var: shift_bv(t.var), kind: t.kind }) + }, + consts: &mut |c: ty::BoundConst| { + Const::new_bound(cx, ty::INNERMOST, ty::BoundConst::new(shift_bv(c.var))) + }, + }, + ) +} + /////////////////////////////////////////////////////////////////////////// // Region folder diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 1f1b581c5e546..dd84cc9792c71 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1038,14 +1038,14 @@ impl Display for Arguments<'_> { #[rustc_on_unimplemented( on( all(crate_local, not(Self = "{union}")), - note = "add `#[derive(Debug)]` to `{Self}` or manually `impl {This} for {Self}`" + note = "add `#[derive(Debug)]` to `{Self}` or manually `impl {this} for {Self}`" ), - on(all(crate_local, Self = "{union}"), note = "manually `impl {This} for {Self}`"), + on(all(crate_local, Self = "{union}"), note = "manually `impl {this} for {Self}`"), on( from_desugaring = "FormatLiteral", - label = "`{Self}` cannot be formatted using `{{:?}}` because it doesn't implement `{This}`" + label = "`{Self}` cannot be formatted using `{{:?}}` because it doesn't implement `{this}`" ), - message = "`{Self}` doesn't implement `{This}`" + message = "`{Self}` doesn't implement `{this}`" )] #[doc(alias = "{:?}")] #[rustc_diagnostic_item = "Debug"] @@ -1179,7 +1179,7 @@ pub use macros::Debug; note = "in format strings you may be able to use `{{:?}}` (or `{{:#?}}` for pretty-print) instead", label = "`{Self}` cannot be formatted with the default formatter", ), - message = "`{Self}` doesn't implement `{This}`" + message = "`{Self}` doesn't implement `{this}`" )] #[doc(alias = "{}")] #[rustc_diagnostic_item = "Display"] diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index 6c0d96ace2a4d..fd1bf57f75ce1 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -67,8 +67,8 @@ use crate::ptr::NonNull; // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" ), - message = "expected `{This:resolved}` signature, found `{Self}`", - label = "expected `{This:resolved}` signature, found `{Self}`" + message = "expected `{this:resolved}` signature, found `{Self}`", + label = "expected `{this:resolved}` signature, found `{Self}`" )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] @@ -154,8 +154,8 @@ pub const trait Fn: [const] FnMut { // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" ), - message = "expected `{This:resolved}` signature, found `{Self}`", - label = "expected `{This:resolved}` signature, found `{Self}`" + message = "expected `{this:resolved}` signature, found `{Self}`", + label = "expected `{this:resolved}` signature, found `{Self}`" )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] @@ -233,8 +233,8 @@ pub const trait FnMut: FnOnce { // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string label = "call the function in a closure: `|| unsafe {{ /* code */ }}`" ), - message = "expected `{This:resolved}` signature, found `{Self}`", - label = "expected `{This:resolved}` signature, found `{Self}`" + message = "expected `{this:resolved}` signature, found `{Self}`", + label = "expected `{this:resolved}` signature, found `{Self}`" )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index d0dd6c8d5c8b7..7fd273f2b1f50 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -118,12 +118,12 @@ use crate::ops::ControlFlow; on( all(from_desugaring = "TryBlock"), message = "a `try` block must return `Result` or `Option` \ - (or another type that implements `{This}`)", + (or another type that implements `{this}`)", label = "could not wrap the final value of the block as `{Self}` doesn't implement `Try`", ), on( all(from_desugaring = "QuestionMark"), - message = "the `?` operator can only be applied to values that implement `{This}`", + message = "the `?` operator can only be applied to values that implement `{this}`", label = "the `?` operator cannot be applied to type `{Self}`" ) )] @@ -232,7 +232,7 @@ pub const trait Try: [const] FromResidual { R = "core::option::Option", ), message = "the `?` operator can only be used on `Result`s, not `Option`s, \ - in {ItemContext} that returns `Result`", + in {item_context} that returns `Result`", label = "use `.ok_or(...)?` to provide an error compatible with `{Self}`", parent_label = "this function returns a `Result`" ), @@ -245,7 +245,7 @@ pub const trait Try: [const] FromResidual { // `From` in `?`, so this is not shown for result-in-result errors, // and thus it can be phrased more strongly than `ControlFlow`'s. message = "the `?` operator can only be used on `Result`s \ - in {ItemContext} that returns `Result`", + in {item_context} that returns `Result`", label = "this `?` produces `{R}`, which is incompatible with `{Self}`", parent_label = "this function returns a `Result`" ), @@ -256,7 +256,7 @@ pub const trait Try: [const] FromResidual { R = "core::result::Result", ), message = "the `?` operator can only be used on `Option`s, not `Result`s, \ - in {ItemContext} that returns `Option`", + in {item_context} that returns `Option`", label = "use `.ok()?` if you want to discard the `{R}` error information", parent_label = "this function returns an `Option`" ), @@ -268,7 +268,7 @@ pub const trait Try: [const] FromResidual { // `Option`-in-`Option` always works, as there's only one possible // residual, so this can also be phrased strongly. message = "the `?` operator can only be used on `Option`s \ - in {ItemContext} that returns `Option`", + in {item_context} that returns `Option`", label = "this `?` produces `{R}`, which is incompatible with `{Self}`", parent_label = "this function returns an `Option`" ), @@ -278,7 +278,7 @@ pub const trait Try: [const] FromResidual { Self = "core::ops::control_flow::ControlFlow", R = "core::ops::control_flow::ControlFlow", ), - message = "the `?` operator in {ItemContext} that returns `ControlFlow` \ + message = "the `?` operator in {item_context} that returns `ControlFlow` \ can only be used on other `ControlFlow`s (with the same Break type)", label = "this `?` produces `{R}`, which is incompatible with `{Self}`", parent_label = "this function returns a `ControlFlow`", @@ -291,16 +291,16 @@ pub const trait Try: [const] FromResidual { // `R` is not a `ControlFlow`, as that case was matched previously ), message = "the `?` operator can only be used on `ControlFlow`s \ - in {ItemContext} that returns `ControlFlow`", + in {item_context} that returns `ControlFlow`", label = "this `?` produces `{R}`, which is incompatible with `{Self}`", parent_label = "this function returns a `ControlFlow`", ), on( all(from_desugaring = "QuestionMark"), - message = "the `?` operator can only be used in {ItemContext} \ + message = "the `?` operator can only be used in {item_context} \ that returns `Result` or `Option` \ - (or another type that implements `{This}`)", - label = "cannot use the `?` operator in {ItemContext} that returns `{Self}`", + (or another type that implements `{this}`)", + label = "cannot use the `?` operator in {item_context} that returns `{Self}`", parent_label = "this function should return `Result` or `Option` to accept `?`" ), )] diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 20ea03d36eb0e..feed6e1ad55a0 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2676,7 +2676,7 @@ pub fn id() -> u32 { #[rustc_on_unimplemented(on( cause = "MainFunctionType", message = "`main` has invalid return type `{Self}`", - label = "`main` can only return types that implement `{This}`" + label = "`main` can only return types that implement `{this}`" ))] pub trait Termination { /// Is called to get the representation of the value as status code. diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 7eb632ba69882..9e0238714da41 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -667,7 +667,8 @@ pub fn run_test( // level. let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_family = "wasm") - && !cfg!(target_os = "zkvm"); + && !cfg!(target_os = "zkvm") + && !cfg!(target_os = "uefi"); if supports_threads { let cfg = thread::Builder::new().name(name.as_slice().to_owned()); let mut runtest = Arc::new(Mutex::new(Some(runtest))); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index c532b670dbef1..f329f61c100c8 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3560,6 +3560,18 @@ fn prepare_cargo_test( helpers::add_dylib_path(dylib_paths, &mut cargo); } + add_cargo_target_runner(&mut cargo, target, builder); + + cargo +} + +/// Tells cargo how to execute binaries built for `target`, e.g. under an emulator or on a remote +/// device. +fn add_cargo_target_runner( + cargo: &mut BootstrapCommand, + target: TargetSelection, + builder: &Builder<'_>, +) { if builder.remote_tested(target) { cargo.env( format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), @@ -3568,8 +3580,6 @@ fn prepare_cargo_test( } else if let Some(tool) = builder.runner(target) { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), tool); } - - cargo } /// Runs `cargo test` for standard library crates. @@ -4690,7 +4700,7 @@ pub struct TestFloatParse { impl CommandLineStep for TestFloatParse { type Output = (); - const IS_HOST: bool = true; + const IS_HOST: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/test-float-parse") @@ -4701,8 +4711,15 @@ impl CommandLineStep for TestFloatParse { } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Self { - build_compiler: get_compiler_to_test(run.builder, run.target), + let builder = run.builder; + + // Other targets usually run under an emulator, which is too slow to do by default. + if run.target != run.build_triple() && !builder.was_invoked_explicitly::(Kind::Test) { + return; + } + + builder.ensure(Self { + build_compiler: builder.compiler(builder.top_stage, run.build_triple()), target: run.target, }); } @@ -4714,6 +4731,8 @@ impl CommandLineStep for TestFloatParse { // Build the standard library that will be tested, and a stdlib for host code builder.std(build_compiler, target); builder.std(build_compiler, builder.host_target); + // Start the emulator or remote test server, if the tests need one. + builder.ensure(RemoteCopyLibs { build_compiler, target }); let record_failed_tests = builder.ensure(SetupFailedTestsFile); // Run any unit tests in the crate @@ -4756,7 +4775,13 @@ impl CommandLineStep for TestFloatParse { cargo_run.args(["--", "--skip-huge"]); } - cargo_run.into_cmd().run(builder); + let mut cargo_run = cargo_run.into_cmd(); + add_cargo_target_runner(&mut cargo_run, target, builder); + cargo_run.run(builder); + } + + fn metadata(&self) -> Option { + Some(StepMetadata::test("test-float-parse", self.target)) } } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 6612faf9d0e00..0967b604412e6 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -215,7 +215,7 @@ expression: test targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index cfea3b0825d0a..cd835904b00d1 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -212,7 +212,7 @@ expression: test --skip=coverage targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index e9833dee88f26..0801bdf09328f 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -215,7 +215,7 @@ expression: test --skip=coverage-map targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index 9f30a345b4fbc..d7ec4e55cc710 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -215,7 +215,7 @@ expression: test --skip=coverage-run targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index df818a6132732..bee21f9fd3b91 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -161,7 +161,7 @@ expression: test --skip=tests targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index f8efe9e31631b..afa6039d5cba2 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -212,7 +212,7 @@ expression: test --skip=tests/coverage targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::RunMake targets: [aarch64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index f9c883c87e51c..20c8ec8b25a9a 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -141,7 +141,7 @@ expression: test --skip=tests --skip=library --skip=tidyselftest targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rust-installer}) [Test] test::TestFloatParse - targets: [x86_64-unknown-linux-gnu] + targets: [aarch64-unknown-linux-gnu] - Set({src/tools/test-float-parse}) [Test] test::IntrinsicTest targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 893fc4f7ee017..bebf17d84618a 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1933,6 +1933,7 @@ mod snapshot { [doc] rustc 0 -> rustc 1 [build] rustc 0 -> HtmlChecker 1 [test] html-check + [test] test-float-parse [build] rustc 0 -> RunMakeSupport 1 [test] compiletest-run-make 1 [build] rustc 0 -> cargo 1 @@ -2118,6 +2119,7 @@ mod snapshot { [doc] rustc 1 -> rustc 2 [build] rustc 0 -> HtmlChecker 1 [test] html-check + [test] test-float-parse [build] rustc 0 -> RunMakeSupport 1 [test] compiletest-run-make 2 [build] rustc 1 -> cargo 2 @@ -2931,6 +2933,38 @@ mod snapshot { "); } + #[test] + fn test_float_parse() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("src/tools/test-float-parse") + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [test] test-float-parse + "); + } + + #[test] + fn test_float_parse_cross() { + let ctx = TestCtx::new(); + insta::assert_snapshot!( + ctx.config("test") + .path("src/tools/test-float-parse") + .targets(&[TEST_TRIPLE_1]) + .render_steps(), @r" + [build] llvm + [build] rustc 0 -> rustc 1 + [build] rustc 1 -> std 1 + [build] rustc 1 -> std 1 + [build] rustdoc 1 + [test] test-float-parse + "); + } + // Check that `x run miri --target FOO` actually builds miri for the host. #[test] fn run_miri() { diff --git a/src/doc/unstable-book/src/language-features/diagnostic-on-unknown.md b/src/doc/unstable-book/src/language-features/diagnostic-on-unknown.md index dee89a6916353..1e53d8d25ccd2 100644 --- a/src/doc/unstable-book/src/language-features/diagnostic-on-unknown.md +++ b/src/doc/unstable-book/src/language-features/diagnostic-on-unknown.md @@ -12,7 +12,7 @@ annotated declaration is involved in a name resolution error. Format parameters with the given named parameter will be replaced with the following text: - `{Unresolved}` — The `SimplePathSegment` of the import path that could not be resolved. -- `{This}` — The name of the annotated item. On `use` statements this is identical to `{Unresolved}`. +- `{this}` — The name of the annotated item. On `use` statements this is identical to `{unresolved}`. The original error message will not be suppressed but is emitted as a note instead. @@ -46,7 +46,7 @@ For more information about this error, try `rustc --explain E0432`. #![feature(diagnostic_on_unknown)] #[diagnostic::on_unknown( - message = "module `{This}` is empty, there is no `{Unresolved}` here", + message = "module `{this}` is empty, there is no `{unresolved}` here", label = "can't import something from an empty module" )] mod empty {} diff --git a/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md b/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md index 830adcf34acdb..7f0156a29584c 100644 --- a/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md +++ b/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md @@ -19,7 +19,7 @@ errors still use their existing diagnostics. #![feature(diagnostic_on_unmatched_args)] #[diagnostic::on_unmatched_args( - message = "invalid arguments to {This} macro invocation", + message = "invalid arguments to {this} macro invocation", label = "expected a type and value here", note = "this macro expects a type and a value, like `pair!(u8, 0)`", note = "see ", diff --git a/src/tools/clippy/clippy_lints/src/large_futures.rs b/src/tools/clippy/clippy_lints/src/large_futures.rs index 0547f273138c5..be793c841cacf 100644 --- a/src/tools/clippy/clippy_lints/src/large_futures.rs +++ b/src/tools/clippy/clippy_lints/src/large_futures.rs @@ -65,11 +65,13 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture { && let ty = cx.typeck_results().expr_ty(arg) && let Some(future_trait_def_id) = cx.tcx.lang_items().future_trait() && implements_trait(cx, ty, future_trait_def_id, &[]) - && let typing_env = cx.typing_env().with_codegen_normalized(cx.tcx) + && let ty::PseudoCanonicalInput { typing_env, value: ty } = cx + .typing_env() + .with_codegen_normalized_invalidating_rigid_aliases(cx.tcx, ty) // Aliases that were rigid during type checking can be revealed in codegen mode. && let Ok(ty) = cx.tcx.try_normalize_erasing_regions( typing_env, - ty::set_aliases_to_non_rigid(cx.tcx, ty), + ty::Unnormalized::new_wip(ty), ) && let Ok(layout) = cx.tcx.layout_of(typing_env.as_query_input(ty)) && let size = layout.layout.size() diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index 450c991dcd9e9..bb134c02ec3d7 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -622,7 +622,8 @@ fn is_uninit_value_valid_for_layout<'tcx>(cx: &LateContext<'tcx>, layout: TyAndL /// Fallback for polymorphic types where `layout_of` fails fn is_uninit_value_valid_for_ty_fallback<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - let typing_env = cx.typing_env().with_post_analysis_normalized(cx.tcx); + let ty::PseudoCanonicalInput { typing_env, value: ty } = + cx.typing_env().with_post_analysis_normalized_invalidating_rigid_aliases(cx.tcx, ty); match *ty.kind() { // The array length may be polymorphic, let's try the inner type. diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 5d0750ddb92b7..5701982840bac 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -858,6 +858,10 @@ impl Config { if self.target.starts_with("wasm") { return self.target.contains("threads"); } + // UEFI targets don't have threads. + if self.target.contains("uefi") { + return false; + } true } diff --git a/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.apple.stderr b/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.apple.stderr index 65818feab4297..74763e490f332 100644 --- a/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.apple.stderr +++ b/tests/ui/abi/numbers-arithmetic/x86-64-sysv64-arg-ext.apple.stderr @@ -19,6 +19,7 @@ error: fn_abi_of(i8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776123356184577, }, }, @@ -51,6 +52,7 @@ error: fn_abi_of(i8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776123356184577, }, }, @@ -96,6 +98,7 @@ error: fn_abi_of(u8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776127651151873, }, }, @@ -128,6 +131,7 @@ error: fn_abi_of(u8) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(1 bytes), + repr_c: false, randomization_seed: 71776127651151873, }, }, @@ -173,6 +177,7 @@ error: fn_abi_of(i16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462603027808258, }, }, @@ -205,6 +210,7 @@ error: fn_abi_of(i16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462603027808258, }, }, @@ -250,6 +256,7 @@ error: fn_abi_of(u16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462607322775554, }, }, @@ -282,6 +289,7 @@ error: fn_abi_of(u16) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(2 bytes), + repr_c: false, randomization_seed: 18446462607322775554, }, }, @@ -327,6 +335,7 @@ error: fn_abi_of(i32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462603027873795, }, }, @@ -359,6 +368,7 @@ error: fn_abi_of(i32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462603027873795, }, }, @@ -404,6 +414,7 @@ error: fn_abi_of(u32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462607322841091, }, }, @@ -436,6 +447,7 @@ error: fn_abi_of(u32) = FnAbi { }, max_repr_align: None, unadjusted_abi_align: Align(4 bytes), + repr_c: false, randomization_seed: 18446462607322841091, }, }, diff --git a/tests/ui/associated-consts/shadowed-const.stderr b/tests/ui/associated-consts/shadowed-const.stderr index 4c105ddaf2974..5c19477c22e51 100644 --- a/tests/ui/associated-consts/shadowed-const.stderr +++ b/tests/ui/associated-consts/shadowed-const.stderr @@ -9,6 +9,7 @@ LL | const QUX: Self::BAR; note: the associated constant is defined here --> $DIR/shadowed-const.rs:18:3 | +LL | trait Baz3 { LL | const BAR: usize; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/consts.stderr b/tests/ui/associated-type-bounds/consts.stderr index ddb677ec74db1..3cd185d66427e 100644 --- a/tests/ui/associated-type-bounds/consts.stderr +++ b/tests/ui/associated-type-bounds/consts.stderr @@ -9,6 +9,7 @@ LL | pub fn accept(_: impl Trait) {} note: the associated constant is defined here --> $DIR/consts.rs:5:5 | +LL | pub trait Trait { LL | const K: i32; | ^^^^^^^^^^^^ diff --git a/tests/ui/associated-types/defaults-in-other-trait-items.stderr b/tests/ui/associated-types/defaults-in-other-trait-items.stderr index fe9023e52324e..e2c9dc4ca9e0c 100644 --- a/tests/ui/associated-types/defaults-in-other-trait-items.stderr +++ b/tests/ui/associated-types/defaults-in-other-trait-items.stderr @@ -1,6 +1,7 @@ error[E0308]: mismatched types --> $DIR/defaults-in-other-trait-items.rs:9:13 | +LL | trait Tr { LL | type A = (); | ------ associated type defaults can't be assumed inside the trait defining them ... @@ -15,6 +16,7 @@ LL | let () = p; error[E0308]: mismatched types --> $DIR/defaults-in-other-trait-items.rs:36:25 | +LL | trait AssocConst { LL | type Ty = u8; | ------- associated type defaults can't be assumed inside the trait defining them ... @@ -29,6 +31,7 @@ LL | const C: Self::Ty = 0u8; error[E0308]: mismatched types --> $DIR/defaults-in-other-trait-items.rs:55:9 | +LL | pub trait Trait { LL | type Res = isize; | -------- associated type defaults can't be assumed inside the trait defining them LL | diff --git a/tests/ui/associated-types/defaults-specialization.stderr b/tests/ui/associated-types/defaults-specialization.stderr index 2e880a7d50ade..a03296af8a37b 100644 --- a/tests/ui/associated-types/defaults-specialization.stderr +++ b/tests/ui/associated-types/defaults-specialization.stderr @@ -20,6 +20,7 @@ LL + fn make() -> as Tr>::Ty { 0 } error[E0053]: method `make` has an incompatible type for trait --> $DIR/defaults-specialization.rs:34:18 | +LL | impl Tr for B { LL | default type Ty = bool; | --------------- associated type is `default` and may be overridden LL | @@ -42,6 +43,7 @@ LL + fn make() -> as Tr>::Ty { true } error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:9:9 | +LL | trait Tr { LL | type Ty = u8; | ------- associated type defaults can't be assumed inside the trait defining them LL | @@ -71,6 +73,7 @@ LL | fn make() -> Self::Ty { 0u8 } error[E0308]: mismatched types --> $DIR/defaults-specialization.rs:43:29 | +LL | impl Tr for B2 { LL | default type Ty = bool; | --------------- associated type is `default` and may be overridden LL | diff --git a/tests/ui/associated-types/issue-26681.stderr b/tests/ui/associated-types/issue-26681.stderr index 798f0eb392c4b..18c70968a29ef 100644 --- a/tests/ui/associated-types/issue-26681.stderr +++ b/tests/ui/associated-types/issue-26681.stderr @@ -1,6 +1,7 @@ error[E0308]: mismatched types --> $DIR/issue-26681.rs:17:39 | +LL | trait Baz { LL | type Fv: Foo = u8; | ------------ associated type defaults can't be assumed inside the trait defining them LL | const C: ::Bar = 6665; diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr index dd38e205b03f9..f4c35ad36c176 100644 --- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr +++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr @@ -10,6 +10,7 @@ LL | needs_send(T::test()); note: `::test` is an `async fn` in trait, which does not automatically imply that its future is `Send` --> $DIR/auxiliary/foreign-async-fn.rs:4:5 | +LL | pub trait Foo { LL | async fn test(); | ^^^^^^^^^^^^^^^^ note: required by a bound in `needs_send` diff --git a/tests/ui/attributes/doc_examples/rustc_on_unimplemented_format.rs b/tests/ui/attributes/doc_examples/rustc_on_unimplemented_format.rs index f67f54e279efd..10aef8a03e6bb 100644 --- a/tests/ui/attributes/doc_examples/rustc_on_unimplemented_format.rs +++ b/tests/ui/attributes/doc_examples/rustc_on_unimplemented_format.rs @@ -4,8 +4,8 @@ #![feature(rustc_attrs)] #[rustc_on_unimplemented(message = "Self = `{Self}`, \n \ - T = `{T}`, this = `{This}`, path = `{This:path}`, \n \ - resolved = `{This:resolved}`, context = `{ItemContext}`")] + T = `{T}`, this = `{this}`, path = `{this:path}`, \n \ + resolved = `{this:resolved}`, context = `{item_context}`")] pub trait From: Sized { fn from(x: T) -> Self; } diff --git a/tests/ui/borrowck/clone-span-on-try-operator.stderr b/tests/ui/borrowck/clone-span-on-try-operator.stderr index 4cf1de52a4a47..cf3a8d17eac80 100644 --- a/tests/ui/borrowck/clone-span-on-try-operator.stderr +++ b/tests/ui/borrowck/clone-span-on-try-operator.stderr @@ -9,6 +9,7 @@ LL | (*foo).foo(); note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo` --> $DIR/clone-span-on-try-operator.rs:6:12 | +LL | impl Foo { LL | fn foo(self) {} | ^^^^ help: consider cloning the value if the performance cost is acceptable diff --git a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr index dde17d1f6523c..82fffe2a5d07a 100644 --- a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr +++ b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr @@ -9,6 +9,7 @@ LL | unsafe { self.change() } note: `Example::::change` takes ownership of the receiver `self`, which moves `*self` --> $DIR/issue-119915-bad-clone-suggestion.rs:16:36 | +LL | impl Example { LL | unsafe fn change(self) -> Example { | ^^^^ note: if `Example` implemented `Clone`, you could clone the value diff --git a/tests/ui/borrowck/ownership-struct-update-moved-error.stderr b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr index f081bea76b7a1..8d4d84c1245dc 100644 --- a/tests/ui/borrowck/ownership-struct-update-moved-error.stderr +++ b/tests/ui/borrowck/ownership-struct-update-moved-error.stderr @@ -11,6 +11,7 @@ LL | println!("{}", start.test); note: `Mine::make_string_bar` takes ownership of the receiver `self`, which moves `start` --> $DIR/ownership-struct-update-moved-error.rs:9:28 | +LL | impl Mine { LL | fn make_string_bar(mut self) -> Mine { | ^^^^ diff --git a/tests/ui/const-generics/associated-const-bindings/assoc-const-ty-mismatch.stderr b/tests/ui/const-generics/associated-const-bindings/assoc-const-ty-mismatch.stderr index b844cfc4ae486..1c4f2dd47f591 100644 --- a/tests/ui/const-generics/associated-const-bindings/assoc-const-ty-mismatch.stderr +++ b/tests/ui/const-generics/associated-const-bindings/assoc-const-ty-mismatch.stderr @@ -9,6 +9,7 @@ LL | fn foo>() {} note: the associated constant is defined here --> $DIR/assoc-const-ty-mismatch.rs:5:5 | +LL | pub trait Foo { LL | const N: usize; | ^^^^^^^^^^^^^^ @@ -23,6 +24,7 @@ LL | fn foo2>() {} note: the associated type is defined here --> $DIR/assoc-const-ty-mismatch.rs:9:5 | +LL | pub trait FooTy { LL | type T; | ^^^^^^ diff --git a/tests/ui/const-generics/associated-const-bindings/unbraced-enum-variant.stderr b/tests/ui/const-generics/associated-const-bindings/unbraced-enum-variant.stderr index 96883bb26b9f8..bb26acc4223bb 100644 --- a/tests/ui/const-generics/associated-const-bindings/unbraced-enum-variant.stderr +++ b/tests/ui/const-generics/associated-const-bindings/unbraced-enum-variant.stderr @@ -33,6 +33,7 @@ LL | pub trait CoolStuff: Parse {} note: the associated constant is defined here --> $DIR/unbraced-enum-variant.rs:10:5 | +LL | pub trait Parse { LL | const MODE: Mode; | ^^^^^^^^^^^^^^^^ help: consider adding braces here @@ -51,6 +52,7 @@ LL | pub trait CoolStuff: Parse {} note: the associated constant is defined here --> $DIR/unbraced-enum-variant.rs:10:5 | +LL | pub trait Parse { LL | const MODE: Mode; | ^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -70,6 +72,7 @@ LL | pub trait CoolStuff: Parse {} note: the associated constant is defined here --> $DIR/unbraced-enum-variant.rs:10:5 | +LL | pub trait Parse { LL | const MODE: Mode; | ^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/delegation/inherent-impls-self-replacement.stderr b/tests/ui/delegation/inherent-impls-self-replacement.stderr index e017bee8af540..eed46d97d557b 100644 --- a/tests/ui/delegation/inherent-impls-self-replacement.stderr +++ b/tests/ui/delegation/inherent-impls-self-replacement.stderr @@ -147,6 +147,7 @@ LL | reuse S::<(), 123>::by_ref { self.get_s() } note: `Trait::get_s` takes ownership of the receiver `self`, which moves `*self` --> $DIR/inherent-impls-self-replacement.rs:20:14 | +LL | trait Trait: Sized { LL | fn get_s(self) -> S<(), 123>; | ^^^^ help: if `Self` implemented `Clone`, you could clone the value @@ -169,6 +170,7 @@ LL | reuse S::<(), 123>::by_mut_ref { self.get_s() } note: `Trait::get_s` takes ownership of the receiver `self`, which moves `*self` --> $DIR/inherent-impls-self-replacement.rs:20:14 | +LL | trait Trait: Sized { LL | fn get_s(self) -> S<(), 123>; | ^^^^ help: if `Self` implemented `Clone`, you could clone the value diff --git a/tests/ui/delegation/self-coercion-errors.stderr b/tests/ui/delegation/self-coercion-errors.stderr index 58f735d282563..bf8bba688bac5 100644 --- a/tests/ui/delegation/self-coercion-errors.stderr +++ b/tests/ui/delegation/self-coercion-errors.stderr @@ -1518,6 +1518,7 @@ LL | &mut x note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1575,6 +1576,7 @@ LL | reuse Trait::* { &mut self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1620,6 +1622,7 @@ LL | reuse Trait::* { &self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1648,6 +1651,7 @@ LL | reuse Trait::* { &&&&self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1676,6 +1680,7 @@ LL | reuse Trait::* { self.0.as_ref() } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1704,6 +1709,7 @@ LL | reuse Trait::* { &mut &mut &mut self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1749,6 +1755,7 @@ LL | reuse Trait::* { &&mut self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1800,6 +1807,7 @@ LL | reuse Trait::* { self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1830,6 +1838,8 @@ LL | reuse Trait::* { self.0 } note: `Trait::r#box` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:14:14 | +LL | trait Trait: Sized { +... LL | fn r#box(self: Box) -> i32 { 4 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1861,6 +1871,7 @@ LL | reuse Trait::* { self.0 } note: `Trait::by_value` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:11:17 | +LL | trait Trait: Sized { LL | fn by_value(self) -> i32 { 1 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value @@ -1891,6 +1902,8 @@ LL | reuse Trait::* { self.0 } note: `Trait::pin_box` takes ownership of the receiver `self`, which moves value --> $DIR/self-coercion-errors.rs:17:16 | +LL | trait Trait: Sized { +... LL | fn pin_box(self: Pin>) -> i32 { 7 } | ^^^^ note: if `F` implemented `Clone`, you could clone the value diff --git a/tests/ui/diagnostic_namespace/auxiliary/on-type-error.rs b/tests/ui/diagnostic_namespace/auxiliary/on-type-error.rs index f0f83b552b710..7d23fc194ea4a 100644 --- a/tests/ui/diagnostic_namespace/auxiliary/on-type-error.rs +++ b/tests/ui/diagnostic_namespace/auxiliary/on-type-error.rs @@ -1,6 +1,6 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "[TEST] cross crate expected `{Expected}`, found `{Found}`" + note = "[TEST] cross crate expected `{expected}`, found `{found}`" )] pub struct Foo(pub T); diff --git a/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs b/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs index 54035d1d0ea67..4f2f7ba482dfb 100644 --- a/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs +++ b/tests/ui/diagnostic_namespace/on_move/on_move_with_format.rs @@ -11,7 +11,7 @@ struct Foo; #[diagnostic::on_move( message="Foo for {X}", label="Bar for {X}", - note = "This is `{This}`", + note = "This is `{this}`", )] struct MyType { _x: X, diff --git a/tests/ui/diagnostic_namespace/on_type_error/auxiliary/on-type-error.rs b/tests/ui/diagnostic_namespace/on_type_error/auxiliary/on-type-error.rs index 0197ae6aa1693..636bc1102b4ad 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/auxiliary/on-type-error.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/auxiliary/on-type-error.rs @@ -1,5 +1,5 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected struct `{Expected}`\n found struct `{Found}`" + note = "custom on_type_error note: expected struct `{expected}`\n found struct `{found}`" )] pub struct S(pub T); diff --git a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-const-generic.rs b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-const-generic.rs index d5b0779049d19..24aee1cda563f 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-const-generic.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-const-generic.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected `{Expected}`, found `{Found}`" + note = "custom on_type_error note: expected `{expected}`, found `{found}`" )] struct Array([T; N]); //~^ WARN `#[diagnostic::on_type_error]` only supports exactly one ADT generic parameter, but found `2` [malformed_diagnostic_attributes] diff --git a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.rs b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.rs index 06a8303eb4fc9..52dfc6e52742c 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_move)] -#[diagnostic::on_move(message = "Foo", label = "Bar", note = "{Expected} {Found}")] -//~^ WARN unknown parameter `Expected` [malformed_diagnostic_format_literals] -//~| WARN unknown parameter `Found` [malformed_diagnostic_format_literals] +#[diagnostic::on_move(message = "Foo", label = "Bar", note = "{expected} {found}")] +//~^ WARN unknown parameter `expected` [malformed_diagnostic_format_literals] +//~| WARN unknown parameter `found` [malformed_diagnostic_format_literals] #[derive(Debug)] struct Foo; fn takes_foo(_: Foo) {} diff --git a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.stderr b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.stderr index 802bdd91a0675..6782dfb63ca47 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.stderr +++ b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-invalid-placeholders.stderr @@ -1,16 +1,16 @@ -warning: unknown parameter `Expected` +warning: unknown parameter `expected` --> $DIR/on-type-error-invalid-placeholders.rs:2:64 | -LL | #[diagnostic::on_move(message = "Foo", label = "Bar", note = "{Expected} {Found}")] +LL | #[diagnostic::on_move(message = "Foo", label = "Bar", note = "{expected} {found}")] | ^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument = note: `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default -warning: unknown parameter `Found` +warning: unknown parameter `found` --> $DIR/on-type-error-invalid-placeholders.rs:2:75 | -LL | #[diagnostic::on_move(message = "Foo", label = "Bar", note = "{Expected} {Found}")] +LL | #[diagnostic::on_move(message = "Foo", label = "Bar", note = "{expected} {found}")] | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -25,7 +25,7 @@ LL | takes_foo(foo); LL | let bar = foo; | ^^^ value used here after move | - = note: {Expected} {Found} + = note: {expected} {found} note: consider changing this parameter type in function `takes_foo` to borrow instead if owning the value isn't necessary --> $DIR/on-type-error-invalid-placeholders.rs:7:17 | diff --git a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-lifetime-generic.rs b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-lifetime-generic.rs index ee7de39e5d1a5..fcc73bafdd7ea 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on-type-error-lifetime-generic.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on-type-error-lifetime-generic.rs @@ -1,6 +1,6 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected `{Expected}`, found `{Found}`" + note = "custom on_type_error note: expected `{expected}`, found `{found}`" )] struct Ref<'a, T>(&'a T); diff --git a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_enum.rs b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_enum.rs index 86a2ceb9c1bd5..edfa86dbae672 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_enum.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_enum.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected enum `{This}<{T}>`, found `{Found}`" + note = "custom on_type_error note: expected enum `{this}<{T}>`, found `{found}`" )] enum MyEnum { Variant(T), diff --git a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_simple.rs b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_simple.rs index 40a6ab82313ff..f66523d813ba7 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_simple.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_simple.rs @@ -1,6 +1,6 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected struct `{Expected}`\n found struct `{Found}`" + note = "custom on_type_error note: expected struct `{expected}`\n found struct `{found}`" )] struct S(T); //~^ NOTE tuple struct defined here diff --git a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_union.rs b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_union.rs index f1a98f163edf1..c4a1874397a5f 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/on_type_error_union.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/on_type_error_union.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_type_error)] #[diagnostic::on_type_error( - note = "custom on_type_error note: expected union `{Expected}`, found `{Found}`" + note = "custom on_type_error note: expected union `{expected}`, found `{found}`" )] union MyUnion { value: std::mem::ManuallyDrop, diff --git a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.rs b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.rs index 0c2389f1793f8..50902ff1fbcd5 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.rs @@ -1,12 +1,12 @@ #![feature(diagnostic_on_type_error)] -#[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {Expected:123}")] +#[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {expected:123}")] //~^ WARN format specifiers are not permitted in diagnostic attributes //~| NOTE `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default //~| NOTE remove this format specifier struct InvalidFormat1(T); -#[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {Expected:!}")] +#[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {expected:!}")] //~^ WARN format specifiers are not permitted in diagnostic attributes //~| NOTE remove this format specifier struct InvalidFormat2(T); diff --git a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.stderr b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.stderr index c4947df2475e6..1a70543b4ffa5 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.stderr +++ b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_invalid_formats.stderr @@ -1,7 +1,7 @@ warning: format specifiers are not permitted in diagnostic attributes --> $DIR/report_warning_on_invalid_formats.rs:3:88 | -LL | #[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {Expected:123}")] +LL | #[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {expected:123}")] | ^^^^ remove this format specifier | = note: `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default @@ -9,7 +9,7 @@ LL | #[diagnostic::on_type_error(note = "custom on_type_error note: invalid form warning: format specifiers are not permitted in diagnostic attributes --> $DIR/report_warning_on_invalid_formats.rs:9:88 | -LL | #[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {Expected:!}")] +LL | #[diagnostic::on_type_error(note = "custom on_type_error note: invalid format {expected:!}")] | ^^ remove this format specifier error[E0308]: mismatched types diff --git a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_non_adt.rs b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_non_adt.rs index 038862ee820a5..daa80b7ee5366 100644 --- a/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_non_adt.rs +++ b/tests/ui/diagnostic_namespace/on_type_error/report_warning_on_non_adt.rs @@ -31,7 +31,7 @@ impl SomeStruct { fn main() { // Create a type error with a valid ADT to ensure the feature works #[diagnostic::on_type_error( - note = "custom on_type_error note: expected `{Expected}`, found `{Found}`" + note = "custom on_type_error note: expected `{expected}`, found `{found}`" )] struct Valid(T); diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs index 03eddef2a5400..2c0a2cf21cc97 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs @@ -35,14 +35,14 @@ impl Bar for i32 {} //~|WARN there is no parameter `r#struct` on trait `Baz` //~|WARN there is no parameter `r#enum` on trait `Baz` //~|WARN there is no parameter `union` on trait `Baz` - label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" + label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" //~^WARN there is no parameter `float` on trait `Baz` //~|WARN there is no parameter `_Self` on trait `Baz` //~|WARN there is no parameter `crate_local` on trait `Baz` - //~|WARN there is no parameter `ItemContext` on trait `Baz` - //~|WARN there is no parameter `This` on trait `Baz` - //~|WARN there is no parameter `This` on trait `Baz` - //~|WARN there is no parameter `This` on trait `Baz` + //~|WARN there is no parameter `item_context` on trait `Baz` + //~|WARN there is no parameter `this` on trait `Baz` + //~|WARN there is no parameter `this` on trait `Baz` + //~|WARN there is no parameter `this` on trait `Baz` //~|WARN format specifiers are not permitted in diagnostic attributes //~|WARN format specifiers are not permitted in diagnostic attributes )] diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr index 566ff1493e769..550132a4d8d71 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.stderr @@ -66,7 +66,7 @@ LL | message = "{from_desugaring}{direct}{cause}{integral}{integer}{struct}{ warning: there is no parameter `float` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:15 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -74,7 +74,7 @@ LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This warning: there is no parameter `_Self` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:22 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" | ^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -82,40 +82,40 @@ LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This warning: there is no parameter `crate_local` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:29 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" | ^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument -warning: there is no parameter `This` on trait `Baz` +warning: there is no parameter `this` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:42 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" | ^^^^ | = help: expect either a generic argument name or `{Self}` as format argument -warning: there is no parameter `ItemContext` on trait `Baz` +warning: there is no parameter `item_context` on trait `Baz` --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:48 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" - | ^^^^^^^^^^^ +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" + | ^^^^^^^^^^^^ | = help: expect either a generic argument name or `{Self}` as format argument -warning: there is no parameter `This` on trait `Baz` - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:61 +warning: there is no parameter `this` on trait `Baz` + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:62 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" - | ^^^^ +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" + | ^^^^ | = help: expect either a generic argument name or `{Self}` as format argument -warning: there is no parameter `This` on trait `Baz` - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:72 +warning: there is no parameter `this` on trait `Baz` + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:73 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" - | ^^^^ +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" + | ^^^^ | = help: expect either a generic argument name or `{Self}` as format argument @@ -162,16 +162,16 @@ LL | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl = note: `#[warn(misplaced_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default warning: format specifiers are not permitted in diagnostic attributes - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:65 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:66 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" - | ^^^^^ remove this format specifier +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" + | ^^^^^ remove this format specifier warning: format specifiers are not permitted in diagnostic attributes - --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:76 + --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:38:77 | -LL | label = "{float}{_Self}{crate_local}{This}{ItemContext}{This:path}{This:resolved}" - | ^^^^^^^^^ remove this format specifier +LL | label = "{float}{_Self}{crate_local}{this}{item_context}{this:path}{this:resolved}" + | ^^^^^^^^^ remove this format specifier error[E0277]: trait has `()` and `i32` as params --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:15 @@ -217,7 +217,7 @@ error[E0277]: {from_desugaring}{direct}{cause}{integral}{integer}{struct}{enum}{ --> $DIR/do_not_accept_options_of_the_internal_rustc_attribute.rs:60:15 | LL | takes_baz(()); - | --------- ^^ {float}{_Self}{crate_local}{This}{ItemContext}{This}{This} + | --------- ^^ {float}{_Self}{crate_local}{this}{item_context}{this}{this} | | | required by a bound introduced by this call | diff --git a/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs index 0dd96c7d0d289..167b311eaada7 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/auxiliary/other_crate_level.rs @@ -2,4 +2,4 @@ #![feature(diagnostic_on_unknown)] #![crate_type = "lib"] -#![diagnostic::on_unknown(message = "you silly, the crate `{This}` is empty")] +#![diagnostic::on_unknown(message = "you silly, the crate `{this}` is empty")] diff --git a/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs b/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs index 3b0a5ef8e3ab5..0fe4f6ac8377f 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/crate_level.rs @@ -7,7 +7,7 @@ #![crate_type = "lib"] // Only applies to the root, not everything in the entire crate -#![diagnostic::on_unknown(message = "crate_level `{This}`")] +#![diagnostic::on_unknown(message = "crate_level `{this}`")] mod module{} diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs b/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs index 82fcf11712db9..d590d9d648833 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.rs @@ -25,7 +25,7 @@ use std::does_not_exist4; use std::does_not_exist5; //~^ ERROR: unresolved import `std::does_not_exist5` -#[diagnostic::on_unknown(note = "foo {Self} {ItemContext} {Trait} {A}")] +#[diagnostic::on_unknown(note = "foo {Self} {item_context} {Trait} {A}")] //~^ WARN: this format argument is not allowed in `#[diagnostic::on_unknown]` //~| WARN: this format argument is not allowed in `#[diagnostic::on_unknown]` //~| WARN: this format argument is not allowed in `#[diagnostic::on_unknown]` diff --git a/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.stderr b/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.stderr index 7bc85c107b9c2..5ff5d616a88a1 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.stderr +++ b/tests/ui/diagnostic_namespace/on_unknown/incorrect_format_string.stderr @@ -52,7 +52,7 @@ LL | use std::does_not_exist6; | | | no `does_not_exist6` in the root | - = note: foo {Self} {ItemContext} {Trait} {A} + = note: foo {Self} {item_context} {Trait} {A} warning: positional arguments are not permitted in diagnostic attributes --> $DIR/incorrect_format_string.rs:3:42 @@ -69,7 +69,7 @@ warning: this format argument is not allowed in `#[diagnostic::on_unknown]` LL | #[diagnostic::on_unknown(message = "foo {A}")] | ^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import warning: positional arguments are not permitted in diagnostic attributes --> $DIR/incorrect_format_string.rs:13:40 @@ -85,7 +85,7 @@ warning: this format argument is not allowed in `#[diagnostic::on_unknown]` LL | #[diagnostic::on_unknown(label = "foo {A}")] | ^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import warning: positional arguments are not permitted in diagnostic attributes --> $DIR/incorrect_format_string.rs:23:39 @@ -98,34 +98,34 @@ LL | #[diagnostic::on_unknown(note = "foo {}")] warning: this format argument is not allowed in `#[diagnostic::on_unknown]` --> $DIR/incorrect_format_string.rs:28:39 | -LL | #[diagnostic::on_unknown(note = "foo {Self} {ItemContext} {Trait} {A}")] +LL | #[diagnostic::on_unknown(note = "foo {Self} {item_context} {Trait} {A}")] | ^^^^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import warning: this format argument is not allowed in `#[diagnostic::on_unknown]` --> $DIR/incorrect_format_string.rs:28:46 | -LL | #[diagnostic::on_unknown(note = "foo {Self} {ItemContext} {Trait} {A}")] - | ^^^^^^^^^^^ remove this format argument +LL | #[diagnostic::on_unknown(note = "foo {Self} {item_context} {Trait} {A}")] + | ^^^^^^^^^^^^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import warning: this format argument is not allowed in `#[diagnostic::on_unknown]` - --> $DIR/incorrect_format_string.rs:28:60 + --> $DIR/incorrect_format_string.rs:28:61 | -LL | #[diagnostic::on_unknown(note = "foo {Self} {ItemContext} {Trait} {A}")] - | ^^^^^ remove this format argument +LL | #[diagnostic::on_unknown(note = "foo {Self} {item_context} {Trait} {A}")] + | ^^^^^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import warning: this format argument is not allowed in `#[diagnostic::on_unknown]` - --> $DIR/incorrect_format_string.rs:28:68 + --> $DIR/incorrect_format_string.rs:28:69 | -LL | #[diagnostic::on_unknown(note = "foo {Self} {ItemContext} {Trait} {A}")] - | ^ remove this format argument +LL | #[diagnostic::on_unknown(note = "foo {Self} {item_context} {Trait} {A}")] + | ^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the failed import + = note: only `this` is allowed as a format argument, referring to the failed import error: aborting due to 6 previous errors; 9 warnings emitted diff --git a/tests/ui/diagnostic_namespace/on_unknown/late_res.rs b/tests/ui/diagnostic_namespace/on_unknown/late_res.rs index 08527c3a8e06e..74a08cc046ba9 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/late_res.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/late_res.rs @@ -2,7 +2,7 @@ #![feature(diagnostic_on_unknown)] #[diagnostic::on_unknown( - message = "it works `{This}` `{Unresolved}`", + message = "it works `{this}` `{unresolved}`", label = "label it works", note = "note it works" )] diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module.rs index 50977ff0acf6d..040718df066fb 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/on_module.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module.rs @@ -1,7 +1,7 @@ #![crate_type = "lib"] #![feature(diagnostic_on_unknown)] -#[diagnostic::on_unknown(message = "oh no, `{Unresolved}` is not in module `{This}`")] +#[diagnostic::on_unknown(message = "oh no, `{unresolved}` is not in module `{this}`")] pub mod x { pub struct Foo; } diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs index 44d5dccf6dad9..4cd8b31999c83 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_inner.rs @@ -3,7 +3,7 @@ #![feature(custom_inner_attributes)] pub mod x { - #![diagnostic::on_unknown(message = "oh no, `{Unresolved}` is not in module `{This}`")] + #![diagnostic::on_unknown(message = "oh no, `{unresolved}` is not in module `{this}`")] pub struct Foo; } diff --git a/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs index c37908b2593bf..13ff613afb839 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/on_module_no_body.rs @@ -1,7 +1,7 @@ #![crate_type = "lib"] #![feature(diagnostic_on_unknown)] -#[diagnostic::on_unknown(message = "oh no, that is not in aux module `{This}`")] +#[diagnostic::on_unknown(message = "oh no, that is not in aux module `{this}`")] #[path = "auxiliary/module.rs"] pub mod x; diff --git a/tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs b/tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs index 80ab7b973e8c0..1131ea0bdfc53 100644 --- a/tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs +++ b/tests/ui/diagnostic_namespace/on_unknown/this_format_argument.rs @@ -3,26 +3,26 @@ pub mod foo {} -#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{this}`")] use foo::Foo; //~^ERROR unresolved import `foo::Foo` //~|NOTE the name of this item is a single ident: `Foo` //~|NOTE no `Foo` in `foo` -#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{this}`")] use foo::foo::Foo; //~^ERROR unresolved import `foo::foo` //~|NOTE the name of this item is a single ident: `foo` //~|NOTE could not find `foo` in `foo` -#[diagnostic::on_unknown(note = "the name of this item is two idents: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this item is two idents: `{this}`")] use foo::{Bar, Foo}; //~^ERROR unresolved imports `foo::Bar`, `foo::Foo` //~|NOTE the name of this item is two idents: `Bar, Foo` //~|NOTE no `Foo` in `foo` //~|NOTE no `Bar` in `foo` -#[diagnostic::on_unknown(note = "the name of this item is many idents: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this item is many idents: `{this}`")] use foo::{ Foo, //~^ERROR unresolved imports `foo::Foo`, `foo::bar` @@ -32,13 +32,13 @@ use foo::{ //~^NOTE could not find `bar` in `foo` }; -#[diagnostic::on_unknown(note = "the name of this is: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this is: `{this}`")] pub use doesnt_exist::*; //~^ERROR unresolved import `doesnt_exist` //~|NOTE use of unresolved module or unlinked crate `doesnt_exist` //~|NOTE the name of this is: `doesnt_exist` -#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{This}`")] +#[diagnostic::on_unknown(note = "the name of this item is a single ident: `{this}`")] use foo::Foo as DoNotUseForThisParam; //~^ERROR unresolved import `foo::Foo` //~|NOTE the name of this item is a single ident: `Foo` diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs index 32cbf69a695ba..c2d76b92971be 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs @@ -2,7 +2,7 @@ #[macro_export] #[diagnostic::on_unmatched_args( - message = "invalid arguments to {This} macro invocation", + message = "invalid arguments to {this} macro invocation", label = "expected a type and value here", note = "this macro expects a type and a value, like `pair!(u8, 0)`", note = "see the macro documentation for accepted forms", diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs index 4209c939ed52f..4a5336794d781 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_unmatched_args)] #[diagnostic::on_unmatched_args( - message = "invalid arguments to {This} macro invocation", + message = "invalid arguments to {this} macro invocation", label = "expected a type and value here", note = "this macro expects a type and a value, like `pair!(u8, 0)`", note = "see the macro documentation for accepted forms", diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs index 66e951297a1b6..007ae2f4c7c3d 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs @@ -1,7 +1,7 @@ #![feature(diagnostic_on_unmatched_args)] #[diagnostic::on_unmatched_args( - message = "{This}! expects exactly two arguments", + message = "{this}! expects exactly two arguments", label = "unexpected extra input starts here", note = "this macro expects a type and a value, like `pair!(u8, 0)`", note = "make sure to pass both arguments", diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs index ec7ea5888b6c9..f41ca526f4d62 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs @@ -2,7 +2,7 @@ #[diagnostic::on_unmatched_args( message = "invalid route method", - note = "this macro expects a action, like `{This}!(get \"/hello\")`" + note = "this macro expects a action, like `{this}!(get \"/hello\")`" )] macro_rules! route { (get $path:literal) => {}; diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs index b98d7f777aee8..c4521a29d0c68 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs @@ -4,7 +4,7 @@ #[diagnostic::on_unmatched_args( message = "{T}! is missing arguments", //~^ WARN this format argument is not allowed in `#[diagnostic::on_unmatched_args]` - //~| NOTE only `This` is allowed as a format argument + //~| NOTE only `this` is allowed as a format argument //~| NOTE remove this format argument //~| NOTE `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default )] diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr index e814ecacc006c..51c274b6ffee9 100644 --- a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr @@ -4,7 +4,7 @@ warning: this format argument is not allowed in `#[diagnostic::on_unmatched_args LL | message = "{T}! is missing arguments", | ^ remove this format argument | - = note: only `This` is allowed as a format argument, referring to the macro's name + = note: only `this` is allowed as a format argument, referring to the macro's name = note: `#[warn(malformed_diagnostic_format_literals)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default warning: 1 warning emitted diff --git a/tests/ui/error-codes/E0507.stderr b/tests/ui/error-codes/E0507.stderr index 70d99ea2cce5c..17ae854ae29db 100644 --- a/tests/ui/error-codes/E0507.stderr +++ b/tests/ui/error-codes/E0507.stderr @@ -9,6 +9,7 @@ LL | x.borrow().nothing_is_true(); note: `TheDarkKnight::nothing_is_true` takes ownership of the receiver `self`, which moves value --> $DIR/E0507.rs:6:24 | +LL | impl TheDarkKnight { LL | fn nothing_is_true(self) {} | ^^^^ note: if `TheDarkKnight` implemented `Clone`, you could clone the value diff --git a/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr b/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr index 558a3d8e34b8b..7f02782a4eeef 100644 --- a/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr +++ b/tests/ui/errors/remap-path-prefix-sysroot.with-remap.stderr @@ -9,6 +9,8 @@ LL | self.thread.join().unwrap(); note: `std::thread::JoinHandle::::join` takes ownership of the receiver `self`, which moves `self.thread` --> remapped/library/std/src/thread/join_handle.rs:LL:COL | +LL | impl JoinHandle { +... LL | pub fn join(self) -> Result { | ^^^^ diff --git a/tests/ui/errors/remap-path-prefix-sysroot.without-remap.stderr b/tests/ui/errors/remap-path-prefix-sysroot.without-remap.stderr index 28c409a50ca7c..584cb505dfe4e 100644 --- a/tests/ui/errors/remap-path-prefix-sysroot.without-remap.stderr +++ b/tests/ui/errors/remap-path-prefix-sysroot.without-remap.stderr @@ -9,6 +9,8 @@ LL | self.thread.join().unwrap(); note: `std::thread::JoinHandle::::join` takes ownership of the receiver `self`, which moves `self.thread` --> $SRC_DIR_REAL/std/src/thread/join_handle.rs:LL:COL | +LL | impl JoinHandle { +... LL | pub fn join(self) -> Result { | ^^^^ diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.rs b/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.rs index 355af18939e83..4786c7d496dc2 100644 --- a/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.rs +++ b/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.rs @@ -1,6 +1,6 @@ //! Test that the feature gate is required for diagnostic_on_type_error -#[diagnostic::on_type_error(note = "custom on_type_error note: expected {Expected}, found {Found}")] +#[diagnostic::on_type_error(note = "custom on_type_error note: expected {expected}, found {found}")] //~^ WARN unknown diagnostic attribute //~| NOTE this is an experimental diagnostic attribute //~| NOTE `#[warn(unknown_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.stderr b/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.stderr index f58f379aa13d0..f6a9fd3b0db40 100644 --- a/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.stderr +++ b/tests/ui/feature-gates/feature-gate-diagnostic-on-type-error.stderr @@ -1,7 +1,7 @@ warning: unknown diagnostic attribute --> $DIR/feature-gate-diagnostic-on-type-error.rs:3:1 | -LL | #[diagnostic::on_type_error(note = "custom on_type_error note: expected {Expected}, found {Found}")] +LL | #[diagnostic::on_type_error(note = "custom on_type_error note: expected {expected}, found {found}")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this is an experimental diagnostic attribute diff --git a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr index 80212808cd511..2a6cf21e4a031 100644 --- a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr +++ b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr @@ -375,6 +375,7 @@ LL | x.foo(); note: `Foo::foo` takes ownership of the receiver `self`, which moves `x` --> $DIR/feature-gate-pin_ergonomics.rs:9:12 | +LL | impl Foo { LL | fn foo(self: Pin<&mut Self>) {} | ^^^^ help: consider reborrowing the `Pin` instead of moving it diff --git a/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.rs b/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.rs new file mode 100644 index 0000000000000..9243de364ce19 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.rs @@ -0,0 +1,16 @@ +//! An unused struct implementing an external trait such as `FromStr` +//! should not be considered live. +//! +//! Regression test for . +#![deny(dead_code)] + +impl std::str::FromStr for Foo { + type Err = (); + fn from_str(_s: &str) -> Result { + panic!(); + } +} + +struct Foo; //~ ERROR: struct `Foo` is never constructed + +fn main() {} diff --git a/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.stderr b/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.stderr new file mode 100644 index 0000000000000..a57d2bc082764 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-struct-with-external-trait-impl.stderr @@ -0,0 +1,14 @@ +error: struct `Foo` is never constructed + --> $DIR/unused-struct-with-external-trait-impl.rs:14:8 + | +LL | struct Foo; + | ^^^ + | +note: the lint level is defined here + --> $DIR/unused-struct-with-external-trait-impl.rs:5:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr index ac218e30b9b85..8fd3c71a62e75 100644 --- a/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr +++ b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr @@ -1,36 +1,42 @@ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:6:5 | +LL | trait MarkerConst { LL | const N: usize; | ^^^^^^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:12:5 | +LL | trait MarkerType { LL | type Output; | ^^^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:18:5 | +LL | trait MarkerFn { LL | fn foo(); | ^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:24:5 | +LL | trait MarkerConstWithDefault { LL | const N: usize = 43; | ^^^^^^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:30:5 | +LL | trait MarkerTypeWithDefault { LL | type Output = (); | ^^^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/marker-trait-with-associated-items.rs:36:5 | +LL | trait MarkerFnWithDefault { LL | fn foo() {} | ^^^^^^^^ diff --git a/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr b/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr index ab86df9c8a5b2..aed22d0ed2b69 100644 --- a/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr +++ b/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr @@ -1,12 +1,15 @@ error[E0714]: marker traits cannot have associated items --> $DIR/override-item-on-marker-trait.rs:5:5 | +LL | trait Marker { LL | const N: usize = 0; | ^^^^^^^^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/override-item-on-marker-trait.rs:7:5 | +LL | trait Marker { +... LL | fn do_something() {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/moves/issue-34721.stderr b/tests/ui/moves/issue-34721.stderr index 9834d009d2227..180d606d15fe7 100644 --- a/tests/ui/moves/issue-34721.stderr +++ b/tests/ui/moves/issue-34721.stderr @@ -16,6 +16,7 @@ LL | x.zero() note: `Foo::zero` takes ownership of the receiver `self`, which moves `x` --> $DIR/issue-34721.rs:4:13 | +LL | pub trait Foo { LL | fn zero(self) -> Self; | ^^^^ help: consider further restricting type parameter `T` with trait `Copy` diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index 1146828d9c421..f1675ab253a1e 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -27,6 +27,7 @@ LL | foo; note: `Foo::use_self` takes ownership of the receiver `self`, which moves `foo` --> $DIR/move-fn-self-receiver.rs:13:17 | +LL | impl Foo { LL | fn use_self(self) {} | ^^^^ @@ -53,6 +54,8 @@ LL | boxed_foo; note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `boxed_foo` --> $DIR/move-fn-self-receiver.rs:14:21 | +LL | impl Foo { +LL | fn use_self(self) {} LL | fn use_box_self(self: Box) {} | ^^^^ help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied @@ -78,6 +81,8 @@ LL | pin_box_foo; note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which moves `pin_box_foo` --> $DIR/move-fn-self-receiver.rs:15:25 | +LL | impl Foo { +... LL | fn use_pin_box_self(self: Pin>) {} | ^^^^ help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied @@ -116,6 +121,8 @@ LL | rc_foo; note: `Foo::use_rc_self` takes ownership of the receiver `self`, which moves `rc_foo` --> $DIR/move-fn-self-receiver.rs:16:20 | +LL | impl Foo { +... LL | fn use_rc_self(self: Rc) {} | ^^^^ help: you can `clone` the value and consume it, but this might not be your desired behavior @@ -187,6 +194,7 @@ LL | container; note: `Container::custom_into_iter` takes ownership of the receiver `self`, which moves `container` --> $DIR/move-fn-self-receiver.rs:23:25 | +LL | impl Container { LL | fn custom_into_iter(self) -> impl Iterator { | ^^^^ diff --git a/tests/ui/moves/pin-mut-reborrow.stderr b/tests/ui/moves/pin-mut-reborrow.stderr index d3ccb0a654e3b..e86ca858e8c8c 100644 --- a/tests/ui/moves/pin-mut-reborrow.stderr +++ b/tests/ui/moves/pin-mut-reborrow.stderr @@ -11,6 +11,7 @@ LL | foo.foo(); note: `Foo::foo` takes ownership of the receiver `self`, which moves `foo` --> $DIR/pin-mut-reborrow.rs:7:12 | +LL | impl Foo { LL | fn foo(self: Pin<&mut Self>) {} | ^^^^ help: consider reborrowing the `Pin` instead of moving it diff --git a/tests/ui/moves/suggest-clone.stderr b/tests/ui/moves/suggest-clone.stderr index ec18d2abdec0f..3976b11ac0ca7 100644 --- a/tests/ui/moves/suggest-clone.stderr +++ b/tests/ui/moves/suggest-clone.stderr @@ -9,6 +9,7 @@ LL | foo.foo(); note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo` --> $DIR/suggest-clone.rs:6:12 | +LL | impl Foo { LL | fn foo(self) {} | ^^^^ help: consider cloning the value if the performance cost is acceptable diff --git a/tests/ui/on-unimplemented/format_specs.rs b/tests/ui/on-unimplemented/format_specs.rs index f92674ab4a888..96fa84dacbffc 100644 --- a/tests/ui/on-unimplemented/format_specs.rs +++ b/tests/ui/on-unimplemented/format_specs.rs @@ -1,7 +1,7 @@ #![feature(rustc_attrs)] #[rustc_on_unimplemented( - message = "normal: {This}, path: {This:path}, resolved: {This:resolved}" + message = "normal: {this}, path: {this:path}, resolved: {this:resolved}" )] pub trait Trait<'lifetime, const CONST_GENERIC: usize, A, B> where A: Send {} diff --git a/tests/ui/on-unimplemented/on-trait.rs b/tests/ui/on-unimplemented/on-trait.rs index b327a4a03917b..984435a947964 100644 --- a/tests/ui/on-unimplemented/on-trait.rs +++ b/tests/ui/on-unimplemented/on-trait.rs @@ -3,7 +3,7 @@ #![feature(rustc_attrs)] pub mod Bar { - #[rustc_on_unimplemented(label ="test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{This}`")] + #[rustc_on_unimplemented(label ="test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{this}`")] pub trait Foo {} } diff --git a/tests/ui/pattern/non-structural-match-types-cycle-err.rs b/tests/ui/pattern/non-structural-match-types-cycle-err.rs index 3bc1964eb21fc..04f7fad864d21 100644 --- a/tests/ui/pattern/non-structural-match-types-cycle-err.rs +++ b/tests/ui/pattern/non-structural-match-types-cycle-err.rs @@ -12,12 +12,14 @@ impl AnyOption { // item which is now borrowck'd together with its parent. As // borrowck of the parent requires us to have already lowered the match, // this is a query cycle. +// +// Update: this no longer has cycle error after #164023 fn uwu() {} fn defines() { match Some(async {}) { AnyOption::<_>::NONE => {} - //~^ ERROR cycle detected when building THIR for `defines` + //~^ ERROR constant pattern cannot depend on generic parameters _ => {} } } diff --git a/tests/ui/pattern/non-structural-match-types-cycle-err.stderr b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr index 14228510d3e06..8f28ee7972579 100644 --- a/tests/ui/pattern/non-structural-match-types-cycle-err.stderr +++ b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr @@ -1,41 +1,13 @@ -error[E0391]: cycle detected when building THIR for `defines` - --> $DIR/non-structural-match-types-cycle-err.rs:19:9 - | -LL | AnyOption::<_>::NONE => {} - | ^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires evaluating type-level constant... - --> $DIR/non-structural-match-types-cycle-err.rs:5:5 +error[E0158]: constant pattern cannot depend on generic parameters + --> $DIR/non-structural-match-types-cycle-err.rs:21:9 | +LL | impl AnyOption { LL | const NONE: Option = None; - | ^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires const-evaluating + checking `::NONE`... -note: ...which requires computing layout of `core::option::Option<{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}>`... - --> $SRC_DIR/core/src/option.rs:LL:COL -note: ...which requires computing layout of `{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}`... - --> $DIR/non-structural-match-types-cycle-err.rs:18:16 - | -LL | match Some(async {}) { - | ^^^^^ - = note: ...which requires optimizing MIR for `defines::{closure#0}`... - = note: ...which requires elaborating drops for `defines::{closure#0}`... -note: ...which requires borrow-checking `defines`... - --> $DIR/non-structural-match-types-cycle-err.rs:17:1 - | -LL | fn defines() { - | ^^^^^^^^^^^^ - = note: ...which requires promoting constants in MIR for `defines`... - = note: ...which requires checking if `defines` contains FFI-unwind calls... - = note: ...which requires building MIR for `defines`... - = note: ...which requires match-checking `defines`... - = note: ...which again requires building THIR for `defines`, completing the cycle -note: cycle used when unsafety-checking `defines` - --> $DIR/non-structural-match-types-cycle-err.rs:17:1 - | -LL | fn defines() { - | ^^^^^^^^^^^^ - = note: for more information, see and + | --------------------- constant defined here +... +LL | AnyOption::<_>::NONE => {} + | ^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0158`. diff --git a/tests/ui/specialization/min_specialization/specialization_marker.stderr b/tests/ui/specialization/min_specialization/specialization_marker.stderr index b47c14f3c9fd1..7618065a5fa65 100644 --- a/tests/ui/specialization/min_specialization/specialization_marker.stderr +++ b/tests/ui/specialization/min_specialization/specialization_marker.stderr @@ -1,12 +1,14 @@ error[E0714]: marker traits cannot have associated items --> $DIR/specialization_marker.rs:7:5 | +LL | trait SpecMarker { LL | fn f(); | ^^^^^^^ error[E0714]: marker traits cannot have associated items --> $DIR/specialization_marker.rs:13:5 | +LL | trait SpecMarker2 { LL | type X; | ^^^^^^ diff --git a/tests/ui/specialization/specialization-default-types.current.stderr b/tests/ui/specialization/specialization-default-types.current.stderr index 2447669a83986..e14d96d5a83e7 100644 --- a/tests/ui/specialization/specialization-default-types.current.stderr +++ b/tests/ui/specialization/specialization-default-types.current.stderr @@ -1,6 +1,7 @@ error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:19:9 | +LL | impl Example for T { LL | default type Output = Box; | ------------------- associated type is `default` and may be overridden LL | default fn generate(self) -> Self::Output { diff --git a/tests/ui/specialization/specialization-default-types.next.stderr b/tests/ui/specialization/specialization-default-types.next.stderr index 2447669a83986..e14d96d5a83e7 100644 --- a/tests/ui/specialization/specialization-default-types.next.stderr +++ b/tests/ui/specialization/specialization-default-types.next.stderr @@ -1,6 +1,7 @@ error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:19:9 | +LL | impl Example for T { LL | default type Output = Box; | ------------------- associated type is `default` and may be overridden LL | default fn generate(self) -> Self::Output { diff --git a/tests/ui/splat/splat-fn-ptr-cast-fail.stderr b/tests/ui/splat/splat-fn-ptr-cast-fail.stderr index d620f3dbcfe8d..b2e6525b6cb87 100644 --- a/tests/ui/splat/splat-fn-ptr-cast-fail.stderr +++ b/tests/ui/splat/splat-fn-ptr-cast-fail.stderr @@ -20,13 +20,13 @@ LL | let _fn_ptr: fn((u32, i8), f64) = splat_non_terminal_arg; = note: expected fn pointer `fn((_, _), _)` found fn item `fn(#[rustc_splat] (_, _), _) {splat_non_terminal_arg}` -error[E0605]: non-primitive cast: `fn(, #[rustc_splat](u32, i8)) {tuple_args}` as `fn((u32, i8))` +error[E0605]: non-primitive cast: `fn(#[rustc_splat] (u32, i8)) {tuple_args}` as `fn((u32, i8))` --> $DIR/splat-fn-ptr-cast-fail.rs:19:34 | LL | let _fn_ptr: fn((u32, i8)) = tuple_args as fn((u32, i8)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast -error[E0605]: non-primitive cast: `fn(, #[rustc_splat](u32, i8), f64) {splat_non_terminal_arg}` as `fn((u32, i8), f64)` +error[E0605]: non-primitive cast: `fn(#[rustc_splat] (u32, i8), f64) {splat_non_terminal_arg}` as `fn((u32, i8), f64)` --> $DIR/splat-fn-ptr-cast-fail.rs:20:39 | LL | let _fn_ptr: fn((u32, i8), f64) = splat_non_terminal_arg as fn((u32, i8), f64); diff --git a/tests/ui/splat/splat-mangling.default.stderr b/tests/ui/splat/splat-mangling.default.stderr index d57d73ff019c2..93d70992a1cc3 100644 --- a/tests/ui/splat/splat-mangling.default.stderr +++ b/tests/ui/splat/splat-mangling.default.stderr @@ -1,5 +1,5 @@ error: symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) - --> $DIR/splat-mangling.rs:22:5 + --> $DIR/splat-mangling.rs:24:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -10,7 +10,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFThmEEuE) - --> $DIR/splat-mangling.rs:32:5 + --> $DIR/splat-mangling.rs:33:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -32,7 +32,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs1_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTThmEEEuE) - --> $DIR/splat-mangling.rs:52:5 + --> $DIR/splat-mangling.rs:51:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -43,7 +43,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) - --> $DIR/splat-mangling.rs:62:5 + --> $DIR/splat-mangling.rs:60:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -54,7 +54,7 @@ LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} = note: demangling-alt(>) error: symbol-name(_RMs3_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFTmaEEuE) - --> $DIR/splat-mangling.rs:72:5 + --> $DIR/splat-mangling.rs:69:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -65,7 +65,7 @@ LL | | impl Type<*const fn((u32, i8))> {} = note: demangling-alt(>) error: symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) - --> $DIR/splat-mangling.rs:82:5 + --> $DIR/splat-mangling.rs:79:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -76,7 +76,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs5_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTmaEdEuE) - --> $DIR/splat-mangling.rs:92:5 + --> $DIR/splat-mangling.rs:88:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -86,5 +86,115 @@ LL | | impl Type {} = note: demangling(>) = note: demangling-alt(>) -error: aborting due to 8 previous errors +error: symbol-name(_RMs6_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmawTdEEuE) + --> $DIR/splat-mangling.rs:98:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, #[rustc_splat] (f64,))> {} + | |______________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs7_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmaTdEEuE) + --> $DIR/splat-mangling.rs:107:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, (f64,))> {} + | |_______________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs8_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmwTafjEdEuE) + --> $DIR/splat-mangling.rs:117:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, #[rustc_splat] (i8, f32, usize), f64)> {} + | |_____________________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs9_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmTafjEdEuE) + --> $DIR/splat-mangling.rs:126:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, (i8, f32, usize), f64)> {} + | |______________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsa_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmwudEuE) + --> $DIR/splat-mangling.rs:135:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, #[rustc_splat] (), f64)> {} + | |___________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsb_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmudEuE) + --> $DIR/splat-mangling.rs:144:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, (), f64)> {} + | |____________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsc_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFwuEuaEdEuEE) + --> $DIR/splat-mangling.rs:154:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |____________________________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMsd_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFwuEuaEdEuEE) + --> $DIR/splat-mangling.rs:163:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMse_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFuEuaEdEuEE) + --> $DIR/splat-mangling.rs:172:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMsf_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFuEuaEdEuEE) + --> $DIR/splat-mangling.rs:181:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |______________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: aborting due to 18 previous errors diff --git a/tests/ui/splat/splat-mangling.legacy.stderr b/tests/ui/splat/splat-mangling.legacy.stderr index 17525117e687e..aa6885b0e02c8 100644 --- a/tests/ui/splat/splat-mangling.legacy.stderr +++ b/tests/ui/splat/splat-mangling.legacy.stderr @@ -1,16 +1,16 @@ -error: symbol-name(_ZN14splat_mangling4main72Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u8$C$u32$RP$$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:22:5 +error: symbol-name(_ZN14splat_mangling4main69Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u8$C$u32$RP$$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:24:5 | LL | / #[rustc_dump_symbol_name] ... | LL | | impl Type {} | |___________________________________________^ | - = note: demangling(splat_mangling::main::Type::hCRATE_HASH) - = note: demangling-alt(splat_mangling::main::Type) + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main38Type$LT$fn$LP$$LP$u8$C$u32$RP$$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:32:5 + --> $DIR/splat-mangling.rs:33:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -20,7 +20,7 @@ LL | | impl Type {} = note: demangling(splat_mangling::main::Type::hCRATE_HASH) = note: demangling-alt(splat_mangling::main::Type) -error: symbol-name(_ZN14splat_mangling4main83Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT$17hCRATE_HASHE) +error: symbol-name(_ZN14splat_mangling4main80Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:42:5 | LL | / #[rustc_dump_symbol_name] @@ -28,11 +28,11 @@ LL | / #[rustc_dump_symbol_name] LL | | impl Type {} | |______________________________________________^ | - = note: demangling(splat_mangling::main::Type::hCRATE_HASH) - = note: demangling-alt(splat_mangling::main::Type) + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main49Type$LT$fn$LP$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:52:5 + --> $DIR/splat-mangling.rs:51:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -42,19 +42,19 @@ LL | | impl Type {} = note: demangling(splat_mangling::main::Type::hCRATE_HASH) = note: demangling-alt(splat_mangling::main::Type) -error: symbol-name(_ZN14splat_mangling4main86Type$LT$$BP$const$u20$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:62:5 +error: symbol-name(_ZN14splat_mangling4main83Type$LT$$BP$const$u20$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u32$C$i8$RP$$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:60:5 | LL | / #[rustc_dump_symbol_name] ... | LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} | |__________________________________________________^ | - = note: demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>::hCRATE_HASH) - = note: demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) + = note: demangling(splat_mangling::main::Type<*const fn(#[rustc_splat] (u32,i8))>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<*const fn(#[rustc_splat] (u32,i8))>) error: symbol-name(_ZN14splat_mangling4main52Type$LT$$BP$const$u20$fn$LP$$LP$u32$C$i8$RP$$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:72:5 + --> $DIR/splat-mangling.rs:69:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -64,19 +64,19 @@ LL | | impl Type<*const fn((u32, i8))> {} = note: demangling(splat_mangling::main::Type<*const fn((u32,i8))>::hCRATE_HASH) = note: demangling-alt(splat_mangling::main::Type<*const fn((u32,i8))>) -error: symbol-name(_ZN14splat_mangling4main78Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$C$f64$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:82:5 +error: symbol-name(_ZN14splat_mangling4main75Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u32$C$i8$RP$$C$f64$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:79:5 | LL | / #[rustc_dump_symbol_name] ... | LL | | impl Type {} | |________________________________________________^ | - = note: demangling(splat_mangling::main::Type::hCRATE_HASH) - = note: demangling-alt(splat_mangling::main::Type) + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main44Type$LT$fn$LP$$LP$u32$C$i8$RP$$C$f64$RP$$GT$17hCRATE_HASHE) - --> $DIR/splat-mangling.rs:92:5 + --> $DIR/splat-mangling.rs:88:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -86,5 +86,115 @@ LL | | impl Type {} = note: demangling(splat_mangling::main::Type::hCRATE_HASH) = note: demangling-alt(splat_mangling::main::Type) -error: aborting due to 8 previous errors +error: symbol-name(_ZN14splat_mangling4main90Type$LT$$BP$mut$u20$fn$LP$u32$C$i8$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$f64$C$$RP$$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:98:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, #[rustc_splat] (f64,))> {} + | |______________________________________________________^ + | + = note: demangling(splat_mangling::main::Type<*mut fn(u32,i8,#[rustc_splat] (f64,))>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<*mut fn(u32,i8,#[rustc_splat] (f64,))>) + +error: symbol-name(_ZN14splat_mangling4main59Type$LT$$BP$mut$u20$fn$LP$u32$C$i8$C$$LP$f64$C$$RP$$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:107:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, (f64,))> {} + | |_______________________________________^ + | + = note: demangling(splat_mangling::main::Type<*mut fn(u32,i8,(f64,))>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<*mut fn(u32,i8,(f64,))>) + +error: symbol-name(_ZN14splat_mangling4main93Type$LT$$RF$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$i8$C$f32$C$usize$RP$$C$f64$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:117:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, #[rustc_splat] (i8, f32, usize), f64)> {} + | |_____________________________________________________________^ + | + = note: demangling(splat_mangling::main::Type<&fn(u32,#[rustc_splat] (i8,f32,usize),f64)>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<&fn(u32,#[rustc_splat] (i8,f32,usize),f64)>) + +error: symbol-name(_ZN14splat_mangling4main62Type$LT$$RF$fn$LP$u32$C$$LP$i8$C$f32$C$usize$RP$$C$f64$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:126:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, (i8, f32, usize), f64)> {} + | |______________________________________________^ + | + = note: demangling(splat_mangling::main::Type<&fn(u32,(i8,f32,usize),f64)>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<&fn(u32,(i8,f32,usize),f64)>) + +error: symbol-name(_ZN14splat_mangling4main85Type$LT$$RF$mut$u20$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$C$f64$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:135:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, #[rustc_splat] (), f64)> {} + | |___________________________________________________^ + | + = note: demangling(splat_mangling::main::Type<&mut fn(u32,#[rustc_splat] (),f64)>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<&mut fn(u32,#[rustc_splat] (),f64)>) + +error: symbol-name(_ZN14splat_mangling4main54Type$LT$$RF$mut$u20$fn$LP$u32$C$$LP$$RP$$C$f64$RP$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:144:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, (), f64)> {} + | |____________________________________^ + | + = note: demangling(splat_mangling::main::Type<&mut fn(u32,(),f64)>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<&mut fn(u32,(),f64)>) + +error: symbol-name(_ZN14splat_mangling4main152Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:154:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |____________________________________________________________________________^ + | + = note: demangling(splat_mangling::main::Type>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type>) + +error: symbol-name(_ZN14splat_mangling4main121Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$LP$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:163:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(splat_mangling::main::Type>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type>) + +error: symbol-name(_ZN14splat_mangling4main121Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$fn$LP$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:172:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(splat_mangling::main::Type>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type>) + +error: symbol-name(_ZN14splat_mangling4main90Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$LP$fn$LP$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT$17hCRATE_HASHE) + --> $DIR/splat-mangling.rs:181:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |______________________________________________^ + | + = note: demangling(splat_mangling::main::Type>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type>) + +error: aborting due to 18 previous errors diff --git a/tests/ui/splat/splat-mangling.rs b/tests/ui/splat/splat-mangling.rs index 982d070199c7d..49c0d1a90e50e 100644 --- a/tests/ui/splat/splat-mangling.rs +++ b/tests/ui/splat/splat-mangling.rs @@ -6,29 +6,30 @@ //@ build-fail // CRATE_HASH normalization doesn't seem to work on some of these symbol logs -//@ normalize-stderr: "splat_mangling\[([0-9a-f]{16})\]::" -> "splat_mangling[CRATE_HASH]::" -//@ normalize-stderr: "h([0-9a-f]{16})E\)" -> "hCRATE_HASHE)" -//@ normalize-stderr: "::h([0-9a-f]{16})\)" -> "::hCRATE_HASH)" +// FIXME: When rustc-demangle/94 is in rust's deps, change this to '{16}' (fixed-length hashes) +//@ normalize-stderr: "splat_mangling\[([0-9a-f]{8,16})\]::" -> "splat_mangling[CRATE_HASH]::" +//@ normalize-stderr: "alloc\[([0-9a-f]{8,16})\]::" -> "alloc[CRATE_HASH]::" +//@ normalize-stderr: "h([0-9a-f]{8,16})E\)" -> "hCRATE_HASHE)" +//@ normalize-stderr: "::h([0-9a-f]{8,16})\)" -> "::hCRATE_HASH)" #![allow(incomplete_features)] #![feature(splat, rustc_attrs)] +// FIXME(rustfmt): the attribute gets deleted by rustfmt +#[rustfmt::skip] fn main() { struct Type(T); - // FIXME(rustfmt): the attribute gets deleted by rustfmt - #[rustfmt::skip] - // FIXME(splat, legacy mangling): the first comma is in the wrong place + // Single argument splat, with different numbers of arguments inside the splat #[rustc_dump_symbol_name] - //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main72Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u8$C$u32$RP$$RP$$GT - //[legacy]~| NOTE demangling(splat_mangling::main::Type:: - //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main69Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u8$C$u32$RP$$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) //[v0,default]~| NOTE demangling(>) impl Type {} - #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main38Type$LT$fn$LP$$LP$u8$C$u32$RP$$RP$$GT //[legacy]~| NOTE demangling(splat_mangling::main::Type:: @@ -38,17 +39,15 @@ fn main() { //[v0,default]~| NOTE demangling-alt(>) impl Type {} - #[rustfmt::skip] #[rustc_dump_symbol_name] - //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main83Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT - //[legacy]~| NOTE demangling(splat_mangling::main::Type:: - //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main80Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs0_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTThmEEEuE) //[v0,default]~| NOTE demangling(>) impl Type {} - #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main49Type$LT$fn$LP$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT //[legacy]~| NOTE demangling(splat_mangling::main::Type:: @@ -58,17 +57,15 @@ fn main() { //[v0,default]~| NOTE demangling-alt(>) impl Type {} - #[rustfmt::skip] #[rustc_dump_symbol_name] - //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main86Type$LT$$BP$const$u20$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$RP$$GT - //[legacy]~| NOTE demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>:: - //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main83Type$LT$$BP$const$u20$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u32$C$i8$RP$$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<*const fn(#[rustc_splat] (u32,i8))>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*const fn(#[rustc_splat] (u32,i8))>) //[v0,default]~^^^^ ERROR symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) //[v0,default]~| NOTE demangling(>) impl Type<*const fn(#[rustc_splat] (u32, i8))> {} - #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main52Type$LT$$BP$const$u20$fn$LP$$LP$u32$C$i8$RP$$RP$$GT //[legacy]~| NOTE demangling(splat_mangling::main::Type<*const fn((u32,i8))>:: @@ -78,17 +75,16 @@ fn main() { //[v0,default]~| NOTE demangling-alt(>) impl Type<*const fn((u32, i8))> {} - #[rustfmt::skip] + // Multi-argument, leading splat #[rustc_dump_symbol_name] - //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main78Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$C$f64$RP$$GT - //[legacy]~| NOTE demangling(splat_mangling::main::Type:: - //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main75Type$LT$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$u32$C$i8$RP$$C$f64$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) //[v0,default]~| NOTE demangling(>) impl Type {} - #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main44Type$LT$fn$LP$$LP$u32$C$i8$RP$$C$f64$RP$$GT //[legacy]~| NOTE demangling(splat_mangling::main::Type:: @@ -97,4 +93,97 @@ fn main() { //[v0,default]~| NOTE demangling(>) impl Type {} + + // Multi-argument, trailing splat + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main90Type$LT$$BP$mut$u20$fn$LP$u32$C$i8$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$f64$C$$RP$$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<*mut fn(u32,i8,#[rustc_splat] (f64,))>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*mut fn(u32,i8,#[rustc_splat] (f64,))>) + //[v0,default]~^^^^ ERROR symbol-name(_RMs6_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmawTdEEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<*mut fn(u32, i8, #[rustc_splat] (f64,))> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main59Type$LT$$BP$mut$u20$fn$LP$u32$C$i8$C$$LP$f64$C$$RP$$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<*mut fn(u32,i8,(f64,))>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*mut fn(u32,i8,(f64,))>) + //[v0,default]~^^^^ ERROR symbol-name(_RMs7_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmaTdEEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<*mut fn(u32, i8, (f64,))> {} + + // Multi-argument, middle splat + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main93Type$LT$$RF$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$i8$C$f32$C$usize$RP$$C$f64$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<&fn(u32,#[rustc_splat] (i8,f32,usize),f64)>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<&fn(u32,#[rustc_splat] (i8,f32,usize),f64)>) + //[v0,default]~^^^^ ERROR symbol-name(_RMs8_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmwTafjEdEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<&fn(u32, #[rustc_splat] (i8, f32, usize), f64)> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main62Type$LT$$RF$fn$LP$u32$C$$LP$i8$C$f32$C$usize$RP$$C$f64$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<&fn(u32,(i8,f32,usize),f64)>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<&fn(u32,(i8,f32,usize),f64)>) + //[v0,default]~^^^^ ERROR symbol-name(_RMs9_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmTafjEdEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<&fn(u32, (i8, f32, usize), f64)> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main85Type$LT$$RF$mut$u20$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$C$f64$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<&mut fn(u32,#[rustc_splat] (),f64)>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<&mut fn(u32,#[rustc_splat] (),f64)>) + //[v0,default]~^^^^ ERROR symbol-name(_RMsa_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmwudEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<&mut fn(u32, #[rustc_splat] (), f64)> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main54Type$LT$$RF$mut$u20$fn$LP$u32$C$$LP$$RP$$C$f64$RP$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type<&mut fn(u32,(),f64)>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<&mut fn(u32,(),f64)>) + //[v0,default]~^^^^ ERROR symbol-name(_RMsb_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmudEuE) + //[v0,default]~| NOTE demangling(>) + impl Type<&mut fn(u32, (), f64)> {} + + // Splats within splats + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main152Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type>) + //[v0,default]~^^^^ ERROR symbol-name(_RMsc_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFwuEuaEdEuEE) + //[v0,default]~| NOTE demangling(>>) + impl Type> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main121Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$LP$fn$LP$$u23$$u5b$rustc_splat$u5d$$u20$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type>) + //[v0,default]~^^^^ ERROR symbol-name(_RMsd_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFwuEuaEdEuEE) + //[v0,default]~| NOTE demangling(>>) + impl Type> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main121Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$u23$$u5b$rustc_splat$u5d$$u20$$LP$fn$LP$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type>) + //[v0,default]~^^^^ ERROR symbol-name(_RMse_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFuEuaEdEuEE) + //[v0,default]~| NOTE demangling(>>) + impl Type> {} + + #[rustc_dump_symbol_name] + //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main90Type$LT$alloc..boxed..Box$LT$fn$LP$u32$C$$LP$fn$LP$$LP$$RP$$RP$$C$i8$RP$$C$f64$RP$$GT$$GT + //[legacy]~| NOTE demangling(splat_mangling::main::Type>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type>) + //[v0,default]~^^^^ ERROR symbol-name(_RMsf_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFuEuaEdEuEE) + //[v0,default]~| NOTE demangling(>>) + impl Type> {} } diff --git a/tests/ui/splat/splat-mangling.v0.stderr b/tests/ui/splat/splat-mangling.v0.stderr index d57d73ff019c2..93d70992a1cc3 100644 --- a/tests/ui/splat/splat-mangling.v0.stderr +++ b/tests/ui/splat/splat-mangling.v0.stderr @@ -1,5 +1,5 @@ error: symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) - --> $DIR/splat-mangling.rs:22:5 + --> $DIR/splat-mangling.rs:24:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -10,7 +10,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFThmEEuE) - --> $DIR/splat-mangling.rs:32:5 + --> $DIR/splat-mangling.rs:33:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -32,7 +32,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs1_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTThmEEEuE) - --> $DIR/splat-mangling.rs:52:5 + --> $DIR/splat-mangling.rs:51:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -43,7 +43,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) - --> $DIR/splat-mangling.rs:62:5 + --> $DIR/splat-mangling.rs:60:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -54,7 +54,7 @@ LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} = note: demangling-alt(>) error: symbol-name(_RMs3_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFTmaEEuE) - --> $DIR/splat-mangling.rs:72:5 + --> $DIR/splat-mangling.rs:69:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -65,7 +65,7 @@ LL | | impl Type<*const fn((u32, i8))> {} = note: demangling-alt(>) error: symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) - --> $DIR/splat-mangling.rs:82:5 + --> $DIR/splat-mangling.rs:79:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -76,7 +76,7 @@ LL | | impl Type {} = note: demangling-alt(>) error: symbol-name(_RMs5_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTmaEdEuE) - --> $DIR/splat-mangling.rs:92:5 + --> $DIR/splat-mangling.rs:88:5 | LL | / #[rustc_dump_symbol_name] ... | @@ -86,5 +86,115 @@ LL | | impl Type {} = note: demangling(>) = note: demangling-alt(>) -error: aborting due to 8 previous errors +error: symbol-name(_RMs6_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmawTdEEuE) + --> $DIR/splat-mangling.rs:98:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, #[rustc_splat] (f64,))> {} + | |______________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs7_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeOFmaTdEEuE) + --> $DIR/splat-mangling.rs:107:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut fn(u32, i8, (f64,))> {} + | |_______________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs8_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmwTafjEdEuE) + --> $DIR/splat-mangling.rs:117:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, #[rustc_splat] (i8, f32, usize), f64)> {} + | |_____________________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMs9_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeRFmTafjEdEuE) + --> $DIR/splat-mangling.rs:126:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&fn(u32, (i8, f32, usize), f64)> {} + | |______________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsa_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmwudEuE) + --> $DIR/splat-mangling.rs:135:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, #[rustc_splat] (), f64)> {} + | |___________________________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsb_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeQFmudEuE) + --> $DIR/splat-mangling.rs:144:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut fn(u32, (), f64)> {} + | |____________________________________^ + | + = note: demangling(>) + = note: demangling-alt(>) + +error: symbol-name(_RMsc_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFwuEuaEdEuEE) + --> $DIR/splat-mangling.rs:154:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |____________________________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMsd_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFwuEuaEdEuEE) + --> $DIR/splat-mangling.rs:163:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMse_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmwTFuEuaEdEuEE) + --> $DIR/splat-mangling.rs:172:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |_____________________________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: symbol-name(_RMsf_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeINtNtCsCRATE_HASH_5alloc5boxed3BoxFmTFuEuaEdEuEE) + --> $DIR/splat-mangling.rs:181:5 + | +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type> {} + | |______________________________________________^ + | + = note: demangling(>>) + = note: demangling-alt(>>) + +error: aborting due to 18 previous errors diff --git a/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.next.stderr b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.next.stderr new file mode 100644 index 0000000000000..a9fa9c89f0d56 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.next.stderr @@ -0,0 +1,13 @@ +error: constant of non-structural type `Option` in a pattern + --> $DIR/dont_reveal_opaque_for_pat_partial_eq_requirement.rs:30:9 + | +LL | const A: Option = None; + | --------------------- constant defined here +... +LL | A::<_> => {} + | ^^^^^^ constant of non-structural type + | + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.old.stderr b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.old.stderr new file mode 100644 index 0000000000000..a9fa9c89f0d56 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.old.stderr @@ -0,0 +1,13 @@ +error: constant of non-structural type `Option` in a pattern + --> $DIR/dont_reveal_opaque_for_pat_partial_eq_requirement.rs:30:9 + | +LL | const A: Option = None; + | --------------------- constant defined here +... +LL | A::<_> => {} + | ^^^^^^ constant of non-structural type + | + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.rs b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.rs new file mode 100644 index 0000000000000..5c59d02a8bf9a --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/dont_reveal_opaque_for_pat_partial_eq_requirement.rs @@ -0,0 +1,35 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// Previously we check the `PartialEq` requirement for pattern types in +// post analysis typing mode which would reveal opaques types so this code +// compiles with the old solver. +// With the next solver, we previously forgot to set opaques to non-rigid when +// entering post-analysis mode which results in an ICE when computing layout. +// +// Now we check the `PartialEq` requirement in the correct typing env and this +// code properly fails with both solvers. + +#![feature(type_alias_impl_trait)] +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +const A: Option = None; + +type Opaque = impl Sized; + +#[define_opaque(Opaque)] +fn value() -> Opaque { + 0usize +} + +fn defines() { + let a = value(); + match Some(a) { + A::<_> => {} + //~^ ERROR constant of non-structural type `Option` in a pattern + _ => {} + } +} +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/typing_env_transition_for_const_pat.rs b/tests/ui/traits/next-solver/normalize/typing_env_transition_for_const_pat.rs new file mode 100644 index 0000000000000..a082824989882 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/typing_env_transition_for_const_pat.rs @@ -0,0 +1,33 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Previously we forgot to invalidate rigid aliases when typing mode is changed +// into `PostAnalysis`. Thus we failed to reveal opaques in const eval. + +#![feature(type_alias_impl_trait)] + +type Opaque = impl Sized; + +#[define_opaque(Opaque)] +fn value() -> Opaque { + 0u8 +} + +trait Trait { + const N: usize; +} + +impl Trait for T { + const N: usize = std::mem::size_of::(); +} + +fn test(n: usize) { + match n { + ::N => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/normalize/typing_env_transition_for_temps_promotion.rs b/tests/ui/traits/next-solver/normalize/typing_env_transition_for_temps_promotion.rs new file mode 100644 index 0000000000000..5a2ceaf97f7c3 --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/typing_env_transition_for_temps_promotion.rs @@ -0,0 +1,26 @@ +//@ revisions: old next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Previously we forgot to invalidate rigid aliases when typing mode is changed +// into `PostAnalysis`. Thus we failed to reveal opaques in const eval. + +#![feature(generic_const_items, type_alias_impl_trait)] +#![allow(incomplete_features)] + +type Opaque = impl Sized; + +#[define_opaque(Opaque)] +fn value() -> Opaque { + 0u8 +} + +const DIV: u8 = std::mem::size_of::() as u8; + +pub fn test() -> &'static u8 { + &(42 / DIV::) +} + +fn main() { +} diff --git a/tests/ui/traits/next-solver/supertrait-hrtb-bound-var-indices.rs b/tests/ui/traits/next-solver/supertrait-hrtb-bound-var-indices.rs new file mode 100644 index 0000000000000..790d4a7c6b90d --- /dev/null +++ b/tests/ui/traits/next-solver/supertrait-hrtb-bound-var-indices.rs @@ -0,0 +1,19 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver=globally + +// Check that elaborating a higher-ranked supertrait correctly shifts +// bound-variable indices when combining the two sets of binders. + +trait Triple<'a, 'b, 'c> {} + +trait Double<'a, 'b>: for<'c> Triple<'a, 'b, 'c> {} + +fn needs_triple Triple<'a, 'b, 'c>>() {} + +fn implied_supertrait Double<'a, 'b>>() { + needs_triple::(); +} + +fn main() {} diff --git a/tests/ui/transmutability/coherence.next.stderr b/tests/ui/transmutability/coherence.next.stderr new file mode 100644 index 0000000000000..ce94c57a7f622 --- /dev/null +++ b/tests/ui/transmutability/coherence.next.stderr @@ -0,0 +1,19 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/coherence.rs:10:37 + | +LL | impl> OpaqueTrait for T {} + | ^^ + +error[E0119]: conflicting implementations of trait `OpaqueTrait` for type `&_` + --> $DIR/coherence.rs:13:1 + | +LL | impl> OpaqueTrait for T {} + | ---------------------------------------------------------- first implementation here +... +LL | impl OpaqueTrait for &T where T: OpaqueTrait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0119, E0747. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/transmutability/coherence.old.stderr b/tests/ui/transmutability/coherence.old.stderr new file mode 100644 index 0000000000000..ce94c57a7f622 --- /dev/null +++ b/tests/ui/transmutability/coherence.old.stderr @@ -0,0 +1,19 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/coherence.rs:10:37 + | +LL | impl> OpaqueTrait for T {} + | ^^ + +error[E0119]: conflicting implementations of trait `OpaqueTrait` for type `&_` + --> $DIR/coherence.rs:13:1 + | +LL | impl> OpaqueTrait for T {} + | ---------------------------------------------------------- first implementation here +... +LL | impl OpaqueTrait for &T where T: OpaqueTrait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0119, E0747. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/transmutability/coherence.rs b/tests/ui/transmutability/coherence.rs new file mode 100644 index 0000000000000..274d7b17a53c5 --- /dev/null +++ b/tests/ui/transmutability/coherence.rs @@ -0,0 +1,16 @@ +//! Regression test for + +//@ revisions: old next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +#![feature(transmutability)] +trait OpaqueTrait {} + +impl> OpaqueTrait for T {} +//~^ ERROR: type provided when a constant was expected + +impl OpaqueTrait for &T where T: OpaqueTrait {} +//~^ ERROR: conflicting implementations of trait `OpaqueTrait` for type `&_` + +fn main() {} diff --git a/tests/ui/use/use-after-move-self-based-on-type.stderr b/tests/ui/use/use-after-move-self-based-on-type.stderr index 17827becccecc..c7b0b5e9cc1de 100644 --- a/tests/ui/use/use-after-move-self-based-on-type.stderr +++ b/tests/ui/use/use-after-move-self-based-on-type.stderr @@ -11,6 +11,8 @@ LL | return self.x; note: `S::bar` takes ownership of the receiver `self`, which moves `self` --> $DIR/use-after-move-self-based-on-type.rs:15:16 | +LL | impl S { +... LL | pub fn bar(self) {} | ^^^^ diff --git a/tests/ui/use/use-after-move-self.stderr b/tests/ui/use/use-after-move-self.stderr index ebd6cef58b431..d29d8eba9199f 100644 --- a/tests/ui/use/use-after-move-self.stderr +++ b/tests/ui/use/use-after-move-self.stderr @@ -11,6 +11,8 @@ LL | return *self.x; note: `S::bar` takes ownership of the receiver `self`, which moves `self` --> $DIR/use-after-move-self.rs:13:16 | +LL | impl S { +... LL | pub fn bar(self) {} | ^^^^