Remove constness
from ParamEnv
This commit is contained in:
parent
3e11b223d7
commit
e6b423aebb
34 changed files with 89 additions and 361 deletions
|
@ -144,85 +144,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
|
|||
}
|
||||
|
||||
let local_did = def_id.as_local();
|
||||
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): This isn't correct for
|
||||
// RPITITs in const trait fn.
|
||||
let hir_id = local_did.and_then(|def_id| tcx.opt_local_def_id_to_hir_id(def_id));
|
||||
|
||||
// FIXME(consts): This is not exactly in line with the constness query.
|
||||
let constness = match hir_id {
|
||||
Some(hir_id) => match tcx.hir().get(hir_id) {
|
||||
hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. })
|
||||
if tcx.is_const_default_method(def_id) =>
|
||||
{
|
||||
hir::Constness::Const
|
||||
}
|
||||
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(..), .. })
|
||||
| hir::Node::Item(hir::Item { kind: hir::ItemKind::Static(..), .. })
|
||||
| hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Const(..), ..
|
||||
})
|
||||
| hir::Node::AnonConst(_)
|
||||
| hir::Node::ConstBlock(_)
|
||||
| hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. })
|
||||
| hir::Node::ImplItem(hir::ImplItem {
|
||||
kind:
|
||||
hir::ImplItemKind::Fn(
|
||||
hir::FnSig {
|
||||
header: hir::FnHeader { constness: hir::Constness::Const, .. },
|
||||
..
|
||||
},
|
||||
..,
|
||||
),
|
||||
..
|
||||
}) => hir::Constness::Const,
|
||||
|
||||
hir::Node::ImplItem(hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Type(..) | hir::ImplItemKind::Fn(..),
|
||||
..
|
||||
}) => {
|
||||
let parent_hir_id = tcx.hir().parent_id(hir_id);
|
||||
match tcx.hir().get(parent_hir_id) {
|
||||
hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Impl(hir::Impl { constness, .. }),
|
||||
..
|
||||
}) => *constness,
|
||||
_ => span_bug!(
|
||||
tcx.def_span(parent_hir_id.owner),
|
||||
"impl item's parent node is not an impl",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
hir::Node::Item(hir::Item {
|
||||
kind:
|
||||
hir::ItemKind::Fn(hir::FnSig { header: hir::FnHeader { constness, .. }, .. }, ..),
|
||||
..
|
||||
})
|
||||
| hir::Node::TraitItem(hir::TraitItem {
|
||||
kind:
|
||||
hir::TraitItemKind::Fn(
|
||||
hir::FnSig { header: hir::FnHeader { constness, .. }, .. },
|
||||
..,
|
||||
),
|
||||
..
|
||||
})
|
||||
| hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Impl(hir::Impl { constness, .. }),
|
||||
..
|
||||
}) => *constness,
|
||||
|
||||
_ => hir::Constness::NotConst,
|
||||
},
|
||||
// FIXME(consts): It's suspicious that a param-env for a foreign item
|
||||
// will always have NotConst param-env, though we don't typically use
|
||||
// that param-env for anything meaningful right now, so it's likely
|
||||
// not an issue.
|
||||
None => hir::Constness::NotConst,
|
||||
};
|
||||
|
||||
let unnormalized_env =
|
||||
ty::ParamEnv::new(tcx.mk_clauses(&predicates), traits::Reveal::UserFacing, constness);
|
||||
ty::ParamEnv::new(tcx.mk_clauses(&predicates), traits::Reveal::UserFacing);
|
||||
|
||||
let body_id = local_did.unwrap_or(CRATE_DEF_ID);
|
||||
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue