@@ -1207,25 +1207,29 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
12071207fn trait_def ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> ty:: TraitDef {
12081208 let item = tcx. hir ( ) . expect_item ( def_id) ;
12091209
1210- let ( is_auto, safety, items) = match item. kind {
1210+ let ( is_alias , is_auto, safety, items) = match item. kind {
12111211 hir:: ItemKind :: Trait ( is_auto, safety, .., items) => {
1212- ( is_auto == hir:: IsAuto :: Yes , safety, items)
1212+ ( false , is_auto == hir:: IsAuto :: Yes , safety, items)
12131213 }
1214- hir:: ItemKind :: TraitAlias ( ..) => ( false , hir:: Safety :: Safe , & [ ] [ ..] ) ,
1214+ hir:: ItemKind :: TraitAlias ( ..) => ( true , false , hir:: Safety :: Safe , & [ ] [ ..] ) ,
12151215 _ => span_bug ! ( item. span, "trait_def_of_item invoked on non-trait" ) ,
12161216 } ;
12171217
1218- let constness = if tcx. has_attr ( def_id, sym:: const_trait) {
1218+ // Only regular traits can be const.
1219+ let constness = if !is_alias && tcx. has_attr ( def_id, sym:: const_trait) {
12191220 hir:: Constness :: Const
12201221 } else {
12211222 hir:: Constness :: NotConst
12221223 } ;
1224+
12231225 let paren_sugar = tcx. has_attr ( def_id, sym:: rustc_paren_sugar) ;
12241226 if paren_sugar && !tcx. features ( ) . unboxed_closures {
12251227 tcx. dcx ( ) . emit_err ( errors:: ParenSugarAttribute { span : item. span } ) ;
12261228 }
12271229
1228- let is_marker = tcx. has_attr ( def_id, sym:: marker) ;
1230+ // Only regular traits can be marker.
1231+ let is_marker = !is_alias && tcx. has_attr ( def_id, sym:: marker) ;
1232+
12291233 let rustc_coinductive = tcx. has_attr ( def_id, sym:: rustc_coinductive) ;
12301234 let is_fundamental = tcx. has_attr ( def_id, sym:: fundamental) ;
12311235
0 commit comments