Skip to content

Commit ef62e05

Browse files
committed
Make wording less confusing
1 parent 14e6947 commit ef62e05

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed

src/librustc_typeck/check/mod.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -1520,31 +1520,25 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
15201520
(0, _) => ("const", "consts", None),
15211521
_ => ("type or const", "types or consts", None),
15221522
};
1523-
let mut err = struct_span_err!(
1523+
struct_span_err!(
15241524
tcx.sess,
15251525
item.span,
15261526
E0044,
15271527
"foreign items may not have {} parameters",
15281528
kinds,
1529-
);
1530-
err.span_label(
1529+
).span_label(
15311530
item.span,
15321531
&format!("can't have {} parameters", kinds),
1533-
);
1534-
// FIXME: once we start storing spans for type arguments, turn this into a
1535-
// suggestion.
1536-
err.help(&format!(
1537-
"use specialization instead of {} parameters by replacing \
1538-
them with concrete {}{}",
1539-
kinds,
1540-
kinds_pl,
1541-
if let Some(egs) = egs {
1542-
format!(" like `{}`", egs)
1543-
} else {
1544-
"".to_string()
1545-
},
1546-
));
1547-
err.emit();
1532+
).help(
1533+
// FIXME: once we start storing spans for type arguments, turn this
1534+
// into a suggestion.
1535+
&format!(
1536+
"replace the {} parameters with concrete {}{}",
1537+
kinds,
1538+
kinds_pl,
1539+
egs.map(|egs| format!(" like `{}`", egs)).unwrap_or_default(),
1540+
),
1541+
).emit();
15481542
}
15491543

15501544
if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node {

src/test/ui/const-generics/foreign-item-const-parameter.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ error[E0044]: foreign items may not have const parameters
1212
LL | fn foo<const X: usize>();
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
1414
|
15-
= help: use specialization instead of const parameters by replacing them with concrete consts
15+
= help: replace the const parameters with concrete consts
1616

1717
error[E0044]: foreign items may not have type or const parameters
1818
--> $DIR/foreign-item-const-parameter.rs:7:5
1919
|
2020
LL | fn bar<T, const X: usize>(_: T);
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
2222
|
23-
= help: use specialization instead of type or const parameters by replacing them with concrete types or consts
23+
= help: replace the type or const parameters with concrete types or consts
2424

2525
error: aborting due to 2 previous errors
2626

src/test/ui/error-codes/E0044.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern {
22
fn sqrt<T>(f: T) -> T;
33
//~^ ERROR foreign items may not have type parameters [E0044]
4-
//~| HELP use specialization instead of type parameters by replacing them with concrete types
4+
//~| HELP replace the type parameters with concrete types
55
//~| NOTE can't have type parameters
66
}
77

src/test/ui/error-codes/E0044.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0044]: foreign items may not have type parameters
44
LL | fn sqrt<T>(f: T) -> T;
55
| ^^^^^^^^^^^^^^^^^^^^^^ can't have type parameters
66
|
7-
= help: use specialization instead of type parameters by replacing them with concrete types like `u32`
7+
= help: replace the type parameters with concrete types like `u32`
88

99
error: aborting due to previous error
1010

src/test/ui/generic/generic-extern.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0044]: foreign items may not have type parameters
44
LL | fn foo<T>();
55
| ^^^^^^^^^^^^ can't have type parameters
66
|
7-
= help: use specialization instead of type parameters by replacing them with concrete types like `u32`
7+
= help: replace the type parameters with concrete types like `u32`
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)