1
Fork 0
rust/compiler/rustc_mir/src/transform
bors cd56e255c4 Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakis
Don't concatenate binders across types

Partially addresses #83737

There's actually two issues that I uncovered in #83737. The first is that we are concatenating bound vars across types, i.e. in
```
F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin)
```
the bound vars on `Future` get set as `for<anon>` since those are the binders on `Fn(&()`. This is obviously wrong, since we should only concatenate directly nested trait refs. This is solved here by introducing a new `TraitRefBoundary` scope, that we put around the "syntactical" trait refs and basically don't allow concatenation across.

Now, this alone *shouldn't* be a super terrible problem. At least not until you consider the other issue, which is a much more elusive and harder to design a "perfect" fix. A repro can be seen in:
```
use core::future::Future;

async fn handle<F>(slf: &F)
where
    F: Fn(&()) -> &mut (dyn for<'a> Future<Output = ()> + Unpin),
{
    (slf)(&()).await;
}
```
Notice the `for<'a>` around `Future`. Here, `'a` is unused, so the `for<'a>` Binder gets changed to a `for<>` Binder in the generator witness, but the "local decl" still has it. This has heavy intersections with region anonymization and erasing. Luckily, it's not *super* common to find this unique set of circumstances. It only became apparently because of the first issue mentioned here. However, this *is* still a problem, so I'm leaving #83737 open.

r? `@nikomatsakis`
2021-04-09 01:50:01 +00:00
..
check_consts Track bound vars 2021-03-31 10:15:27 -04:00
coverage Reduce size of statements 2021-04-02 19:11:50 -04:00
inline Use small hash set in mir_inliner_callees 2021-02-24 00:00:00 +00:00
add_call_guards.rs Remember the MirSource for each Body 2020-10-04 11:01:38 -07:00
add_moves_for_packed_drops.rs Replace (Body, DefId) with Body where possible 2020-10-04 16:07:03 -07:00
add_retag.rs Retagging: do not retag 'raw reborrows' 2020-10-31 15:31:27 +01:00
check_const_item_mutation.rs Suppress CONST_ITEM_MUTATION lint if a dereference occurs anywhere 2020-12-17 15:25:55 -05:00
check_packed_ref.rs make unaligned_refereces future-incompat lint warn-by-default, and remove the safe_packed_borrows lint that it replaces 2021-03-27 16:59:37 +01:00
check_unsafety.rs make unaligned_refereces future-incompat lint warn-by-default, and remove the safe_packed_borrows lint that it replaces 2021-03-27 16:59:37 +01:00
cleanup_post_borrowck.rs Remember the MirSource for each Body 2020-10-04 11:01:38 -07:00
const_debuginfo.rs Disable the constant debuginfo promotion pass by default 2020-12-14 19:56:10 -05:00
const_goto.rs Bump all mir_opt_level 3 to 4 2021-03-05 17:13:56 -03:00
const_prop.rs extract ConstKind::Unevaluated into a struct 2021-03-20 17:21:44 +01:00
deaggregator.rs Remember the MirSource for each Body 2020-10-04 11:01:38 -07:00
deduplicate_blocks.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
dest_prop.rs Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
dump_mir.rs Remember the MirSource for each Body 2020-10-04 11:01:38 -07:00
early_otherwise_branch.rs Mark early otherwise optimization unsound 2021-03-18 20:57:44 -03:00
elaborate_drops.rs Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
function_item_references.rs Review changes 2021-01-16 18:56:37 -05:00
generator.rs Don't concatenate binders across types 2021-04-05 00:41:08 -04:00
inline.rs extract ConstKind::Unevaluated into a struct 2021-03-20 17:21:44 +01:00
instcombine.rs move to separate pass, cache layouts 2021-03-16 21:34:31 -04:00
lower_intrinsics.rs Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
match_branches.rs Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
mod.rs make unaligned_refereces future-incompat lint warn-by-default, and remove the safe_packed_borrows lint that it replaces 2021-03-27 16:59:37 +01:00
multiple_return_terminators.rs Bump all mir_opt_level 3 to 4 2021-03-05 17:13:56 -03:00
no_landing_pads.rs Visit only terminators when removing landing pads 2021-01-18 00:00:00 +00:00
nrvo.rs Extract mir_opt_level to a method and use Option to be able to know if the value is provided or not 2021-03-05 17:13:56 -03:00
promote_consts.rs Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
remove_noop_landing_pads.rs Switch to changing cp_non_overlap in tform 2021-03-09 16:54:14 +00:00
remove_storage_markers.rs Remove storage markers if they won't be used during code generation 2021-02-28 20:10:44 +01:00
remove_unneeded_drops.rs Visit only terminators when removing unneeded drops 2021-01-17 00:00:00 +00:00
remove_zsts.rs RemoveZsts: don't touch unions 2021-03-24 13:00:36 -04:00
required_consts.rs extract ConstKind::Unevaluated into a struct 2021-03-20 17:21:44 +01:00
rustc_peek.rs Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
simplify.rs Auto merge of #83177 - erikdesjardins:zstassign, r=oli-obk 2021-03-23 12:23:27 +00:00
simplify_branches.rs Simplify assert terminator only if condition evaluates to expected value 2020-10-21 00:00:00 +00:00
simplify_comparison_integral.rs Prepare mir::Constant for ty::Const only supporting valtrees 2021-03-12 12:43:54 +00:00
simplify_try.rs Drive-by formatting of comment 2021-02-21 21:22:04 +01:00
uninhabited_enum_branching.rs Refactor how SwitchInt stores jump targets 2020-10-10 17:46:11 +02:00
unreachable_prop.rs Bump all mir_opt_level 3 to 4 2021-03-05 17:13:56 -03:00
validate.rs Clean up todos 2021-03-09 19:31:31 +00:00