Skip to content

Commit 62c6e4e

Browse files
committed
Add an is_marker flag to TraitDef
1 parent ed45f9c commit 62c6e4e

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ impl_stable_hash_for!(struct ty::TraitDef {
10331033
unsafety,
10341034
paren_sugar,
10351035
has_auto_impl,
1036+
is_marker,
10361037
def_path_hash,
10371038
});
10381039

src/librustc/ty/trait_def.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ pub struct TraitDef {
3636

3737
pub has_auto_impl: bool,
3838

39+
/// If `true`, then this trait has the `#[marker]` attribute, indicating
40+
/// that all its associated items have defaults that cannot be overridden,
41+
/// and thus `impl`s of it are allowed to overlap.
42+
pub is_marker: bool,
43+
3944
/// The ICH of this trait's DefPath, cached here so it doesn't have to be
4045
/// recomputed all the time.
4146
pub def_path_hash: DefPathHash,
@@ -53,13 +58,15 @@ impl<'a, 'gcx, 'tcx> TraitDef {
5358
unsafety: hir::Unsafety,
5459
paren_sugar: bool,
5560
has_auto_impl: bool,
61+
is_marker: bool,
5662
def_path_hash: DefPathHash)
5763
-> TraitDef {
5864
TraitDef {
5965
def_id,
60-
paren_sugar,
6166
unsafety,
67+
paren_sugar,
6268
has_auto_impl,
69+
is_marker,
6370
def_path_hash,
6471
}
6572
}

src/librustc_metadata/decoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ impl<'a, 'tcx> CrateMetadata {
539539
data.unsafety,
540540
data.paren_sugar,
541541
data.has_auto_impl,
542+
data.is_marker,
542543
self.def_path_table.def_path_hash(item_id))
543544
}
544545

src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
11521152
unsafety: trait_def.unsafety,
11531153
paren_sugar: trait_def.paren_sugar,
11541154
has_auto_impl: tcx.trait_is_auto(def_id),
1155+
is_marker: trait_def.is_marker,
11551156
super_predicates: self.lazy(&tcx.super_predicates_of(def_id)),
11561157
};
11571158

src/librustc_metadata/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,15 @@ pub struct TraitData<'tcx> {
472472
pub unsafety: hir::Unsafety,
473473
pub paren_sugar: bool,
474474
pub has_auto_impl: bool,
475+
pub is_marker: bool,
475476
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
476477
}
477478

478479
impl_stable_hash_for!(struct TraitData<'tcx> {
479480
unsafety,
480481
paren_sugar,
481482
has_auto_impl,
483+
is_marker,
482484
super_predicates
483485
});
484486

src/librustc_typeck/collect.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,10 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::
735735
err.emit();
736736
}
737737

738+
let is_marker = false; // FIXME (scottmcm)
739+
738740
let def_path_hash = tcx.def_path_hash(def_id);
739-
let def = ty::TraitDef::new(def_id, unsafety, paren_sugar, is_auto, def_path_hash);
741+
let def = ty::TraitDef::new(def_id, unsafety, paren_sugar, is_auto, is_marker, def_path_hash);
740742
tcx.alloc_trait_def(def)
741743
}
742744

0 commit comments

Comments
 (0)