Skip to content

Commit

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

- Successful merges: #35396, #35402, #35446, #35466, #35470, #35475
- Failed merges: #35395, #35415
  • Loading branch information
bors committed Aug 7, 2016
2 parents 1744c46 + 09e2e04 commit 8913330
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/doc/book/crates-and-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ As an example, let’s make a *phrases* crate, which will give us various phrase
in different languages. To keep things simple, we’ll stick to ‘greetings’ and
‘farewells’ as two kinds of phrases, and use English and Japanese (日本語) as
two languages for those phrases to be in. We’ll use this module layout:

```text
+-----------+
+---| greetings |
Expand Down
22 changes: 15 additions & 7 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
self.convert_angle_bracketed_parameters(rscope, span, decl_generics, data)
}
hir::ParenthesizedParameters(..) => {
span_err!(tcx.sess, span, E0214,
"parenthesized parameters may only be used with a trait");
struct_span_err!(tcx.sess, span, E0214,
"parenthesized parameters may only be used with a trait")
.span_label(span, &format!("only traits may use parentheses"))
.emit();

let ty_param_defs = decl_generics.types.get_slice(TypeSpace);
(Substs::empty(),
ty_param_defs.iter().map(|_| tcx.types.err).collect(),
Expand Down Expand Up @@ -1201,10 +1204,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
}

for (trait_def_id, name) in associated_types {
span_err!(tcx.sess, span, E0191,
struct_span_err!(tcx.sess, span, E0191,
"the value of the associated type `{}` (from the trait `{}`) must be specified",
name,
tcx.item_path_str(trait_def_id));
tcx.item_path_str(trait_def_id))
.span_label(span, &format!(
"missing associated type `{}` value", name))
.emit();
}

tcx.mk_trait(object.principal, object.bounds)
Expand Down Expand Up @@ -1584,9 +1590,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
return self.tcx().types.err;
}
_ => {
span_err!(tcx.sess, span, E0248,
"found value `{}` used as a type",
tcx.item_path_str(def.def_id()));
struct_span_err!(tcx.sess, span, E0248,
"found value `{}` used as a type",
tcx.item_path_str(def.def_id()))
.span_label(span, &format!("value used as a type"))
.emit();
return self.tcx().types.err;
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,23 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.check_pat(&subpat, field_ty);
}
} else {
span_err!(tcx.sess, pat.span, E0023,
"this pattern has {} field{s}, but the corresponding {} has {} field{s}",
subpats.len(), def.kind_name(), variant.fields.len(),
s = if variant.fields.len() == 1 {""} else {"s"});
let subpats_ending = if subpats.len() == 1 {
""
} else {
"s"
};
let fields_ending = if variant.fields.len() == 1 {
""
} else {
"s"
};
struct_span_err!(tcx.sess, pat.span, E0023,
"this pattern has {} field{}, but the corresponding {} has {} field{}",
subpats.len(), subpats_ending, def.kind_name(),
variant.fields.len(), fields_ending)
.span_label(pat.span, &format!("expected {} field{}, found {}",
variant.fields.len(), fields_ending, subpats.len()))
.emit();
on_error();
}
}
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 @@ -330,10 +330,17 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
.emit()
}
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
5 changes: 5 additions & 0 deletions src/test/compile-fail/E0023.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ enum Fruit {
Pear(u32),
}


fn main() {
let x = Fruit::Apple(String::new(), String::new());
match x {
Fruit::Apple(a) => {}, //~ ERROR E0023
//~| NOTE expected 2 fields, found 1
Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
//~| NOTE expected 2 fields, found 3
Fruit::Pear(1, 2) => {}, //~ ERROR E0023
//~| NOTE expected 1 field, found 2
}
}
1 change: 1 addition & 0 deletions src/test/compile-fail/E0191.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ trait Trait {
}

type Foo = Trait; //~ ERROR E0191
//~| NOTE missing associated type `Bar` value

fn main() {
}
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() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0214.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 v: Vec(&str) = vec!["foo"]; //~ ERROR E0214
let v: Vec(&str) = vec!["foo"];
//~^ ERROR E0214
//~| NOTE only traits may use parentheses
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0248.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ enum Foo {
}

fn do_something(x: Foo::Bar) { } //~ ERROR E0248

//~| NOTE value used as a type
fn main() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) {
//~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified
//~| NOTE could derive from `Vehicle`
//~| NOTE could derive from `Box`
//~| NOTE missing associated type `Color` value
}

fn paint<C:BoxCar>(c: C, d: C::Color) {
Expand Down
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

0 comments on commit 8913330

Please sign in to comment.