|
1 |
| -use rustc_ast::{MetaItemInner, MetaItemKind, ast, attr}; |
2 |
| -use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr, list_contains_name}; |
| 1 | +use rustc_ast::{ast, attr, MetaItemInner, MetaItemKind}; |
| 2 | +use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr}; |
3 | 3 | use rustc_data_structures::fx::FxHashMap;
|
4 | 4 | use rustc_errors::codes::*;
|
5 |
| -use rustc_errors::{DiagMessage, SubdiagMessage, struct_span_code_err}; |
| 5 | +use rustc_errors::{struct_span_code_err, DiagMessage, SubdiagMessage}; |
6 | 6 | use rustc_hir as hir;
|
7 | 7 | use rustc_hir::def::DefKind;
|
8 |
| -use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; |
| 8 | +use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; |
9 | 9 | use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
|
10 |
| -use rustc_hir::{LangItem, lang_items}; |
| 10 | +use rustc_hir::{lang_items, LangItem}; |
11 | 11 | use rustc_middle::middle::codegen_fn_attrs::{
|
12 | 12 | CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry,
|
13 | 13 | };
|
14 | 14 | use rustc_middle::mir::mono::Linkage;
|
15 | 15 | use rustc_middle::query::Providers;
|
16 | 16 | use rustc_middle::ty::{self as ty, TyCtxt};
|
17 | 17 | use rustc_session::parse::feature_err;
|
18 |
| -use rustc_session::{Session, lint}; |
| 18 | +use rustc_session::{lint, Session}; |
19 | 19 | use rustc_span::symbol::Ident;
|
20 |
| -use rustc_span::{Span, sym}; |
21 |
| -use rustc_target::spec::{SanitizerSet, abi}; |
| 20 | +use rustc_span::{sym, Span}; |
| 21 | +use rustc_target::spec::{abi, SanitizerSet}; |
22 | 22 |
|
23 | 23 | use crate::errors;
|
24 | 24 | use crate::target_features::{check_target_feature_trait_unsafe, from_target_feature_attr};
|
@@ -376,10 +376,29 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
376 | 376 | Some(InstructionSetAttr::ArmA32)
|
377 | 377 | } else if segments[1] == sym::t32 {
|
378 | 378 | Some(InstructionSetAttr::ArmT32)
|
| 379 | + } else if segments[1] != sym::a32 || segments[1] != sym::t32 { |
| 380 | + struct_span_code_err!( |
| 381 | + tcx.dcx(), |
| 382 | + attr.span, |
| 383 | + E0779, |
| 384 | + "`[instruction_set]` attribute argument should be valid" |
| 385 | + ) |
| 386 | + .emit(); |
| 387 | + None |
379 | 388 | } else {
|
380 | 389 | unreachable!()
|
381 | 390 | }
|
382 | 391 | }
|
| 392 | + [] => { |
| 393 | + struct_span_code_err!( |
| 394 | + tcx.dcx(), |
| 395 | + attr.span, |
| 396 | + E0778, |
| 397 | + "`[instruction_set]` requires an argument" |
| 398 | + ) |
| 399 | + .emit(); |
| 400 | + None |
| 401 | + } |
383 | 402 | _ => None,
|
384 | 403 | }
|
385 | 404 | }
|
|
0 commit comments