Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
) {
let cause =
traits::ObligationCause::new(span, self.body_id, ObligationCauseCode::WellFormed(loc));
// for a type to be WF, we do not need to check if const trait predicates satisfy.
let param_env = self.param_env.without_const();
self.ocx.register_obligation(traits::Obligation::new(
cause,
self.param_env,
param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(self.tcx()),
));
}
Expand Down Expand Up @@ -1444,7 +1446,13 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations =
iter::zip(&predicates.predicates, &predicates.spans).flat_map(|(&p, &sp)| {
traits::wf::predicate_obligations(infcx, wfcx.param_env, wfcx.body_id, p, sp)
traits::wf::predicate_obligations(
infcx,
wfcx.param_env.without_const(),
wfcx.body_id,
p,
sp,
)
});

let obligations: Vec<_> = wf_obligations.chain(default_obligations).collect();
Expand Down
29 changes: 29 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// revisions: nn ny yn yy
// check-pass
#![feature(const_trait_impl, associated_type_defaults, const_mut_refs)]

#[cfg_attr(any(yn, yy), const_trait)]
pub trait Index {
type Output;
}

#[cfg_attr(any(ny, yy), const_trait)]
pub trait IndexMut where Self: Index {
const C: <Self as Index>::Output;
type Assoc = <Self as Index>::Output;
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
}

impl Index for () { type Output = (); }

impl const IndexMut for <() as Index>::Output {
const C: <Self as Index>::Output = ();
type Assoc = <Self as Index>::Output;
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
where <Self as Index>::Output:,
{}
}

const C: <() as Index>::Output = ();

fn main() {}