Make wording less confusing
This commit is contained in:
parent
14e6947fa4
commit
ef62e05062
5 changed files with 17 additions and 23 deletions
|
|
@ -1520,31 +1520,25 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
|
|||
(0, _) => ("const", "consts", None),
|
||||
_ => ("type or const", "types or consts", None),
|
||||
};
|
||||
let mut err = struct_span_err!(
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
item.span,
|
||||
E0044,
|
||||
"foreign items may not have {} parameters",
|
||||
kinds,
|
||||
);
|
||||
err.span_label(
|
||||
).span_label(
|
||||
item.span,
|
||||
&format!("can't have {} parameters", kinds),
|
||||
);
|
||||
// FIXME: once we start storing spans for type arguments, turn this into a
|
||||
// suggestion.
|
||||
err.help(&format!(
|
||||
"use specialization instead of {} parameters by replacing \
|
||||
them with concrete {}{}",
|
||||
kinds,
|
||||
kinds_pl,
|
||||
if let Some(egs) = egs {
|
||||
format!(" like `{}`", egs)
|
||||
} else {
|
||||
"".to_string()
|
||||
},
|
||||
));
|
||||
err.emit();
|
||||
).help(
|
||||
// FIXME: once we start storing spans for type arguments, turn this
|
||||
// into a suggestion.
|
||||
&format!(
|
||||
"replace the {} parameters with concrete {}{}",
|
||||
kinds,
|
||||
kinds_pl,
|
||||
egs.map(|egs| format!(" like `{}`", egs)).unwrap_or_default(),
|
||||
),
|
||||
).emit();
|
||||
}
|
||||
|
||||
if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ error[E0044]: foreign items may not have const parameters
|
|||
LL | fn foo<const X: usize>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
|
||||
|
|
||||
= help: use specialization instead of const parameters by replacing them with concrete consts
|
||||
= help: replace the const parameters with concrete consts
|
||||
|
||||
error[E0044]: foreign items may not have type or const parameters
|
||||
--> $DIR/foreign-item-const-parameter.rs:7:5
|
||||
|
|
@ -20,7 +20,7 @@ error[E0044]: foreign items may not have type or const parameters
|
|||
LL | fn bar<T, const X: usize>(_: T);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
|
||||
|
|
||||
= help: use specialization instead of type or const parameters by replacing them with concrete types or consts
|
||||
= help: replace the type or const parameters with concrete types or consts
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
extern {
|
||||
fn sqrt<T>(f: T) -> T;
|
||||
//~^ ERROR foreign items may not have type parameters [E0044]
|
||||
//~| HELP use specialization instead of type parameters by replacing them with concrete types
|
||||
//~| HELP replace the type parameters with concrete types
|
||||
//~| NOTE can't have type parameters
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0044]: foreign items may not have type parameters
|
|||
LL | fn sqrt<T>(f: T) -> T;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ can't have type parameters
|
||||
|
|
||||
= help: use specialization instead of type parameters by replacing them with concrete types like `u32`
|
||||
= help: replace the type parameters with concrete types like `u32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0044]: foreign items may not have type parameters
|
|||
LL | fn foo<T>();
|
||||
| ^^^^^^^^^^^^ can't have type parameters
|
||||
|
|
||||
= help: use specialization instead of type parameters by replacing them with concrete types like `u32`
|
||||
= help: replace the type parameters with concrete types like `u32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue