Skip to content

Commit 9ac8b19

Browse files
committed
Parse #[rustc_evaluate_where_clauses]
1 parent 8a54dd2 commit 9ac8b19

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
@@ -149,3 +149,18 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcDelayedBugFromInsideQueryParser
149149
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
150150
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcDelayedBugFromInsideQuery;
151151
}
152+
153+
pub(crate) struct RustcEvaluateWhereClausesParser;
154+
155+
impl<S: Stage> NoArgsAttributeParser<S> for RustcEvaluateWhereClausesParser {
156+
const PATH: &[Symbol] = &[sym::rustc_evaluate_where_clauses];
157+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
158+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
159+
Allow(Target::Fn),
160+
Allow(Target::Method(MethodKind::Inherent)),
161+
Allow(Target::Method(MethodKind::Trait { body: true })),
162+
Allow(Target::Method(MethodKind::TraitImpl)),
163+
Allow(Target::Method(MethodKind::Trait { body: false })),
164+
]);
165+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEvaluateWhereClauses;
166+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ attribute_parsers!(
259259
Single<WithoutArgs<RustcDumpPredicatesParser>>,
260260
Single<WithoutArgs<RustcDumpUserArgsParser>>,
261261
Single<WithoutArgs<RustcDumpVtableParser>>,
262+
Single<WithoutArgs<RustcEvaluateWhereClausesParser>>,
262263
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
263264
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
264265
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
@@ -1097,6 +1097,9 @@ pub enum AttributeKind {
10971097
/// Represents `#[rustc_dyn_incompatible_trait]`.
10981098
RustcDynIncompatibleTrait(Span),
10991099

1100+
/// Represents `#[rustc_evaluate_where_clauses]`
1101+
RustcEvaluateWhereClauses,
1102+
11001103
/// Represents `#[rustc_has_incoherent_inherent_impls]`
11011104
RustcHasIncoherentInherentImpls,
11021105

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl AttributeKind {
113113
RustcDumpUserArgs => No,
114114
RustcDumpVtable(..) => No,
115115
RustcDynIncompatibleTrait(..) => No,
116+
RustcEvaluateWhereClauses => Yes,
116117
RustcHasIncoherentInherentImpls => Yes,
117118
RustcHiddenTypeOfOpaques => No,
118119
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
@@ -308,6 +308,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
308308
| AttributeKind::RustcDumpUserArgs
309309
| AttributeKind::RustcDumpVtable(..)
310310
| AttributeKind::RustcDynIncompatibleTrait(..)
311+
| AttributeKind::RustcEvaluateWhereClauses
311312
| AttributeKind::RustcHasIncoherentInherentImpls
312313
| AttributeKind::RustcHiddenTypeOfOpaques
313314
| AttributeKind::RustcIfThisChanged(..)
@@ -405,7 +406,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
405406
| sym::rustc_effective_visibility
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)