From 98f38b28a21dc087c8176b82717d092fc1028d72 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 17 Apr 2019 22:41:30 +0100 Subject: [PATCH 1/2] Correct E0392 diagnostic --- src/librustc_typeck/check/wfcheck.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index d108e7c3107..37be1c3b5b7 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -938,10 +938,12 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .map(|(index, _)| Parameter(index as u32)) .collect(); - identify_constrained_generic_params(tcx, - &ty_predicates, - None, - &mut constrained_parameters); + identify_constrained_generic_params( + tcx, + &ty_predicates, + None, + &mut constrained_parameters, + ); for (index, _) in variances.iter().enumerate() { if constrained_parameters.contains(&Parameter(index as u32)) { @@ -949,6 +951,7 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let param = &hir_generics.params[index]; + match param.name { hir::ParamName::Error => { } _ => report_bivariance(tcx, param.span, param.name.ident().name), @@ -1123,7 +1126,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast: -> DiagnosticBuilder<'tcx> { let mut err = struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name); - err.span_label(span, "unused type parameter"); + err.span_label(span, "unused parameter"); err } From 048ba28ad1ec2fcf6611e29d388a3becc97f984a Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 17 Apr 2019 22:41:34 +0100 Subject: [PATCH 2/2] Update tests --- src/test/ui/error-codes/E0392.stderr | 2 +- src/test/ui/inner-static-type-parameter.stderr | 2 +- src/test/ui/issues/issue-17904-2.stderr | 2 +- src/test/ui/issues/issue-20413.stderr | 2 +- src/test/ui/issues/issue-36299.stderr | 4 ++-- src/test/ui/issues/issue-36638.stderr | 2 +- src/test/ui/issues/issue-37534.stderr | 2 +- .../region-bounds-on-objects-and-type-parameters.stderr | 2 +- src/test/ui/self/self_type_keyword.stderr | 2 +- src/test/ui/variance/variance-regions-unused-direct.stderr | 4 ++-- .../ui/variance/variance-regions-unused-indirect.stderr | 4 ++-- src/test/ui/variance/variance-unused-region-param.stderr | 4 ++-- src/test/ui/variance/variance-unused-type-param.stderr | 6 +++--- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/test/ui/error-codes/E0392.stderr b/src/test/ui/error-codes/E0392.stderr index 18419572233..d0b808df184 100644 --- a/src/test/ui/error-codes/E0392.stderr +++ b/src/test/ui/error-codes/E0392.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/E0392.rs:1:10 | LL | enum Foo { Bar } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/inner-static-type-parameter.stderr b/src/test/ui/inner-static-type-parameter.stderr index 3c14e217aeb..78514dd93ff 100644 --- a/src/test/ui/inner-static-type-parameter.stderr +++ b/src/test/ui/inner-static-type-parameter.stderr @@ -12,7 +12,7 @@ error[E0392]: parameter `T` is never used --> $DIR/inner-static-type-parameter.rs:3:10 | LL | enum Bar { What } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-17904-2.stderr b/src/test/ui/issues/issue-17904-2.stderr index b8fabd3b13f..930409cc637 100644 --- a/src/test/ui/issues/issue-17904-2.stderr +++ b/src/test/ui/issues/issue-17904-2.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-17904-2.rs:4:12 | LL | struct Foo where T: Copy; - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 893f4faab0d..f331600b03c 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-20413.rs:5:15 | LL | struct NoData; - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-36299.stderr b/src/test/ui/issues/issue-36299.stderr index dce4bd31ca3..edbe790a0c9 100644 --- a/src/test/ui/issues/issue-36299.stderr +++ b/src/test/ui/issues/issue-36299.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/issue-36299.rs:1:12 | LL | struct Foo<'a, A> {} - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `A` is never used --> $DIR/issue-36299.rs:1:16 | LL | struct Foo<'a, A> {} - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-36638.stderr b/src/test/ui/issues/issue-36638.stderr index 17134309014..2e440861611 100644 --- a/src/test/ui/issues/issue-36638.stderr +++ b/src/test/ui/issues/issue-36638.stderr @@ -14,7 +14,7 @@ error[E0392]: parameter `Self` is never used --> $DIR/issue-36638.rs:3:12 | LL | struct Foo(Self); - | ^^^^ unused type parameter + | ^^^^ unused parameter | = help: consider removing `Self` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-37534.stderr b/src/test/ui/issues/issue-37534.stderr index fe143540b73..7e06d51d97f 100644 --- a/src/test/ui/issues/issue-37534.stderr +++ b/src/test/ui/issues/issue-37534.stderr @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-37534.rs:1:12 | LL | struct Foo { } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index ec71d55705e..394a45a3e49 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -25,7 +25,7 @@ error[E0392]: parameter `'c` is never used --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 | LL | struct Foo<'a,'b,'c> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'c` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index f75377a220b..e0df00ffa92 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -62,7 +62,7 @@ error[E0392]: parameter `'Self` is never used --> $DIR/self_type_keyword.rs:8:12 | LL | struct Bar<'Self>; - | ^^^^^ unused type parameter + | ^^^^^ unused parameter | = help: consider removing `'Self` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-regions-unused-direct.stderr b/src/test/ui/variance/variance-regions-unused-direct.stderr index ab5dce03fa0..21ff475663c 100644 --- a/src/test/ui/variance/variance-regions-unused-direct.stderr +++ b/src/test/ui/variance/variance-regions-unused-direct.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-direct.rs:5:18 | LL | struct Bivariant<'a>; - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'d` is never used --> $DIR/variance-regions-unused-direct.rs:7:19 | LL | struct Struct<'a, 'd> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'d` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-regions-unused-indirect.stderr b/src/test/ui/variance/variance-regions-unused-indirect.stderr index 69631b4a504..fd66217f692 100644 --- a/src/test/ui/variance/variance-regions-unused-indirect.stderr +++ b/src/test/ui/variance/variance-regions-unused-indirect.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:3:10 | LL | enum Foo<'a> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:7:10 | LL | enum Bar<'a> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-unused-region-param.stderr b/src/test/ui/variance/variance-unused-region-param.stderr index 6c103f168f4..a96b2338bf4 100644 --- a/src/test/ui/variance/variance-unused-region-param.stderr +++ b/src/test/ui/variance/variance-unused-region-param.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-unused-region-param.rs:3:19 | LL | struct SomeStruct<'a> { x: u32 } - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-unused-region-param.rs:4:15 | LL | enum SomeEnum<'a> { Nothing } - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-unused-type-param.stderr b/src/test/ui/variance/variance-unused-type-param.stderr index 34c430f5498..883db462986 100644 --- a/src/test/ui/variance/variance-unused-type-param.stderr +++ b/src/test/ui/variance/variance-unused-type-param.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `A` is never used --> $DIR/variance-unused-type-param.rs:6:19 | LL | struct SomeStruct { x: u32 } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `A` is never used --> $DIR/variance-unused-type-param.rs:9:15 | LL | enum SomeEnum { Nothing } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used --> $DIR/variance-unused-type-param.rs:13:15 | LL | enum ListCell { - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData`