Skip to content

Commit f0d7e4e

Browse files
authored
Auto merge of #35430 - jonathandturner:rollup, r=jonathandturner
Rollup of 9 pull requests - Successful merges: #35362, #35393, #35394, #35402, #35410, #35411, #35413, #35419, #35421 - Failed merges: #35395, #35415
2 parents ddf92ff + 11022b4 commit f0d7e4e

29 files changed

+158
-70
lines changed

src/librustc_resolve/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,11 @@ impl<'a> Resolver<'a> {
33753375
(true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
33763376
_ => match (old_binding.is_import(), binding.is_import()) {
33773377
(false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
3378-
(true, true) => struct_span_err!(self.session, span, E0252, "{}", msg),
3378+
(true, true) => {
3379+
let mut e = struct_span_err!(self.session, span, E0252, "{}", msg);
3380+
e.span_label(span, &format!("already imported"));
3381+
e
3382+
},
33793383
_ => {
33803384
let mut e = struct_span_err!(self.session, span, E0255, "{}", msg);
33813385
e.span_label(span, &format!("`{}` was already imported", name));

src/librustc_typeck/astconv.rs

+29-17
Original file line numberDiff line numberDiff line change
@@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
12151215
type_str: &str,
12161216
trait_str: &str,
12171217
name: &str) {
1218-
span_err!(self.tcx().sess, span, E0223,
1219-
"ambiguous associated type; specify the type using the syntax \
1220-
`<{} as {}>::{}`",
1221-
type_str, trait_str, name);
1218+
struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
1219+
.span_label(span, &format!("ambiguous associated type"))
1220+
.note(&format!("specify the type using the syntax `<{} as {}>::{}`",
1221+
type_str, trait_str, name))
1222+
.emit();
1223+
12221224
}
12231225

12241226
// Search for a bound on a type parameter which includes the associated item
@@ -2095,8 +2097,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
20952097

20962098
if !trait_bounds.is_empty() {
20972099
let b = &trait_bounds[0];
2098-
span_err!(self.tcx().sess, b.trait_ref.path.span, E0225,
2099-
"only the builtin traits can be used as closure or object bounds");
2100+
let span = b.trait_ref.path.span;
2101+
struct_span_err!(self.tcx().sess, span, E0225,
2102+
"only the builtin traits can be used as closure or object bounds")
2103+
.span_label(span, &format!("non-builtin trait used as bounds"))
2104+
.emit();
21002105
}
21012106

21022107
let region_bound =
@@ -2255,20 +2260,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
22552260
} else {
22562261
"expected"
22572262
};
2258-
span_err!(tcx.sess, span, E0243,
2259-
"wrong number of type arguments: {} {}, found {}",
2260-
expected, required, supplied);
2263+
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
2264+
.span_label(
2265+
span,
2266+
&format!("{} {} type arguments, found {}", expected, required, supplied)
2267+
)
2268+
.emit();
22612269
} else if supplied > accepted {
2262-
let expected = if required < accepted {
2263-
"expected at most"
2270+
let expected = if required == 0 {
2271+
"expected no".to_string()
2272+
} else if required < accepted {
2273+
format!("expected at most {}", accepted)
22642274
} else {
2265-
"expected"
2275+
format!("expected {}", accepted)
22662276
};
2267-
span_err!(tcx.sess, span, E0244,
2268-
"wrong number of type arguments: {} {}, found {}",
2269-
expected,
2270-
accepted,
2271-
supplied);
2277+
2278+
struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
2279+
.span_label(
2280+
span,
2281+
&format!("{} type arguments, found {}", expected, supplied)
2282+
)
2283+
.emit();
22722284
}
22732285
}
22742286

src/librustc_typeck/check/_match.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
9393
end.span
9494
};
9595

96-
// Note: spacing here is intentional, we want a space before "start" and "end".
97-
span_err!(tcx.sess, span, E0029,
98-
"only char and numeric types are allowed in range patterns\n \
99-
start type: {}\n end type: {}",
100-
self.ty_to_string(lhs_ty),
101-
self.ty_to_string(rhs_ty)
102-
);
96+
struct_span_err!(tcx.sess, span, E0029,
97+
"only char and numeric types are allowed in range patterns")
98+
.span_label(span, &format!("ranges require char or numeric types"))
99+
.note(&format!("start type: {}", self.ty_to_string(lhs_ty)))
100+
.note(&format!("end type: {}", self.ty_to_string(rhs_ty)))
101+
.emit();
103102
return;
104103
}
105104

