This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed
rustc_query_system/src/query Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,10 @@ impl Key for (DefId, Option<Ident>) {
178
178
fn default_span ( & self , tcx : TyCtxt < ' _ > ) -> Span {
179
179
tcx. def_span ( self . 0 )
180
180
}
181
+ #[ inline( always) ]
182
+ fn key_as_def_id ( & self ) -> Option < DefId > {
183
+ Some ( self . 0 )
184
+ }
181
185
}
182
186
183
187
impl Key for ( DefId , LocalDefId , Ident ) {
Original file line number Diff line number Diff line change @@ -600,16 +600,23 @@ pub(crate) fn report_cycle<'a>(
600
600
) ) ;
601
601
}
602
602
603
- if !stack. is_empty ( )
604
- && stack. iter ( ) . all ( |entry| {
605
- entry. query . def_kind . map_or ( false , |def_kind| {
606
- matches ! ( def_kind, SimpleDefKind :: TyAlias | SimpleDefKind :: TraitAlias )
607
- } )
603
+ if stack. iter ( ) . all ( |entry| {
604
+ entry. query . def_kind . map_or ( false , |def_kind| {
605
+ matches ! ( def_kind, SimpleDefKind :: TyAlias | SimpleDefKind :: TraitAlias )
608
606
} )
609
- {
610
- err. note ( "type aliases cannot be recursive" ) ;
611
- err. help ( "consider using a struct, enum, or union instead to break the cycle" ) ;
612
- err. help ( "see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information" ) ;
607
+ } ) {
608
+ if stack. iter ( ) . all ( |entry| {
609
+ entry
610
+ . query
611
+ . def_kind
612
+ . map_or ( false , |def_kind| matches ! ( def_kind, SimpleDefKind :: TyAlias ) )
613
+ } ) {
614
+ err. note ( "type aliases cannot be recursive" ) ;
615
+ err. help ( "consider using a struct, enum, or union instead to break the cycle" ) ;
616
+ err. help ( "see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information" ) ;
617
+ } else {
618
+ err. note ( "trait aliases cannot be recursive" ) ;
619
+ }
613
620
}
614
621
615
622
if let Some ( ( span, query) ) = usage {
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ note: ...which requires computing the super traits of `T3`...
30
30
LL | trait T3 = T1 + T3;
31
31
| ^^
32
32
= note: ...which again requires computing the super predicates of `T1`, completing the cycle
33
+ = note: trait aliases cannot be recursive
33
34
note: cycle used when collecting item types in top-level module
34
35
--> $DIR/infinite-trait-alias-recursion.rs:3:1
35
36
|
You can’t perform that action at this time.
0 commit comments