Skip to content

Commit 292ab39

Browse files
Point at struct field if possible
1 parent c0c6603 commit 292ab39

File tree

10 files changed

+194
-136
lines changed

10 files changed

+194
-136
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 176 additions & 118 deletions
Large diffs are not rendered by default.

src/test/ui/chalkify/type_wf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ fn main() {
1515
x: 5,
1616
};
1717

18-
let s = S { //~ ERROR the trait bound `{float}: Foo` is not satisfied
19-
x: 5.0,
18+
let s = S {
19+
x: 5.0, //~ ERROR the trait bound `{float}: Foo` is not satisfied
2020
};
2121

2222
let s = S {

src/test/ui/chalkify/type_wf.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `{float}: Foo` is not satisfied
2-
--> $DIR/type_wf.rs:18:13
2+
--> $DIR/type_wf.rs:19:9
33
|
4-
LL | let s = S {
5-
| ^ the trait `Foo` is not implemented for `{float}`
4+
LL | x: 5.0,
5+
| ^^^^^^ the trait `Foo` is not implemented for `{float}`
66
|
77
= help: the trait `Foo` is implemented for `i32`
88
note: required by a bound in `S`

src/test/ui/range/range-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi
2727
--> $DIR/range-1.rs:14:17
2828
|
2929
LL | let range = *arr..;
30-
| ^^^^^^ doesn't have a size known at compile-time
30+
| ^^^^ doesn't have a size known at compile-time
3131
|
3232
= help: the trait `Sized` is not implemented for `[{integer}]`
3333
note: required by a bound in `RangeFrom`

src/test/ui/traits/bound/on-structs-and-enums-locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ struct Foo<T:Trait> {
88

99
fn main() {
1010
let foo = Foo {
11-
//~^ ERROR E0277
1211
x: 3
12+
//~^ ERROR E0277
1313
};
1414

1515
let baz: Foo<usize> = loop { };

src/test/ui/traits/bound/on-structs-and-enums-locals.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | struct Foo<T:Trait> {
1111
| ^^^^^ required by this bound in `Foo`
1212

1313
error[E0277]: the trait bound `{integer}: Trait` is not satisfied
14-
--> $DIR/on-structs-and-enums-locals.rs:10:15
14+
--> $DIR/on-structs-and-enums-locals.rs:11:9
1515
|
16-
LL | let foo = Foo {
17-
| ^^^ the trait `Trait` is not implemented for `{integer}`
16+
LL | x: 3
17+
| ^^^^ the trait `Trait` is not implemented for `{integer}`
1818
|
1919
note: required by a bound in `Foo`
2020
--> $DIR/on-structs-and-enums-locals.rs:5:14

src/test/ui/traits/bound/on-structs-and-enums-xc1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use on_structs_and_enums_xc::{Bar, Foo, Trait};
66

77
fn main() {
88
let foo = Foo {
9-
//~^ ERROR E0277
109
x: 3
10+
//~^ ERROR E0277
1111
};
1212
let bar: Bar<f64> = return;
1313
//~^ ERROR E0277

src/test/ui/traits/bound/on-structs-and-enums-xc1.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | pub enum Bar<T:Trait> {
1111
| ^^^^^ required by this bound in `Bar`
1212

1313
error[E0277]: the trait bound `{integer}: Trait` is not satisfied
14-
--> $DIR/on-structs-and-enums-xc1.rs:8:15
14+
--> $DIR/on-structs-and-enums-xc1.rs:9:9
1515
|
16-
LL | let foo = Foo {
17-
| ^^^ the trait `Trait` is not implemented for `{integer}`
16+
LL | x: 3
17+
| ^^^^ the trait `Trait` is not implemented for `{integer}`
1818
|
1919
note: required by a bound in `Foo`
2020
--> $DIR/auxiliary/on_structs_and_enums_xc.rs:5:18

src/test/ui/union/union-generic.mirunsafeck.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | union U<T: Copy> {
1111
| ^^^^ required by this bound in `U`
1212

1313
error[E0277]: the trait bound `Rc<u32>: Copy` is not satisfied
14-
--> $DIR/union-generic.rs:13:13
14+
--> $DIR/union-generic.rs:13:17
1515
|
1616
LL | let u = U::<Rc<u32>> { a: Default::default() };
17-
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
17+
| ^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
1818
|
1919
note: required by a bound in `U`
2020
--> $DIR/union-generic.rs:6:12

src/test/ui/union/union-generic.thirunsafeck.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ LL | union U<T: Copy> {
1111
| ^^^^ required by this bound in `U`
1212

1313
error[E0277]: the trait bound `Rc<u32>: Copy` is not satisfied
14-
--> $DIR/union-generic.rs:13:13
14+
--> $DIR/union-generic.rs:13:17
1515
|
1616
LL | let u = U::<Rc<u32>> { a: Default::default() };
17-
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
17+
| ^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
1818
|
1919
note: required by a bound in `U`
2020
--> $DIR/union-generic.rs:6:12

0 commit comments

Comments
 (0)