Skip to content

Commit acd3542

Browse files
Don't do intra-pass validation on MIR shims
1 parent ee5cb9e commit acd3542

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

compiler/rustc_mir_transform/src/shim.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
9090
};
9191
debug!("make_shim({:?}) = untransformed {:?}", instance, result);
9292

93-
pm::run_passes(
93+
// We don't validate MIR here because the shims may generate code that's
94+
// only valid in a reveal-all param-env. However, since we do initial
95+
// validation with the MirBuilt phase, which uses a user-facing param-env.
96+
// This causes validation errors when TAITs are involved.
97+
pm::run_passes_no_validate(
9498
tcx,
9599
&mut result,
96100
&[
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// crate foo
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
type Tait = impl Sized;
6+
fn _constrain() -> Tait {}
7+
8+
struct WrapperWithDrop<T>(T);
9+
impl<T> Drop for WrapperWithDrop<T> {
10+
fn drop(&mut self) {}
11+
}
12+
13+
pub struct Foo(WrapperWithDrop<Tait>);
14+
15+
trait Id {
16+
type Id: ?Sized;
17+
}
18+
impl<T: ?Sized> Id for T {
19+
type Id = T;
20+
}
21+
pub struct Bar(WrapperWithDrop<<Tait as Id>::Id>);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build:drop-shim-relates-opaque-aux.rs
2+
// compile-flags: -Zvalidate-mir --crate-type=lib
3+
// build-pass
4+
5+
extern crate drop_shim_relates_opaque_aux;
6+
7+
pub fn drop_foo(_: drop_shim_relates_opaque_aux::Foo) {}
8+
pub fn drop_bar(_: drop_shim_relates_opaque_aux::Bar) {}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)