@@ -1207,25 +1207,29 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
1207
1207
fn trait_def ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> ty:: TraitDef {
1208
1208
let item = tcx. hir ( ) . expect_item ( def_id) ;
1209
1209
1210
- let ( is_auto, safety, items) = match item. kind {
1210
+ let ( is_alias , is_auto, safety, items) = match item. kind {
1211
1211
hir:: ItemKind :: Trait ( is_auto, safety, .., items) => {
1212
- ( is_auto == hir:: IsAuto :: Yes , safety, items)
1212
+ ( false , is_auto == hir:: IsAuto :: Yes , safety, items)
1213
1213
}
1214
- hir:: ItemKind :: TraitAlias ( ..) => ( false , hir:: Safety :: Safe , & [ ] [ ..] ) ,
1214
+ hir:: ItemKind :: TraitAlias ( ..) => ( true , false , hir:: Safety :: Safe , & [ ] [ ..] ) ,
1215
1215
_ => span_bug ! ( item. span, "trait_def_of_item invoked on non-trait" ) ,
1216
1216
} ;
1217
1217
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) {
1219
1220
hir:: Constness :: Const
1220
1221
} else {
1221
1222
hir:: Constness :: NotConst
1222
1223
} ;
1224
+
1223
1225
let paren_sugar = tcx. has_attr ( def_id, sym:: rustc_paren_sugar) ;
1224
1226
if paren_sugar && !tcx. features ( ) . unboxed_closures {
1225
1227
tcx. dcx ( ) . emit_err ( errors:: ParenSugarAttribute { span : item. span } ) ;
1226
1228
}
1227
1229
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
+
1229
1233
let rustc_coinductive = tcx. has_attr ( def_id, sym:: rustc_coinductive) ;
1230
1234
let is_fundamental = tcx. has_attr ( def_id, sym:: fundamental) ;
1231
1235
0 commit comments