diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index ddf1b7942ca11..0bed40ca639fb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -27,7 +27,7 @@ pub(crate) mod on_move; pub(crate) mod on_type_error; pub(crate) mod on_unimplemented; pub(crate) mod on_unknown; -pub(crate) mod on_unmatch_args; +pub(crate) mod on_unmatched_args; #[derive(Copy, Clone)] pub(crate) enum Mode { @@ -41,8 +41,8 @@ pub(crate) enum Mode { DiagnosticOnMove, /// `#[diagnostic::on_unknown]` DiagnosticOnUnknown, - /// `#[diagnostic::on_unmatch_args]` - DiagnosticOnUnmatchArgs, + /// `#[diagnostic::on_unmatched_args]` + DiagnosticOnUnmatchedArgs, /// `#[diagnostic::on_type_error]` DiagnosticOnTypeError, } @@ -55,7 +55,7 @@ impl Mode { Self::DiagnosticOnConst => "diagnostic::on_const", Self::DiagnosticOnMove => "diagnostic::on_move", Self::DiagnosticOnUnknown => "diagnostic::on_unknown", - Self::DiagnosticOnUnmatchArgs => "diagnostic::on_unmatch_args", + Self::DiagnosticOnUnmatchedArgs => "diagnostic::on_unmatched_args", Self::DiagnosticOnTypeError => "diagnostic::on_type_error", } } @@ -73,7 +73,7 @@ impl Mode { Self::DiagnosticOnConst => DEFAULT, Self::DiagnosticOnMove => DEFAULT, Self::DiagnosticOnUnknown => DEFAULT, - Self::DiagnosticOnUnmatchArgs => DEFAULT, + Self::DiagnosticOnUnmatchedArgs => DEFAULT, Self::DiagnosticOnTypeError => DIAGNOSTIC_ON_TYPE_ERROR_EXPECTED_OPTIONS, } } @@ -90,7 +90,7 @@ impl Mode { Self::DiagnosticOnConst => DEFAULT, Self::DiagnosticOnMove => DEFAULT, Self::DiagnosticOnUnknown => DEFAULT, - Self::DiagnosticOnUnmatchArgs => DEFAULT, + Self::DiagnosticOnUnmatchedArgs => DEFAULT, Self::DiagnosticOnTypeError => DIAGNOSTIC_ON_TYPE_ERROR_ALLOWED_OPTIONS, } } @@ -112,7 +112,7 @@ impl Mode { Self::DiagnosticOnUnknown => { "only `This` is allowed as a format argument, referring to the failed import" } - Self::DiagnosticOnUnmatchArgs => { + Self::DiagnosticOnUnmatchedArgs => { "only `This` is allowed as a format argument, referring to the macro's name" } Self::DiagnosticOnTypeError => { @@ -313,7 +313,7 @@ fn parse_directive_items<'p>( | Mode::DiagnosticOnConst | Mode::DiagnosticOnMove | Mode::DiagnosticOnUnknown - | Mode::DiagnosticOnUnmatchArgs, + | Mode::DiagnosticOnUnmatchedArgs, sym::message, ) => { let value = or_malformed!(value?); @@ -329,7 +329,7 @@ fn parse_directive_items<'p>( | Mode::DiagnosticOnConst | Mode::DiagnosticOnMove | Mode::DiagnosticOnUnknown - | Mode::DiagnosticOnUnmatchArgs, + | Mode::DiagnosticOnUnmatchedArgs, sym::label, ) => { let value = or_malformed!(value?); @@ -469,7 +469,7 @@ fn parse_arg( ( Mode::DiagnosticOnUnknown | Mode::DiagnosticOnMove - | Mode::DiagnosticOnUnmatchArgs + | Mode::DiagnosticOnUnmatchedArgs | Mode::DiagnosticOnTypeError, sym::This, ) => FormatArg::This, @@ -502,7 +502,7 @@ fn parse_arg( ) => FormatArg::GenericParam { generic_param, span }, // Generics are explicitly not allowed, we print those back as is. - (Mode::DiagnosticOnUnknown | Mode::DiagnosticOnUnmatchArgs, as_is) => { + (Mode::DiagnosticOnUnknown | Mode::DiagnosticOnUnmatchedArgs, as_is) => { warnings.push(FormatWarning::DisallowedPlaceholder { span, attr: mode.as_str(), diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatch_args.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs similarity index 74% rename from compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatch_args.rs rename to compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs index 4d6f833a79751..17b9fcd52d225 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatch_args.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs @@ -4,21 +4,21 @@ use rustc_session::lint::builtin::MISPLACED_DIAGNOSTIC_ATTRIBUTES; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; -use crate::diagnostics::DiagnosticOnUnmatchArgsOnlyForMacros; +use crate::diagnostics::DiagnosticOnUnmatchedArgsOnlyForMacros; #[derive(Default)] -pub(crate) struct OnUnmatchArgsParser { +pub(crate) struct OnUnmatchedArgsParser { span: Option, directive: Option<(Span, Directive)>, } -impl AttributeParser for OnUnmatchArgsParser { +impl AttributeParser for OnUnmatchedArgsParser { const ATTRIBUTES: AcceptMapping = &[( - &[sym::diagnostic, sym::on_unmatch_args], + &[sym::diagnostic, sym::on_unmatched_args], template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]), AttributeStability::Stable, // Unstable, stability checked manually in the parser |this, cx, args| { - if !cx.features().diagnostic_on_unmatch_args() { + if !cx.features().diagnostic_on_unmatched_args() { return; } @@ -28,13 +28,13 @@ impl AttributeParser for OnUnmatchArgsParser { if !matches!(cx.target, Target::MacroDef) { cx.emit_lint( MISPLACED_DIAGNOSTIC_ATTRIBUTES, - DiagnosticOnUnmatchArgsOnlyForMacros, + DiagnosticOnUnmatchedArgsOnlyForMacros, span, ); return; } - let mode = Mode::DiagnosticOnUnmatchArgs; + let mode = Mode::DiagnosticOnUnmatchedArgs; let Some(items) = parse_list(cx, args, mode) else { return }; let Some(directive) = parse_directive_items(cx, mode, items.mixed(), true) else { @@ -48,7 +48,9 @@ impl AttributeParser for OnUnmatchArgsParser { fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option { if let Some(_span) = self.span { - Some(AttributeKind::OnUnmatchArgs { directive: self.directive.map(|d| Box::new(d.1)) }) + Some(AttributeKind::OnUnmatchedArgs { + directive: self.directive.map(|d| Box::new(d.1)), + }) } else { None } diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index b03d28c0cdfa5..bda71e6d566c7 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -35,7 +35,7 @@ use crate::attributes::diagnostic::on_move::*; use crate::attributes::diagnostic::on_type_error::*; use crate::attributes::diagnostic::on_unimplemented::*; use crate::attributes::diagnostic::on_unknown::*; -use crate::attributes::diagnostic::on_unmatch_args::*; +use crate::attributes::diagnostic::on_unmatched_args::*; use crate::attributes::doc::*; use crate::attributes::dummy::*; use crate::attributes::inline::*; @@ -149,7 +149,7 @@ attribute_parsers!( OnTypeErrorParser, OnUnimplementedParser, OnUnknownParser, - OnUnmatchArgsParser, + OnUnmatchedArgsParser, RustcAlignParser, RustcAlignStaticParser, RustcCguTestAttributeParser, diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 7cca75462ab8c..98b72f2fa97f6 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -302,8 +302,8 @@ pub(crate) struct DiagnosticOnUnknownOnlyForImports { } #[derive(Diagnostic)] -#[diag("`#[diagnostic::on_unmatch_args]` can only be applied to macro definitions")] -pub(crate) struct DiagnosticOnUnmatchArgsOnlyForMacros; +#[diag("`#[diagnostic::on_unmatched_args]` can only be applied to macro definitions")] +pub(crate) struct DiagnosticOnUnmatchedArgsOnlyForMacros; #[derive(Diagnostic)] #[diag("`#[diagnostic::on_type_error]` can only be applied to enums, structs or unions")] diff --git a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs index 259330611c483..590c2c9c3965b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs +++ b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs @@ -12,8 +12,8 @@ use rustc_middle::ty::{ Unnormalized, }; use rustc_span::Span; +use rustc_trait_selection::diagnostics::impl_trait_overcapture_suggestion; use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic; -use rustc_trait_selection::errors::impl_trait_overcapture_suggestion; use crate::MirBorrowckCtxt; use crate::borrow_set::BorrowData; diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index 7abf3ac308805..a80842c8def18 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -33,7 +33,7 @@ pub(super) fn failed_to_match_macro( args: FailedMacro<'_>, body: &TokenStream, rules: &[MacroRule], - on_unmatch_args: Option<&Directive>, + on_unmatched_args: Option<&Directive>, ) -> (Span, ErrorGuaranteed) { debug!("failed to match macro"); let def_head_span = if !def_span.is_dummy() && !psess.source_map().is_imported(def_span) { @@ -77,7 +77,7 @@ pub(super) fn failed_to_match_macro( let CustomDiagnostic { message: custom_message, label: custom_label, notes: custom_notes, .. } = { - on_unmatch_args + on_unmatched_args .map(|directive| directive.eval(None, &FormatArgs { this: name.to_string(), .. })) .unwrap_or_default() }; diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 1a1ef0f06963e..e50ffb556b3ba 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -166,7 +166,7 @@ pub struct MacroRulesMacroExpander { node_id: NodeId, name: Ident, span: Span, - on_unmatch_args: Option, + on_unmatched_args: Option, transparency: Transparency, kinds: MacroKinds, rules: Vec, @@ -249,7 +249,7 @@ impl MacroRulesMacroExpander { FailedMacro::Derive, body, rules, - self.on_unmatch_args.as_ref(), + self.on_unmatched_args.as_ref(), ); cx.macro_error_and_trace_macros_diag(); Err(guar) @@ -274,7 +274,7 @@ impl TTMacroExpander for MacroRulesMacroExpander { self.transparency, input, &self.rules, - self.on_unmatch_args.as_ref(), + self.on_unmatched_args.as_ref(), )) } } @@ -309,7 +309,7 @@ impl AttrProcMacro for MacroRulesMacroExpander { args, body, &self.rules, - self.on_unmatch_args.as_ref(), + self.on_unmatched_args.as_ref(), ) } } @@ -371,7 +371,7 @@ impl<'matcher> Tracker<'matcher> for NoopTracker { } /// Expands the rules based macro defined by `rules` for a given input `arg`. -#[instrument(skip(cx, transparency, arg, rules, on_unmatch_args))] +#[instrument(skip(cx, transparency, arg, rules, on_unmatched_args))] fn expand_macro<'cx, 'a: 'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, @@ -381,7 +381,7 @@ fn expand_macro<'cx, 'a: 'cx>( transparency: Transparency, arg: TokenStream, rules: &'a [MacroRule], - on_unmatch_args: Option<&Directive>, + on_unmatched_args: Option<&Directive>, ) -> Box { let psess = &cx.sess.psess; @@ -440,7 +440,7 @@ fn expand_macro<'cx, 'a: 'cx>( FailedMacro::Func, &arg, rules, - on_unmatch_args, + on_unmatched_args, ); cx.macro_error_and_trace_macros_diag(); DummyResult::any(span, guar) @@ -449,7 +449,7 @@ fn expand_macro<'cx, 'a: 'cx>( } /// Expands the rules based macro defined by `rules` for a given attribute `args` and `body`. -#[instrument(skip(cx, transparency, args, body, rules, on_unmatch_args))] +#[instrument(skip(cx, transparency, args, body, rules, on_unmatched_args))] fn expand_macro_attr( cx: &mut ExtCtxt<'_>, sp: Span, @@ -461,7 +461,7 @@ fn expand_macro_attr( args: TokenStream, body: TokenStream, rules: &[MacroRule], - on_unmatch_args: Option<&Directive>, + on_unmatched_args: Option<&Directive>, ) -> Result { let psess = &cx.sess.psess; // Macros defined in the current crate have a real node id, @@ -526,7 +526,7 @@ fn expand_macro_attr( FailedMacro::Attr(&args), &body, rules, - on_unmatch_args, + on_unmatched_args, ); cx.trace_macros_diag(); Err(guar) @@ -865,9 +865,9 @@ pub fn compile_declarative_macro( return dummy_syn_ext(guar); } - let on_unmatch_args = find_attr!( + let on_unmatched_args = find_attr!( attrs, - OnUnmatchArgs { directive, .. } => directive.clone() + OnUnmatchedArgs { directive, .. } => directive.clone() ) .flatten() .map(|directive| *directive); @@ -877,7 +877,7 @@ pub fn compile_declarative_macro( kinds, span, node_id, - on_unmatch_args, + on_unmatched_args, transparency, rules, macro_rules, diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 431461e1ddf15..ab24b0ed37d22 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -106,6 +106,8 @@ declare_features! ( (removed, deprecated_safe, "1.95.0", Some(94978), Some("never properly implemented, in the way of attribute refactor"), 152554), /// Allows deriving traits as per `SmartPointer` specification (removed, derive_smart_pointer, "1.84.0", Some(123430), Some("replaced by `CoercePointee`"), 131284), + /// Allows macros to customize macro argument matcher diagnostics. + (removed, diagnostic_on_unmatch_args, "CURRENT_RUSTC_VERSION", Some(155642), Some("renamed to `diagnostic_on_unmatched_args`"), 157887), /// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. (removed, doc_auto_cfg, "1.92.0", Some(43781), Some("merged into `doc_cfg`"), 138907), /// Allows `#[doc(cfg_hide(...))]`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 9220b31a1cce0..675ad38d7a0e2 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -515,7 +515,7 @@ declare_features! ( /// Allows giving unresolved imports a custom diagnostic message (unstable, diagnostic_on_unknown, "1.96.0", Some(152900)), /// Allows macros to customize macro argument matcher diagnostics. - (unstable, diagnostic_on_unmatch_args, "1.97.0", Some(155642)), + (unstable, diagnostic_on_unmatched_args, "1.97.0", Some(155642)), /// Allows `#[doc(cfg(...))]`. (unstable, doc_cfg, "1.21.0", Some(43781)), /// Allows `#[doc(masked)]`. diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index dc850e22ef5ea..bf9f0709bbdc4 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -1191,8 +1191,8 @@ pub enum AttributeKind { directive: Option>, }, - /// Represents `#[diagnostic::on_unmatch_args]`. - OnUnmatchArgs { + /// Represents `#[diagnostic::on_unmatched_args]`. + OnUnmatchedArgs { /// None if the directive was malformed in some way. directive: Option>, }, diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 40ec566b43d11..11dcd37816bd6 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -81,7 +81,7 @@ impl AttributeKind { OnTypeError { .. } => Yes, OnUnimplemented { .. } => Yes, OnUnknown { .. } => Yes, - OnUnmatchArgs { .. } => Yes, + OnUnmatchedArgs { .. } => Yes, Optimize(..) => No, PanicRuntime => No, PatchableFunctionEntry { .. } => Yes, diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 7042849c11bfd..d49326a089c90 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -31,7 +31,21 @@ pub(crate) fn orphan_check_impl( Err(err) => match orphan_check(tcx, impl_def_id, OrphanCheckMode::Compat) { Ok(()) => match err { OrphanCheckErr::UncoveredTyParams(uncovered_ty_params) => { - lint_uncovered_ty_params(tcx, uncovered_ty_params, impl_def_id) + let hir_id = tcx.local_def_id_to_hir_id(impl_def_id); + + for param_def_id in uncovered_ty_params.uncovered { + let ident = tcx.item_ident(param_def_id); + + tcx.emit_node_span_lint( + UNCOVERED_PARAM_IN_PROJECTION, + hir_id, + ident.span, + diagnostics::UncoveredTyParam { + param: ident, + local_ty: uncovered_ty_params.local_ty, + }, + ); + } } OrphanCheckErr::NonLocalInputType(_) => { bug!("orphanck: shouldn't've gotten non-local input tys in compat mode") @@ -458,56 +472,18 @@ fn emit_orphan_check_error<'tcx>( diag.emit() } traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => { - let mut reported = None; + let mut guar = None; for param_def_id in uncovered { - let name = tcx.item_ident(param_def_id); - let span = name.span; - - reported.get_or_insert(match local_ty { - Some(local_type) => tcx.dcx().emit_err(diagnostics::TyParamFirstLocal { - span, - note: (), - param: name, - local_type, - }), - None => { - tcx.dcx().emit_err(diagnostics::TyParamSome { span, note: (), param: name }) - } - }); + guar.get_or_insert(tcx.dcx().emit_err(diagnostics::UncoveredTyParam { + param: tcx.item_ident(param_def_id), + local_ty, + })); } - reported.unwrap() // FIXME(fmease): This is very likely reachable. + guar.unwrap() } } } -fn lint_uncovered_ty_params<'tcx>( - tcx: TyCtxt<'tcx>, - UncoveredTyParams { uncovered, local_ty }: UncoveredTyParams, FxIndexSet>, - impl_def_id: LocalDefId, -) { - let hir_id = tcx.local_def_id_to_hir_id(impl_def_id); - - for param_def_id in uncovered { - let span = tcx.def_ident_span(param_def_id).unwrap(); - let name = tcx.item_ident(param_def_id); - - match local_ty { - Some(local_type) => tcx.emit_node_span_lint( - UNCOVERED_PARAM_IN_PROJECTION, - hir_id, - span, - diagnostics::TyParamFirstLocalLint { span, note: (), param: name, local_type }, - ), - None => tcx.emit_node_span_lint( - UNCOVERED_PARAM_IN_PROJECTION, - hir_id, - span, - diagnostics::TyParamSomeLint { span, note: (), param: name }, - ), - }; - } -} - struct UncoveredTyParamCollector<'cx, 'tcx> { infcx: &'cx InferCtxt<'tcx>, uncovered_params: FxIndexSet, diff --git a/compiler/rustc_hir_analysis/src/diagnostics.rs b/compiler/rustc_hir_analysis/src/diagnostics.rs index d969f9761d132..5997f16b42917 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics.rs @@ -1474,72 +1474,6 @@ pub struct NoFieldOnType<'tcx> { pub field: Ident, } -// FIXME(fmease): Deduplicate: - -#[derive(Diagnostic)] -#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)] -#[note( - "implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type" -)] -pub(crate) struct TyParamFirstLocal<'tcx> { - #[primary_span] - #[label( - "type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)" - )] - pub span: Span, - #[note( - "in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last" - )] - pub note: (), - pub param: Ident, - pub local_type: Ty<'tcx>, -} - -#[derive(Diagnostic)] -#[diag("type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)", code = E0210)] -#[note( - "implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type" -)] -pub(crate) struct TyParamFirstLocalLint<'tcx> { - #[label( - "type parameter `{$param}` must be covered by another type when it appears before the first local type (`{$local_type}`)" - )] - pub span: Span, - #[note( - "in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last" - )] - pub note: (), - pub param: Ident, - pub local_type: Ty<'tcx>, -} - -#[derive(Diagnostic)] -#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)] -#[note( - "implementing a foreign trait is only possible if at least one of the types for which it is implemented is local" -)] -pub(crate) struct TyParamSome { - #[primary_span] - #[label("type parameter `{$param}` must be used as the type parameter for some local type")] - pub span: Span, - #[note("only traits defined in the current crate can be implemented for a type parameter")] - pub note: (), - pub param: Ident, -} - -#[derive(Diagnostic)] -#[diag("type parameter `{$param}` must be used as the type parameter for some local type (e.g., `MyStruct<{$param}>`)", code = E0210)] -#[note( - "implementing a foreign trait is only possible if at least one of the types for which it is implemented is local" -)] -pub(crate) struct TyParamSomeLint { - #[label("type parameter `{$param}` must be used as the type parameter for some local type")] - pub span: Span, - #[note("only traits defined in the current crate can be implemented for a type parameter")] - pub note: (), - pub param: Ident, -} - #[derive(Diagnostic)] pub(crate) enum OnlyCurrentTraits { #[diag("only traits defined in the current crate can be implemented for types defined outside of the crate", code = E0117)] @@ -2024,3 +1958,53 @@ pub(crate) struct PinV2OnPacked { pub pin_v2_span: Option, pub adt_name: Symbol, } + +pub(crate) struct UncoveredTyParam<'tcx> { + pub(crate) param: Ident, + pub(crate) local_ty: Option>, +} + +impl Diagnostic<'_, G> for UncoveredTyParam<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + let Self { param, local_ty } = self; + + let mut diag = Diag::new(dcx, level, "") + .with_span(param.span) + .with_span_label(param.span, "uncovered type parameter"); + if diag.is_error() { + diag.code(E0210); + } + + let note = "\ + implementing a foreign trait is only possible if \ + at least one of the types for which it is implemented is local"; + + if let Some(local_ty) = local_ty { + diag.primary_message(format!( + "type parameter `{param}` must be covered by another type when \ + it appears before the first local type (`{local_ty}`)" + )); + + diag.note(format!( + "{note},\nand no uncovered type parameters appear before that first local type" + )); + diag.note( + "in this case, 'before' refers to the following order: \ + `impl<..> ForeignTrait for T0`,\n\ + where `T0` is the first and `Tn` is the last", + ); + } else { + diag.primary_message(format!( + "type parameter `{param}` must be used as an argument to \ + some local type (e.g., `MyStruct<{param}>`)" + )); + + diag.note(note); + diag.note( + "only traits defined in the current crate can be implemented for a type parameter", + ); + } + + diag + } +} diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 5fea7454e57ea..922a9d7e95bda 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -197,25 +197,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn err_ctxt(&'a self) -> TypeErrCtxt<'a, 'tcx> { TypeErrCtxt { infcx: &self.infcx, + param_env: Some(self.param_env), typeck_results: Some(self.typeck_results.borrow()), diverging_fallback_has_occurred: self.diverging_fallback_has_occurred.get(), - normalize_fn_sig: Box::new(|fn_sig| { - if fn_sig.skip_normalization().has_escaping_bound_vars() { - return fn_sig.skip_normalization(); - } - self.probe(|_| { - let ocx = ObligationCtxt::new(self); - let normalized_fn_sig = - ocx.normalize(&ObligationCause::dummy(), self.param_env, fn_sig); - if ocx.evaluate_obligations_error_on_ambiguity().is_empty() { - let normalized_fn_sig = self.resolve_vars_if_possible(normalized_fn_sig); - if !normalized_fn_sig.has_infer() { - return normalized_fn_sig; - } - } - fn_sig.skip_normalization() - }) - }), autoderef_steps: Box::new(|ty| { let mut autoderef = self.autoderef(DUMMY_SP, ty).silence_errors(); let mut steps = vec![]; diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 76d55030b1312..842a9be7093a7 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -23,7 +23,7 @@ use rustc_middle::{bug, span_bug}; use rustc_session::lint::fcw; use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::{Span, Symbol}; -use rustc_trait_selection::errors::{ +use rustc_trait_selection::diagnostics::{ AddPreciseCapturingForOvercapture, impl_trait_overcapture_suggestion, }; use rustc_trait_selection::regions::OutlivesEnvironmentBuildExt; diff --git a/compiler/rustc_mir_transform/src/check_call_recursion.rs b/compiler/rustc_mir_transform/src/check_call_recursion.rs index b47e7bd168678..216ada600ce34 100644 --- a/compiler/rustc_mir_transform/src/check_call_recursion.rs +++ b/compiler/rustc_mir_transform/src/check_call_recursion.rs @@ -10,7 +10,7 @@ use rustc_middle::ty::{self, GenericArg, GenericArgs, Instance, Ty, TyCtxt, Unno use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION; use rustc_span::Span; -use crate::errors::UnconditionalRecursion; +use crate::diagnostics::UnconditionalRecursion; use crate::pass_manager::MirLint; pub(super) struct CheckCallRecursion; diff --git a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs index 8545704cb6a34..f1876bafbf79b 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -6,7 +6,7 @@ use rustc_session::lint::builtin::CONST_ITEM_MUTATION; use rustc_span::Span; use rustc_span::def_id::DefId; -use crate::errors; +use crate::diagnostics; pub(super) struct CheckConstItemMutation; @@ -108,7 +108,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { CONST_ITEM_MUTATION, lint_root, span, - errors::ConstMutate::Modify { konst: item }, + diagnostics::ConstMutate::Modify { konst: item }, ); } @@ -154,7 +154,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { CONST_ITEM_MUTATION, lint_root, span, - errors::ConstMutate::MutBorrow { method_call, konst: item }, + diagnostics::ConstMutate::MutBorrow { method_call, konst: item }, ); } } diff --git a/compiler/rustc_mir_transform/src/check_inline.rs b/compiler/rustc_mir_transform/src/check_inline.rs index 50ef94f623dc5..c267fb171fba5 100644 --- a/compiler/rustc_mir_transform/src/check_inline.rs +++ b/compiler/rustc_mir_transform/src/check_inline.rs @@ -26,7 +26,7 @@ impl<'tcx> MirLint<'tcx> for CheckForceInline { if let Err(reason) = is_inline_valid_on_fn(tcx, def_id).and_then(|_| is_inline_valid_on_body(tcx, body)) { - tcx.dcx().emit_err(crate::errors::InvalidForceInline { + tcx.dcx().emit_err(crate::diagnostics::InvalidForceInline { attr_span, callee_span: tcx.def_span(def_id), callee: tcx.def_path_str(def_id), diff --git a/compiler/rustc_mir_transform/src/check_packed_ref.rs b/compiler/rustc_mir_transform/src/check_packed_ref.rs index 9ce244a00fcec..fd87587b8f9ce 100644 --- a/compiler/rustc_mir_transform/src/check_packed_ref.rs +++ b/compiler/rustc_mir_transform/src/check_packed_ref.rs @@ -3,7 +3,7 @@ use rustc_middle::mir::*; use rustc_middle::span_bug; use rustc_middle::ty::{self, TyCtxt}; -use crate::{errors, util}; +use crate::{diagnostics, util}; pub(super) struct CheckPackedRef; @@ -50,7 +50,7 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> { // shouldn't do. span_bug!(self.source_info.span, "builtin derive created an unaligned reference"); } else { - self.tcx.dcx().emit_err(errors::UnalignedPackedRef { + self.tcx.dcx().emit_err(diagnostics::UnalignedPackedRef { span: self.source_info.span, ty_descr: adt.descr(), align: pack.bytes(), diff --git a/compiler/rustc_mir_transform/src/coroutine/layout.rs b/compiler/rustc_mir_transform/src/coroutine/layout.rs index be8402f082e62..7262d44dcab99 100644 --- a/compiler/rustc_mir_transform/src/coroutine/layout.rs +++ b/compiler/rustc_mir_transform/src/coroutine/layout.rs @@ -46,7 +46,7 @@ use rustc_trait_selection::infer::TyCtxtInferExt as _; use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt}; use tracing::{debug, instrument, trace}; -use crate::errors::{MustNotSupend, MustNotSuspendReason}; +use crate::diagnostics::{MustNotSupend, MustNotSuspendReason}; const SELF_ARG: Local = Local::arg(0); diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/diagnostics.rs similarity index 100% rename from compiler/rustc_mir_transform/src/errors.rs rename to compiler/rustc_mir_transform/src/diagnostics.rs diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 06e7bf974b515..1d90d282a62b9 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -9,7 +9,7 @@ use rustc_session::lint::builtin::FFI_UNWIND_CALLS; use rustc_target::spec::PanicStrategy; use tracing::debug; -use crate::errors; +use crate::diagnostics; // Check if the body of this def_id can possibly leak a foreign unwind into Rust code. fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { @@ -67,7 +67,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { FFI_UNWIND_CALLS, lint_root, span, - errors::AsmUnwindCall { span }, + diagnostics::AsmUnwindCall { span }, ); tainted = true; @@ -119,7 +119,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { FFI_UNWIND_CALLS, lint_root, span, - errors::FfiUnwindCall { span, foreign }, + diagnostics::FfiUnwindCall { span, foreign }, ); tainted = true; diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 71c9b79d682df..ca1aeedf10180 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt}; use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES; use rustc_span::{Span, Spanned, sym}; -use crate::errors; +use crate::diagnostics; pub(super) struct FunctionItemReferences; @@ -179,7 +179,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { FUNCTION_ITEM_REFERENCES, lint_root, span, - errors::FnItemRef { span, sugg, ident }, + diagnostics::FnItemRef { span, sugg, ident }, ); } } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index f234166be24a6..bfd200884b676 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -253,7 +253,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> { let call_span = callsite.source_info.span; let callee = tcx.def_path_str(callsite.callee.def_id()); - tcx.dcx().emit_err(crate::errors::ForceInlineFailure { + tcx.dcx().emit_err(crate::diagnostics::ForceInlineFailure { call_span, attr_span, caller_span: tcx.def_span(self.def_id), @@ -262,7 +262,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> { callee: callee.clone(), reason, justification: justification - .map(|sym| crate::errors::ForceInlineJustification { sym, callee }), + .map(|sym| crate::diagnostics::ForceInlineJustification { sym, callee }), }); } } diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index ff5006032308e..cd8dc963eb33c 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -22,7 +22,7 @@ use rustc_middle::ty::{self, ConstInt, ScalarInt, Ty, TyCtxt, TypeVisitableExt, use rustc_span::Span; use tracing::{debug, instrument, trace}; -use crate::errors::{AssertLint, AssertLintKind}; +use crate::diagnostics::{AssertLint, AssertLintKind}; pub(super) struct KnownPanicsLint; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index b783cc2d5933b..edf0dcca775ca 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -40,8 +40,8 @@ mod check_pointers; mod cost_checker; mod cross_crate_inline; mod deduce_param_attrs; +mod diagnostics; mod elaborate_drop; -mod errors; mod ffi_unwind_calls; mod lint; mod lint_tail_expr_drop_order; diff --git a/compiler/rustc_mir_transform/src/lint_and_remove_uninhabited.rs b/compiler/rustc_mir_transform/src/lint_and_remove_uninhabited.rs index 0b46ba6ffc747..81e98585995fd 100644 --- a/compiler/rustc_mir_transform/src/lint_and_remove_uninhabited.rs +++ b/compiler/rustc_mir_transform/src/lint_and_remove_uninhabited.rs @@ -3,7 +3,7 @@ use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::UNREACHABLE_CODE; -use crate::errors::UnreachableDueToUninhabited; +use crate::diagnostics::UnreachableDueToUninhabited; /// Lint unreachable code due to uninhabited values from function calls, /// and remove return edges from those calls. diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index c449cf6867395..795b0b9cac82e 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -19,7 +19,7 @@ use rustc_span::Span; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::symbol::{Symbol, kw, sym}; -use crate::errors; +use crate::diagnostics; #[derive(Copy, Clone, Debug, PartialEq, Eq)] enum AccessKind { @@ -175,7 +175,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>( name: Symbol, span: Span, ty: Ty<'tcx>, -) -> Option { +) -> Option { if let ty::Adt(adt_def, _) = ty.peel_refs().kind() { let variant_names: Vec<_> = adt_def .variants() @@ -189,7 +189,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>( .iter() .find(|v| v.name == name && matches!(v.ctor, Some((CtorKind::Const, _)))) { - return Some(errors::PatternTypo { + return Some(diagnostics::PatternTypo { span, code: with_no_trimmed_paths!(tcx.def_path_str(variant.def_id)), kind: tcx.def_descr(variant.def_id), @@ -213,7 +213,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>( && let Some(position) = names.iter().position(|&n| n == item_name) && let Some(&def_id) = constants.get(position) { - return Some(errors::PatternTypo { + return Some(diagnostics::PatternTypo { span, code: with_no_trimmed_paths!(tcx.def_path_str(def_id)), kind: "constant", @@ -275,7 +275,7 @@ fn annotate_mut_binding_to_immutable_binding<'tcx>( body_def_id: LocalDefId, assignment_span: Span, body: &Body<'tcx>, -) -> Option { +) -> Option { use rustc_hir as hir; use rustc_hir::intravisit::{self, Visitor}; @@ -316,7 +316,7 @@ fn annotate_mut_binding_to_immutable_binding<'tcx>( Some(mut_ty.ty.span.shrink_to_lo()) }; - return Some(errors::UnusedAssignSuggestion { + return Some(diagnostics::UnusedAssignSuggestion { ty_span, pre, // Span of the `mut` before the binding. @@ -939,7 +939,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { .split(&brace_name) .any(|c| matches!(c.chars().next(), Some('}' | ':'))) }) - .map(|&(lit, _)| errors::UnusedVariableStringInterp { lit }) + .map(|&(lit, _)| diagnostics::UnusedVariableStringInterp { lit }) .collect::>() }; @@ -997,16 +997,16 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { } let sugg = if from_macro { - errors::UnusedVariableSugg::NoSugg { span: def_span, name } + diagnostics::UnusedVariableSugg::NoSugg { span: def_span, name } } else { let typo = maybe_suggest_typo(); - errors::UnusedVariableSugg::TryPrefix { spans: vec![def_span], name, typo } + diagnostics::UnusedVariableSugg::TryPrefix { spans: vec![def_span], name, typo } }; tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, hir_id, def_span, - errors::UnusedVariable { + diagnostics::UnusedVariable { name, string_interp: maybe_suggest_literal_matching_name(name), sugg, @@ -1056,7 +1056,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { lint::builtin::UNUSED_VARIABLES, hir_id, def_span, - errors::UnusedVarAssignedOnly { name, typo }, + diagnostics::UnusedVarAssignedOnly { name, typo }, ); continue; } @@ -1067,7 +1067,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { let any_shorthand = introductions.iter().any(|intro| intro.is_shorthand); let sugg = if any_shorthand { - errors::UnusedVariableSugg::TryIgnore { + diagnostics::UnusedVariableSugg::TryIgnore { name: name.to_ident_string(), shorthands: introductions .iter() @@ -1085,20 +1085,20 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { .collect(), } } else if from_macro { - errors::UnusedVariableSugg::NoSugg { span: def_span, name } + diagnostics::UnusedVariableSugg::NoSugg { span: def_span, name } } else if !introductions.is_empty() { let typo = maybe_suggest_typo(); - errors::UnusedVariableSugg::TryPrefix { name, typo, spans: spans.clone() } + diagnostics::UnusedVariableSugg::TryPrefix { name, typo, spans: spans.clone() } } else { let typo = maybe_suggest_typo(); - errors::UnusedVariableSugg::TryPrefix { name, typo, spans: vec![def_span] } + diagnostics::UnusedVariableSugg::TryPrefix { name, typo, spans: vec![def_span] } }; tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES, hir_id, spans, - errors::UnusedVariable { + diagnostics::UnusedVariable { name, string_interp: maybe_suggest_literal_matching_name(name), sugg, @@ -1147,7 +1147,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { .rfind(|(_, overwrite_location)| { location.is_predecessor_of(*overwrite_location, self.body) }) - .map(|&(overwrite_span, _)| errors::UnusedAssignOverwrite { + .map(|&(overwrite_span, _)| diagnostics::UnusedAssignOverwrite { assigned_span: source_info.span, overwrite_span, name, @@ -1190,20 +1190,20 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> { lint::builtin::UNUSED_ASSIGNMENTS, hir_id, source_info.span, - errors::UnusedAssign { name, overwrite, help, suggestion }, + diagnostics::UnusedAssign { name, overwrite, help, suggestion }, ) } AccessKind::Param => tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, source_info.span, - errors::UnusedAssignPassed { name }, + diagnostics::UnusedAssignPassed { name }, ), AccessKind::Capture => tcx.emit_node_span_lint( lint::builtin::UNUSED_ASSIGNMENTS, hir_id, decl_span, - errors::UnusedCaptureMaybeCaptureRef { name }, + diagnostics::UnusedCaptureMaybeCaptureRef { name }, ), } } diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index fbf16f91610c5..72af7b846861e 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -9,7 +9,7 @@ use rustc_session::Session; use tracing::trace; use crate::lint::lint_body; -use crate::{errors, validate}; +use crate::{diagnostics, validate}; thread_local! { /// Maps MIR pass names to a snake case form to match profiling naming style @@ -255,14 +255,14 @@ fn run_passes_inner<'tcx>( let mut unknown_found = false; for &name in named_passes.difference(&*crate::PASS_NAMES) { - tcx.dcx().emit_warn(errors::UnknownPassName { name }); + tcx.dcx().emit_warn(diagnostics::UnknownPassName { name }); unknown_found = true; } if unknown_found { let mut valid_pass_names = crate::PASS_NAMES.iter().copied().collect::>(); valid_pass_names.sort(); - tcx.dcx().emit_note(errors::ValidPassNames { valid_passes: valid_pass_names.into() }); + tcx.dcx().emit_note(diagnostics::ValidPassNames { valid_passes: valid_pass_names.into() }); } // Verify that no passes are missing from the `declare_passes` invocation diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index aa72068387b30..e414e10e84169 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1278,10 +1278,14 @@ impl<'a> Parser<'a> { None }; let open_paren = self.token.span; + let call_depth = self.token_cursor.stack.len(); let seq = match self.parse_expr_paren_seq() { Ok(args) => Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args))), - Err(err) if self.is_expected_raw_ref_mut() => { + Err(err) + if self.is_expected_raw_ref_mut() + && self.token_cursor.stack.len() == call_depth => + { let guar = err.emit(); // Preserve the call expression so later passes can still diagnose the callee, // while treating the malformed `&raw ` argument as an error expression. @@ -1299,9 +1303,8 @@ impl<'a> Parser<'a> { fn recover_raw_ref_call_args(&mut self, guar: ErrorGuaranteed) -> ThinVec> { let err_span = self.prev_token.span.to(self.token.span); let mut args = thin_vec![self.mk_expr_err(err_span, guar)]; - while self.token != token::Eof && self.token != token::CloseParen { - if self.eat(exp!(Comma)) && self.token != token::Eof && self.token != token::CloseParen - { + while !self.token.kind.is_close_delim_or_eof() { + if self.eat(exp!(Comma)) && !self.token.kind.is_close_delim_or_eof() { args.push(self.mk_expr_err(self.prev_token.span.shrink_to_hi(), guar)); } else { self.parse_token_tree(); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index e639b9e3b0709..ec94e33e92c69 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -301,7 +301,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::NoMangle(..) => (), AttributeKind::NoStd { .. } => (), AttributeKind::OnUnknown { .. } => (), - AttributeKind::OnUnmatchArgs { .. } => (), + AttributeKind::OnUnmatchedArgs { .. } => (), AttributeKind::Optimize(..) => (), AttributeKind::PanicRuntime => (), AttributeKind::PatchableFunctionEntry { .. } => (), diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 9c92ce85f44e8..2a5c2e6c2df83 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -719,7 +719,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { (sym::on_move, Some(sym::diagnostic_on_move)), (sym::on_const, Some(sym::diagnostic_on_const)), (sym::on_unknown, Some(sym::diagnostic_on_unknown)), - (sym::on_unmatch_args, Some(sym::diagnostic_on_unmatch_args)), + (sym::on_unmatched_args, Some(sym::diagnostic_on_unmatched_args)), (sym::on_type_error, Some(sym::diagnostic_on_type_error)), ]; diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c5410563f65e0..f544521d4cbfe 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -816,6 +816,7 @@ symbols! { diagnostic_on_type_error, diagnostic_on_unknown, diagnostic_on_unmatch_args, + diagnostic_on_unmatched_args, dialect, direct, discriminant_kind, @@ -1458,7 +1459,7 @@ symbols! { on_type_error, on_unimplemented, on_unknown, - on_unmatch_args, + on_unmatched_args, opaque, opaque_module_name_placeholder: "", ops, diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/diagnostics.rs similarity index 100% rename from compiler/rustc_trait_selection/src/errors.rs rename to compiler/rustc_trait_selection/src/diagnostics.rs diff --git a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs b/compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs similarity index 100% rename from compiler/rustc_trait_selection/src/errors/note_and_explain.rs rename to compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index dc5b9b2ccb1eb..ad9ac989c6c7f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -72,17 +72,18 @@ use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Pos, Span, sym}; use thin_vec::ThinVec; use tracing::{debug, instrument}; +use crate::diagnostics::{ObligationCauseFailureCode, TypeErrorAdditionalDiags}; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::traits::ambiguity::{ CandidateSource, compute_applicable_impls_for_diagnostics, }; -use crate::errors::{ObligationCauseFailureCode, TypeErrorAdditionalDiags}; use crate::infer; use crate::infer::relate::{self, RelateResult, TypeRelation}; use crate::infer::{InferCtxt, InferCtxtExt as _, TypeTrace, ValuePairs}; use crate::solve::deeply_normalize_for_diagnostics; use crate::traits::{ - MatchExpressionArmCause, Obligation, ObligationCause, ObligationCauseCode, specialization_graph, + MatchExpressionArmCause, Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt, + specialization_graph, }; mod note_and_explain; @@ -115,6 +116,31 @@ fn escape_literal(s: &str) -> String { } impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { + fn normalize_fn_sig( + &self, + fn_sig: Unnormalized<'tcx, ty::PolyFnSig<'tcx>>, + ) -> ty::PolyFnSig<'tcx> { + let Some(param_env) = self.param_env else { + return fn_sig.skip_normalization(); + }; + + if fn_sig.skip_normalization().has_escaping_bound_vars() { + return fn_sig.skip_normalization(); + } + + self.probe(|_| { + let ocx = ObligationCtxt::new(self); + let normalized_fn_sig = ocx.normalize(&ObligationCause::dummy(), param_env, fn_sig); + if ocx.evaluate_obligations_error_on_ambiguity().is_empty() { + let normalized_fn_sig = self.resolve_vars_if_possible(normalized_fn_sig); + if !normalized_fn_sig.has_infer() { + return normalized_fn_sig; + } + } + fn_sig.skip_normalization() + }) + } + // [Note-Type-error-reporting] // An invariant is that anytime the expected or actual type is Error (the special // error type, meaning that an error occurred when typechecking this expression), @@ -760,18 +786,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { /// Given two `fn` signatures highlight only sub-parts that are different. fn cmp_fn_sig( &self, - sig1: &ty::PolyFnSig<'tcx>, + sig1: ty::PolyFnSig<'tcx>, fn_def1: Option<(DefId, Option<&'tcx [ty::GenericArg<'tcx>]>)>, - sig2: &ty::PolyFnSig<'tcx>, + sig2: ty::PolyFnSig<'tcx>, fn_def2: Option<(DefId, Option<&'tcx [ty::GenericArg<'tcx>]>)>, ) -> (DiagStyledString, DiagStyledString) { - let sig1 = &(self.normalize_fn_sig)(Unnormalized::new_wip(*sig1)); - let sig2 = &(self.normalize_fn_sig)(Unnormalized::new_wip(*sig2)); + let sig1 = self.normalize_fn_sig(Unnormalized::new_wip(sig1)); + let sig2 = self.normalize_fn_sig(Unnormalized::new_wip(sig2)); let get_lifetimes = |sig| { use rustc_hir::def::Namespace; let (sig, reg) = ty::print::FmtPrinter::new(self.tcx, Namespace::TypeNS) - .name_all_regions(sig, WrapBinderMode::ForAll) + .name_all_regions(&sig, WrapBinderMode::ForAll) .unwrap(); let lts: Vec = reg.into_items().map(|(_, kind)| kind.to_string()).into_sorted_stable_ord(); @@ -1284,26 +1310,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1).skip_norm_wip(); let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2).skip_norm_wip(); - self.cmp_fn_sig( - &sig1, - Some((*did1, Some(args1))), - &sig2, - Some((*did2, Some(args2))), - ) + self.cmp_fn_sig(sig1, Some((*did1, Some(args1))), sig2, Some((*did2, Some(args2)))) } (ty::FnDef(did1, args1), ty::FnPtr(sig_tys2, hdr2)) => { let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1).skip_norm_wip(); - self.cmp_fn_sig(&sig1, Some((*did1, Some(args1))), &sig_tys2.with(*hdr2), None) + self.cmp_fn_sig(sig1, Some((*did1, Some(args1))), sig_tys2.with(*hdr2), None) } (ty::FnPtr(sig_tys1, hdr1), ty::FnDef(did2, args2)) => { let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2).skip_norm_wip(); - self.cmp_fn_sig(&sig_tys1.with(*hdr1), None, &sig2, Some((*did2, Some(args2)))) + self.cmp_fn_sig(sig_tys1.with(*hdr1), None, sig2, Some((*did2, Some(args2)))) } (ty::FnPtr(sig_tys1, hdr1), ty::FnPtr(sig_tys2, hdr2)) => { - self.cmp_fn_sig(&sig_tys1.with(*hdr1), None, &sig_tys2.with(*hdr2), None) + self.cmp_fn_sig(sig_tys1.with(*hdr1), None, sig_tys2.with(*hdr2), None) } _ => { @@ -2190,7 +2211,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (None, None) }; - Some(self.cmp_fn_sig(&exp_found.expected, fn_def1, &exp_found.found, fn_def2)) + Some(self.cmp_fn_sig(exp_found.expected, fn_def1, exp_found.found, fn_def2)) } } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index e075be19693cb..2aea9e5bcf369 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -23,11 +23,11 @@ use rustc_span::{BytePos, DUMMY_SP, Ident, Span, sym}; use tracing::{debug, instrument, warn}; use super::nice_region_error::placeholder_error::Highlighted; -use crate::error_reporting::TypeErrCtxt; -use crate::errors::{ +use crate::diagnostics::{ AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, SourceKindMultiSuggestion, SourceKindSubdiag, }; +use crate::error_reporting::TypeErrCtxt; use crate::infer::{InferCtxt, TyOrConstInferVar}; pub enum TypeAnnotationNeeded { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs index 9cb58a9d45bd7..e315f53cad7fb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs @@ -7,10 +7,10 @@ use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::{Region, TyCtxt}; use tracing::debug; +use crate::diagnostics::{AddLifetimeParamsSuggestion, LifetimeMismatch, LifetimeMismatchLabels}; use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo; -use crate::errors::{AddLifetimeParamsSuggestion, LifetimeMismatch, LifetimeMismatchLabels}; use crate::infer::{RegionResolutionError, SubregionOrigin}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs index 4422980051afb..e8a9e929d6a5d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs @@ -9,11 +9,11 @@ use rustc_middle::bug; use rustc_middle::ty::TypeVisitor; use tracing::debug; -use crate::error_reporting::infer::nice_region_error::NiceRegionError; -use crate::errors::{ +use crate::diagnostics::{ DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag, IntroducesStaticBecauseUnmetLifetimeReq, MismatchedStaticLifetime, note_and_explain, }; +use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace}; use crate::traits::ObligationCauseCode; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs index ad8cc5d279af1..f555f0435dd8f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs @@ -5,9 +5,9 @@ use rustc_errors::Diag; use rustc_middle::ty; use tracing::debug; +use crate::diagnostics::ExplicitLifetimeRequired; use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; -use crate::errors::ExplicitLifetimeRequired; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// When given a `ConcreteFailure` for a function with parameters containing a named region and diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index fdbf4cf228de9..31bd3b32e76d8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -10,11 +10,11 @@ use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHi use rustc_middle::ty::{self, GenericArgsRef, RePlaceholder, Region, TyCtxt}; use tracing::{debug, instrument}; -use crate::error_reporting::infer::nice_region_error::NiceRegionError; -use crate::errors::{ +use crate::diagnostics::{ ActualImplExpectedKind, ActualImplExpectedLifetimeKind, ActualImplExplNotes, TraitPlaceholderMismatch, TyOrSig, }; +use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace, ValuePairs}; use crate::traits::{ObligationCause, ObligationCauseCode}; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs index 05a1e3fe95dd9..97101fe8f6884 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs @@ -3,8 +3,8 @@ use rustc_errors::Diag; use rustc_middle::bug; use rustc_middle::ty::{self, RePlaceholder, Region}; +use crate::diagnostics::PlaceholderRelationLfNotSatisfied; use crate::error_reporting::infer::nice_region_error::NiceRegionError; -use crate::errors::PlaceholderRelationLfNotSatisfied; use crate::infer::{RegionResolutionError, SubregionOrigin}; impl<'tcx> NiceRegionError<'_, 'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index b227cd065eab9..dfa0d4a3bfd48 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -13,8 +13,8 @@ use rustc_span::def_id::LocalDefId; use rustc_span::{Ident, Span}; use tracing::debug; +use crate::diagnostics::ButNeedsToSatisfy; use crate::error_reporting::infer::nice_region_error::NiceRegionError; -use crate::errors::ButNeedsToSatisfy; use crate::infer::{RegionResolutionError, SubregionOrigin}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs index 7e6f566e242a3..eb0b9a0234275 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs @@ -14,9 +14,9 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; use rustc_span::{Ident, Span}; use tracing::debug; +use crate::diagnostics::{ConsiderBorrowingParamHelp, TraitImplDiff}; use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlighted; -use crate::errors::{ConsiderBorrowingParamHelp, TraitImplDiff}; use crate::infer::{RegionResolutionError, ValuePairs}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 9d2eb42496e2f..f6ef59918af0c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -19,12 +19,12 @@ use tracing::{debug, instrument}; use super::ObligationCauseAsDiagArg; use super::nice_region_error::find_anon_type; -use crate::error_reporting::TypeErrCtxt; -use crate::error_reporting::infer::ObligationCauseExt; -use crate::errors::{ +use crate::diagnostics::{ self, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent, RefLongerThanData, RegionOriginNote, WhereClauseSuggestions, note_and_explain, }; +use crate::error_reporting::TypeErrCtxt; +use crate::error_reporting::infer::ObligationCauseExt; use crate::infer::region_constraints::GenericKind; use crate::infer::{ BoundRegionConversionTime, InferCtxt, RegionResolutionError, RegionVariableOrigin, @@ -1276,7 +1276,7 @@ pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>( opaque_ty_key: ty::OpaqueTypeKey<'tcx>, ) -> Diag<'a> { let tcx = infcx.tcx; - let mut err = infcx.dcx().create_err(errors::OpaqueCapturesLifetime { + let mut err = infcx.dcx().create_err(diagnostics::OpaqueCapturesLifetime { span, opaque_ty: Ty::new_opaque(tcx, opaque_ty_key.def_id.to_def_id(), opaque_ty_key.args), opaque_ty_span: tcx.def_span(opaque_ty_key.def_id), @@ -1389,7 +1389,12 @@ fn suggest_precise_capturing<'tcx>( (span.with_hi(span.hi() - BytePos(1)).shrink_to_hi(), "", "") }; - diag.subdiagnostic(errors::AddPreciseCapturing::Existing { span, new_lifetime, pre, post }); + diag.subdiagnostic(diagnostics::AddPreciseCapturing::Existing { + span, + new_lifetime, + pre, + post, + }); } else { let mut captured_lifetimes = FxIndexSet::default(); let mut captured_non_lifetimes = FxIndexSet::default(); @@ -1437,7 +1442,7 @@ fn suggest_precise_capturing<'tcx>( .collect::>() .join(", "); - diag.subdiagnostic(errors::AddPreciseCapturing::New { + diag.subdiagnostic(diagnostics::AddPreciseCapturing::New { span: tcx.def_span(opaque_def_id).shrink_to_hi(), new_lifetime, concatenated_bounds, @@ -1504,7 +1509,7 @@ fn suggest_precise_capturing<'tcx>( format!(" + use<{concatenated_bounds}>"), )); - diag.subdiagnostic(errors::AddPreciseCapturingAndParams { + diag.subdiagnostic(diagnostics::AddPreciseCapturingAndParams { suggs, new_lifetime, apit_spans, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs index 224be68bbcd10..516164bb2e58e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs @@ -17,13 +17,13 @@ use rustc_middle::ty::{ use rustc_span::{Span, sym}; use tracing::debug; -use crate::error_reporting::TypeErrCtxt; -use crate::error_reporting::infer::hir::Path; -use crate::errors::{ +use crate::diagnostics::{ ConsiderAddingAwait, FnConsiderCasting, FnConsiderCastingBoth, FnItemsAreDistinct, FnUniqTypes, FunctionPointerSuggestion, SuggestAccessingField, SuggestRemoveSemiOrReturnBinding, SuggestTuplePatternMany, SuggestTuplePatternOne, TypeErrorAdditionalDiags, }; +use crate::error_reporting::TypeErrCtxt; +use crate::error_reporting::infer::hir::Path; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] enum StatementAsExpression { @@ -412,13 +412,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { match (expected_inner.kind(), found_inner.kind()) { (ty::FnPtr(sig_tys, hdr), ty::FnDef(did, args)) => { let sig = sig_tys.with(*hdr); - let expected_sig = &(self.normalize_fn_sig)(Unnormalized::new_wip(sig)); + let expected_sig = self.normalize_fn_sig(Unnormalized::new_wip(sig)); let found_sig = - &(self.normalize_fn_sig)(self.tcx.fn_sig(*did).instantiate(self.tcx, args)); + self.normalize_fn_sig(self.tcx.fn_sig(*did).instantiate(self.tcx, args)); let fn_name = self.tcx.def_path_str_with_args(*did, args); - if !self.same_type_modulo_infer(*found_sig, *expected_sig) + if !self.same_type_modulo_infer(found_sig, expected_sig) || !sig.is_suggestable(self.tcx, true) || self.tcx.intrinsic(*did).is_some() { @@ -450,15 +450,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { let expected_sig = - &(self.normalize_fn_sig)(self.tcx.fn_sig(*did1).instantiate(self.tcx, args1)); + self.normalize_fn_sig(self.tcx.fn_sig(*did1).instantiate(self.tcx, args1)); let found_sig = - &(self.normalize_fn_sig)(self.tcx.fn_sig(*did2).instantiate(self.tcx, args2)); + self.normalize_fn_sig(self.tcx.fn_sig(*did2).instantiate(self.tcx, args2)); - if self.same_type_modulo_infer(*expected_sig, *found_sig) { + if self.same_type_modulo_infer(expected_sig, found_sig) { diag.subdiagnostic(FnUniqTypes); } - if !self.same_type_modulo_infer(*found_sig, *expected_sig) + if !self.same_type_modulo_infer(found_sig, expected_sig) || !found_sig.is_suggestable(self.tcx, true) || !expected_sig.is_suggestable(self.tcx, true) || self.tcx.intrinsic(*did1).is_some() @@ -470,7 +470,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let fn_name = self.tcx.def_path_str_with_args(*did2, args2); let Some(span) = span else { - diag.subdiagnostic(FnConsiderCastingBoth { sig: *expected_sig }); + diag.subdiagnostic(FnConsiderCastingBoth { sig: expected_sig }); return; }; @@ -478,14 +478,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { FunctionPointerSuggestion::CastBothRef { span, fn_name, - found_sig: *found_sig, - expected_sig: *expected_sig, + found_sig, + expected_sig, } } else { FunctionPointerSuggestion::CastBoth { span: span.shrink_to_hi(), - found_sig: *found_sig, - expected_sig: *expected_sig, + found_sig, + expected_sig, } }; @@ -493,10 +493,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did, args), ty::FnPtr(sig_tys, hdr)) => { let expected_sig = - &(self.normalize_fn_sig)(self.tcx.fn_sig(*did).instantiate(self.tcx, args)); - let found_sig = &(self.normalize_fn_sig)(Unnormalized::new_wip(sig_tys.with(*hdr))); + self.normalize_fn_sig(self.tcx.fn_sig(*did).instantiate(self.tcx, args)); + let found_sig = self.normalize_fn_sig(Unnormalized::new_wip(sig_tys.with(*hdr))); - if !self.same_type_modulo_infer(*found_sig, *expected_sig) { + if !self.same_type_modulo_infer(found_sig, expected_sig) { return; } diff --git a/compiler/rustc_trait_selection/src/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/mod.rs index 7821a0e8ab6e3..ff0ac4fcfbe6a 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/mod.rs @@ -5,7 +5,7 @@ use rustc_infer::infer::InferCtxt; use rustc_infer::traits::PredicateObligations; use rustc_macros::extension; use rustc_middle::bug; -use rustc_middle::ty::{self, Ty, Unnormalized}; +use rustc_middle::ty::{self, Ty}; pub mod infer; pub mod traits; @@ -19,13 +19,11 @@ pub mod traits; /// methods which should not be used during the happy path. pub struct TypeErrCtxt<'a, 'tcx> { pub infcx: &'a InferCtxt<'tcx>, + pub param_env: Option>, pub typeck_results: Option>>, pub diverging_fallback_has_occurred: bool, - pub normalize_fn_sig: - Box>) -> ty::PolyFnSig<'tcx> + 'a>, - pub autoderef_steps: Box) -> Vec<(Ty<'tcx>, PredicateObligations<'tcx>)> + 'a>, } @@ -36,9 +34,9 @@ impl<'tcx> InferCtxt<'tcx> { fn err_ctxt(&self) -> TypeErrCtxt<'_, 'tcx> { TypeErrCtxt { infcx: self, + param_env: None, typeck_results: None, diverging_fallback_has_occurred: false, - normalize_fn_sig: Box::new(|fn_sig| fn_sig.skip_normalization()), autoderef_steps: Box::new(|ty| { debug_assert!(false, "shouldn't be using autoderef_steps outside of typeck"); vec![(ty, PredicateObligations::new())] diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 051604c94c445..aa414dc6fedb6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -39,10 +39,12 @@ use tracing::{debug, instrument}; use super::suggestions::get_explanation_based_on_obligation; use super::{ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate}; +use crate::diagnostics::{ + ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn, +}; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::TyCategory; use crate::error_reporting::traits::report_dyn_incompatibility; -use crate::errors::{ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn}; use crate::infer::{self, InferCtxt, InferCtxtExt as _}; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use crate::traits::{ 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 6594fac09af76..0849215c13404 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -48,8 +48,8 @@ use super::{ DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation, }; +use crate::diagnostics; use crate::error_reporting::TypeErrCtxt; -use crate::errors; use crate::infer::InferCtxtExt as _; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt, SelectionContext}; @@ -6119,11 +6119,11 @@ fn hint_missing_borrow<'tcx>( } if !to_borrow.is_empty() { - err.subdiagnostic(errors::AdjustSignatureBorrow::Borrow { to_borrow }); + err.subdiagnostic(diagnostics::AdjustSignatureBorrow::Borrow { to_borrow }); } if !remove_borrow.is_empty() { - err.subdiagnostic(errors::AdjustSignatureBorrow::RemoveBorrow { remove_borrow }); + err.subdiagnostic(diagnostics::AdjustSignatureBorrow::RemoveBorrow { remove_borrow }); } } diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index c1a0dcf5aa4c2..9f1bfc018f3a2 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -25,8 +25,8 @@ #![recursion_limit = "512"] // For rustdoc // tidy-alphabetical-end +pub mod diagnostics; pub mod error_reporting; -pub mod errors; pub mod infer; pub mod opaque_types; pub mod regions; diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 28b9bf21eee59..9606efe4a3d8b 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -9,7 +9,7 @@ use rustc_middle::ty::{ }; use rustc_span::{ErrorGuaranteed, Span}; -use crate::errors::NonGenericOpaqueTypeParam; +use crate::diagnostics::NonGenericOpaqueTypeParam; use crate::regions::OutlivesEnvironmentBuildExt; use crate::traits::ObligationCtxt; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 3a58dbaf1ec8d..5331773e58bed 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -13,7 +13,7 @@ use rustc_span::DUMMY_SP; use tracing::debug; use super::*; -use crate::errors::UnableToConstructConstantValue; +use crate::diagnostics::UnableToConstructConstantValue; use crate::infer::TypeFreshener; use crate::infer::region_constraints::{ConstraintKind, RegionConstraintData}; use crate::regions::OutlivesEnvironmentBuildExt; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index cc802a6342807..e267d18515a40 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -25,7 +25,7 @@ use super::{ PredicateObligation, ProjectionCacheEntry, ProjectionCacheKey, Selection, SelectionContext, SelectionError, specialization_graph, translate_args, util, }; -use crate::errors::InherentProjectionNormalizationOverflow; +use crate::diagnostics::InherentProjectionNormalizationOverflow; use crate::infer::{BoundRegionConversionTime, InferOk}; use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to}; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 164d01a3285e6..506d38c17bc9a 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -28,8 +28,8 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, sym}; use specialization_graph::GraphExt; use tracing::{debug, instrument}; +use crate::diagnostics::NegativePositiveConflict; use crate::error_reporting::traits::to_pretty_impl_header; -use crate::errors::NegativePositiveConflict; use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::traits::select::IntercrateAmbiguityCause; use crate::traits::{ diff --git a/library/core/src/field.rs b/library/core/src/field.rs index 90d16e5f2af5f..33b978c786b53 100644 --- a/library/core/src/field.rs +++ b/library/core/src/field.rs @@ -125,7 +125,7 @@ impl Ord /// variant must also be specified. Only a single field is supported. #[unstable(feature = "field_projections", issue = "145383")] #[allow_internal_unstable(field_representing_type_raw, builtin_syntax)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( note = "this macro expects a container type and a field path, like `field_of!(Type, field)` or `field_of!(Enum, Variant.field)`" )] // NOTE: when stabilizing this macro, we can never add new trait impls for `FieldRepresentingType`, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 192c5eff29e10..a26304c46ecea 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -131,7 +131,7 @@ #![feature(deprecated_suggestion)] #![feature(derive_const)] #![feature(diagnostic_on_const)] -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] #![feature(doc_cfg)] #![feature(doc_notable_trait)] #![feature(extern_types)] diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 565c23e1ca48b..828572df6968b 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -1604,7 +1604,7 @@ impl SizedTypeProperties for T {} /// [`offset_of_enum`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-enum.html /// [`offset_of_slice`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-slice.html #[stable(feature = "offset_of", since = "1.77.0")] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( note = "this macro expects a container type and a (nested) field path, like `offset_of!(Type, field)`" )] #[doc(alias = "memoffset")] diff --git a/src/doc/unstable-book/src/language-features/diagnostic-on-unmatch-args.md b/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md similarity index 84% rename from src/doc/unstable-book/src/language-features/diagnostic-on-unmatch-args.md rename to src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md index 514ad1969bb0f..830adcf34acdb 100644 --- a/src/doc/unstable-book/src/language-features/diagnostic-on-unmatch-args.md +++ b/src/doc/unstable-book/src/language-features/diagnostic-on-unmatched-args.md @@ -1,4 +1,4 @@ -# `diagnostic_on_unmatch_args` +# `diagnostic_on_unmatched_args` The tracking issue for this feature is: [#155642] @@ -6,8 +6,8 @@ The tracking issue for this feature is: [#155642] ------------------------ -The `diagnostic_on_unmatch_args` feature adds the -`#[diagnostic::on_unmatch_args(...)]` attribute for declarative macros. +The `diagnostic_on_unmatched_args` feature adds the +`#[diagnostic::on_unmatched_args(...)]` attribute for declarative macros. It lets a macro definition customize diagnostics for matcher failures after all arms have been tried, such as incomplete invocations or trailing extra arguments. @@ -16,9 +16,9 @@ It is currently used for errors emitted by declarative macro matching itself; fr errors still use their existing diagnostics. ```rust,compile_fail -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( 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)`", diff --git a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs index a4fd771071887..29d323790de8e 100644 --- a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs +++ b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs @@ -5,7 +5,7 @@ #![feature(coerce_unsized)] impl std::ops::CoerceUnsized for A {} -//~^ ERROR type parameter `A` must be used as the type parameter for some local type +//~^ ERROR type parameter `A` must be used as an argument to some local type //~| ERROR the trait `CoerceUnsized` may only be implemented for a coercion between structures const C: usize = 1; diff --git a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr index 377906ee334a9..60ee317e7f9ee 100644 --- a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr +++ b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `A` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/invalid-blanket-coerce-unsized-impl.rs:7:6 | LL | impl std::ops::CoerceUnsized for A {} - | ^ type parameter `A` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/coherence-all-remote.stderr b/tests/ui/coherence/coherence-all-remote.stderr index 0cf9f87b40ac7..f5072451db148 100644 --- a/tests/ui/coherence/coherence-all-remote.stderr +++ b/tests/ui/coherence/coherence-all-remote.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/coherence-all-remote.rs:6:6 | LL | impl Remote1 for isize { } - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/coherence-bigint-param.stderr b/tests/ui/coherence/coherence-bigint-param.stderr index e6c77624a8e8d..0b1570f8fceae 100644 --- a/tests/ui/coherence/coherence-bigint-param.stderr +++ b/tests/ui/coherence/coherence-bigint-param.stderr @@ -2,10 +2,12 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/coherence-bigint-param.rs:8:6 | LL | impl Remote1 for T { } - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`BigInt`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 1 previous error diff --git a/tests/ui/coherence/coherence-cross-crate-conflict.stderr b/tests/ui/coherence/coherence-cross-crate-conflict.stderr index 812ce97721ccf..887e7e69ccb90 100644 --- a/tests/ui/coherence/coherence-cross-crate-conflict.stderr +++ b/tests/ui/coherence/coherence-cross-crate-conflict.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `A` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/coherence-cross-crate-conflict.rs:9:6 | LL | impl Foo for A { - | ^ type parameter `A` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/coherence-lone-type-parameter.stderr b/tests/ui/coherence/coherence-lone-type-parameter.stderr index 48d25bba8d714..710b47ad70fd2 100644 --- a/tests/ui/coherence/coherence-lone-type-parameter.stderr +++ b/tests/ui/coherence/coherence-lone-type-parameter.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/coherence-lone-type-parameter.rs:6:6 | LL | impl Remote for T { } - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].rs b/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].rs index d9616b9adda79..036896d631f0d 100644 --- a/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].rs +++ b/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].rs @@ -8,8 +8,7 @@ use std::rc::Rc; struct Local; impl Remote for Box { - //~^ ERROR type parameter `T` must be used as the type parameter for - // | some local type (e.g., `MyStruct`) + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr b/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr index 12d9a807f492d..b48a607802998 100644 --- a/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr +++ b/tests/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign-for-fundamental[t].rs:10:6 | LL | impl Remote for Box { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].rs b/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].rs index 9d4440ba4866a..76d262eabbfbe 100644 --- a/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].rs +++ b/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].rs @@ -8,11 +8,11 @@ use std::rc::Rc; struct Local; impl Remote1 for Box { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } impl<'a, T> Remote1 for &'a T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr b/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr index 95a20cc5b0f5c..e551534e473b0 100644 --- a/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr +++ b/tests/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr @@ -1,17 +1,17 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:10:6 | LL | impl Remote1 for Box { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:14:10 | LL | impl<'a, T> Remote1 for &'a T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.rs b/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.rs index 533f0892b98fe..701c1dcaff4c0 100644 --- a/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.rs +++ b/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.rs @@ -8,7 +8,7 @@ use std::rc::Rc; struct Local; impl Remote1 for T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr b/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr index 6ca3ccd05febc..53481700b65fb 100644 --- a/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr +++ b/tests/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[foreign]-for-t.rs:10:6 | LL | impl Remote1 for T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.rs b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.rs index 02731052a6a96..25f0f51ddd03d 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.rs +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.rs @@ -8,11 +8,11 @@ use std::rc::Rc; struct Local; impl Remote1> for u32 { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } impl<'a, T> Remote1<&'a T> for u32 { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr index 73b1e2c6ed248..138a8526a283e 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr @@ -1,17 +1,17 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:10:6 | LL | impl Remote1> for u32 { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:14:10 | LL | impl<'a, T> Remote1<&'a T> for u32 { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs index 7c94fd80af2f2..ffe630c4b9492 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs @@ -8,10 +8,10 @@ use std::rc::Rc; struct Local; impl<'a, T> Remote1> for &'a T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } impl<'a, T> Remote1<&'a T> for Box { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr index 5f89a7aa469c1..72a8a6c14c630 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr @@ -1,17 +1,17 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:10:10 | LL | impl<'a, T> Remote1> for &'a T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:13:10 | LL | impl<'a, T> Remote1<&'a T> for Box { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.rs b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.rs index d998731687c4f..d0deb1cde1ffd 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.rs +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.rs @@ -8,10 +8,10 @@ use std::rc::Rc; struct Local; impl Remote1> for T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } impl<'a, T> Remote1<&'a T> for T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr index 45559d8b62d37..6c73e9e18ed45 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr @@ -1,17 +1,17 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:10:6 | LL | impl Remote1> for T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:13:10 | LL | impl<'a, T> Remote1<&'a T> for T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr b/tests/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr index f94f04c8df5c1..347ca8dea5b1d 100644 --- a/tests/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr +++ b/tests/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr @@ -2,19 +2,23 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:10:6 | LL | impl Remote2, Local> for u32 { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:14:10 | LL | impl<'a, T> Remote2<&'a T, Local> for u32 { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 2 previous errors diff --git a/tests/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr b/tests/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr index e68f2fe585637..48ea6ba0948b5 100644 --- a/tests/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr +++ b/tests/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr @@ -2,19 +2,23 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:10:6 | LL | impl Remote1 for Box { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:14:6 | LL | impl Remote1 for &T { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 2 previous errors diff --git a/tests/ui/coherence/impl[t]-foreign[local]-for-t.stderr b/tests/ui/coherence/impl[t]-foreign[local]-for-t.stderr index 1f3463e88371b..09a2fa5b3f99f 100644 --- a/tests/ui/coherence/impl[t]-foreign[local]-for-t.stderr +++ b/tests/ui/coherence/impl[t]-foreign[local]-for-t.stderr @@ -2,10 +2,12 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/impl[t]-foreign[local]-for-t.rs:10:6 | LL | impl Remote1 for T { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 1 previous error diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.rs b/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.rs index c23a2d87a695c..79ad1a5a3a7e1 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.rs +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.rs @@ -8,7 +8,7 @@ use std::rc::Rc; struct Local; impl Remote1 for u32 { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr b/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr index a1f3936497e65..b1d8927509be8 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[t]-for-foreign.rs:10:6 | LL | impl Remote1 for u32 { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.rs b/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.rs index e9426e5127a04..eed22cfc20d71 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.rs +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.rs @@ -8,11 +8,11 @@ use std::rc::Rc; struct Local; impl Remote1 for Box { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } impl<'a, A, B> Remote1 for &'a B { - //~^ ERROR type parameter `B` must be used as the type parameter for some local type + //~^ ERROR type parameter `B` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr b/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr index 80fb5dbec8662..022f1caa6914b 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr @@ -1,17 +1,17 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:10:6 | LL | impl Remote1 for Box { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0210]: type parameter `B` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `B` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:14:13 | LL | impl<'a, A, B> Remote1 for &'a B { - | ^ type parameter `B` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-t.rs b/tests/ui/coherence/impl[t]-foreign[t]-for-t.rs index 9c3e82ad762f0..1ffff0b6ff72c 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-t.rs +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-t.rs @@ -8,7 +8,7 @@ use std::rc::Rc; struct Local; impl Remote1 for T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type } fn main() {} diff --git a/tests/ui/coherence/impl[t]-foreign[t]-for-t.stderr b/tests/ui/coherence/impl[t]-foreign[t]-for-t.stderr index acd84f7115f57..66d5964f9b37d 100644 --- a/tests/ui/coherence/impl[t]-foreign[t]-for-t.stderr +++ b/tests/ui/coherence/impl[t]-foreign[t]-for-t.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/impl[t]-foreign[t]-for-t.rs:10:6 | LL | impl Remote1 for T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/orphan-check-alias.classic.stderr b/tests/ui/coherence/orphan-check-alias.classic.stderr index 06b6bd4eb0fd5..29e09ff550e9e 100644 --- a/tests/ui/coherence/orphan-check-alias.classic.stderr +++ b/tests/ui/coherence/orphan-check-alias.classic.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`B`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`B`) --> $DIR/orphan-check-alias.rs:21:6 | LL | impl foreign::Trait2 for ::Assoc { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`B`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-alias.next.stderr b/tests/ui/coherence/orphan-check-alias.next.stderr index 06b6bd4eb0fd5..29e09ff550e9e 100644 --- a/tests/ui/coherence/orphan-check-alias.next.stderr +++ b/tests/ui/coherence/orphan-check-alias.next.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`B`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`B`) --> $DIR/orphan-check-alias.rs:21:6 | LL | impl foreign::Trait2 for ::Assoc { - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`B`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-diagnostics.rs b/tests/ui/coherence/orphan-check-diagnostics.rs index 4b6557fc9c8e9..39c5d6258b77d 100644 --- a/tests/ui/coherence/orphan-check-diagnostics.rs +++ b/tests/ui/coherence/orphan-check-diagnostics.rs @@ -9,6 +9,6 @@ use orphan_check_diagnostics::RemoteTrait; trait LocalTrait { fn dummy(&self) { } } impl RemoteTrait for T where T: LocalTrait {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//~^ ERROR type parameter `T` must be used as an argument to some local type fn main() {} diff --git a/tests/ui/coherence/orphan-check-diagnostics.stderr b/tests/ui/coherence/orphan-check-diagnostics.stderr index b9fa7baf4c276..cd154d38d86e0 100644 --- a/tests/ui/coherence/orphan-check-diagnostics.stderr +++ b/tests/ui/coherence/orphan-check-diagnostics.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/orphan-check-diagnostics.rs:11:6 | LL | impl RemoteTrait for T where T: LocalTrait {} - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/coherence/orphan-check-opaque-types-not-covering.stderr b/tests/ui/coherence/orphan-check-opaque-types-not-covering.stderr index 6203742b47c0a..2c67ec0ad2478 100644 --- a/tests/ui/coherence/orphan-check-opaque-types-not-covering.stderr +++ b/tests/ui/coherence/orphan-check-opaque-types-not-covering.stderr @@ -2,19 +2,23 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/orphan-check-opaque-types-not-covering.rs:15:6 | LL | impl foreign::Trait0 for Identity {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-opaque-types-not-covering.rs:25:6 | LL | impl foreign::Trait1 for Opaque {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 2 previous errors diff --git a/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.classic.stderr b/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.classic.stderr index a000fc2f0bc11..635d9e6619004 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.classic.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.classic.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering-ambiguity.rs:25:6 | LL | impl foreign::Trait1 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.next.stderr b/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.next.stderr index a000fc2f0bc11..635d9e6619004 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.next.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering-ambiguity.next.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering-ambiguity.rs:25:6 | LL | impl foreign::Trait1 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.classic.stderr b/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.classic.stderr index 1d71966b18cb7..e75d4e61772f1 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.classic.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.classic.stderr @@ -1,26 +1,29 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-not-covering-multiple-params.rs:17:6 | LL | impl foreign::Trait0 for <() as Trait>::Assoc {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default -warning[E0210]: type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-not-covering-multiple-params.rs:17:9 | LL | impl foreign::Trait0 for <() as Trait>::Assoc {} - | ^ type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 warning: 2 warnings emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.next.stderr b/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.next.stderr index 1d71966b18cb7..e75d4e61772f1 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.next.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering-multiple-params.next.stderr @@ -1,26 +1,29 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-not-covering-multiple-params.rs:17:6 | LL | impl foreign::Trait0 for <() as Trait>::Assoc {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default -warning[E0210]: type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-not-covering-multiple-params.rs:17:9 | LL | impl foreign::Trait0 for <() as Trait>::Assoc {} - | ^ type parameter `U` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 warning: 2 warnings emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-not-covering.classic.stderr b/tests/ui/coherence/orphan-check-projections-not-covering.classic.stderr index 8ea6496a42d70..6d1a3114937af 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering.classic.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering.classic.stderr @@ -1,37 +1,42 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:22:6 | LL | impl foreign::Trait0 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:27:6 | LL | impl foreign::Trait0<::Output, Local, T> for Option {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:40:6 | LL | impl foreign::Trait1 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 warning: 3 warnings emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-not-covering.next.stderr b/tests/ui/coherence/orphan-check-projections-not-covering.next.stderr index 8ea6496a42d70..6d1a3114937af 100644 --- a/tests/ui/coherence/orphan-check-projections-not-covering.next.stderr +++ b/tests/ui/coherence/orphan-check-projections-not-covering.next.stderr @@ -1,37 +1,42 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:22:6 | LL | impl foreign::Trait0 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:27:6 | LL | impl foreign::Trait0<::Output, Local, T> for Option {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`Local`) --> $DIR/orphan-check-projections-not-covering.rs:40:6 | LL | impl foreign::Trait1 for ::Output {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 warning: 3 warnings emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-unsat-bounds.classic.stderr b/tests/ui/coherence/orphan-check-projections-unsat-bounds.classic.stderr index 1289c65b40d06..9021a4757b851 100644 --- a/tests/ui/coherence/orphan-check-projections-unsat-bounds.classic.stderr +++ b/tests/ui/coherence/orphan-check-projections-unsat-bounds.classic.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-unsat-bounds.rs:28:6 | LL | impl foreign::Trait1 for as Discard>::Output - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-projections-unsat-bounds.next.stderr b/tests/ui/coherence/orphan-check-projections-unsat-bounds.next.stderr index 1289c65b40d06..9021a4757b851 100644 --- a/tests/ui/coherence/orphan-check-projections-unsat-bounds.next.stderr +++ b/tests/ui/coherence/orphan-check-projections-unsat-bounds.next.stderr @@ -1,15 +1,16 @@ -warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) +warning: type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) --> $DIR/orphan-check-projections-unsat-bounds.rs:28:6 | LL | impl foreign::Trait1 for as Discard>::Output - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`LocalTy`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #124559 = note: `#[warn(uncovered_param_in_projection)]` (part of `#[warn(future_incompatible)]`) on by default warning: 1 warning emitted -For more information about this error, try `rustc --explain E0210`. diff --git a/tests/ui/coherence/orphan-check-weak-aliases-not-covering.stderr b/tests/ui/coherence/orphan-check-weak-aliases-not-covering.stderr index df915141a769f..37f6684692564 100644 --- a/tests/ui/coherence/orphan-check-weak-aliases-not-covering.stderr +++ b/tests/ui/coherence/orphan-check-weak-aliases-not-covering.stderr @@ -2,10 +2,12 @@ error[E0210]: type parameter `T` must be covered by another type when it appears --> $DIR/orphan-check-weak-aliases-not-covering.rs:13:6 | LL | impl foreign::Trait1 for Identity {} - | ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`) + | ^ uncovered type parameter | - = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type - = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, where `T0` is the first and `Tn` is the last + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, + and no uncovered type parameters appear before that first local type + = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait for T0`, + where `T0` is the first and `Tn` is the last error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.rs b/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.rs deleted file mode 100644 index aa5371de07c09..0000000000000 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass -#![feature(diagnostic_on_unmatch_args)] - -#[diagnostic::on_unmatch_args = "foo"] -//~^ WARN malformed `diagnostic::on_unmatch_args` attribute [malformed_diagnostic_attributes] -macro_rules! pair { - ($ty:ty, $value:expr) => {}; -} - -fn main() { - pair!(u8, 0); -} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.rs b/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.rs deleted file mode 100644 index 13eec1834d7cd..0000000000000 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass -#![feature(diagnostic_on_unmatch_args)] - -#[diagnostic::on_unmatch_args] -//~^ WARN missing options for `diagnostic::on_unmatch_args` attribute [malformed_diagnostic_attributes] -macro_rules! pair { - ($ty:ty, $value:expr) => {}; -} - -fn main() { - pair!(u8, 0); -} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.rs b/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.rs deleted file mode 100644 index 6f8629d679a0c..0000000000000 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass -#![feature(diagnostic_on_unmatch_args)] - -#[diagnostic::on_unmatch_args(message = "not allowed here")] -//~^ WARN `#[diagnostic::on_unmatch_args]` can only be applied to macro definitions -struct Foo; - -fn main() { - let _ = Foo; -} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.rs b/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.rs deleted file mode 100644 index b1e50256dc886..0000000000000 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass -#![feature(diagnostic_on_unmatch_args)] - -#[diagnostic::on_unmatch_args(unsupported = "foo")] -//~^ WARN malformed `diagnostic::on_unmatch_args` attribute [malformed_diagnostic_attributes] -macro_rules! pair { - ($ty:ty, $value:expr) => {}; -} - -fn main() { - pair!(u8, 0); -} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.stderr b/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.stderr deleted file mode 100644 index 2e897a6b180da..0000000000000 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_unknown_options.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: malformed `diagnostic::on_unmatch_args` attribute - --> $DIR/report_warning_on_unknown_options.rs:4:31 - | -LL | #[diagnostic::on_unmatch_args(unsupported = "foo")] - | ^^^^^^^^^^^^^^^^^^^ invalid option found here - | - = help: only `message`, `note` and `label` are allowed as options - = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default - -warning: 1 warning emitted - diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/auxiliary/other.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs similarity index 80% rename from tests/ui/diagnostic_namespace/on_unmatch_args/auxiliary/other.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs index 2dd032ecf41cb..32cbf69a695ba 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/auxiliary/other.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/auxiliary/other.rs @@ -1,7 +1,7 @@ -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] #[macro_export] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( 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)`", diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/error_is_shown_in_downstream_crates.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/error_is_shown_in_downstream_crates.rs similarity index 100% rename from tests/ui/diagnostic_namespace/on_unmatch_args/error_is_shown_in_downstream_crates.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/error_is_shown_in_downstream_crates.rs diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/error_is_shown_in_downstream_crates.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/error_is_shown_in_downstream_crates.stderr similarity index 100% rename from tests/ui/diagnostic_namespace/on_unmatch_args/error_is_shown_in_downstream_crates.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/error_is_shown_in_downstream_crates.stderr diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/message_and_label.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs similarity index 89% rename from tests/ui/diagnostic_namespace/on_unmatch_args/message_and_label.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs index 26a8b07bd6e48..4209c939ed52f 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/message_and_label.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.rs @@ -1,6 +1,6 @@ -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( 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)`", diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/message_and_label.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.stderr similarity index 100% rename from tests/ui/diagnostic_namespace/on_unmatch_args/message_and_label.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/message_and_label.stderr diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/notes_on_extra_args.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs similarity index 89% rename from tests/ui/diagnostic_namespace/on_unmatch_args/notes_on_extra_args.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs index 083445c7f9691..66e951297a1b6 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/notes_on_extra_args.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.rs @@ -1,6 +1,6 @@ -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( 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)`", diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/notes_on_extra_args.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.stderr similarity index 100% rename from tests/ui/diagnostic_namespace/on_unmatch_args/notes_on_extra_args.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/notes_on_extra_args.stderr diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/on_unmatch_args.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.rs similarity index 87% rename from tests/ui/diagnostic_namespace/on_unmatch_args/on_unmatch_args.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.rs index a4fc1460b60ed..12ed333cd6621 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/on_unmatch_args.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.rs @@ -1,6 +1,6 @@ -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( 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_unmatch_args/on_unmatch_args.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.stderr similarity index 85% rename from tests/ui/diagnostic_namespace/on_unmatch_args/on_unmatch_args.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.stderr index 9d3c4a5392cde..3e9a7a969fd9e 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/on_unmatch_args.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/on_unmatched_args.stderr @@ -1,5 +1,5 @@ error: unexpected end of macro invocation - --> $DIR/on_unmatch_args.rs:14:13 + --> $DIR/on_unmatched_args.rs:14:13 | LL | macro_rules! pair { | ----------------- when calling this macro @@ -8,7 +8,7 @@ LL | pair!(u8); | ^ missing tokens in macro arguments | note: while trying to match `,` - --> $DIR/on_unmatch_args.rs:9:12 + --> $DIR/on_unmatched_args.rs:9:12 | LL | ($ty:ty, $value:expr) => {}; | ^ diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/other_match_macro_error.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs similarity index 76% rename from tests/ui/diagnostic_namespace/on_unmatch_args/other_match_macro_error.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs index 36197997b3e60..ec7ea5888b6c9 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/other_match_macro_error.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.rs @@ -1,6 +1,6 @@ -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( message = "invalid route method", note = "this macro expects a action, like `{This}!(get \"/hello\")`" )] diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/other_match_macro_error.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.stderr similarity index 100% rename from tests/ui/diagnostic_namespace/on_unmatch_args/other_match_macro_error.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/other_match_macro_error.stderr diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_formats.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs similarity index 82% rename from tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_formats.rs rename to tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs index 1fcaca8300f85..b98d7f777aee8 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_formats.rs +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.rs @@ -1,9 +1,9 @@ //@ check-pass -#![feature(diagnostic_on_unmatch_args)] +#![feature(diagnostic_on_unmatched_args)] -#[diagnostic::on_unmatch_args( +#[diagnostic::on_unmatched_args( message = "{T}! is missing arguments", - //~^ WARN this format argument is not allowed in `#[diagnostic::on_unmatch_args]` + //~^ WARN this format argument is not allowed in `#[diagnostic::on_unmatched_args]` //~| 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_unmatch_args/report_warning_on_invalid_formats.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr similarity index 96% rename from tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_formats.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr index fd68ad5570f31..e814ecacc006c 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_formats.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_formats.stderr @@ -1,4 +1,4 @@ -warning: this format argument is not allowed in `#[diagnostic::on_unmatch_args]` +warning: this format argument is not allowed in `#[diagnostic::on_unmatched_args]` --> $DIR/report_warning_on_invalid_formats.rs:5:17 | LL | message = "{T}! is missing arguments", diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.rs new file mode 100644 index 0000000000000..407b6b013ef7d --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.rs @@ -0,0 +1,12 @@ +//@ check-pass +#![feature(diagnostic_on_unmatched_args)] + +#[diagnostic::on_unmatched_args = "foo"] +//~^ WARN malformed `diagnostic::on_unmatched_args` attribute [malformed_diagnostic_attributes] +macro_rules! pair { + ($ty:ty, $value:expr) => {}; +} + +fn main() { + pair!(u8, 0); +} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.stderr similarity index 62% rename from tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.stderr index 51f25f1165d60..488abeb097d6e 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_invalid_meta_item_syntax.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_invalid_meta_item_syntax.stderr @@ -1,8 +1,8 @@ -warning: malformed `diagnostic::on_unmatch_args` attribute +warning: malformed `diagnostic::on_unmatched_args` attribute --> $DIR/report_warning_on_invalid_meta_item_syntax.rs:4:1 | -LL | #[diagnostic::on_unmatch_args = "foo"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here +LL | #[diagnostic::on_unmatched_args = "foo"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here | = help: only `message`, `note` and `label` are allowed as options = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.rs new file mode 100644 index 0000000000000..622fac89e1539 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.rs @@ -0,0 +1,12 @@ +//@ check-pass +#![feature(diagnostic_on_unmatched_args)] + +#[diagnostic::on_unmatched_args] +//~^ WARN missing options for `diagnostic::on_unmatched_args` attribute [malformed_diagnostic_attributes] +macro_rules! pair { + ($ty:ty, $value:expr) => {}; +} + +fn main() { + pair!(u8, 0); +} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.stderr similarity index 67% rename from tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.stderr index bbd8dba4e6206..f0af014cfc6c7 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_missing_options.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_missing_options.stderr @@ -1,8 +1,8 @@ -warning: missing options for `diagnostic::on_unmatch_args` attribute +warning: missing options for `diagnostic::on_unmatched_args` attribute --> $DIR/report_warning_on_missing_options.rs:4:1 | -LL | #[diagnostic::on_unmatch_args] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diagnostic::on_unmatched_args] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: at least one of the `message`, `note` and `label` options are expected = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.rs new file mode 100644 index 0000000000000..28b6e0cbe3be7 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.rs @@ -0,0 +1,10 @@ +//@ check-pass +#![feature(diagnostic_on_unmatched_args)] + +#[diagnostic::on_unmatched_args(message = "not allowed here")] +//~^ WARN `#[diagnostic::on_unmatched_args]` can only be applied to macro definitions +struct Foo; + +fn main() { + let _ = Foo; +} diff --git a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.stderr similarity index 64% rename from tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.stderr rename to tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.stderr index c6d1b620c44be..10c6fd9ce8bea 100644 --- a/tests/ui/diagnostic_namespace/on_unmatch_args/report_warning_on_non_macro.stderr +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_non_macro.stderr @@ -1,8 +1,8 @@ -warning: `#[diagnostic::on_unmatch_args]` can only be applied to macro definitions +warning: `#[diagnostic::on_unmatched_args]` can only be applied to macro definitions --> $DIR/report_warning_on_non_macro.rs:4:1 | -LL | #[diagnostic::on_unmatch_args(message = "not allowed here")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[diagnostic::on_unmatched_args(message = "not allowed here")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(misplaced_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.rs new file mode 100644 index 0000000000000..b18003ca0f0d5 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.rs @@ -0,0 +1,12 @@ +//@ check-pass +#![feature(diagnostic_on_unmatched_args)] + +#[diagnostic::on_unmatched_args(unsupported = "foo")] +//~^ WARN malformed `diagnostic::on_unmatched_args` attribute [malformed_diagnostic_attributes] +macro_rules! pair { + ($ty:ty, $value:expr) => {}; +} + +fn main() { + pair!(u8, 0); +} diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.stderr b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.stderr new file mode 100644 index 0000000000000..194aeed3f5d88 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/report_warning_on_unknown_options.stderr @@ -0,0 +1,11 @@ +warning: malformed `diagnostic::on_unmatched_args` attribute + --> $DIR/report_warning_on_unknown_options.rs:4:33 + | +LL | #[diagnostic::on_unmatched_args(unsupported = "foo")] + | ^^^^^^^^^^^^^^^^^^^ invalid option found here + | + = help: only `message`, `note` and `label` are allowed as options + = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/error-codes/e0119/issue-28981.stderr b/tests/ui/error-codes/e0119/issue-28981.stderr index be3e4aea51a1a..13d18697378f3 100644 --- a/tests/ui/error-codes/e0119/issue-28981.stderr +++ b/tests/ui/error-codes/e0119/issue-28981.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `Foo` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/issue-28981.rs:5:6 | LL | impl Deref for Foo { } - | ^^^ type parameter `Foo` must be used as the type parameter for some local type + | ^^^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.rs b/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.rs similarity index 89% rename from tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.rs rename to tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.rs index 72686d1003279..97f7211465a67 100644 --- a/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.rs +++ b/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.rs @@ -1,7 +1,7 @@ //! This is an unusual feature gate test, as it doesn't test the feature //! gate, but the fact that not adding the feature gate will cause the //! diagnostic to not emit the custom diagnostic message. -#[diagnostic::on_unmatch_args(note = "custom note")] +#[diagnostic::on_unmatched_args(note = "custom note")] macro_rules! pair { //~^ NOTE when calling this macro ($ty:ty, $value:expr) => {}; diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.stderr b/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.stderr similarity index 73% rename from tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.stderr rename to tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.stderr index 39eecc8322b22..26de03f51d2ee 100644 --- a/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatch-args.stderr +++ b/tests/ui/feature-gates/feature-gate-diagnostic-on-unmatched-args.stderr @@ -1,5 +1,5 @@ error: unexpected end of macro invocation - --> $DIR/feature-gate-diagnostic-on-unmatch-args.rs:12:13 + --> $DIR/feature-gate-diagnostic-on-unmatched-args.rs:12:13 | LL | macro_rules! pair { | ----------------- when calling this macro @@ -8,7 +8,7 @@ LL | pair!(u8); | ^ missing tokens in macro arguments | note: while trying to match `,` - --> $DIR/feature-gate-diagnostic-on-unmatch-args.rs:7:12 + --> $DIR/feature-gate-diagnostic-on-unmatched-args.rs:7:12 | LL | ($ty:ty, $value:expr) => {}; | ^ diff --git a/tests/ui/issues/issue-41974.stderr b/tests/ui/issues/issue-41974.stderr index e249db9df5324..2ae073dd1ba82 100644 --- a/tests/ui/issues/issue-41974.stderr +++ b/tests/ui/issues/issue-41974.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/issue-41974.rs:7:6 | LL | impl Drop for T where T: A { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.rs b/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.rs new file mode 100644 index 0000000000000..061a690ec30f6 --- /dev/null +++ b/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.rs @@ -0,0 +1,6 @@ +// Regression test for https://github.com/rust-lang/rust/issues/157853. + +fn main() { + Test([&raw 2]) + //~^ ERROR expected one of +} diff --git a/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.stderr b/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.stderr new file mode 100644 index 0000000000000..5beeae63356e3 --- /dev/null +++ b/tests/ui/parser/recover/raw-no-const-mut-nested-call-arg.stderr @@ -0,0 +1,15 @@ +error: expected one of `!`, `,`, `.`, `::`, `;`, `?`, `]`, `const`, `mut`, `{`, or an operator, found `2` + --> $DIR/raw-no-const-mut-nested-call-arg.rs:4:16 + | +LL | Test([&raw 2]) + | ^ expected one of 11 possible tokens + | +help: `&raw` must be followed by `const` or `mut` to be a raw reference expression + | +LL | Test([&raw const 2]) + | +++++ +LL | Test([&raw mut 2]) + | +++ + +error: aborting due to 1 previous error + diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.rs b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.rs index f0a40efde19e7..3eeed016f8a63 100644 --- a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.rs +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.rs @@ -15,7 +15,7 @@ where trait Check {} impl<'a, T> Eq for T where >::Ty: Valid {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//~^ ERROR type parameter `T` must be used as an argument to some local type trait Valid {} diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr index 5db98e73af60c..79117229300ae 100644 --- a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr @@ -15,11 +15,11 @@ note: required by a bound in `Iterate::Ty` LL | type Ty: Valid; | ^^^^^ required by this bound in `Iterate::Ty` -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/fuzzing-ice-134905.rs:17:10 | LL | impl<'a, T> Eq for T where >::Ty: Valid {} - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/specialization/issue-43037.current.stderr b/tests/ui/specialization/issue-43037.current.stderr index 2711350925716..caa1354c22cc9 100644 --- a/tests/ui/specialization/issue-43037.current.stderr +++ b/tests/ui/specialization/issue-43037.current.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/issue-43037.rs:19:6 | LL | impl From< as Z>::Assoc> for T {} - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/specialization/issue-43037.negative.stderr b/tests/ui/specialization/issue-43037.negative.stderr index 2711350925716..caa1354c22cc9 100644 --- a/tests/ui/specialization/issue-43037.negative.stderr +++ b/tests/ui/specialization/issue-43037.negative.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/issue-43037.rs:19:6 | LL | impl From< as Z>::Assoc> for T {} - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/specialization/issue-43037.rs b/tests/ui/specialization/issue-43037.rs index fb9a581369e6c..b4603230a47b9 100644 --- a/tests/ui/specialization/issue-43037.rs +++ b/tests/ui/specialization/issue-43037.rs @@ -17,6 +17,6 @@ impl Z for A { // this impl is invalid, but causes an ICE anyway impl From< as Z>::Assoc> for T {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +//~^ ERROR type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) fn main() {} diff --git a/tests/ui/stability-attribute/generics-default-stability-where.rs b/tests/ui/stability-attribute/generics-default-stability-where.rs index a7bc1756d78a4..578c20dfdee83 100644 --- a/tests/ui/stability-attribute/generics-default-stability-where.rs +++ b/tests/ui/stability-attribute/generics-default-stability-where.rs @@ -5,7 +5,7 @@ extern crate unstable_generic_param; use unstable_generic_param::*; impl Trait3 for T where T: Trait2 { //~ ERROR use of unstable library feature `unstable_default` -//~^ ERROR `T` must be used as the type parameter for some local type +//~^ ERROR `T` must be used as an argument to some local type fn foo() -> usize { T::foo() } } diff --git a/tests/ui/stability-attribute/generics-default-stability-where.stderr b/tests/ui/stability-attribute/generics-default-stability-where.stderr index 9437f5d65fac2..ca4414aa9e004 100644 --- a/tests/ui/stability-attribute/generics-default-stability-where.stderr +++ b/tests/ui/stability-attribute/generics-default-stability-where.stderr @@ -7,11 +7,11 @@ LL | impl Trait3 for T where T: Trait2 { = help: add `#![feature(unstable_default)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/generics-default-stability-where.rs:7:6 | LL | impl Trait3 for T where T: Trait2 { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs index af552ac0c5e71..8a6efda6e9b41 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.rs @@ -4,7 +4,7 @@ use std::ops::FromResidual; impl const FromResidual for T { - //~^ ERROR type parameter `T` must be used as the type parameter for some local type + //~^ ERROR type parameter `T` must be used as an argument to some local type fn from_residual(t: T) -> _ { //~^ ERROR the placeholder `_` is not allowed t diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index 08fc73fe77b4d..1d1805a1d1a9f 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/ice-119717-constant-lifetime.rs:6:6 | LL | impl const FromResidual for T { - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs b/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs index 4e0e7ca9793f8..6b169cbcc41fa 100644 --- a/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs +++ b/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs @@ -4,7 +4,7 @@ #![feature(dispatch_from_dyn)] impl std::ops::DispatchFromDyn for T {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +//~^ ERROR type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) //~| ERROR the trait `DispatchFromDyn` may only be implemented for a coercion between structures fn main() {} diff --git a/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr b/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr index 69f360817805a..68e6e5bea4732 100644 --- a/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr +++ b/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `T` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/dispatch-from-dyn-blanket-impl.rs:6:6 | LL | impl std::ops::DispatchFromDyn for T {} - | ^ type parameter `T` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr index f0cf681d8bb72..8127b1a8df201 100644 --- a/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr +++ b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr @@ -1,8 +1,8 @@ -error[E0210]: type parameter `F` must be used as the type parameter for some local type (e.g., `MyStruct`) +error[E0210]: type parameter `F` must be used as an argument to some local type (e.g., `MyStruct`) --> $DIR/incoherent-assoc-imp-trait.rs:10:6 | LL | impl FnOnce<()> for &F { - | ^ type parameter `F` must be used as the type parameter for some local type + | ^ uncovered type parameter | = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter