-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not emit empty suggestion #133843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Do not emit empty suggestion #133843
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.rs
This file contains hidden or 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,26 @@ | ||
//! Regression test for suggestions that were fired on empty spans | ||
//! involving macro-call statements. For some reason the semicolon | ||
//! is not included in the overall span of the macro-call statement. | ||
//! | ||
//! Issue 1: <https://github.com/rust-lang/rust/issues/133833>. | ||
//! Issue 2: <https://github.com/rust-lang/rust/issues/133834>. | ||
//! See also: <https://github.com/rust-lang/rust/issues/133845>. | ||
|
||
fn foo() -> String { | ||
let mut list = { | ||
println!(); | ||
}; | ||
list //~ ERROR mismatched types | ||
} | ||
|
||
fn bar() { | ||
String::new() | ||
.chars() | ||
.filter(|x| !x.is_whitespace()) | ||
.map(|x| { | ||
println!("Child spawned with the size: {}", x); | ||
}) | ||
.collect::<String>(); //~ ERROR E0277 | ||
} | ||
|
||
fn main() {} |
50 changes: 50 additions & 0 deletions
50
tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr
This file contains hidden or 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,50 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:13:5 | ||
| | ||
LL | fn foo() -> String { | ||
| ------ expected `String` because of return type | ||
LL | let mut list = { | ||
| ____________________- | ||
LL | | println!(); | ||
LL | | }; | ||
| |_____- this block is missing a tail expression | ||
LL | list | ||
| ^^^^ expected `String`, found `()` | ||
|
||
error[E0277]: a value of type `String` cannot be built from an iterator over elements of type `()` | ||
--> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:23:20 | ||
| | ||
LL | .collect::<String>(); | ||
| ------- ^^^^^^ value of type `String` cannot be built from `std::iter::Iterator<Item=()>` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `FromIterator<()>` is not implemented for `String` | ||
= help: the following other types implement trait `FromIterator<A>`: | ||
`String` implements `FromIterator<&char>` | ||
`String` implements `FromIterator<&str>` | ||
`String` implements `FromIterator<Box<str, A>>` | ||
`String` implements `FromIterator<Cow<'_, str>>` | ||
`String` implements `FromIterator<String>` | ||
`String` implements `FromIterator<char>` | ||
note: the method call chain might not have had the expected associated types | ||
--> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:20:10 | ||
| | ||
LL | String::new() | ||
| ------------- this expression has type `String` | ||
LL | .chars() | ||
| ------- `Iterator::Item` is `char` here | ||
LL | .filter(|x| !x.is_whitespace()) | ||
| ------------------------------ `Iterator::Item` remains `char` here | ||
LL | .map(|x| { | ||
| __________^ | ||
LL | | println!("Child spawned with the size: {}", x); | ||
LL | | }) | ||
| |__________^ `Iterator::Item` changed to `()` here | ||
note: required by a bound in `collect` | ||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0308. | ||
For more information about an error, try `rustc --explain E0277`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.