diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index 788121f7a304f..339dc814ed5fb 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -16,7 +16,7 @@ use rustc_errors::struct_span_err; use rustc_hir::def::DefKind; use rustc_hir::def_id::{LocalDefId, LocalModDefId}; use rustc_middle::query::Providers; -use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::{Span, Symbol}; mod min_specialization; @@ -82,6 +82,14 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) ); return; } + + let other_span = tcx.source_span(impl_def_id); + let other_span = tcx.sess.source_map().span_until_char(other_span, '{'); + let prev_span = tcx.sess.source_map().span_through_char(other_span, '>'); + let other_span = prev_span.between(other_span.shrink_to_hi()); + + let impl_subject = tcx.impl_subject(impl_def_id.into()).instantiate_identity(); + let impl_generics = tcx.generics_of(impl_def_id); let impl_predicates = tcx.predicates_of(impl_def_id); let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).map(ty::EarlyBinder::instantiate_identity); @@ -119,7 +127,31 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) ty::GenericParamDefKind::Type { .. } => { let param_ty = ty::ParamTy::for_def(param); if !input_parameters.contains(&cgp::Parameter::from(param_ty)) { - report_unused_parameter(tcx, tcx.def_span(param.def_id), "type", param_ty.name); + let relevant_spans: Vec<_> = impl_predicates + .predicates + .iter() + .filter_map(|(clause, span)| match clause.kind().skip_binder() { + ty::ClauseKind::Trait(t) => { + if param_ty.to_ty(tcx) == t.self_ty() { + Some(Span::clone(span)) + } else { + None + } + } + _ => None, + }) + .collect(); + + report_unused_parameter( + tcx, + tcx.def_span(param.def_id), + "type", + param_ty.name, + impl_self_ty, + impl_subject, + other_span, + relevant_spans, + ); } } ty::GenericParamDefKind::Lifetime => { @@ -132,6 +164,10 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) tcx.def_span(param.def_id), "lifetime", param.name, + impl_self_ty, + impl_subject, + other_span, + Vec::new(), ); } } @@ -143,6 +179,10 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) tcx.def_span(param.def_id), "const", param_ct.name, + impl_self_ty, + impl_subject, + other_span, + Vec::new(), ); } } @@ -169,7 +209,26 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) // used elsewhere are not projected back out. } -fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) { +fn report_unused_parameter( + tcx: TyCtxt<'_>, + span: Span, + kind: &str, + name: Symbol, + ty: Ty<'_>, + impl_subject: ImplSubject<'_>, + impl_subject_span: Span, + _extra_spans: Vec, +) { + let raw_ty = format!("{ty}"); + let ty_using_param = if raw_ty.contains("<") { + let mut tmp = raw_ty.clone(); + let end_idx = raw_ty.rfind(">").unwrap(); + tmp.insert_str(end_idx, &format!(", {name}")); + tmp + } else { + format!("{raw_ty}<{name}>") + }; + let mut err = struct_span_err!( tcx.sess, span, @@ -180,6 +239,33 @@ fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol name ); err.span_label(span, format!("unconstrained {kind} parameter")); + + let param_span = + tcx.sess.source_map().span_extend_while(span, |tmp| tmp != '>' && tmp != ',').unwrap(); + + err.multipart_suggestion( + format!("consider using the Parameter like {ty_using_param}"), + core::iter::once((impl_subject_span, ty_using_param)).collect(), + rustc_lint_defs::Applicability::Unspecified, + ); + + match impl_subject { + ImplSubject::Trait(_) => { + // err.note(format!("Use the {kind} paramter `{name}` on an associated type")); + } + ImplSubject::Inherent(_) => { + err.multipart_suggestion( + format!( + "consider moving the {kind} paramter `{name}` to one of the inner functions" + ), + core::iter::once((param_span, String::new())) + // .chain(extra_spans.iter().map(|span| (span.to_owned(), String::new()))) + .collect(), + rustc_lint_defs::Applicability::Unspecified, + ); + } + }; + if kind == "const" { err.note( "expressions using a const parameter must map each value to a distinct output value", diff --git a/tests/ui/async-await/issues/issue-78654.full.stderr b/tests/ui/async-await/issues/issue-78654.full.stderr index 0d12a948c68bd..1e444b314c569 100644 --- a/tests/ui/async-await/issues/issue-78654.full.stderr +++ b/tests/ui/async-await/issues/issue-78654.full.stderr @@ -10,6 +10,7 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self LL | impl Foo { | ^^^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `H` in the impl on `Foo` or otherwise constrain `H` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/tests/ui/async-await/issues/issue-78654.min.stderr b/tests/ui/async-await/issues/issue-78654.min.stderr index 0d12a948c68bd..1e444b314c569 100644 --- a/tests/ui/async-await/issues/issue-78654.min.stderr +++ b/tests/ui/async-await/issues/issue-78654.min.stderr @@ -10,6 +10,7 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self LL | impl Foo { | ^^^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `H` in the impl on `Foo` or otherwise constrain `H` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/tests/ui/const-generics/issues/issue-68366.full.stderr b/tests/ui/const-generics/issues/issue-68366.full.stderr index ca9eb801dfce7..61d4941373fa6 100644 --- a/tests/ui/const-generics/issues/issue-68366.full.stderr +++ b/tests/ui/const-generics/issues/issue-68366.full.stderr @@ -4,6 +4,7 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self LL | impl Collatz<{Some(N)}> {} | ^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `N` in the impl on `Collatz<{Some(N)}>` or otherwise constrain `N` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported @@ -13,6 +14,7 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self LL | impl Foo {} | ^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `N` in the impl on `Foo` or otherwise constrain `N` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/tests/ui/const-generics/issues/issue-68366.min.stderr b/tests/ui/const-generics/issues/issue-68366.min.stderr index 3740ced90b1d7..00380a669fa25 100644 --- a/tests/ui/const-generics/issues/issue-68366.min.stderr +++ b/tests/ui/const-generics/issues/issue-68366.min.stderr @@ -13,6 +13,7 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self LL | impl Collatz<{Some(N)}> {} | ^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `N` in the impl on `Collatz<{Some(N)}>` or otherwise constrain `N` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported @@ -22,6 +23,7 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self LL | impl Foo {} | ^^^^^^^^^^^^^^ unconstrained const parameter | + = note: consider using const parameter `N` in the impl on `Foo` or otherwise constrain `N` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/tests/ui/consts/rustc-impl-const-stability.stderr b/tests/ui/consts/rustc-impl-const-stability.stderr index ba8e6c1555ce2..02471ec3587ad 100644 --- a/tests/ui/consts/rustc-impl-const-stability.stderr +++ b/tests/ui/consts/rustc-impl-const-stability.stderr @@ -13,6 +13,7 @@ error[E0207]: the const parameter `host` is not constrained by the impl trait, s LL | impl const Default for Data { | ^^^^^ unconstrained const parameter | + = note: consider using const parameter `host` in the impl on `Data` or otherwise constrain `host` = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported diff --git a/tests/ui/duplicate/duplicate-type-parameter.stderr b/tests/ui/duplicate/duplicate-type-parameter.stderr index 628f898d5c879..40368e04f18f1 100644 --- a/tests/ui/duplicate/duplicate-type-parameter.stderr +++ b/tests/ui/duplicate/duplicate-type-parameter.stderr @@ -59,6 +59,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl Qux for Option {} | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `Option` or otherwise constrain `T` error: aborting due to 8 previous errors diff --git a/tests/ui/error-codes/E0207.stderr b/tests/ui/error-codes/E0207.stderr index 5ef51ed86926a..7f162a264ad90 100644 --- a/tests/ui/error-codes/E0207.stderr +++ b/tests/ui/error-codes/E0207.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl Foo { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `Foo` or otherwise constrain `T` error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.stderr b/tests/ui/generic-associated-types/bugs/issue-87735.stderr index ebe2054ce5efc..ccfb01b422dc6 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-87735.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self | LL | impl<'b, T, U> AsRef2 for Foo | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `Foo` or otherwise constrain `U` error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/bugs/issue-88526.stderr b/tests/ui/generic-associated-types/bugs/issue-88526.stderr index 56857c6550bdc..aa4db500af151 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88526.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-88526.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `I` is not constrained by the impl trait, self | LL | impl<'q, Q, I, F> A for TestB | ^ unconstrained type parameter + | + = note: consider using type parameter `I` in the impl on `TestB` or otherwise constrain `I` error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr index cb2b9f32bfe72..f00813897b1f3 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr @@ -18,6 +18,8 @@ error[E0207]: the type parameter `T1` is not constrained by the impl trait, self | LL | impl Foo for T { | ^^ unconstrained type parameter + | + = note: consider using type parameter `T1` in the impl on `T` or otherwise constrain `T1` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr index cfce355672065..4aa86a032cd52 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, T> Foo for T { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `T` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/impl-trait/issues/issue-87340.stderr b/tests/ui/impl-trait/issues/issue-87340.stderr index 2ab1e6a031248..34c96750a0a0c 100644 --- a/tests/ui/impl-trait/issues/issue-87340.stderr +++ b/tests/ui/impl-trait/issues/issue-87340.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl X for () { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `()` or otherwise constrain `T` error: aborting due to previous error diff --git a/tests/ui/impl-unused-rps-in-assoc-type.stderr b/tests/ui/impl-unused-rps-in-assoc-type.stderr index c7ad1b4e608fc..a7feb6bdc2112 100644 --- a/tests/ui/impl-unused-rps-in-assoc-type.stderr +++ b/tests/ui/impl-unused-rps-in-assoc-type.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a> Fun for Holder { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `Holder` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/impl-unused-tps-inherent.stderr b/tests/ui/impl-unused-tps-inherent.stderr index 43f63cf968cf5..cc7ba1e9ac1e8 100644 --- a/tests/ui/impl-unused-tps-inherent.stderr +++ b/tests/ui/impl-unused-tps-inherent.stderr @@ -3,12 +3,16 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl MyType { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `MyType` or otherwise constrain `T` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps-inherent.rs:17:8 | LL | impl MyType1 { | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `MyType1` or otherwise constrain `U` error: aborting due to 2 previous errors diff --git a/tests/ui/impl-unused-tps.stderr b/tests/ui/impl-unused-tps.stderr index 053ab91c89328..23192bdc2ed89 100644 --- a/tests/ui/impl-unused-tps.stderr +++ b/tests/ui/impl-unused-tps.stderr @@ -3,30 +3,40 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self | LL | impl Foo for [isize;1] { | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `[isize; 1]` or otherwise constrain `U` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps.rs:30:8 | LL | impl Bar for T { | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `T` or otherwise constrain `U` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps.rs:38:8 | LL | impl Bar for T | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `T` or otherwise constrain `U` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps.rs:46:8 | LL | impl Foo for T | ^ unconstrained type parameter + | + = note: consider using type parameter `U` in the impl on `T` or otherwise constrain `U` error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps.rs:46:10 | LL | impl Foo for T | ^ unconstrained type parameter + | + = note: consider using type parameter `V` in the impl on `T` or otherwise constrain `V` error: aborting due to 5 previous errors diff --git a/tests/ui/issues/issue-16562.stderr b/tests/ui/issues/issue-16562.stderr index 3fe7507e8a412..9227d600f0dd6 100644 --- a/tests/ui/issues/issue-16562.stderr +++ b/tests/ui/issues/issue-16562.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl Collection for Col { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `Col` or otherwise constrain `T` error: aborting due to previous error diff --git a/tests/ui/issues/issue-22886.stderr b/tests/ui/issues/issue-22886.stderr index c4b3965592411..3892d43f9413f 100644 --- a/tests/ui/issues/issue-22886.stderr +++ b/tests/ui/issues/issue-22886.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a> Iterator for Newtype { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `Newtype` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/issues/issue-26262.stderr b/tests/ui/issues/issue-26262.stderr index 90e2d0d930164..b104c6fada156 100644 --- a/tests/ui/issues/issue-26262.stderr +++ b/tests/ui/issues/issue-26262.stderr @@ -3,12 +3,16 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl S { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `S<::Assoc>` or otherwise constrain `T` error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-26262.rs:17:6 | LL | impl<'a,T: Trait2<'a>> Trait1<>::Foo> for T { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `T` or otherwise constrain `'a` error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-29861.stderr b/tests/ui/issues/issue-29861.stderr index d9d3cf360df2d..b6591bae27b30 100644 --- a/tests/ui/issues/issue-29861.stderr +++ b/tests/ui/issues/issue-29861.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, T: 'a> MakeRef2 for T { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `T` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/issues/issue-35139.stderr b/tests/ui/issues/issue-35139.stderr index 79e889b7e599e..a97b1f4209996 100644 --- a/tests/ui/issues/issue-35139.stderr +++ b/tests/ui/issues/issue-35139.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a> MethodType for MTFn { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `MTFn` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr index e594dc577b1cd..36e82f14bd47a 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr +++ b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, I> UnwrapItemsExt for I { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `I` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr index 8cf8fb1d16c4d..bcc224ba45bc5 100644 --- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr +++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl X for () { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `()` or otherwise constrain `T` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/issue-74244.stderr b/tests/ui/type-alias-impl-trait/issue-74244.stderr index ff6bacd277e1e..a1960751ecb6e 100644 --- a/tests/ui/type-alias-impl-trait/issue-74244.stderr +++ b/tests/ui/type-alias-impl-trait/issue-74244.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl Allocator for DefaultAllocator { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `DefaultAllocator` or otherwise constrain `T` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/issue-74761-2.stderr b/tests/ui/type-alias-impl-trait/issue-74761-2.stderr index f15d0a069ca8a..6bc8cb8c99058 100644 --- a/tests/ui/type-alias-impl-trait/issue-74761-2.stderr +++ b/tests/ui/type-alias-impl-trait/issue-74761-2.stderr @@ -3,12 +3,16 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, 'b> A for () { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `()` or otherwise constrain `'a` error[E0207]: the lifetime parameter `'b` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-74761-2.rs:7:10 | LL | impl<'a, 'b> A for () { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'b` in the impl on `()` or otherwise constrain `'b` error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/issue-74761.stderr b/tests/ui/type-alias-impl-trait/issue-74761.stderr index 1d016fe070f9c..2e23bd20a2b07 100644 --- a/tests/ui/type-alias-impl-trait/issue-74761.stderr +++ b/tests/ui/type-alias-impl-trait/issue-74761.stderr @@ -3,12 +3,16 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, 'b> A for () { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `()` or otherwise constrain `'a` error[E0207]: the lifetime parameter `'b` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-74761.rs:7:10 | LL | impl<'a, 'b> A for () { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'b` in the impl on `()` or otherwise constrain `'b` error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr index 8cdce2f8e81ca..03155a9247286 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a, I: Iterator> Trait for (i32, I) { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `(i32, I)` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr index 65139307f8e01..e538354fb35f9 100644 --- a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr +++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr @@ -3,6 +3,8 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, | LL | impl<'a> Trait for Opaque<&'a str> { | ^^ unconstrained lifetime parameter + | + = note: consider using lifetime parameter `'a` in the impl on `Opaque<&'a str>` or otherwise constrain `'a` error: aborting due to previous error diff --git a/tests/ui/typeck/issue-13853-5.stderr b/tests/ui/typeck/issue-13853-5.stderr index 3d8f824ec94cb..ff4c34b4561be 100644 --- a/tests/ui/typeck/issue-13853-5.stderr +++ b/tests/ui/typeck/issue-13853-5.stderr @@ -3,6 +3,8 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self | LL | impl<'a, T: Deserializable> Deserializable for &'a str { | ^ unconstrained type parameter + | + = note: consider using type parameter `T` in the impl on `&'a str` or otherwise constrain `T` error: aborting due to previous error