Use full expr span for return suggestion on type error/ambiguity by compiler-errors · Pull Request #127129 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation11 Commits1 Checks6 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
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 #127109
r? @jieyouxu
rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r?
to explicitly pick a reviewer
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
This comment has been minimized.
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 |
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
// 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).
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.
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 added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Made the test file less dumb
@rustbot ready
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
labels
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.
📌 Commit 583b5fc has been approved by jieyouxu
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request
…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
tormake
) - rust-lang#126941 (Migrate
run-make/llvm-ident
tormake.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
bors added a commit to rust-lang-ci/rust that referenced this pull request
…llaumeGomez
Rollup of 8 pull requests
Successful merges:
- rust-lang#126732 (Stabilize
PanicInfo::message()
andPanicMessage
) - 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
tormake
) - 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
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
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
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.