Skip to content

Commit 1d023ec

Browse files
authored
Unrolled build for #152212
Rollup merge of #152212 - Ozzy1423:three-attrs, r=JonathanBrouwer Port some attributes to the attr parser Tracking issue: #131229 r? @JonathanBrouwer
2 parents 286fbe5 + 6361d5f commit 1d023ec

File tree

8 files changed

+67
-8
lines changed

8 files changed

+67
-8
lines changed

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,41 @@ impl<S: Stage> SingleAttributeParser<S> for RustcAbiParser {
190190
Some(AttributeKind::RustcAbi { attr_span: cx.attr_span, kind })
191191
}
192192
}
193+
194+
pub(crate) struct RustcDelayedBugFromInsideQueryParser;
195+
196+
impl<S: Stage> NoArgsAttributeParser<S> for RustcDelayedBugFromInsideQueryParser {
197+
const PATH: &[Symbol] = &[sym::rustc_delayed_bug_from_inside_query];
198+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
199+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
200+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDelayedBugFromInsideQuery;
201+
}
202+
203+
pub(crate) struct RustcEvaluateWhereClausesParser;
204+
205+
impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
206+
const PATH: &[Symbol] = &[sym::rustc_evaluate_where_clauses];
207+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
208+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
209+
Allow(Target::Fn),
210+
Allow(Target::Method(MethodKind::Inherent)),
211+
Allow(Target::Method(MethodKind::Trait { body: true })),
212+
Allow(Target::Method(MethodKind::TraitImpl)),
213+
Allow(Target::Method(MethodKind::Trait { body: false })),
214+
]);
215+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEvaluateWhereClauses;
216+
}
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+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,14 @@ attribute_parsers!(
262262
Single<WithoutArgs<RustcAllocatorZeroedParser>>,
263263
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
264264
Single<WithoutArgs<RustcDeallocatorParser>>,
265+
Single<WithoutArgs<RustcDelayedBugFromInsideQueryParser>>,
265266
Single<WithoutArgs<RustcDumpDefParentsParser>>,
266267
Single<WithoutArgs<RustcDumpItemBoundsParser>>,
267268
Single<WithoutArgs<RustcDumpPredicatesParser>>,
268269
Single<WithoutArgs<RustcDumpUserArgsParser>>,
269270
Single<WithoutArgs<RustcDumpVtableParser>>,
270271
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
272+
Single<WithoutArgs<RustcEvaluateWhereClausesParser>>,
271273
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
272274
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
273275
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
@@ -281,6 +283,7 @@ attribute_parsers!(
281283
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
282284
Single<WithoutArgs<RustcNounwindParser>>,
283285
Single<WithoutArgs<RustcOffloadKernelParser>>,
286+
Single<WithoutArgs<RustcOutlivesParser>>,
284287
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
285288
Single<WithoutArgs<RustcPreserveUbChecksParser>>,
286289
Single<WithoutArgs<RustcReallocatorParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,9 @@ pub enum AttributeKind {
10841084
/// Represents `#[rustc_def_path]`
10851085
RustcDefPath(Span),
10861086

1087+
/// Represents `#[rustc_delayed_bug_from_inside_query]`
1088+
RustcDelayedBugFromInsideQuery,
1089+
10871090
/// Represents `#[rustc_deny_explicit_impl]`.
10881091
RustcDenyExplicitImpl(Span),
10891092

@@ -1111,6 +1114,9 @@ pub enum AttributeKind {
11111114
/// Represents `#[rustc_effective_visibility]`.
11121115
RustcEffectiveVisibility,
11131116

1117+
/// Represents `#[rustc_evaluate_where_clauses]`
1118+
RustcEvaluateWhereClauses,
1119+
11141120
/// Represents `#[rustc_has_incoherent_inherent_impls]`
11151121
RustcHasIncoherentInherentImpls,
11161122

@@ -1186,6 +1192,9 @@ pub enum AttributeKind {
11861192
/// Represents `#[rustc_offload_kernel]`
11871193
RustcOffloadKernel,
11881194

1195+
/// Represents `#[rustc_outlives]`
1196+
RustcOutlives,
1197+
11891198
/// Represents `#[rustc_paren_sugar]`.
11901199
RustcParenSugar(Span),
11911200

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl AttributeKind {
106106
RustcConstStabilityIndirect => No,
107107
RustcDeallocator => No,
108108
RustcDefPath(..) => No,
109+
RustcDelayedBugFromInsideQuery => No,
109110
RustcDenyExplicitImpl(..) => No,
110111
RustcDummy => No,
111112
RustcDumpDefParents => No,
@@ -115,6 +116,7 @@ impl AttributeKind {
115116
RustcDumpVtable(..) => No,
116117
RustcDynIncompatibleTrait(..) => No,
117118
RustcEffectiveVisibility => Yes,
119+
RustcEvaluateWhereClauses => Yes,
118120
RustcHasIncoherentInherentImpls => Yes,
119121
RustcHiddenTypeOfOpaques => No,
120122
RustcIfThisChanged(..) => No,
@@ -140,6 +142,7 @@ impl AttributeKind {
140142
RustcObjcSelector { .. } => No,
141143
RustcObjectLifetimeDefault => No,
142144
RustcOffloadKernel => Yes,
145+
RustcOutlives => No,
143146
RustcParenSugar(..) => No,
144147
RustcPassByValue(..) => Yes,
145148
RustcPassIndirectlyInNonRusticAbis(..) => No,

compiler/rustc_hir_analysis/src/outlives/dump.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use rustc_hir::attrs::AttributeKind;
2+
use rustc_hir::find_attr;
13
use rustc_middle::bug;
24
use rustc_middle::ty::{self, TyCtxt};
35
use rustc_span::sym;
46

57
pub(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

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use std::iter;
33
use rustc_abi::{CanonAbi, ExternAbi};
44
use rustc_ast::util::parser::ExprPrecedence;
55
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, inline_fluent};
6+
use rustc_hir::attrs::AttributeKind;
67
use rustc_hir::def::{self, CtorKind, Namespace, Res};
78
use rustc_hir::def_id::DefId;
8-
use rustc_hir::{self as hir, HirId, LangItem};
9+
use rustc_hir::{self as hir, HirId, LangItem, find_attr};
910
use rustc_hir_analysis::autoderef::Autoderef;
1011
use rustc_infer::infer::BoundRegionConversionTime;
1112
use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode};
@@ -526,7 +527,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
526527
// `#[rustc_evaluate_where_clauses]` trigger special output
527528
// to let us test the trait evaluation system.
528529
if self.has_rustc_attrs
529-
&& self.tcx.has_attr(def_id, sym::rustc_evaluate_where_clauses)
530+
&& find_attr!(
531+
self.tcx.get_all_attrs(def_id),
532+
AttributeKind::RustcEvaluateWhereClauses
533+
)
530534
{
531535
let predicates = self.tcx.predicates_of(def_id);
532536
let predicates = predicates.instantiate(self.tcx, args);

compiler/rustc_interface/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use rustc_errors::timings::TimingSection;
1818
use rustc_expand::base::{ExtCtxt, LintStoreExpand};
1919
use rustc_feature::Features;
2020
use rustc_fs_util::try_canonicalize;
21-
use rustc_hir::Attribute;
2221
use rustc_hir::attrs::AttributeKind;
2322
use rustc_hir::def_id::{LOCAL_CRATE, StableCrateId, StableCrateIdMap};
2423
use rustc_hir::definitions::Definitions;
2524
use rustc_hir::limit::Limit;
25+
use rustc_hir::{Attribute, find_attr};
2626
use rustc_incremental::setup_dep_graph;
2727
use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_store};
2828
use rustc_metadata::EncodedMetadata;
@@ -1227,7 +1227,7 @@ pub(crate) fn start_codegen<'tcx>(
12271227

12281228
// Hook for tests.
12291229
if let Some((def_id, _)) = tcx.entry_fn(())
1230-
&& tcx.has_attr(def_id, sym::rustc_delayed_bug_from_inside_query)
1230+
&& find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcDelayedBugFromInsideQuery)
12311231
{
12321232
tcx.ensure_ok().trigger_delayed_bug(def_id);
12331233
}

compiler/rustc_passes/src/check_attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
301301
| AttributeKind::RustcConstStabilityIndirect
302302
| AttributeKind::RustcDeallocator
303303
| AttributeKind::RustcDefPath(..)
304+
| AttributeKind::RustcDelayedBugFromInsideQuery
304305
| AttributeKind::RustcDenyExplicitImpl(..)
305306
| AttributeKind::RustcDummy
306307
| AttributeKind::RustcDumpDefParents
@@ -310,6 +311,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
310311
| AttributeKind::RustcDumpVtable(..)
311312
| AttributeKind::RustcDynIncompatibleTrait(..)
312313
| AttributeKind::RustcEffectiveVisibility
314+
| AttributeKind::RustcEvaluateWhereClauses
313315
| AttributeKind::RustcHasIncoherentInherentImpls
314316
| AttributeKind::RustcHiddenTypeOfOpaques
315317
| AttributeKind::RustcIfThisChanged(..)
@@ -332,6 +334,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
332334
| AttributeKind::RustcObjcClass { .. }
333335
| AttributeKind::RustcObjcSelector { .. }
334336
| AttributeKind::RustcOffloadKernel
337+
| AttributeKind::RustcOutlives
335338
| AttributeKind::RustcParenSugar(..)
336339
| AttributeKind::RustcPassByValue (..)
337340
| AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)
@@ -404,9 +407,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
404407
| sym::rustc_capture_analysis
405408
| sym::rustc_strict_coherence
406409
| sym::rustc_mir
407-
| sym::rustc_outlives
408-
| sym::rustc_evaluate_where_clauses
409-
| sym::rustc_delayed_bug_from_inside_query
410410
| sym::rustc_partition_reused
411411
| sym::rustc_partition_codegened
412412
| sym::rustc_expected_cgu_reuse

0 commit comments

Comments
 (0)