diff options
| author | b-naber <bn263@gmx.de> | 2021-10-25 15:34:59 +0200 |
|---|---|---|
| committer | b-naber <bn263@gmx.de> | 2021-10-25 16:04:57 +0200 |
| commit | c6b69017e21610b1ef491c028697728fbd3f581a (patch) | |
| tree | c37a8bf438ee113bcc85bc1f5e6c7b54a787283e | |
| parent | aa5740c715001f981515ed46faaddebf67cb9539 (diff) | |
| download | rust-c6b69017e21610b1ef491c028697728fbd3f581a.tar.gz rust-c6b69017e21610b1ef491c028697728fbd3f581a.zip | |
expose default substs in param_env
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index bc77c94809e..af3706f886e 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -247,6 +247,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> { } /// See `ParamEnv` struct definition for details. +#[instrument(level = "debug", skip(tcx))] fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { // The param_env of an impl Trait type is its defining function's param_env if let Some(parent) = ty::is_impl_trait_defn(tcx, def_id) { @@ -274,9 +275,20 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { predicates.extend(environment); } + // It's important that we include the default substs in unevaluated + // constants, since `Unevaluated` instances in predicates whose substs are None + // can lead to "duplicate" caller bounds candidates during trait selection, + // duplicate in the sense that both have their default substs, but the + // candidate that resulted from a superpredicate still uses `None` in its + // `substs_` field of `Unevaluated` to indicate that it has its default substs, + // whereas the other candidate has `substs_: Some(default_substs)`, see + // issue #89334 + predicates = tcx.expose_default_const_substs(predicates); + let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates), traits::Reveal::UserFacing); + debug!("unnormalized_env caller bounds: {:?}", unnormalized_env.caller_bounds()); let body_id = def_id .as_local() .map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)) |
