Skip to content
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

Tighten span when suggesting lifetime on path #92333

Merged
merged 1 commit into from
Dec 28, 2021

Conversation

compiler-errors
Copy link
Member

This is kind of a hack.

Really the issue here is that we want to suggest the segment's span if the path resolves to something defined outside of the macro, and the macro's span if it resolves to something defined within.. I'll look into seeing if we can do something like that.

Fixes #92324

r? @cjgillot

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 27, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 27, 2021
@rust-log-analyzer

This comment has been minimized.

Comment on lines 280 to 281
// HACK: we use find_ancestor_inside to associate to properly suggest elided spans
// in paths originating from macros.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: grammar

also, what do macros have to do with this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so macros have nothing to #92324. But src/test/ui/in-band-lifetimes/elided-lifetimes.rs regresses if we don't return a subspan of the path_span.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's presumably why segment.ident.span was changed to path_span in #90446, but we still need a span that points to just the segment, not the whole path.

So this finds the segment's span inside of any macro if path_span inside of one.

@cjgillot
Copy link
Contributor

Thanks @compiler-errors!
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 28, 2021

📌 Commit e37d012 has been approved by cjgillot

@bors 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 Dec 28, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 28, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#92076 (Ignore other `PredicateKind`s in rustdoc auto trait finder)
 - rust-lang#92219 (Remove VCVARS_BAT)
 - rust-lang#92238 (Add a test suite for stringify macro)
 - rust-lang#92330 (Add myself to .mailmap)
 - rust-lang#92333 (Tighten span when suggesting lifetime on path)
 - rust-lang#92335 (Document units for `std::column`)
 - rust-lang#92344 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 98c61b6 into rust-lang:master Dec 28, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 28, 2021
@compiler-errors compiler-errors deleted the elided-lifetime-spans branch April 7, 2022 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken help message for missing lifetime when using <_ as Trait> syntax in type alias
7 participants