Unconditionally run RevealAll
pass and run it earlier
This commit is contained in:
parent
ec6f554536
commit
f5df26dbec
8 changed files with 80 additions and 26 deletions
|
@ -480,6 +480,7 @@ fn run_runtime_lowering_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
let passes: &[&dyn MirPass<'tcx>] = &[
|
let passes: &[&dyn MirPass<'tcx>] = &[
|
||||||
// These next passes must be executed together
|
// These next passes must be executed together
|
||||||
&add_call_guards::CriticalCallEdges,
|
&add_call_guards::CriticalCallEdges,
|
||||||
|
&reveal_all::RevealAll, // has to be done before drop elaboration, since we need to drop opaque types, too.
|
||||||
&elaborate_drops::ElaborateDrops,
|
&elaborate_drops::ElaborateDrops,
|
||||||
// This will remove extraneous landing pads which are no longer
|
// This will remove extraneous landing pads which are no longer
|
||||||
// necessary as well as well as forcing any call in a non-unwinding
|
// necessary as well as well as forcing any call in a non-unwinding
|
||||||
|
@ -526,7 +527,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
body,
|
body,
|
||||||
&[
|
&[
|
||||||
&check_alignment::CheckAlignment,
|
&check_alignment::CheckAlignment,
|
||||||
&reveal_all::RevealAll, // has to be done before inlining, since inlined code is in RevealAll mode.
|
|
||||||
&lower_slice_len::LowerSliceLenCalls, // has to be done before inlining, otherwise actual call will be almost always inlined. Also simple, so can just do first
|
&lower_slice_len::LowerSliceLenCalls, // has to be done before inlining, otherwise actual call will be almost always inlined. Also simple, so can just do first
|
||||||
&unreachable_prop::UnreachablePropagation,
|
&unreachable_prop::UnreachablePropagation,
|
||||||
&uninhabited_enum_branching::UninhabitedEnumBranching,
|
&uninhabited_enum_branching::UninhabitedEnumBranching,
|
||||||
|
|
|
@ -8,10 +8,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
pub struct RevealAll;
|
pub struct RevealAll;
|
||||||
|
|
||||||
impl<'tcx> MirPass<'tcx> for RevealAll {
|
impl<'tcx> MirPass<'tcx> for RevealAll {
|
||||||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
|
|
||||||
sess.mir_opt_level() >= 3 || super::inline::Inline.is_enabled(sess)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
// Do not apply this transformation to generators.
|
// Do not apply this transformation to generators.
|
||||||
if body.generator.is_some() {
|
if body.generator.is_some() {
|
||||||
|
|
|
@ -302,7 +302,7 @@ pub fn return_impl_trait() -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(cfail1,cfail4)))]
|
#[cfg(not(any(cfail1,cfail4)))]
|
||||||
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
|
#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")]
|
||||||
#[rustc_clean(cfg = "cfail3")]
|
#[rustc_clean(cfg = "cfail3")]
|
||||||
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
|
#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")]
|
||||||
#[rustc_clean(cfg = "cfail6")]
|
#[rustc_clean(cfg = "cfail6")]
|
||||||
|
|
|
@ -15,28 +15,44 @@
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_4 = hide_foo() -> [return: bb1, unwind unreachable];
|
_4 = hide_foo() -> [return: bb1, unwind: bb6];
|
||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
_3 = &_4;
|
_3 = &_4;
|
||||||
StorageLive(_5);
|
StorageLive(_5);
|
||||||
_5 = ();
|
_5 = ();
|
||||||
- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable];
|
- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5];
|
||||||
+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable];
|
+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5];
|
||||||
}
|
}
|
||||||
|
|
||||||
bb2: {
|
bb2: {
|
||||||
StorageDead(_5);
|
StorageDead(_5);
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
StorageDead(_4);
|
drop(_4) -> [return: bb3, unwind: bb6];
|
||||||
StorageDead(_2);
|
|
||||||
_0 = const ();
|
|
||||||
drop(_1) -> [return: bb3, unwind unreachable];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb3: {
|
bb3: {
|
||||||
|
StorageDead(_4);
|
||||||
|
StorageDead(_2);
|
||||||
|
_0 = const ();
|
||||||
|
drop(_1) -> [return: bb4, unwind: bb7];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb4: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bb5 (cleanup): {
|
||||||
|
drop(_4) -> [return: bb6, unwind terminate(cleanup)];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb6 (cleanup): {
|
||||||
|
drop(_1) -> [return: bb7, unwind terminate(cleanup)];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb7 (cleanup): {
|
||||||
|
resume;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,35 +15,43 @@
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_4 = hide_foo() -> [return: bb1, unwind: bb4];
|
_4 = hide_foo() -> [return: bb1, unwind: bb6];
|
||||||
}
|
}
|
||||||
|
|
||||||
bb1: {
|
bb1: {
|
||||||
_3 = &_4;
|
_3 = &_4;
|
||||||
StorageLive(_5);
|
StorageLive(_5);
|
||||||
_5 = ();
|
_5 = ();
|
||||||
- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4];
|
- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5];
|
||||||
+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4];
|
+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5];
|
||||||
}
|
}
|
||||||
|
|
||||||
bb2: {
|
bb2: {
|
||||||
StorageDead(_5);
|
StorageDead(_5);
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
StorageDead(_4);
|
drop(_4) -> [return: bb3, unwind: bb6];
|
||||||
StorageDead(_2);
|
|
||||||
_0 = const ();
|
|
||||||
drop(_1) -> [return: bb3, unwind: bb5];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb3: {
|
bb3: {
|
||||||
|
StorageDead(_4);
|
||||||
|
StorageDead(_2);
|
||||||
|
_0 = const ();
|
||||||
|
drop(_1) -> [return: bb4, unwind continue];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb4: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb4 (cleanup): {
|
bb5 (cleanup): {
|
||||||
drop(_1) -> [return: bb5, unwind terminate(cleanup)];
|
drop(_4) -> [return: bb6, unwind terminate(cleanup)];
|
||||||
}
|
}
|
||||||
|
|
||||||
bb5 (cleanup): {
|
bb6 (cleanup): {
|
||||||
|
drop(_1) -> [return: bb7, unwind terminate(cleanup)];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb7 (cleanup): {
|
||||||
resume;
|
resume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ where
|
||||||
|
|
||||||
#[rustc_polymorphize_error]
|
#[rustc_polymorphize_error]
|
||||||
pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
|
//~^ ERROR item has unused generic parameters
|
||||||
|| {
|
|| {
|
||||||
//~^ ERROR item has unused generic parameters
|
//~^ ERROR item has unused generic parameters
|
||||||
yield 1;
|
yield 1;
|
||||||
|
@ -57,6 +58,7 @@ pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Retu
|
||||||
|
|
||||||
#[rustc_polymorphize_error]
|
#[rustc_polymorphize_error]
|
||||||
pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
|
//~^ ERROR item has unused generic parameters
|
||||||
|| {
|
|| {
|
||||||
//~^ ERROR item has unused generic parameters
|
//~^ ERROR item has unused generic parameters
|
||||||
yield 1;
|
yield 1;
|
||||||
|
|
|
@ -8,20 +8,34 @@ LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)]
|
||||||
= note: `#[warn(incomplete_features)]` on by default
|
= note: `#[warn(incomplete_features)]` on by default
|
||||||
|
|
||||||
error: item has unused generic parameters
|
error: item has unused generic parameters
|
||||||
--> $DIR/generators.rs:35:5
|
--> $DIR/generators.rs:36:5
|
||||||
|
|
|
|
||||||
LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
| - generic parameter `T` is unused
|
| - generic parameter `T` is unused
|
||||||
|
LL |
|
||||||
LL | || {
|
LL | || {
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: item has unused generic parameters
|
error: item has unused generic parameters
|
||||||
--> $DIR/generators.rs:60:5
|
--> $DIR/generators.rs:34:8
|
||||||
|
|
|
||||||
|
LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
|
| ^^^^^^^^^^^ - generic parameter `T` is unused
|
||||||
|
|
||||||
|
error: item has unused generic parameters
|
||||||
|
--> $DIR/generators.rs:62:5
|
||||||
|
|
|
|
||||||
LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
| ------------ generic parameter `T` is unused
|
| ------------ generic parameter `T` is unused
|
||||||
|
LL |
|
||||||
LL | || {
|
LL | || {
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors; 1 warning emitted
|
error: item has unused generic parameters
|
||||||
|
--> $DIR/generators.rs:60:8
|
||||||
|
|
|
||||||
|
LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
|
||||||
|
| ^^^^^^^^^^^^ ------------ generic parameter `T` is unused
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors; 1 warning emitted
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// build-pass
|
||||||
|
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
|
pub struct Foo {
|
||||||
|
/// This type must have nontrivial drop glue
|
||||||
|
field: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Tait = impl Sized;
|
||||||
|
|
||||||
|
pub fn ice_cold(beverage: Tait) {
|
||||||
|
// Must destructure at least one field of `Foo`
|
||||||
|
let Foo { field } = beverage;
|
||||||
|
_ = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue