Skip to content

Commit

Permalink
Don't do intra-pass validation on MIR shims
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Aug 19, 2023
1 parent ee5cb9e commit acd3542
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
tcx,
&mut result,
&[
Expand Down
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>);
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() {}

0 comments on commit acd3542

Please sign in to comment.