Avoid pointing out return span if it has nothing to do with type error#100130
Merged
bors merged 2 commits intorust-lang:masterfrom Aug 7, 2022
Merged
Avoid pointing out return span if it has nothing to do with type error#100130bors merged 2 commits intorust-lang:masterfrom
return span if it has nothing to do with type error#100130bors merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
|
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
Contributor
Author
|
Specifically, #84128 regresses because the error that: struct Foo<T>(T);
fn main() {
|| {
if false {
return Foo(0);
}
Foo(())
};
}the given code^ emits is not being emitted in in struct Foo<T>(T);
fn main() {
|| {
if false {
return Foo(0);
}
Foo::<i32>(())
};
}Unfortunately, by the time we get to checking the arguments of the second |
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 6, 2022
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#100071 (deps: dedupe `annotate-snippets` crate versions) - rust-lang#100127 (Remove Windows function preloading) - rust-lang#100130 (Avoid pointing out `return` span if it has nothing to do with type error) - rust-lang#100169 (Optimize `pointer::as_aligned_to`) - rust-lang#100175 (ascii -> ASCII in code comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This code:
Emits this:
Specifically, that note has nothing to do with the type error in question. This is because the change implemented in #84244 tries to point out the
returnspan on any type coercion error within a closure that happens after areturnstatement, regardless of if the error has anything to do with it.This is really easy to trigger -- just needs a closure (or an
async) and an early return (or any other form, e.g.?operator suffices) -- and super distracting in production codebases. I'm letting #84128 regress because that issue is much harder to fix correctly, and I can re-open that issue after this lands.As a drive-by, I added a
resolve_vars_if_possibleto the coercion error logic, which leads to some error improvements. Unrelated to the issue above, though.