forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#100898 - compiler-errors:too-many-expr-fiel…
…ds, r=spastorino Do not report too many expr field candidates When considering "this expressions' field has a {field/method}" suggestions: 1. Don't report methods that are out of scope 2. Use `span_suggestions` instead of reporting each field candidate, which caps the number of suggestions to 4 4. Blacklist some common traits like `Clone` and `Deref` Fixes rust-lang#100894
- Loading branch information
Showing
8 changed files
with
160 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,7 @@ symbols! { | |
BTreeSet, | ||
BinaryHeap, | ||
Borrow, | ||
BorrowMut, | ||
Break, | ||
C, | ||
CStr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
struct Thing { | ||
a0: Foo, | ||
a1: Foo, | ||
a2: Foo, | ||
a3: Foo, | ||
a4: Foo, | ||
a5: Foo, | ||
a6: Foo, | ||
a7: Foo, | ||
a8: Foo, | ||
a9: Foo, | ||
} | ||
|
||
struct Foo { | ||
field: Field, | ||
} | ||
|
||
struct Field; | ||
|
||
impl Foo { | ||
fn bar(&self) {} | ||
} | ||
|
||
fn bar(t: Thing) { | ||
t.bar(); //~ ERROR no method named `bar` found for struct `Thing` | ||
t.field; //~ ERROR no field `field` on type `Thing` | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
error[E0599]: no method named `bar` found for struct `Thing` in the current scope | ||
--> $DIR/too-many-field-suggestions.rs:25:7 | ||
| | ||
LL | struct Thing { | ||
| ------------ method `bar` not found for this struct | ||
... | ||
LL | t.bar(); | ||
| ^^^ method not found in `Thing` | ||
| | ||
help: some of the expressions' fields have a method of the same name | ||
| | ||
LL | t.a0.bar(); | ||
| +++ | ||
LL | t.a1.bar(); | ||
| +++ | ||
LL | t.a2.bar(); | ||
| +++ | ||
LL | t.a3.bar(); | ||
| +++ | ||
and 6 other candidates | ||
|
||
error[E0609]: no field `field` on type `Thing` | ||
--> $DIR/too-many-field-suggestions.rs:26:7 | ||
| | ||
LL | t.field; | ||
| ^^^^^ unknown field | ||
| | ||
= note: available fields are: `a0`, `a1`, `a2`, `a3`, `a4` ... and 5 others | ||
help: some of the expressions' fields have a field of the same name | ||
| | ||
LL | t.a0.field; | ||
| +++ | ||
LL | t.a1.field; | ||
| +++ | ||
LL | t.a2.field; | ||
| +++ | ||
LL | t.a3.field; | ||
| +++ | ||
and 6 other candidates | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0599, E0609. | ||
For more information about an error, try `rustc --explain E0599`. |