Normalize param_env for trait assoc consts in typeck
This commit is contained in:
parent
07608bd60e
commit
77b0c47b82
2 changed files with 10 additions and 2 deletions
|
@ -130,7 +130,7 @@ pub fn predicates_for_generics<'tcx>(
|
||||||
move |(idx, (predicate, span))| Obligation {
|
move |(idx, (predicate, span))| Obligation {
|
||||||
cause: cause(idx, span),
|
cause: cause(idx, span),
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
param_env: param_env,
|
param_env,
|
||||||
predicate,
|
predicate,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -1418,13 +1418,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
code: impl Fn(usize, Span) -> ObligationCauseCode<'tcx>,
|
code: impl Fn(usize, Span) -> ObligationCauseCode<'tcx>,
|
||||||
) {
|
) {
|
||||||
|
// Associated consts have `Self: ~const Trait` bounds that should be satisfiable when
|
||||||
|
// `Self: Trait` is satisfied because it does not matter whether the impl is `const`.
|
||||||
|
// Therefore we have to remap the param env here to be non-const.
|
||||||
|
let param_env = if let hir::def::DefKind::AssocConst = self.tcx.def_kind(def_id) {
|
||||||
|
self.param_env.without_const()
|
||||||
|
} else {
|
||||||
|
self.param_env
|
||||||
|
};
|
||||||
let (bounds, _) = self.instantiate_bounds(span, def_id, &substs);
|
let (bounds, _) = self.instantiate_bounds(span, def_id, &substs);
|
||||||
|
|
||||||
for obligation in traits::predicates_for_generics(
|
for obligation in traits::predicates_for_generics(
|
||||||
|idx, predicate_span| {
|
|idx, predicate_span| {
|
||||||
traits::ObligationCause::new(span, self.body_id, code(idx, predicate_span))
|
traits::ObligationCause::new(span, self.body_id, code(idx, predicate_span))
|
||||||
},
|
},
|
||||||
self.param_env,
|
param_env,
|
||||||
bounds,
|
bounds,
|
||||||
) {
|
) {
|
||||||
self.register_predicate(obligation);
|
self.register_predicate(obligation);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue