Auto merge of #127200 - fee1-dead-contrib:trait_def_const_trait, r=compiler-errors
Add `constness` to `TraitDef` Second attempt at fixing the regression @ https://github.com/rust-lang/rust/pull/120639#issuecomment-2198373716 r? project-const-traits
This commit is contained in:
commit
5be2ec7245
9 changed files with 42 additions and 31 deletions
|
@ -1194,6 +1194,11 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
_ => span_bug!(item.span, "trait_def_of_item invoked on non-trait"),
|
||||
};
|
||||
|
||||
let constness = if tcx.has_attr(def_id, sym::const_trait) {
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
};
|
||||
let paren_sugar = tcx.has_attr(def_id, sym::rustc_paren_sugar);
|
||||
if paren_sugar && !tcx.features().unboxed_closures {
|
||||
tcx.dcx().emit_err(errors::ParenSugarAttribute { span: item.span });
|
||||
|
@ -1349,6 +1354,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
ty::TraitDef {
|
||||
def_id: def_id.to_def_id(),
|
||||
safety,
|
||||
constness,
|
||||
paren_sugar,
|
||||
has_auto_impl: is_auto,
|
||||
is_marker,
|
||||
|
@ -1682,7 +1688,7 @@ fn check_impl_constness(
|
|||
}
|
||||
|
||||
let trait_def_id = hir_trait_ref.trait_def_id()?;
|
||||
if tcx.has_attr(trait_def_id, sym::const_trait) {
|
||||
if tcx.is_const_trait(trait_def_id) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue