Skip to content

Commit

Permalink
Auto merge of #35430 - jonathandturner:rollup, r=jonathandturner
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

- Successful merges: #35362, #35393, #35394, #35402, #35410, #35411, #35413, #35419, #35421
- Failed merges: #35395, #35415
  • Loading branch information
bors committed Aug 6, 2016
2 parents ddf92ff + 11022b4 commit f0d7e4e
Show file tree
Hide file tree
Showing 29 changed files with 158 additions and 70 deletions.
6 changes: 5 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,11 @@ impl<'a> Resolver<'a> {
(true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
_ => match (old_binding.is_import(), binding.is_import()) {
(false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
(true, true) => struct_span_err!(self.session, span, E0252, "{}", msg),
(true, true) => {
let mut e = struct_span_err!(self.session, span, E0252, "{}", msg);
e.span_label(span, &format!("already imported"));
e
},
_ => {
let mut e = struct_span_err!(self.session, span, E0255, "{}", msg);
e.span_label(span, &format!("`{}` was already imported", name));
Expand Down
46 changes: 29 additions & 17 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
type_str: &str,
trait_str: &str,
name: &str) {
span_err!(self.tcx().sess, span, E0223,
"ambiguous associated type; specify the type using the syntax \
`<{} as {}>::{}`",
type_str, trait_str, name);
struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
.span_label(span, &format!("ambiguous associated type"))
.note(&format!("specify the type using the syntax `<{} as {}>::{}`",
type_str, trait_str, name))
.emit();

}

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

if !trait_bounds.is_empty() {
let b = &trait_bounds[0];
span_err!(self.tcx().sess, b.trait_ref.path.span, E0225,
"only the builtin traits can be used as closure or object bounds");
let span = b.trait_ref.path.span;
struct_span_err!(self.tcx().sess, span, E0225,
"only the builtin traits can be used as closure or object bounds")
.span_label(span, &format!("non-builtin trait used as bounds"))
.emit();
}

let region_bound =
Expand Down Expand Up @@ -2255,20 +2260,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
} else {
"expected"
};
span_err!(tcx.sess, span, E0243,
"wrong number of type arguments: {} {}, found {}",
expected, required, supplied);
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
.span_label(
span,
&format!("{} {} type arguments, found {}", expected, required, supplied)
)
.emit();
} else if supplied > accepted {
let expected = if required < accepted {
"expected at most"
let expected = if required == 0 {
"expected no".to_string()
} else if required < accepted {
format!("expected at most {}", accepted)
} else {
"expected"
format!("expected {}", accepted)
};
span_err!(tcx.sess, span, E0244,
"wrong number of type arguments: {} {}, found {}",
expected,
accepted,
supplied);

struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
.span_label(
span,
&format!("{} type arguments, found {}", expected, supplied)
)
.emit();
}
}

Expand Down
21 changes: 11 additions & 10 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
end.span
};

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

Expand Down Expand Up @@ -700,9 +699,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for field in variant.fields
.iter()
.filter(|field| !used_fields.contains_key(&field.name)) {
span_err!(tcx.sess, span, E0027,
"pattern does not mention field `{}`",
field.name);
struct_span_err!(tcx.sess, span, E0027,
"pattern does not mention field `{}`",
field.name)
.span_label(span, &format!("missing field `{}`", field.name))
.emit();
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/librustc_typeck/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,17 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
name)
}
Err(CopyImplementationError::NotAnAdt) => {
span_err!(tcx.sess, span, E0206,
"the trait `Copy` may not be implemented \
for this type; type is not a structure or \
enumeration")
let item = tcx.map.expect_item(impl_node_id);
let span = if let ItemImpl(_, _, _, _, ref ty, _) = item.node {
ty.span
} else {
span
};

struct_span_err!(tcx.sess, span, E0206,
"the trait `Copy` may not be implemented for this type")
.span_label(span, &format!("type is not a structure or enumeration"))
.emit();
}
Err(CopyImplementationError::HasDestructor) => {
span_err!(tcx.sess, span, E0184,
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,10 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201,
"duplicate definitions with name `{}`:",
impl_item.name);
span_note!(&mut err, *entry.get(),
"previous definition of `{}` here",
impl_item.name);
err.span_label(*entry.get(),
&format!("previous definition of `{}` here",
impl_item.name));
err.span_label(impl_item.span, &format!("duplicate definition"));
err.emit();
}
Vacant(entry) => {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0027.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ fn main() {
let d = Dog { name: "Rusty".to_string(), age: 8 };

match d {
Dog { age: x } => {} //~ ERROR E0027
Dog { age: x } => {}
//~^ ERROR pattern does not mention field `name`
//~| NOTE missing field `name`
}
}
6 changes: 5 additions & 1 deletion src/test/compile-fail/E0029.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ fn main() {
let s = "hoho";

match s {
"hello" ... "world" => {} //~ ERROR E0029
"hello" ... "world" => {}
//~^ ERROR only char and numeric types are allowed in range patterns
//~| NOTE ranges require char or numeric types
//~| NOTE start type: &'static str
//~| NOTE end type: &'static str
_ => {}
}
}
10 changes: 7 additions & 3 deletions src/test/compile-fail/E0206.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@

type Foo = i32;

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

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

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

fn main() {
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0223.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
trait MyTrait { type X; }

fn main() {
let foo: MyTrait::X; //~ ERROR E0223
let foo: MyTrait::X;
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Type as MyTrait>::X`
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0225.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
// except according to those terms.

fn main() {
let _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
let _: Box<std::io::Read + std::io::Write>;
//~^ ERROR only the builtin traits can be used as closure or object bounds [E0225]
//~| NOTE non-builtin trait used as bounds
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0243.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
// except according to those terms.

struct Foo<T> { x: T }
struct Bar { x: Foo } //~ ERROR E0243
struct Bar { x: Foo }
//~^ ERROR E0243
//~| NOTE expected 1 type arguments, found 0

fn main() {
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0244.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// except according to those terms.

struct Foo { x: bool }
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244
struct Bar<S, T> { x: Foo<S, T> }
//~^ ERROR E0244
//~| NOTE expected no type arguments, found 2


fn main() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ trait Get {

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

trait Grab {
type Value;
fn grab(&self) -> Grab::Value;
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Type as Grab>::Value`
}

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

fn main() {
}
15 changes: 10 additions & 5 deletions src/test/compile-fail/coherence-impls-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } }
impl Copy for MyType {}

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

