Move impl constness into impl trait header
This commit is contained in:
parent
c0e0d8f874
commit
2ffe3b1e70
8 changed files with 35 additions and 33 deletions
|
@ -253,6 +253,7 @@ pub struct ImplTraitHeader<'tcx> {
|
|||
pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,
|
||||
pub polarity: ImplPolarity,
|
||||
pub safety: hir::Safety,
|
||||
pub constness: hir::Constness,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
|
||||
|
@ -2004,11 +2005,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let def_id: DefId = def_id.into();
|
||||
match self.def_kind(def_id) {
|
||||
DefKind::Impl { of_trait: true } => {
|
||||
self.constness(def_id) == hir::Constness::Const
|
||||
&& self.is_const_trait(
|
||||
self.trait_id_of_impl(def_id)
|
||||
.expect("expected trait for trait implementation"),
|
||||
)
|
||||
let header = self.impl_trait_header(def_id).unwrap();
|
||||
header.constness == hir::Constness::Const
|
||||
&& self.is_const_trait(header.trait_ref.skip_binder().def_id)
|
||||
}
|
||||
DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) => {
|
||||
self.constness(def_id) == hir::Constness::Const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue