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

Don't use guess_head_span in predicates_of for foreign span #88414

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

Aaron1011
Copy link
Member

Previously, the result of predicates_of for a foreign trait
would depend on the current state of the corresponding source
file in the foreign crate. This could lead to ICEs during incremental
compilation, since the on-disk contents of the upstream source file
could potentially change without the upstream crate being recompiled.

Additionally, this ensure that that the metadata we produce for a crate
only depends on its compiled upstream dependencies (e.g an rlib or
rmeta file), not the current on-disk state of the upstream crate
source files.

@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2021
@rust-log-analyzer

This comment has been minimized.

Previously, the result of `predicates_of` for a foreign trait
would depend on the *current* state of the corresponding source
file in the foreign crate. This could lead to ICEs during incremental
compilation, since the on-disk contents of the upstream source file
could potentially change without the upstream crate being recompiled.

Additionally, this ensure that that the metadata we produce for a crate
only depends on its *compiled* upstream dependencies (e.g an rlib or
rmeta file), *not* the current on-disk state of the upstream crate
source files.
@Aaron1011
Copy link
Member Author

In the future, I'd like to encode the head span into the crate metadata (for items where it might be needed). That would allow us to use the trait head span in all cases, without needing to read from a from an upstream crate's on-disk source.

However, that will require a much larger effort. This change should hopefully be enough to fix the predicates_of fingerprint ICEs that people have been running across.

@cjgillot
Copy link
Contributor

cjgillot commented Aug 28, 2021

For functions, def_span already encodes the head span, by special-casing rustc_middle::hir::map::Map::opt_span. A similar trick could be employed for traits.

@Aaron1011
Copy link
Member Author

I think we might want to use the full trait span in some cases (cc @estebank)

@estebank
Copy link
Contributor

I think we might want to use the full trait span in some cases

I'm pretty sure there are cases where this is true (although I can't think of any off the top of my head), but I think it might be a handful of cases and concentrated on things that are in the local crate.

Comment on lines +54 to +56
LL | | // FIXME(estebank): once support to add notes in `rustc_on_unimplemented`
LL | | // lands in beta, and it has been extended to check whether a closure is
LL | | // anywhere in the requirement chain, extend it as such (#48534):
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is... like being caught coming out of the shower 😅

Comment on lines 27 to +37
note: required by a bound in `Iterator`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | pub trait Iterator {
| ^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator`
LL | / pub trait Iterator {
LL | | /// The type of the elements being iterated over.
LL | | #[stable(feature = "rust1", since = "1.0.0")]
LL | | type Item;
... |
LL | | }
LL | | }
| |_^ required by this bound in `Iterator`
Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing all of these I think we need to extend the metadata to have clearer wording here. We are pointing at a whole trait while saying "this bound in the trait". The trait itself is "the bound". I don't know what better wording would be.

@estebank
Copy link
Contributor

Let's use def_span if we can here. Either way, r=me

r? @estebank

@Aaron1011
Copy link
Member Author

Let's use def_span if we can here.

Where do you want me to switch to def_span?

@estebank
Copy link
Contributor

@bors r+

I misread how you were getting the span. We should still make the def_span smaller, but that's a tangential change.

@bors
Copy link
Contributor

bors commented Aug 30, 2021

📌 Commit c9157ef has been approved by estebank

@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 Aug 30, 2021
@Aaron1011
Copy link
Member Author

An unusually large number of people have been reporting predicates_of fingerprint ICEs lately. Let's get this in quickly so that we can determine if this fixes those issues.

@bors p=1

@bors
Copy link
Contributor

bors commented Aug 31, 2021

⌛ Testing commit c9157ef with merge 1e37e83...

@bors
Copy link
Contributor

bors commented Aug 31, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 1e37e83 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants