-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Make type_implements_trait not a query #86901
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
Merged
+142
−108
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// edition:2018 | ||
// revisions: rpass1 | ||
|
||
|
||
// Regression test for #86753. The `type_implements_trait` query (since moved to a method) | ||
// was encountering an ICE during incremental testing when hashing its arguments. | ||
#![warn(rust_2021_compatibility)] | ||
|
||
use std::future::Future; | ||
use std::pin::Pin; | ||
use std::task::{Poll, Context}; | ||
|
||
struct LocalSet {} | ||
struct RunUntil<'a, F> { | ||
_local_set: &'a LocalSet, | ||
_future: F, | ||
} | ||
impl<'a, F> RunUntil<'a, F> { | ||
fn project<'pin>(self: Pin<&'pin mut Self>) -> Projection<'pin, 'a, F> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
struct Projection<'pin, 'a, F> | ||
where | ||
RunUntil<'a, F>: 'pin, | ||
{ | ||
pub local_set: &'pin mut &'a LocalSet, | ||
pub future: Pin<&'pin mut F>, | ||
} | ||
|
||
impl LocalSet { | ||
fn with<T>(&self, _f: impl FnOnce() -> T) -> T { | ||
unimplemented!() | ||
} | ||
} | ||
impl<T: Future> Future for RunUntil<'_, T> { | ||
type Output = T::Output; | ||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
let me = self.project(); | ||
me.local_set.with(|| { | ||
let _ = cx.waker(); | ||
let f = me.future; | ||
let _ = f.poll(cx); | ||
Poll::Pending | ||
}) | ||
} | ||
} | ||
|
||
fn main() {} |
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
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
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.
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.
Can you modify the
ty.has_infer_types
above toty.needs_infer
, which is a more complete fix? (Actually, I think I'd prefer an assertion, but that's more of a matter for @rust-lang/clippy to decide -- I would be surprised though if inference variables make their way here)For that matter, I think the function should have a comment explaining that it returns false in the case of inference variables, as that is not obvious (also not obviously correct)
Uh oh!
There was an error while loading. Please reload this page.
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
ty.has_infer_types()
was added as a fix for a ICE: #72775Clippy changes LGTM, if
needs_infer
also works 👍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.
Makes sense --
needs_infer
would probably avoid more ICEs :)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.
Note though @flip1995 that there's probably a "better fix" that just makes the code work
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.
Oh, I see, but the ICE in question was #72766 and is not part of clippy, right?
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.
it might well be that this can be an
assert!
in the clippy codeThere 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.
I really don't know if this is required in Clippy, I've never tested it without it since it was added. We call this utils function in many places, so it's likely that this actually prevents an ICE, even if it is just there as a precaution, so that this function can just be used without checking preconditions.