Skip to content

Commit 622ac04

Browse files
committed
Auto merge of rust-lang#140633 - Zalathar:rollup-iay94wa, r=Zalathar
Rollup of 7 pull requests Successful merges: - rust-lang#139675 (Add the AVX10 target features) - rust-lang#140286 (Check if format argument is identifier to avoid error err-emit) - rust-lang#140456 (Fix test simd/extract-insert-dyn on s390x) - rust-lang#140551 (Move some tests out of tests/ui) - rust-lang#140588 (Adjust some ui tests re. target-dependent errors) - rust-lang#140617 (Report the `unsafe_attr_outside_unsafe` lint at the closest node) - rust-lang#140626 (allow `#[rustfmt::skip]` in combination with `#[naked]`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1bea580 + 1239f49 commit 622ac04

File tree

57 files changed

+543
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+543
-226
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct AstValidator<'a> {
8282
/// Used to ban explicit safety on foreign items when the extern block is not marked as unsafe.
8383
extern_mod_safety: Option<Safety>,
8484

85+
lint_node_id: NodeId,
86+
8587
lint_buffer: &'a mut LintBuffer,
8688
}
8789

@@ -826,7 +828,7 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
826828

827829
impl<'a> Visitor<'a> for AstValidator<'a> {
828830
fn visit_attribute(&mut self, attr: &Attribute) {
829-
validate_attr::check_attr(&self.sess.psess, attr);
831+
validate_attr::check_attr(&self.sess.psess, attr, self.lint_node_id);
830832
}
831833

832834
fn visit_ty(&mut self, ty: &'a Ty) {
@@ -839,6 +841,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
839841
self.has_proc_macro_decls = true;
840842
}
841843

844+
let previous_lint_node_id = mem::replace(&mut self.lint_node_id, item.id);
845+
842846
if let Some(ident) = item.kind.ident()
843847
&& attr::contains_name(&item.attrs, sym::no_mangle)
844848
{
@@ -1128,6 +1132,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11281132
}
11291133
_ => visit::walk_item(self, item),
11301134
}
1135+
1136+
self.lint_node_id = previous_lint_node_id;
11311137
}
11321138

11331139
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
@@ -1694,6 +1700,7 @@ pub fn check_crate(
16941700
outer_impl_trait_span: None,
16951701
disallow_tilde_const: Some(TildeConstReason::Item),
16961702
extern_mod_safety: None,
1703+
lint_node_id: CRATE_NODE_ID,
16971704
lint_buffer: lints,
16981705
};
16991706
visit::walk_crate(&mut validator, krate);

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
301301
None
302302
}
303303
("x86", "movrs") if get_version().0 < 20 => None,
304+
("x86", "avx10.1") => Some(LLVMFeature::new("avx10.1-512")),
305+
("x86", "avx10.2") if get_version().0 < 20 => None,
306+
("x86", "avx10.2") if get_version().0 >= 20 => Some(LLVMFeature::new("avx10.2-512")),
304307
(_, s) => Some(LLVMFeature::new(s)),
305308
}
306309
}