@@ -700,9 +699,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
700699
for field in variant.fields
701700
.iter()
702701
.filter(|field| !used_fields.contains_key(&field.name)) {
703-
span_err!(tcx.sess, span, E0027,
704-
"pattern does not mention field `{}`",
705-
field.name);
702+
struct_span_err!(tcx.sess, span, E0027,
703+
"pattern does not mention field `{}`",
704+
field.name)
705+
.span_label(span, &format!("missing field `{}`", field.name))
706+
.emit();
706707
}
707708
}
708709
}

src/librustc_typeck/coherence/mod.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,17 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
325325
name)
326326
}
327327
Err(CopyImplementationError::NotAnAdt) => {
328-
span_err!(tcx.sess, span, E0206,
329-
"the trait `Copy` may not be implemented \
330-
for this type; type is not a structure or \
331-
enumeration")
328+
let item = tcx.map.expect_item(impl_node_id);
329+
let span = if let ItemImpl(_, _, _, _, ref ty, _) = item.node {
330+
ty.span
331+
} else {
332+
span
333+
};
334+
335+
struct_span_err!(tcx.sess, span, E0206,
336+
"the trait `Copy` may not be implemented for this type")
337+
.span_label(span, &format!("type is not a structure or enumeration"))
338+
.emit();
332339
}
333340
Err(CopyImplementationError::HasDestructor) => {
334341
span_err!(tcx.sess, span, E0184,

src/librustc_typeck/collect.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,10 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
770770
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201,
771771
"duplicate definitions with name `{}`:",
772772
impl_item.name);
773-
span_note!(&mut err, *entry.get(),
774-
"previous definition of `{}` here",
775-
impl_item.name);
773+
err.span_label(*entry.get(),
774+
&format!("previous definition of `{}` here",
775+
impl_item.name));
776+
err.span_label(impl_item.span, &format!("duplicate definition"));
776777
err.emit();
777778
}
778779
Vacant(entry) => {

src/test/compile-fail/E0027.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ fn main() {
1717
let d = Dog { name: "Rusty".to_string(), age: 8 };
1818

1919
match d {
20-
Dog { age: x } => {} //~ ERROR E0027
20+
Dog { age: x } => {}
21+
//~^ ERROR pattern does not mention field `name`
22+
//~| NOTE missing field `name`
2123
}
2224
}

src/test/compile-fail/E0029.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ fn main() {
1212
let s = "hoho";
1313

1414
match s {
15-
"hello" ... "world" => {} //~ ERROR E0029
15+
"hello" ... "world" => {}
16+
//~^ ERROR only char and numeric types are allowed in range patterns
17+
//~| NOTE ranges require char or numeric types
18+
//~| NOTE start type: &'static str
19+
//~| NOTE end type: &'static str
1620
_ => {}
1721
}
1822
}

src/test/compile-fail/E0206.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010

1111
type Foo = i32;
1212

13-
impl Copy for Foo { } //~ ERROR E0206
14-
//~^ ERROR E0117
13+
impl Copy for Foo { }
14+
//~^ ERROR the trait `Copy` may not be implemented for this type
15+
//~| NOTE type is not a structure or enumeration
16+
//~| ERROR E0117
1517

1618
#[derive(Copy, Clone)]
1719
struct Bar;
1820

19-
impl Copy for &'static Bar { } //~ ERROR E0206
21+
impl Copy for &'static Bar { }
22+
//~^ ERROR the trait `Copy` may not be implemented for this type
23+
//~| NOTE type is not a structure or enumeration
2024

2125
fn main() {
2226
}

src/test/compile-fail/E0223.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
trait MyTrait { type X; }
1212

1313
fn main() {
14-
let foo: MyTrait::X; //~ ERROR E0223
14+
let foo: MyTrait::X;
15+
//~^ ERROR ambiguous associated type
16+
//~| NOTE ambiguous associated type
17+
//~| NOTE specify the type using the syntax `<Type as MyTrait>::X`
1518
}

src/test/compile-fail/E0225.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
12+
let _: Box<std::io::Read + std::io::Write>;
13+
//~^ ERROR only the builtin traits can be used as closure or object bounds [E0225]
14+
//~| NOTE non-builtin trait used as bounds
1315
}

src/test/compile-fail/E0243.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// except according to those terms.
1010

1111
struct Foo<T> { x: T }
12-
struct Bar { x: Foo } //~ ERROR E0243
12+
struct Bar { x: Foo }
13+
//~^ ERROR E0243
14+
//~| NOTE expected 1 type arguments, found 0
1315

1416
fn main() {
1517
}

src/test/compile-fail/E0244.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
// except according to those terms.
1010

1111
struct Foo { x: bool }
12-
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
12+
struct Bar<S, T> { x: Foo<S, T> }
13+
//~^ ERROR E0244
14+
//~| NOTE expected no type arguments, found 2
15+
1316

1417
fn main() {
1518
}

src/test/compile-fail/associated-types-in-ambiguous-context.rs

+6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ trait Get {
1515

1616
fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
1717
//~^ ERROR ambiguous associated type
18+
//~| NOTE ambiguous associated type
19+
//~| NOTE specify the type using the syntax `<Type as Get>::Value`
1820

1921
trait Grab {
2022
type Value;
2123
fn grab(&self) -> Grab::Value;
2224
//~^ ERROR ambiguous associated type
25+
//~| NOTE ambiguous associated type
26+
//~| NOTE specify the type using the syntax `<Type as Grab>::Value`
2327
}
2428

2529
type X = std::ops::Deref::Target;
2630
//~^ ERROR ambiguous associated type
31+
//~| NOTE ambiguous associated type
32+
//~| NOTE specify the type using the syntax `<Type as std::ops::Deref>::Target`
2733

2834
fn main() {
2935
}

src/test/compile-fail/coherence-impls-copy.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,27 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } }
2727
impl Copy for MyType {}
2828

