@@ -33,11 +33,33 @@ pub struct TraitDef {
3333 /// and thus `impl`s of it are allowed to overlap.
3434 pub is_marker : bool ,
3535
36+ /// Used to determine whether the standard library is allowed to specialize
37+ /// on this trait.
38+ pub specialization_kind : TraitSpecializationKind ,
39+
3640 /// The ICH of this trait's DefPath, cached here so it doesn't have to be
3741 /// recomputed all the time.
3842 pub def_path_hash : DefPathHash ,
3943}
4044
45+ /// Whether this trait is treated specially by the standard library
46+ /// specialization lint.
47+ #[ derive( HashStable , PartialEq , Clone , Copy , RustcEncodable , RustcDecodable ) ]
48+ pub enum TraitSpecializationKind {
49+ /// The default. Specializing on this trait is not allowed.
50+ None ,
51+ /// Specializing on this trait is allowed because it doesn't have any
52+ /// methods. For example `Sized` or `FusedIterator`.
53+ /// Applies to traits with the `rustc_unsafe_specialization_marker`
54+ /// attribute.
55+ Marker ,
56+ /// Specializing on this trait is allowed because all of the impls of this
57+ /// trait are "always applicable". Always applicable means that if
58+ /// `X<'x>: T<'y>` for any lifetimes, then `for<'a, 'b> X<'a>: T<'b>`.
59+ /// Applies to traits with the `rustc_specialization_trait` attribute.
60+ AlwaysApplicable ,
61+ }
62+
4163#[ derive( Default ) ]
4264pub struct TraitImpls {
4365 blanket_impls : Vec < DefId > ,
@@ -52,9 +74,18 @@ impl<'tcx> TraitDef {
5274 paren_sugar : bool ,
5375 has_auto_impl : bool ,
5476 is_marker : bool ,
77+ specialization_kind : TraitSpecializationKind ,
5578 def_path_hash : DefPathHash ,
5679 ) -> TraitDef {
57- TraitDef { def_id, unsafety, paren_sugar, has_auto_impl, is_marker, def_path_hash }
80+ TraitDef {
81+ def_id,
82+ unsafety,
83+ paren_sugar,
84+ has_auto_impl,
85+ is_marker,
86+ specialization_kind,
87+ def_path_hash,
88+ }
5889 }
5990
6091 pub fn ancestors (
0 commit comments