Skip to content

Commit fa91a4d

Browse files
committed
Parse #[rustc_evaluate_where_clauses]
1 parent 2f214f4 commit fa91a4d

6 files changed

Lines changed: 27 additions & 3 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/test_attrs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,18 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDelayedBugFromInsideQueryParser
199199
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
200200
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDelayedBugFromInsideQuery;
201201
}
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+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ attribute_parsers!(
261261
Single<WithoutArgs<RustcDumpUserArgsParser>>,
262262
Single<WithoutArgs<RustcDumpVtableParser>>,
263263
Single<WithoutArgs<RustcEffectiveVisibilityParser>>,
264+
Single<WithoutArgs<RustcEvaluateWhereClausesParser>>,
264265
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
265266
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
266267
Single<WithoutArgs<RustcLintOptTyParser>>,

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,9 @@ pub enum AttributeKind {
11111111
/// Represents `#[rustc_effective_visibility]`.
11121112
RustcEffectiveVisibility,
11131113

1114+
/// Represents `#[rustc_evaluate_where_clauses]`
1115+
RustcEvaluateWhereClauses,
1116+
11141117
/// Represents `#[rustc_has_incoherent_inherent_impls]`
11151118
RustcHasIncoherentInherentImpls,
11161119

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ impl AttributeKind {
115115
RustcDumpVtable(..) => No,
116116
RustcDynIncompatibleTrait(..) => No,
117117
RustcEffectiveVisibility => Yes,
118+
RustcEvaluateWhereClauses => Yes,
118119
RustcHasIncoherentInherentImpls => Yes,
119120
RustcHiddenTypeOfOpaques => No,
120121
RustcIfThisChanged(..) => No,

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_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
310310
| AttributeKind::RustcDumpVtable(..)
311311
| AttributeKind::RustcDynIncompatibleTrait(..)
312312
| AttributeKind::RustcEffectiveVisibility
313+
| AttributeKind::RustcEvaluateWhereClauses
313314
| AttributeKind::RustcHasIncoherentInherentImpls
314315
| AttributeKind::RustcHiddenTypeOfOpaques
315316
| AttributeKind::RustcIfThisChanged(..)
@@ -405,7 +406,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
405406
| sym::rustc_mir
406407
| sym::rustc_outlives
407408
| sym::rustc_symbol_name
408-
| sym::rustc_evaluate_where_clauses
409409
| sym::rustc_def_path
410410
| sym::rustc_partition_reused
411411
| sym::rustc_partition_codegened

0 commit comments

Comments
 (0)