Auto merge of #42807 - arielb1:consistent-coercion, r=eddyb

Coerce fields to the expected field type

Fully fixes #31260.

This needs a crater run. I was supposed to do this last month but it slipped. Let's get this done.
This commit is contained in:
bors 2017-06-30 13:39:25 +00:00
commit e72580cf09
4 changed files with 29 additions and 39 deletions

View file

@ -12,9 +12,12 @@ pub struct Struct<K: 'static> {
pub field: K,
}
// Partial fix for #31260, doesn't work without {...}.
static STRUCT: Struct<&'static [u8]> = Struct {
field: {&[1]}
};
static STRUCT2: Struct<&'static [u8]> = Struct {
field: &[1]
};
fn main() {}

View file

@ -39,23 +39,25 @@ fn c() -> Result<Foo, Bar> {
}
fn d() -> X<X<String, String>, String> {
X {
let x = X {
x: X {
x: "".to_string(),
y: 2,
},
y: 3,
}
};
x
}
fn e() -> X<X<String, String>, String> {
X {
let x = X {
x: X {
x: "".to_string(),
y: 2,
},
y: "".to_string(),
}
};
x
}
fn main() {}

View file

@ -35,31 +35,19 @@ error[E0308]: mismatched types
found type `Foo`
error[E0308]: mismatched types
--> $DIR/abridged.rs:42:5
--> $DIR/abridged.rs:49:5
|
42 | / X {
43 | | x: X {
44 | | x: "".to_string(),
45 | | y: 2,
46 | | },
47 | | y: 3,
48 | | }
| |_____^ expected struct `std::string::String`, found integral variable
49 | x
| ^ expected struct `std::string::String`, found integral variable
|
= note: expected type `X<X<_, std::string::String>, std::string::String>`
found type `X<X<_, {integer}>, {integer}>`
error[E0308]: mismatched types
--> $DIR/abridged.rs:52:5
--> $DIR/abridged.rs:60:5
|
52 | / X {
53 | | x: X {
54 | | x: "".to_string(),
55 | | y: 2,
56 | | },
57 | | y: "".to_string(),
58 | | }
| |_____^ expected struct `std::string::String`, found integral variable
60 | x
| ^ expected struct `std::string::String`, found integral variable
|
= note: expected type `X<X<_, std::string::String>, _>`
found type `X<X<_, {integer}>, _>`