diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2021-04-29 19:27:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-29 19:27:22 -0400 |
| commit | 26a4f461d7ddc7cae4ec7f524e21fc712657159e (patch) | |
| tree | ba0134dba9e511365f729017ceb0524506d5efb3 | |
| parent | e720df672dc88b2d6822582a644de977a889bcdb (diff) | |
| parent | 5f82e22ba4c3a17b17fb81664e21d0baa68e3d87 (diff) | |
| download | rust-26a4f461d7ddc7cae4ec7f524e21fc712657159e.tar.gz rust-26a4f461d7ddc7cae4ec7f524e21fc712657159e.zip | |
Rollup merge of #84682 - jackh726:transitive_bounds_rebind, r=nikomatsakis
Don't rebind in `transitive_bounds_that_define_assoc_type` Fixes #83737 Fixes #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`````
| -rw-r--r-- | compiler/rustc_infer/src/traits/util.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/flags.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/lifetimes/issue-84604.rs | 9 |
4 files changed, 28 insertions, 3 deletions
diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 87684c2715f..1cde4802a40 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -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); } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 01bc5cc761c..92288c89827 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -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); diff --git a/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs new file mode 100644 index 00000000000..c496a3556c8 --- /dev/null +++ b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs @@ -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() {} diff --git a/src/test/ui/lifetimes/issue-84604.rs b/src/test/ui/lifetimes/issue-84604.rs new file mode 100644 index 00000000000..df8368da0a0 --- /dev/null +++ b/src/test/ui/lifetimes/issue-84604.rs @@ -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>>(); +} |
