Add fundamental to trait def
This commit is contained in:
parent
382148d9a2
commit
b2e30bdec4
@ -1201,6 +1201,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
|
||||
let is_marker = tcx.has_attr(def_id, sym::marker);
|
||||
let rustc_coinductive = tcx.has_attr(def_id, sym::rustc_coinductive);
|
||||
let is_fundamental = tcx.has_attr(def_id, sym::fundamental);
|
||||
|
||||
// FIXME: We could probably do way better attribute validation here.
|
||||
let mut skip_array_during_method_dispatch = false;
|
||||
@ -1352,6 +1353,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
||||
has_auto_impl: is_auto,
|
||||
is_marker,
|
||||
is_coinductive: rustc_coinductive || is_auto,
|
||||
is_fundamental,
|
||||
skip_array_during_method_dispatch,
|
||||
skip_boxed_slice_during_method_dispatch,
|
||||
specialization_kind,
|
||||
|
@ -31,7 +31,7 @@ pub struct TraitDef {
|
||||
/// and thus `impl`s of it are allowed to overlap.
|
||||
pub is_marker: bool,
|
||||
|
||||
/// If `true`, then this trait has to `#[rustc_coinductive]` attribute or
|
||||
/// If `true`, then this trait has the `#[rustc_coinductive]` attribute or
|
||||
/// is an auto trait. This indicates that trait solver cycles involving an
|
||||
/// `X: ThisTrait` goal are accepted.
|
||||
///
|
||||
@ -40,6 +40,11 @@ pub struct TraitDef {
|
||||
/// also have already switched to the new trait solver.
|
||||
pub is_coinductive: bool,
|
||||
|
||||
/// If `true`, then this trait has the `#[fundamental]` attribute. This
|
||||
/// affects how conherence computes whether a trait may have trait implementations
|
||||
/// added in the future.
|
||||
pub is_fundamental: bool,
|
||||
|
||||
/// If `true`, then this trait has the `#[rustc_skip_during_method_dispatch(array)]`
|
||||
/// attribute, indicating that editions before 2021 should not consider this trait
|
||||
/// during method dispatch if the receiver is an array.
|
||||
|
@ -666,7 +666,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> bool {
|
||||
trait_ref.def_id.is_local() || tcx.has_attr(trait_ref.def_id, sym::fundamental)
|
||||
trait_ref.def_id.is_local() || tcx.trait_def(trait_ref.def_id).is_fundamental
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user