Skip to content

Commit eab26e3

Browse files
committed
Port rustc_no_mir_inline to the new attribute parser
1 parent f4c135f commit eab26e3

6 files changed

Lines changed: 41 additions & 31 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,21 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcTrivialFieldReadsParser {
511511
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcTrivialFieldReads;
512512
}
513513

514+
pub(crate) struct RustcNoMirInlineParser;
515+
516+
impl<S: Stage> NoArgsAttributeParser<S> for RustcNoMirInlineParser {
517+
const PATH: &[Symbol] = &[sym::rustc_no_mir_inline];
518+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
519+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
520+
Allow(Target::Fn),
521+
Allow(Target::Method(MethodKind::Inherent)),
522+
Allow(Target::Method(MethodKind::Trait { body: false })),
523+
Allow(Target::Method(MethodKind::Trait { body: true })),
524+
Allow(Target::Method(MethodKind::TraitImpl)),
525+
]);
526+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoMirInline;
527+
}
528+
514529
pub(crate) struct RustcLintQueryInstabilityParser;
515530

516531
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintQueryInstabilityParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -169,32 +169,6 @@ attribute_parsers!(
169169
// tidy-alphabetical-end
170170

171171
// tidy-alphabetical-start
172-
%%%%%%% Changes from base to side #1
173-
%%%%%%%%%%% Changes from base to side #1
174-
Single<WithoutArgs<RustcStrictCoherenceParser>>,
175-
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
176-
Single<WithoutArgs<RustcVarianceParser>>,
177-
Single<WithoutArgs<SpecializationTraitParser>>,
178-
Single<WithoutArgs<StdInternalSymbolParser>>,
179-
Single<WithoutArgs<ThreadLocalParser>>,
180-
Single<WithoutArgs<TrackCallerParser>>,
181-
+ Single<WithoutArgs<RustcStrictCoherenceParser>>,
182-
+++++++ Contents of side #2
183-
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
184-
+++++++++++ Contents of side #2
185-
- Single<WithoutArgs<TypeConstParser>>,
186-
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
187-
<<<<<<< Conflict 1 of 1
188-
<<<<<<<<<<< Conflict 2 of 2
189-
>>>>>>> Conflict 1 of 1 ends
190-
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
191-
Single<WithoutArgs<RustcVarianceParser>>,
192-
Single<WithoutArgs<SpecializationTraitParser>>,
193-
Single<WithoutArgs<StdInternalSymbolParser>>,
194-
Single<WithoutArgs<ThreadLocalParser>>,
195-
Single<WithoutArgs<TrackCallerParser>>,
196-
Single<WithoutArgs<TypeConstParser>>,
197-
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
198172
Single<CfiEncodingParser>,
199173
Single<CollapseDebugInfoParser>,
200174
Single<CoverageParser>,
@@ -237,9 +211,9 @@ attribute_parsers!(
237211
Single<RustcLintOptDenyFieldAccessParser>,
238212
Single<RustcMustImplementOneOfParser>,
239213
Single<RustcNeverTypeOptionsParser>,
214+
Single<RustcNeverTypeOptionsParser>,
240215
Single<RustcObjectLifetimeDefaultParser>,
241216
Single<RustcReservationImplParser>,
242-
Single<RustcNeverTypeOptionsParser>,
243217
Single<RustcScalableVectorParser>,
244218
Single<RustcSimdMonomorphizeLaneLimitParser>,
245219
Single<RustcSymbolName>,
@@ -315,6 +289,7 @@ attribute_parsers!(
315289
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
316290
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
317291
Single<WithoutArgs<RustcNoImplicitBoundsParser>>,
292+
Single<WithoutArgs<RustcNoMirInlineParser>>,
318293
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
319294
Single<WithoutArgs<RustcNounwindParser>>,
320295
Single<WithoutArgs<RustcOffloadKernelParser>>,
@@ -324,7 +299,23 @@ attribute_parsers!(
324299
Single<WithoutArgs<RustcReallocatorParser>>,
325300
Single<WithoutArgs<RustcRegionsParser>>,
326301
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
327-
>>>>>>>>>>> Conflict 2 of 2 ends
302+
Single<WithoutArgs<RustcStrictCoherenceParser>>,
303+
Single<WithoutArgs<RustcStrictCoherenceParser>>,
304+
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
305+
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
306+
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
307+
Single<WithoutArgs<RustcVarianceParser>>,
308+
Single<WithoutArgs<RustcVarianceParser>>,
309+
Single<WithoutArgs<SpecializationTraitParser>>,
310+
Single<WithoutArgs<SpecializationTraitParser>>,
311+
Single<WithoutArgs<StdInternalSymbolParser>>,
312+
Single<WithoutArgs<StdInternalSymbolParser>>,
313+
Single<WithoutArgs<ThreadLocalParser>>,
314+
Single<WithoutArgs<ThreadLocalParser>>,
315+
Single<WithoutArgs<TrackCallerParser>>,
316+
Single<WithoutArgs<TrackCallerParser>>,
317+
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
318+
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
328319
// tidy-alphabetical-end
329320
];
330321
);

compiler/rustc_hir/src/attrs/data_structures.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,9 @@ pub enum AttributeKind {
12491249
/// Represents `#[rustc_no_implicit_bounds]`
12501250
RustcNoImplicitBounds,
12511251

1252+
/// Represents `#[rustc_no_mir_inline]`
1253+
RustcNoMirInline,
1254+
12521255
/// Represents `#[rustc_non_const_trait_method]`.
12531256
RustcNonConstTraitMethod,
12541257

compiler/rustc_hir/src/attrs/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl AttributeKind {
143143
RustcNeverTypeOptions { .. } => No,
144144
RustcNoImplicitAutorefs => Yes,
145145
RustcNoImplicitBounds => No,
146+
RustcNoMirInline => Yes,
146147
RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
147148
RustcNounwind => No,
148149
RustcObjcClass { .. } => No,

compiler/rustc_mir_transform/src/check_inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
88
use rustc_middle::mir::{Body, TerminatorKind};
99
use rustc_middle::ty;
1010
use rustc_middle::ty::TyCtxt;
11-
use rustc_span::sym;
1211

1312
use crate::pass_manager::MirLint;
1413

@@ -42,7 +41,8 @@ pub(super) fn is_inline_valid_on_fn<'tcx>(
4241
def_id: DefId,
4342
) -> Result<(), &'static str> {
4443
let codegen_attrs = tcx.codegen_fn_attrs(def_id);
45-
if tcx.has_attr(def_id, sym::rustc_no_mir_inline) {
44+
45+
if find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcNoMirInline) {
4646
return Err("#[rustc_no_mir_inline]");
4747
}
4848

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
336336
| AttributeKind::RustcNeverTypeOptions {..}
337337
| AttributeKind::RustcNoImplicitAutorefs
338338
| AttributeKind::RustcNoImplicitBounds
339+
| AttributeKind::RustcNoMirInline
339340
| AttributeKind::RustcNonConstTraitMethod
340341
| AttributeKind::RustcNounwind
341342
| AttributeKind::RustcObjcClass { .. }
@@ -397,7 +398,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
397398
| sym::lang
398399
| sym::default_lib_allocator
399400
| sym::rustc_diagnostic_item
400-
| sym::rustc_no_mir_inline
401401
| sym::rustc_nonnull_optimization_guaranteed
402402
| sym::rustc_inherit_overflow_checks
403403
| sym::rustc_on_unimplemented

0 commit comments

Comments
 (0)