Skip to content

Commit

Permalink
Rollup merge of rust-lang#84682 - jackh726:transitive_bounds_rebind, …
Browse files Browse the repository at this point in the history
…r=nikomatsakis

Don't rebind in `transitive_bounds_that_define_assoc_type`

Fixes rust-lang#83737
Fixes rust-lang#84604

Also fixes another issue that I don't have a test for, popped up in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Duplicate.20symbol.20error.20.2384604/near/236570445)

r? ````@nikomatsakis````
  • Loading branch information
jackh726 authored Apr 29, 2021
2 parents 17ab74e + 5f82e22 commit ddb846e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
Some(assoc_name),
));
for (super_predicate, _) in super_predicates.predicates {
let bound_predicate = super_predicate.kind();
let subst_predicate = super_predicate
.subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder()));
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() {
stack.push(binder.value);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl FlagComputation {
{
let mut computation = FlagComputation::new();

if !value.bound_vars().is_empty() {
computation.flags = computation.flags | TypeFlags::HAS_RE_LATE_BOUND;
}

f(&mut computation, value.skip_binder());

self.add_flags(computation.flags);
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// build-pass
// compile-flags: --edition 2018
// compile-flags: --crate-type rlib

use std::future::Future;

async fn handle<F>(slf: &F)
where
F: Fn(&()) -> Box<dyn for<'a> Future<Output = ()> + Unpin>,
{
(slf)(&()).await;
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/lifetimes/issue-84604.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-pass
// compile-flags: -Zsymbol-mangling-version=v0

pub fn f<T: ?Sized>() {}
pub trait Frob<T: ?Sized> {}
fn main() {
f::<dyn Frob<str>>();
f::<dyn for<'a> Frob<str>>();
}

0 comments on commit ddb846e

Please sign in to comment.