File tree Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Expand file tree Collapse file tree 3 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 1+ // Regression test for <https://github.com/rust-lang/rust/issues/104923>
2+ // ignore-tidy-linelength
3+
4+ #![ feature( trait_alias) ]
5+
6+ // @set Orig = "$.index[*][?(@.name == 'Orig')].id"
7+ // @is "$.index[*][?(@.name == 'Orig')].kind" '"trait"'
8+ pub trait Orig < T > { }
9+
10+ // @set Alias = "$.index[*][?(@.name == 'Alias')].id"
11+ // @is "$.index[*][?(@.name == 'Alias')].kind" '"trait_alias"'
12+ // @is "$.index[*][?(@.name == 'Alias')].inner.generics" '{"params": [], "where_predicates": []}'
13+ // @count "$.index[*][?(@.name == 'Alias')].inner.params[*]" 1
14+ // @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.id" $Orig
15+ // @is "$.index[*][?(@.name == 'Alias')].inner.params[0].trait_bound.trait.args.angle_bracketed.args[0].type.inner" '"i32"'
16+ pub trait Alias = Orig < i32 > ;
17+
18+ pub struct Struct ;
19+
20+ impl Orig < i32 > for Struct { }
21+
22+ // @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].kind" '"impl_trait"'
23+ // @is "$.index[*][?(@.name=='takes_alias')].inner.decl.inputs[0][1].inner[0].trait_bound.trait.id" $Alias
24+ // @is "$.index[*][?(@.name=='takes_alias')].inner.generics.params[0].kind.type.bounds[0].trait_bound.trait.id" $Alias
25+ pub fn takes_alias ( _: impl Alias ) { }
26+ // FIXME: Should the trait be mentioned in both the decl and generics?
27+
28+ fn main ( ) {
29+ takes_alias ( Struct ) ;
30+ }
Original file line number Diff line number Diff line change @@ -111,8 +111,8 @@ impl Kind {
111111 pub fn is_variant ( self ) -> bool {
112112 matches ! ( self , Kind :: Variant )
113113 }
114- pub fn is_trait ( self ) -> bool {
115- matches ! ( self , Kind :: Trait )
114+ pub fn is_trait_or_alias ( self ) -> bool {
115+ matches ! ( self , Kind :: Trait | Kind :: TraitAlias )
116116 }
117117 pub fn is_type ( self ) -> bool {
118118 matches ! ( self , Kind :: Struct | Kind :: Enum | Kind :: Union | Kind :: Typedef )
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ impl<'a> Validator<'a> {
266266
267267 fn check_path ( & mut self , x : & ' a Path , kind : PathKind ) {
268268 match kind {
269- PathKind :: Trait => self . add_trait_id ( & x. id ) ,
269+ PathKind :: Trait => self . add_trait_or_alias_id ( & x. id ) ,
270270 PathKind :: Type => self . add_type_id ( & x. id ) ,
271271 }
272272 if let Some ( args) = & x. args {
@@ -391,8 +391,8 @@ impl<'a> Validator<'a> {
391391 self . add_id_checked ( id, Kind :: is_variant, "Variant" ) ;
392392 }
393393
394- fn add_trait_id ( & mut self , id : & ' a Id ) {
395- self . add_id_checked ( id, Kind :: is_trait , "Trait" ) ;
394+ fn add_trait_or_alias_id ( & mut self , id : & ' a Id ) {
395+ self . add_id_checked ( id, Kind :: is_trait_or_alias , "Trait (or TraitAlias) " ) ;
396396 }
397397
398398 fn add_type_id ( & mut self , id : & ' a Id ) {
You can’t perform that action at this time.
0 commit comments