2929
impl Copy for &'static mut MyType {}
30-
//~^ ERROR E0206
30+
//~^ ERROR the trait `Copy` may not be implemented for this type
31+
//~| NOTE type is not a structure or enumeration
3132
impl Clone for MyType { fn clone(&self) -> Self { *self } }
3233

3334
impl Copy for (MyType, MyType) {}
34-
//~^ ERROR E0206
35+
//~^ ERROR the trait `Copy` may not be implemented for this type
36+
//~| NOTE type is not a structure or enumeration
3537
//~| ERROR E0117
3638

3739
impl Copy for &'static NotSync {}
38-
//~^ ERROR E0206
40+
//~^ ERROR the trait `Copy` may not be implemented for this type
41+
//~| NOTE type is not a structure or enumeration
3942

4043
impl Copy for [MyType] {}
41-
//~^ ERROR E0206
44+
//~^ ERROR the trait `Copy` may not be implemented for this type
45+
//~| NOTE type is not a structure or enumeration
4246
//~| ERROR E0117
4347

4448
impl Copy for &'static [NotSync] {}
45-
//~^ ERROR E0206
49+
//~^ ERROR the trait `Copy` may not be implemented for this type
50+
//~| NOTE type is not a structure or enumeration
4651
//~| ERROR E0117
4752

