File tree Expand file tree Collapse file tree
rustc_hir_analysis/src/outlives Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,3 +164,17 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
164164 ] ) ;
165165 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcEvaluateWhereClauses ;
166166}
167+
168+ pub ( crate ) struct RustcOutlivesParser ;
169+
170+ impl < S : Stage > NoArgsAttributeParser < S > for RustcOutlivesParser {
171+ const PATH : & [ Symbol ] = & [ sym:: rustc_outlives] ;
172+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
173+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
174+ Allow ( Target :: Struct ) ,
175+ Allow ( Target :: Enum ) ,
176+ Allow ( Target :: Union ) ,
177+ Allow ( Target :: TyAlias ) ,
178+ ] ) ;
179+ const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcOutlives ;
180+ }
Original file line number Diff line number Diff line change @@ -271,6 +271,7 @@ attribute_parsers!(
271271 Single <WithoutArgs <RustcNonConstTraitMethodParser >>,
272272 Single <WithoutArgs <RustcNounwindParser >>,
273273 Single <WithoutArgs <RustcOffloadKernelParser >>,
274+ Single <WithoutArgs <RustcOutlivesParser >>,
274275 Single <WithoutArgs <RustcPassIndirectlyInNonRusticAbisParser >>,
275276 Single <WithoutArgs <RustcPreserveUbChecksParser >>,
276277 Single <WithoutArgs <RustcReallocatorParser >>,
Original file line number Diff line number Diff line change @@ -1169,6 +1169,9 @@ pub enum AttributeKind {
11691169 /// Represents `#[rustc_offload_kernel]`
11701170 RustcOffloadKernel ,
11711171
1172+ /// Represents `#[rustc_outlives]`
1173+ RustcOutlives ,
1174+
11721175 /// Represents `#[rustc_paren_sugar]`.
11731176 RustcParenSugar ( Span ) ,
11741177
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ impl AttributeKind {
137137 RustcObjcSelector { .. } => No ,
138138 RustcObjectLifetimeDefault => No ,
139139 RustcOffloadKernel => Yes ,
140+ RustcOutlives => No ,
140141 RustcParenSugar ( ..) => No ,
141142 RustcPassByValue ( ..) => Yes ,
142143 RustcPassIndirectlyInNonRusticAbis ( ..) => No ,
Original file line number Diff line number Diff line change 1+ use rustc_hir:: attrs:: AttributeKind ;
2+ use rustc_hir:: find_attr;
13use rustc_middle:: bug;
24use rustc_middle:: ty:: { self , TyCtxt } ;
35use rustc_span:: sym;
46
57pub ( crate ) fn inferred_outlives ( tcx : TyCtxt < ' _ > ) {
68 for id in tcx. hir_free_items ( ) {
7- if !tcx. has_attr ( id. owner_id , sym :: rustc_outlives ) {
9+ if !find_attr ! ( tcx. get_all_attrs ( id. owner_id) , AttributeKind :: RustcOutlives ) {
810 continue ;
911 }
1012
Original file line number Diff line number Diff line change @@ -329,6 +329,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
329329 | AttributeKind :: RustcObjcClass { .. }
330330 | AttributeKind :: RustcObjcSelector { .. }
331331 | AttributeKind :: RustcOffloadKernel
332+ | AttributeKind :: RustcOutlives
332333 | AttributeKind :: RustcParenSugar ( ..)
333334 | AttributeKind :: RustcPassByValue ( ..)
334335 | AttributeKind :: RustcPassIndirectlyInNonRusticAbis ( ..)
@@ -404,7 +405,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
404405 | sym:: rustc_strict_coherence
405406 | sym:: rustc_mir
406407 | sym:: rustc_effective_visibility
407- | sym:: rustc_outlives
408408 | sym:: rustc_symbol_name
409409 | sym:: rustc_def_path
410410 | sym:: rustc_partition_reused
You can’t perform that action at this time.
0 commit comments