Prevent const trait methods from being marked stable
This commit is contained in:
parent
cb81712d10
commit
5f06ce2c0f
@ -10,6 +10,14 @@ use std::borrow::Cow;
|
||||
type McfResult = Result<(), (Span, Cow<'static, str>)>;
|
||||
|
||||
pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -> McfResult {
|
||||
// Prevent const trait methods from being annotated as `stable`.
|
||||
if tcx.features().staged_api {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
if crate::const_eval::is_parent_const_impl_raw(tcx, hir_id) {
|
||||
return Err((body.span, "trait methods cannot be stable const fn".into()));
|
||||
}
|
||||
}
|
||||
|
||||
let mut current = def_id;
|
||||
loop {
|
||||
let predicates = tcx.predicates_of(current);
|
||||
|
Loading…
x
Reference in New Issue
Block a user