-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use full expr span for return suggestion on type error/ambiguity #127129
Conversation
This comment has been minimized.
This comment has been minimized.
7ac8186
to
d5bddee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The span changes LGTM, the UI test I believe has incorrect "follow-up error annotation" syntax (pre-existing, which may have led you astray).
if true { | ||
Receiver.generic(); | ||
//~^ ERROR type annotations needed | ||
//| HELP you might have meant to return this value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem: I think this needs to be
//| HELP you might have meant to return this value | |
//~| HELP you might have meant to return this value |
to quality as a "follow-up error annotation" in the UI test mode (and suite). Hm. Actually, is the HELP error annotation just wrong in that entire file? I dug through compiletest a little and
rust/src/tools/compiletest/src/errors.rs
Lines 125 to 131 in 716752e
// Matches comments like: | |
// //~ | |
// //~| | |
// //~^ | |
// //~^^^^^ | |
// //[rev1]~ | |
// //[rev1,rev2]~^^ |
to the best of my knowledge //|
is not a supported form of test annotation lol. Apparently there's a few other tests that also does the //|
but AFAICT compiletest only uses the //~|
form (cargo or r-a might be different here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #127155 so I don't forgor about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was my typo from copypasting from the file without thinking rather than just writing my own UI test -- //|
is definitely not valid and I should have seen that lmao
@rustbot author |
d5bddee
to
583b5fc
Compare
Made the test file less dumb @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! r=me after CI is green.
@bors r=jieyouxu rollup |
…jieyouxu Use full expr span for return suggestion on type error/ambiguity We sometimes use parts of an expression rather than the whole thing for an obligation span. For example, a method obligation will just point to the path segment corresponding to the `method` in `rcvr.method(args)`. So let's not use that assuming it'll point to the *whole* expression span, which we can access from the expr hir id we store in `ObligationCauseCode::WhereClauseInExpr`. Fixes rust-lang#127109
…llaumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#126753 (Add nightly style guide section for `precise_capturing` `use<>` syntax) - rust-lang#126880 (Migrate `volatile-intrinsics`, `weird-output-filenames`, `wasm-override-linker`, `wasm-exceptions-nostd` to `rmake`) - rust-lang#126941 (Migrate `run-make/llvm-ident` to `rmake.rs`) - rust-lang#127128 (Stabilize `duration_abs_diff`) - rust-lang#127129 (Use full expr span for return suggestion on type error/ambiguity) - rust-lang#127188 ( improve the way bootstrap handles rustlib components) - rust-lang#127201 (Improve run-make-support API) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#126732 (Stabilize `PanicInfo::message()` and `PanicMessage`) - rust-lang#126753 (Add nightly style guide section for `precise_capturing` `use<>` syntax) - rust-lang#126832 (linker: Refactor interface for passing arguments to linker) - rust-lang#126880 (Migrate `volatile-intrinsics`, `weird-output-filenames`, `wasm-override-linker`, `wasm-exceptions-nostd` to `rmake`) - rust-lang#127128 (Stabilize `duration_abs_diff`) - rust-lang#127129 (Use full expr span for return suggestion on type error/ambiguity) - rust-lang#127188 ( improve the way bootstrap handles rustlib components) - rust-lang#127201 (Improve run-make-support API) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#127129 - compiler-errors:full-expr-span, r=jieyouxu Use full expr span for return suggestion on type error/ambiguity We sometimes use parts of an expression rather than the whole thing for an obligation span. For example, a method obligation will just point to the path segment corresponding to the `method` in `rcvr.method(args)`. So let's not use that assuming it'll point to the *whole* expression span, which we can access from the expr hir id we store in `ObligationCauseCode::WhereClauseInExpr`. Fixes rust-lang#127109
We sometimes use parts of an expression rather than the whole thing for an obligation span. For example, a method obligation will just point to the path segment corresponding to the
method
inrcvr.method(args)
.So let's not use that assuming it'll point to the whole expression span, which we can access from the expr hir id we store in
ObligationCauseCode::WhereClauseInExpr
.Fixes #127109