forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#56188 - zackmdavis:if_i_may_suggest, r=davi…
…dtwco enum type instead of variant suggestion unification Fixes rust-lang#56028. Weirdly, we were deciding between a help note and a structured suggestion based on whether the import candidate span was a dummy—but we weren't using that span in any case! The dummy-ness of the span (which appears to be a matter of this-crate vs. other-crate definition) isn't the right criterion by which we should decide whether it's germane to mention that "there is an enum variant"; instead, let's use the someness of `def` (which is used as the `has_unexpected_resolution` argument to `error_code`). Since `import_candidate_to_paths` has no other callers, we are free to stop returning the span and rename the function. By using `span_suggestions_`, we leverage the max-suggestions output limit already built in to the emitter, thus resolving rust-lang#56028. In the matter of message wording, "you can" is redundant (and perhaps too informal); prefer the imperative. In a second commit, we do some unprincipled special-casing to correct and beautify suggestions for `Option` and `Result` (where the existing code was being confused by their being reexported in the prelude). r? @davidtwco
- Loading branch information
Showing
10 changed files
with
133 additions
and
58 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
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
15 changes: 15 additions & 0 deletions
15
src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.rs
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,15 @@ | ||
enum PutDown { Set } | ||
enum AffixHeart { Set } | ||
enum CauseToBe { Set } | ||
enum Determine { Set } | ||
enum TableDishesAction { Set } | ||
enum Solidify { Set } | ||
enum UnorderedCollection { Set } | ||
|
||
fn setup() -> Set { Set } | ||
//~^ ERROR cannot find type `Set` in this scope | ||
//~| ERROR cannot find value `Set` in this scope | ||
|
||
fn main() { | ||
setup(); | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr
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,38 @@ | ||
error[E0412]: cannot find type `Set` in this scope | ||
--> $DIR/issue-56028-there-is-an-enum-variant.rs:9:15 | ||
| | ||
LL | fn setup() -> Set { Set } | ||
| ^^^ not found in this scope | ||
help: there is an enum variant `AffixHeart::Set` and 7 others; try using the variant's enum | ||
| | ||
LL | fn setup() -> AffixHeart { Set } | ||
| ^^^^^^^^^^ | ||
LL | fn setup() -> CauseToBe { Set } | ||
| ^^^^^^^^^ | ||
LL | fn setup() -> Determine { Set } | ||
| ^^^^^^^^^ | ||
LL | fn setup() -> PutDown { Set } | ||
| ^^^^^^^ | ||
and 3 other candidates | ||
|
||
error[E0425]: cannot find value `Set` in this scope | ||
--> $DIR/issue-56028-there-is-an-enum-variant.rs:9:21 | ||
| | ||
LL | fn setup() -> Set { Set } | ||
| ^^^ not found in this scope | ||
help: possible candidates are found in other modules, you can import them into scope | ||
| | ||
LL | use AffixHeart::Set; | ||
| | ||
LL | use CauseToBe::Set; | ||
| | ||
LL | use Determine::Set; | ||
| | ||
LL | use PutDown::Set; | ||
| | ||
and 3 other candidates | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0412, E0425. | ||
For more information about an error, try `rustc --explain E0412`. |
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