impl Copy for (MyType, MyType) {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

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

impl Copy for [MyType] {}
//~^ ERROR E0206
//~^ ERROR the trait `Copy` may not be implemented for this type
//~| NOTE type is not a structure or enumeration
//~| ERROR E0117

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

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/double-import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_core)]
#![no_core]

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

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

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ struct Vec<T, A = Heap>(
marker::PhantomData<(T,A)>);

fn main() {
let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0
let _: Vec;
//~^ ERROR E0243
//~| NOTE expected at least 1 type arguments, found 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ struct Vec<T, A = Heap>(

fn main() {
let _: Vec<isize, Heap, bool>;
//~^ ERROR wrong number of type arguments: expected at most 2, found 3
//~^ ERROR E0244
//~| NOTE expected at most 2 type arguments, found 3
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/impl-duplicate-methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ struct Foo;

impl Foo {
fn orange(&self) {} //~ NOTE previous definition of `orange` here
fn orange(&self) {} //~ ERROR duplicate definitions with name `orange`
fn orange(&self) {}
//~^ ERROR duplicate definition
//~| NOTE duplicate definition
}

fn main() {}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-14092.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

fn main() {}
7 changes: 6 additions & 1 deletion src/test/compile-fail/issue-23024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ fn main()
vfnfer.push(box h);
println!("{:?}",(vfnfer[0] as Fn)(3));
//~^ ERROR the precise format of `Fn`-family traits'
//~| ERROR wrong number of type arguments: expected 1, found 0
//~| ERROR E0243
//~| NOTE expected 1 type arguments, found 0
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`)
//~| NOTE in this expansion of println!
//~| NOTE in this expansion of println!
//~| NOTE in this expansion of println!
//~| NOTE in this expansion of println!
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-26886.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use std::sync::{self, Arc}; //~ NOTE previous import
//~^ NOTE previous import
use std::sync::Arc; //~ ERROR a type named
//~| NOTE already imported
use std::sync; //~ ERROR a module named
//~| NOTE already imported

fn main() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-34209.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ enum S {
fn bug(l: S) {
match l {
S::B{ } => { },
//~^ ERROR ambiguous associated type; specify the type using the syntax `<S as Trait>::B`
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<S as Trait>::B`
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/test/compile-fail/qualified-path-params-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ impl S {
fn f<T>() {}
}

type A = <S as Tr>::A::f<u8>; //~ ERROR type parameters are not allowed on this type
//~^ ERROR ambiguous associated type; specify the type using the syntax `<<S as Tr>::A as Trait>::f`
type A = <S as Tr>::A::f<u8>;
//~^ ERROR type parameters are not allowed on this type
//~| NOTE type parameter not allowed
//~| ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<<S as Tr>::A as Trait>::f`

fn main() {}
Loading

0 comments on commit f0d7e4e

Please sign in to comment.