-
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
Don't do intra-pass validation on MIR shims #115005
Merged
Merged
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -90,7 +90,11 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' | |
}; | ||
debug!("make_shim({:?}) = untransformed {:?}", instance, result); | ||
|
||
pm::run_passes( | ||
// We don't validate MIR here because the shims may generate code that's | ||
// only valid in a reveal-all param-env. However, since we do initial | ||
// validation with the MirBuilt phase, which uses a user-facing param-env. | ||
// This causes validation errors when TAITs are involved. | ||
pm::run_passes_no_validate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, perhaps, only do this for drop shims. Other shims are (probably?) alright to do validation on. But I'm fine with ignoring all shims -- we still do final validation after passes are run since we're transitioning to |
||
tcx, | ||
&mut result, | ||
&[ | ||
|
21 changes: 21 additions & 0 deletions
21
tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs
This file contains 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,21 @@ | ||
// crate foo | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
type Tait = impl Sized; | ||
fn _constrain() -> Tait {} | ||
|
||
struct WrapperWithDrop<T>(T); | ||
impl<T> Drop for WrapperWithDrop<T> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
pub struct Foo(WrapperWithDrop<Tait>); | ||
|
||
trait Id { | ||
type Id: ?Sized; | ||
} | ||
impl<T: ?Sized> Id for T { | ||
type Id = T; | ||
} | ||
pub struct Bar(WrapperWithDrop<<Tait as Id>::Id>); |
10 changes: 10 additions & 0 deletions
10
tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs
This file contains 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,10 @@ | ||
// aux-build:drop-shim-relates-opaque-aux.rs | ||
// compile-flags: -Zvalidate-mir --crate-type=lib | ||
// build-pass | ||
|
||
extern crate drop_shim_relates_opaque_aux; | ||
|
||
pub fn drop_foo(_: drop_shim_relates_opaque_aux::Foo) {} | ||
pub fn drop_bar(_: drop_shim_relates_opaque_aux::Bar) {} | ||
|
||
fn main() {} |
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.
What about setting
body.phase
toRuntime(Initial)
?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.
That probably works. I'm not sure if that breaks any other invariants of validation, let me try it.
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.
This does not work, because validation fails before the
Derefer
is run.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.
I went down this path last week but wasn't very happy with the result as I had to run
Derefer
and then it seemed wise to run the other passes to actually put us in the same state as we should be whenphase = Runtime(Initial)
but that required either duplicating the list of passes or splitting uprun_runtime_lowering_passes()
since runningElaborateDrops
again caused other issues. In the end, it felt pretty hacky and I think @compiler-errors's solution here is better.