@@ -33,11 +33,33 @@ pub struct TraitDef {
33
33
/// and thus `impl`s of it are allowed to overlap.
34
34
pub is_marker : bool ,
35
35
36
+ /// Used to determine whether the standard library is allowed to specialize
37
+ /// on this trait.
38
+ pub specialization_kind : TraitSpecializationKind ,
39
+
36
40
/// The ICH of this trait's DefPath, cached here so it doesn't have to be
37
41
/// recomputed all the time.
38
42
pub def_path_hash : DefPathHash ,
39
43
}
40
44
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
+
41
63
#[ derive( Default ) ]
42
64
pub struct TraitImpls {
43
65
blanket_impls : Vec < DefId > ,
@@ -52,9 +74,18 @@ impl<'tcx> TraitDef {
52
74
paren_sugar : bool ,
53
75
has_auto_impl : bool ,
54
76
is_marker : bool ,
77
+ specialization_kind : TraitSpecializationKind ,
55
78
def_path_hash : DefPathHash ,
56
79
) -> 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
+ }
58
89
}
59
90
60
91
pub fn ancestors (
0 commit comments