4853
fn main() {

src/test/compile-fail/double-import.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![feature(no_core)]
11-
#![no_core]
1210

1311
// This tests that conflicting imports shows both `use` lines
1412
// when reporting the error.
@@ -23,5 +21,6 @@ mod sub2 {
2321

2422
use sub1::foo; //~ NOTE previous import of `foo` here
2523
use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252]
24+
//~| NOTE already imported
2625

2726
fn main() {}

src/test/compile-fail/generic-type-less-params-with-defaults.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ struct Vec<T, A = Heap>(
1616
marker::PhantomData<(T,A)>);
1717

1818
fn main() {
19-
let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0
19+
let _: Vec;
20+
//~^ ERROR E0243
21+
//~| NOTE expected at least 1 type arguments, found 0
2022
}

src/test/compile-fail/generic-type-more-params-with-defaults.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ struct Vec<T, A = Heap>(
1717

1818
fn main() {
1919
let _: Vec<isize, Heap, bool>;
20-
//~^ ERROR wrong number of type arguments: expected at most 2, found 3
20+
//~^ ERROR E0244
21+
//~| NOTE expected at most 2 type arguments, found 3
2122
}

src/test/compile-fail/impl-duplicate-methods.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ struct Foo;
1212

1313
impl Foo {
1414
fn orange(&self) {} //~ NOTE previous definition of `orange` here
15-
fn orange(&self) {} //~ ERROR duplicate definitions with name `orange`
15+
fn orange(&self) {}
16+
//~^ ERROR duplicate definition
17+
//~| NOTE duplicate definition
1618
}
1719

1820
fn main() {}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn fn1(0: Box) {} //~ ERROR: wrong number of type arguments: expected 1, found 0
11+
fn fn1(0: Box) {}
12+
//~^ ERROR E0243
13+
//~| NOTE expected 1 type arguments, found 0
1214

1315
fn main() {}

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ fn main()
1818
vfnfer.push(box h);
1919
println!("{:?}",(vfnfer[0] as Fn)(3));
2020
//~^ ERROR the precise format of `Fn`-family traits'
21-
//~| ERROR wrong number of type arguments: expected 1, found 0
21+
//~| ERROR E0243
22+
//~| NOTE expected 1 type arguments, found 0
2223
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
24+
//~| NOTE in this expansion of println!
25+
//~| NOTE in this expansion of println!
26+
//~| NOTE in this expansion of println!
27+
//~| NOTE in this expansion of println!
2328
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
use std::sync::{self, Arc}; //~ NOTE previous import
1212
//~^ NOTE previous import
1313
use std::sync::Arc; //~ ERROR a type named
14+
//~| NOTE already imported
1415
use std::sync; //~ ERROR a module named
16+
//~| NOTE already imported
1517

1618
fn main() {
1719
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ enum S {
1515
fn bug(l: S) {
1616
match l {
1717
S::B{ } => { },
18-
//~^ ERROR ambiguous associated type; specify the type using the syntax `<S as Trait>::B`
18+
//~^ ERROR ambiguous associated type
19+
//~| NOTE ambiguous associated type
20+
//~| NOTE specify the type using the syntax `<S as Trait>::B`
1921
}
2022
}
2123

src/test/compile-fail/qualified-path-params-2.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ impl S {
2525
fn f<T>() {}
2626
}
2727

28-
type A = <S as Tr>::A::f<u8>; //~ ERROR type parameters are not allowed on this type
29-
//~^ ERROR ambiguous associated type; specify the type using the syntax `<<S as Tr>::A as Trait>::f`
28+
type A = <S as Tr>::A::f<u8>;
29+
//~^ ERROR type parameters are not allowed on this type
30+
//~| NOTE type parameter not allowed
31+
//~| ERROR ambiguous associated type
32+
//~| NOTE ambiguous associated type
33+
//~| NOTE specify the type using the syntax `<<S as Tr>::A as Trait>::f`
3034

3135
fn main() {}

0 commit comments

Comments
 (0)