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 @@ -214,3 +214,17 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
214214 ] ) ;
215215 const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcEvaluateWhereClauses ;
216216}
217+
218+ pub ( crate ) struct RustcOutlivesParser ;
219+
220+ impl < S : Stage > NoArgsAttributeParser < S > for RustcOutlivesParser {
221+ const PATH : & [ Symbol ] = & [ sym:: rustc_outlives] ;
222+ const ON_DUPLICATE : OnDuplicate < S > = OnDuplicate :: Warn ;
223+ const ALLOWED_TARGETS : AllowedTargets = AllowedTargets :: AllowList ( & [
224+ Allow ( Target :: Struct ) ,
225+ Allow ( Target :: Enum ) ,
226+ Allow ( Target :: Union ) ,
227+ Allow ( Target :: TyAlias ) ,
228+ ] ) ;
229+ const CREATE : fn ( Span ) -> AttributeKind = |_| AttributeKind :: RustcOutlives ;
230+ }
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ attribute_parsers!(
273273 Single <WithoutArgs <RustcNonConstTraitMethodParser >>,
274274 Single <WithoutArgs <RustcNounwindParser >>,
275275 Single <WithoutArgs <RustcOffloadKernelParser >>,
276+ Single <WithoutArgs <RustcOutlivesParser >>,
276277 Single <WithoutArgs <RustcPassIndirectlyInNonRusticAbisParser >>,
277278 Single <WithoutArgs <RustcPreserveUbChecksParser >>,
278279 Single <WithoutArgs <RustcReallocatorParser >>,
Original file line number Diff line number Diff line change @@ -1183,6 +1183,9 @@ pub enum AttributeKind {
11831183 /// Represents `#[rustc_offload_kernel]`
11841184 RustcOffloadKernel ,
11851185
1186+ /// Represents `#[rustc_outlives]`
1187+ RustcOutlives ,
1188+
11861189 /// Represents `#[rustc_paren_sugar]`.
11871190 RustcParenSugar ( Span ) ,
11881191
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ impl AttributeKind {
139139 RustcObjcSelector { .. } => No ,
140140 RustcObjectLifetimeDefault => No ,
141141 RustcOffloadKernel => Yes ,
142+ RustcOutlives => No ,
142143 RustcParenSugar ( ..) => No ,
143144 RustcPassByValue ( ..) => Yes ,
144145 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 @@ -331,6 +331,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
331331 | AttributeKind :: RustcObjcClass { .. }
332332 | AttributeKind :: RustcObjcSelector { .. }
333333 | AttributeKind :: RustcOffloadKernel
334+ | AttributeKind :: RustcOutlives
334335 | AttributeKind :: RustcParenSugar ( ..)
335336 | AttributeKind :: RustcPassByValue ( ..)
336337 | AttributeKind :: RustcPassIndirectlyInNonRusticAbis ( ..)
@@ -404,7 +405,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
404405 | sym:: rustc_regions
405406 | sym:: rustc_strict_coherence
406407 | sym:: rustc_mir
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