compiler/rustc_expand/src/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,12 @@ impl<'a> StripUnconfigured<'a> {
274274
/// is in the original source file. Gives a compiler error if the syntax of
275275
/// the attribute is incorrect.
276276
pub(crate) fn expand_cfg_attr(&self, cfg_attr: &Attribute, recursive: bool) -> Vec<Attribute> {
277-
validate_attr::check_attribute_safety(&self.sess.psess, AttributeSafety::Normal, &cfg_attr);
277+
validate_attr::check_attribute_safety(
278+
&self.sess.psess,
279+
AttributeSafety::Normal,
280+
&cfg_attr,
281+
ast::CRATE_NODE_ID,
282+
);
278283

279284
// A trace attribute left in AST in place of the original `cfg_attr` attribute.
280285
// It can later be used by lints or other diagnostics.

compiler/rustc_expand/src/expand.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,11 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19831983
let mut span: Option<Span> = None;
19841984
while let Some(attr) = attrs.next() {
19851985
rustc_ast_passes::feature_gate::check_attribute(attr, self.cx.sess, features);
1986-
validate_attr::check_attr(&self.cx.sess.psess, attr);
1986+
validate_attr::check_attr(
1987+
&self.cx.sess.psess,
1988+
attr,
1989+
self.cx.current_expansion.lint_node_id,
1990+
);
19871991

19881992
let current_span = if let Some(sp) = span { sp.to(attr.span) } else { attr.span };
19891993
span = Some(current_span);

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ declare_features! (
393393
(unstable, async_for_loop, "1.77.0", Some(118898)),
394394
/// Allows `async` trait bound modifier.
395395
(unstable, async_trait_bounds, "1.85.0", Some(62290)),
396+
/// Allows using Intel AVX10 target features and intrinsics
397+
(unstable, avx10_target_feature, "CURRENT_RUSTC_VERSION", Some(138843)),
396398
/// Allows using C-variadics.
397399
(unstable, c_variadic, "1.34.0", Some(44930)),
398400
/// Allows the use of `#[cfg(contract_checks)` to check if contract checks are enabled.

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use rustc_ast::token::Delimiter;
44
use rustc_ast::tokenstream::DelimSpan;
55
use rustc_ast::{
6-
self as ast, AttrArgs, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, Safety,
6+
self as ast, AttrArgs, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, NodeId,
7+
Safety,
78
};
89
use rustc_errors::{Applicability, FatalError, PResult};
910
use rustc_feature::{AttributeSafety, AttributeTemplate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
@@ -15,7 +16,7 @@ use rustc_span::{Span, Symbol, sym};
1516

1617
use crate::{errors, parse_in};
1718

18-
pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
19+
pub fn check_attr(psess: &ParseSess, attr: &Attribute, id: NodeId) {
1920
if attr.is_doc_comment() || attr.has_name(sym::cfg_trace) || attr.has_name(sym::cfg_attr_trace)
2021
{
2122
return;
@@ -26,7 +27,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
2627

2728
// All non-builtin attributes are considered safe
2829
let safety = attr_info.map(|x| x.safety).unwrap_or(AttributeSafety::Normal);
29-
check_attribute_safety(psess, safety, attr);
30+
check_attribute_safety(psess, safety, attr, id);
3031

3132
// Check input tokens for built-in and key-value attributes.
3233
match attr_info {
@@ -154,7 +155,12 @@ fn is_attr_template_compatible(template: &AttributeTemplate, meta: &ast::MetaIte
154155
}
155156
}
156157

157-
pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr: &Attribute) {
158+
pub fn check_attribute_safety(
159+
psess: &ParseSess,
160+
safety: AttributeSafety,
161+
attr: &Attribute,
162+
id: NodeId,
163+
) {
158164
let attr_item = attr.get_normal_item();
159165

160166
if let AttributeSafety::Unsafe { unsafe_since } = safety {
@@ -185,7 +191,7 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
185191
psess.buffer_lint(
186192
UNSAFE_ATTR_OUTSIDE_UNSAFE,
187193
path_span,
188-
ast::CRATE_NODE_ID,
194+
id,
189195
BuiltinLintDiag::UnsafeAttrOutsideUnsafe {
190196
attribute_name_span: path_span,
191197
sugg_spans: (diag_span.shrink_to_lo(), diag_span.shrink_to_hi()),

compiler/rustc_parse_format/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ pub struct Argument<'a> {
100100
pub format: FormatSpec<'a>,
101101
}
102102

103+
impl<'a> Argument<'a> {
104+
pub fn is_identifier(&self) -> bool {
105+
matches!(self.position, Position::ArgumentNamed(_))
106+
&& matches!(
107+
self.format,
108+
FormatSpec {
109+
fill: None,
110+
fill_span: None,
111+
align: AlignUnknown,
112+
sign: None,
113+
alternate: false,
114+
zero_pad: false,
115+
debug_hex: None,
116+
precision: CountImplied,
117+
precision_span: None,
118+
width: CountImplied,
119+
width_span: None,
120+
ty: "",
121+
ty_span: None,
122+
},
123+
)
124+
}
125+
}
126+
103127
/// Specification for the formatting of an argument in the format string.
104128
#[derive(Copy, Clone, Debug, PartialEq)]
105129
pub struct FormatSpec<'a> {
@@ -894,6 +918,11 @@ impl<'a> Parser<'a> {
894918
}
895919

896920
fn suggest_positional_arg_instead_of_captured_arg(&mut self, arg: Argument<'a>) {
921+
// If the argument is not an identifier, it is not a field access.
922+
if !arg.is_identifier() {
923+
return;
924+
}
925+
897926
if let Some(end) = self.consume_pos('.') {
898927
let byte_pos = self.to_span_index(end);
899928
let start = InnerOffset(byte_pos.0 + 1);

compiler/rustc_passes/src/check_attr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
683683
}
684684
}
685685

686-
if !other_attr.has_any_name(ALLOW_LIST) {
686+
if !other_attr.has_any_name(ALLOW_LIST)
687+
&& !matches!(other_attr.path().as_slice(), [sym::rustfmt, ..])
688+
{
687689
let path = other_attr.path();
688690
let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
689691
let other_attr_name = path.join("::");

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ symbols! {
531531
autodiff,
532532
automatically_derived,
533533
avx,
534+
avx10_target_feature,
534535
avx512_target_feature,
535536
avx512bw,
536537
avx512f,

compiler/rustc_target/src/target_features.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,26 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
394394
("amx-tile", Unstable(sym::x86_amx_intrinsics), &[]),
395395
("amx-transpose", Unstable(sym::x86_amx_intrinsics), &["amx-tile"]),
396396
("avx", Stable, &["sse4.2"]),
397+
(
398+
"avx10.1",
399+
Unstable(sym::avx10_target_feature),
400+
&[
401+
"avx512bf16",
402+
"avx512bitalg",
403+
"avx512bw",
404+
"avx512cd",
405+
"avx512dq",
406+
"avx512f",
407+
"avx512fp16",
408+
"avx512ifma",
409+
"avx512vbmi",
410+
"avx512vbmi2",
411+
"avx512vl",
412+
"avx512vnni",
413+
"avx512vpopcntdq",
414+
],
415+
),
416+
("avx10.2", Unstable(sym::avx10_target_feature), &["avx10.1"]),
397417
("avx2", Stable, &["avx"]),
398418
("avx512bf16", Unstable(sym::avx512_target_feature), &["avx512bw"]),
399419
("avx512bitalg", Unstable(sym::avx512_target_feature), &["avx512bw"]),

0 commit comments

Comments
 (0)