Skip to content

Commit

Permalink
Rollup merge of rust-lang#64931 - estebank:missing-param-ref, r=matth…
Browse files Browse the repository at this point in the history
…ewjasper,Centril

Reword E0392 slightly

Make it clearer that a type or lifetime argument not being used can be
fixed by referencing it in a struct's fields, not just using `PhathomData`.

CC rust-lang#53589.
  • Loading branch information
Centril authored Oct 3, 2019
2 parents 3e15e51 + a180294 commit 17b1fd1
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 25 deletions.
15 changes: 10 additions & 5 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,16 @@ fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: ast::Name) {

let suggested_marker_id = tcx.lang_items().phantom_data();
// Help is available only in presence of lang items.
if let Some(def_id) = suggested_marker_id {
err.help(&format!("consider removing `{}` or using a marker such as `{}`",
param_name,
tcx.def_path_str(def_id)));
}
let msg = if let Some(def_id) = suggested_marker_id {
format!(
"consider removing `{}`, refering to it in a field, or using a marker such as `{}`",
param_name,
tcx.def_path_str(def_id),
)
} else {
format!( "consider removing `{}` or refering to it in a field", param_name)
};
err.help(&msg);
err.emit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0392.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
LL | enum Foo<T> { Bar }
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/inner-static-type-parameter.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0392]: parameter `T` is never used
LL | enum Bar<T> { What }
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-17904-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
LL | struct Foo<T> where T: Copy;
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-20413.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
LL | struct NoData<T>;
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:8:1
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-36299.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0392]: parameter `'a` is never used
LL | struct Foo<'a, A> {}
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `A` is never used
--> $DIR/issue-36299.rs:1:16
|
LL | struct Foo<'a, A> {}
| ^ unused parameter
|
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-36638.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ error[E0392]: parameter `Self` is never used
LL | struct Foo<Self>(Self);
| ^^^^ unused parameter
|
= help: consider removing `Self` or using a marker such as `std::marker::PhantomData`
= help: consider removing `Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 3 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-37534.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ error[E0392]: parameter `T` is never used
LL | struct Foo<T: ?Hash> { }
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ error[E0392]: parameter `'c` is never used
LL | struct Foo<'a,'b,'c> {
| ^^ unused parameter
|
= help: consider removing `'c` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'c`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 3 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/self/self_type_keyword.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ error[E0392]: parameter `'Self` is never used
LL | struct Bar<'Self>;
| ^^^^^ unused parameter
|
= help: consider removing `'Self` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 12 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/variance/variance-regions-unused-direct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0392]: parameter `'a` is never used
LL | struct Bivariant<'a>;
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `'d` is never used
--> $DIR/variance-regions-unused-direct.rs:7:19
|
LL | struct Struct<'a, 'd> {
| ^^ unused parameter
|
= help: consider removing `'d` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'d`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/variance/variance-regions-unused-indirect.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0392]: parameter `'a` is never used
LL | enum Foo<'a> {
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `'a` is never used
--> $DIR/variance-regions-unused-indirect.rs:7:10
|
LL | enum Bar<'a> {
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/variance/variance-unused-region-param.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ error[E0392]: parameter `'a` is never used
LL | struct SomeStruct<'a> { x: u32 }
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `'a` is never used
--> $DIR/variance-unused-region-param.rs:4:15
|
LL | enum SomeEnum<'a> { Nothing }
| ^^ unused parameter
|
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 2 previous errors

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/variance/variance-unused-type-param.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ error[E0392]: parameter `A` is never used
LL | struct SomeStruct<A> { x: u32 }
| ^ unused parameter
|
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `A` is never used
--> $DIR/variance-unused-type-param.rs:9:15
|
LL | enum SomeEnum<A> { Nothing }
| ^ unused parameter
|
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error[E0392]: parameter `T` is never used
--> $DIR/variance-unused-type-param.rs:13:15
|
LL | enum ListCell<T> {
| ^ unused parameter
|
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`

error: aborting due to 3 previous errors

Expand Down

0 comments on commit 17b1fd1

Please sign in to comment.