Skip to content

Commit 766a0ab

Browse files
committed
E0128 update error format
1 parent f013914 commit 766a0ab

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/librustc_typeck/collect.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,9 +1901,12 @@ fn convert_default_type_parameter<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
19011901
for leaf_ty in ty.walk() {
19021902
if let ty::TyParam(p) = leaf_ty.sty {
19031903
if p.space == space && p.idx >= index {
1904-
span_err!(ccx.tcx.sess, path.span, E0128,
1905-
"type parameters with a default cannot use \
1906-
forward declared identifiers");
1904+
struct_span_err!(ccx.tcx.sess, path.span, E0128,
1905+
"type parameters with a default cannot use \
1906+
forward declared identifiers")
1907+
.span_label(path.span, &format!("defaulted type parameters \
1908+
cannot be forward declared"))
1909+
.emit();
19071910

19081911
return ccx.tcx.types.err
19091912
}

src/test/compile-fail/E0128.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
struct Foo<T=U, U=()> { //~ ERROR E0128
12+
//~| NOTE defaulted type parameters cannot be forward declared
1213
field1: T,
1314
field2: U,
1415
}

src/test/compile-fail/issue-18183.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
// except according to those terms.
1010

1111
pub struct Foo<Bar=Bar>; //~ ERROR E0128
12+
//~| NOTE defaulted type parameters cannot be forward declared
1213
pub struct Baz(Foo);
1314
fn main() {}

0 commit comments

Comments
 (0)