Skip to content

Commit 601b0e9

Browse files
committed
Auto merge of #160481 - jhpratt:rollup-rFextrK, r=<try>
Rollup of 29 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
2 parents c9ff496 + c05e0e4 commit 601b0e9

216 files changed

Lines changed: 2236 additions & 1683 deletions

File tree

Some content is hidden

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

.github/renovate.json5

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,24 @@
3535
"dependencyDashboardApproval": false
3636
},
3737
{
38-
// Update all Cargo.lock files except library/Cargo.lock in one PR.
38+
// Set defaults for all Cargo.lock files.
39+
// library/Cargo.lock is grouped into a dedicated PR by the more
40+
// specific rule below.
3941
"matchManagers": ["cargo"],
4042
"matchUpdateTypes": ["lockFileMaintenance"],
4143
"groupName": "Cargo lock file maintenance",
42-
"commitMessageAction": "Cargo lock file maintenance"
44+
"commitMessageAction": "Compiler and tools lock file update",
45+
// Renovate merges all matching rules, so the lockfiles rules below
46+
// also inherits this note and asks Triagebot for a dep-bumps reviewer.
47+
"prBodyNotes": ["r? dep-bumps"]
4348
},
4449
{
4550
// Update library/Cargo.lock in a dedicated PR.
4651
"matchManagers": ["cargo"],
4752
"matchUpdateTypes": ["lockFileMaintenance"],
4853
"matchFileNames": ["library/Cargo.lock"],
4954
"groupName": "library lock file maintenance",
50-
"commitMessageAction": "Library lock file maintenance"
55+
"commitMessageAction": "Library lock file update"
5156
},
5257
{
5358
// These packages don't have a committed Cargo.lock file.
@@ -63,7 +68,7 @@
6368
"matchManagers": ["npm"],
6469
"matchUpdateTypes": ["lockFileMaintenance"],
6570
"groupName": "Yarn lock file maintenance",
66-
"commitMessageAction": "Yarn lock file maintenance"
71+
"commitMessageAction": "Yarn lock file update"
6772
}
6873
],
6974
"ignorePaths": [

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5927,9 +5927,9 @@ dependencies = [
59275927

59285928
[[package]]
59295929
name = "tracing-tree"
5930-
version = "0.3.1"
5930+
version = "0.4.1"
59315931
source = "registry+https://github.com/rust-lang/crates.io-index"
5932-
checksum = "b56c62d2c80033cb36fae448730a2f2ef99410fe3ecbffc916681a32f6807dbe"
5932+
checksum = "ac87aa03b6a4d5a7e4810d1a80c19601dbe0f8a837e9177f23af721c7ba7beec"
59335933
dependencies = [
59345934
"nu-ansi-term",
59355935
"tracing-core",

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,7 +3981,7 @@ pub struct Fn {
39813981
/// This function is an implementation of an externally implementable item (EII).
39823982
/// This means, there was an EII declared somewhere and this function is the
39833983
/// implementation that should be run when the declaration is called.
3984-
pub eii_impls: ThinVec<EiiImpl>,
3984+
pub eii_impl: Option<Box<EiiImpl>>,
39853985
}
39863986

39873987
impl Fn {
@@ -4073,9 +4073,7 @@ pub struct StaticItem {
40734073
/// This static is an implementation of an externally implementable item (EII).
40744074
/// This means, there was an EII declared somewhere and this static is the
40754075
/// implementation that should be used for the declaration.
4076-
///
4077-
/// For statics, there may be at most one `EiiImpl`, but this is a `ThinVec` to make usages of this field nicer.
4078-
pub eii_impls: ThinVec<EiiImpl>,
4076+
pub eii_impl: Option<Box<EiiImpl>>,
40794077
}
40804078

40814079
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,12 +933,12 @@ macro_rules! common_visitor_and_walkers {
933933
_ctxt,
934934
// Visibility is visited as a part of the item.
935935
_vis,
936-
Fn { defaultness, ident, sig, generics, contract, body, define_opaque, eii_impls },
936+
Fn { defaultness, ident, sig, generics, contract, body, define_opaque, eii_impl },
937937
) => {
938938
let FnSig { header, decl, span } = sig;
939939
visit_visitable!($($mut)? vis,
940940
defaultness, ident, header, generics, decl,
941-
contract, body, span, define_opaque, eii_impls
941+
contract, body, span, define_opaque, eii_impl
942942
);
943943
}
944944
FnKind::Closure(binder, coroutine_kind, decl, body) =>

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
170170
i: &ItemKind,
171171
) -> Vec<hir::Attribute> {
172172
match i {
173-
ItemKind::Fn(Fn { eii_impls, .. }) | ItemKind::Static(StaticItem { eii_impls, .. })
174-
if eii_impls.is_empty() =>
175-
{
176-
Vec::new()
177-
}
178-
ItemKind::Fn(Fn { eii_impls, .. }) | ItemKind::Static(StaticItem { eii_impls, .. }) => {
179-
vec![hir::Attribute::Parsed(AttributeKind::EiiImpls(
180-
eii_impls.iter().map(|i| self.lower_eii_impl(i)).collect(),
181-
))]
173+
ItemKind::Fn(Fn { eii_impl: None, .. })
174+
| ItemKind::Static(StaticItem { eii_impl: None, .. }) => Vec::new(),
175+
ItemKind::Fn(Fn { eii_impl: Some(eii_impl), .. })
176+
| ItemKind::Static(StaticItem { eii_impl: Some(eii_impl), .. }) => {
177+
vec![hir::Attribute::Parsed(AttributeKind::EiiImpl(Box::new(
178+
self.lower_eii_impl(eii_impl),
179+
)))]
182180
}
183181
ItemKind::MacroDef(name, MacroDef { eii_declaration: Some(target), .. }) => self
184182
.lower_eii_decl(id, *name, target)
@@ -226,7 +224,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
226224
kind,
227225
vis_span,
228226
span: self.lower_span(i.span),
229-
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
227+
eii: find_attr!(attrs, EiiImpl(..) | EiiDeclaration(..)),
230228
};
231229
self.arena.alloc(item)
232230
}
@@ -259,7 +257,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
259257
mutability: m,
260258
expr: e,
261259
define_opaque,
262-
eii_impls: _,
260+
eii_impl: _,
263261
}) => {
264262
let ident = self.lower_ident(*ident);
265263
let ty = self
@@ -696,7 +694,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
696694
kind,
697695
vis_span,
698696
span: this.lower_span(use_tree.span()),
699-
eii: find_attr!(attrs, EiiImpls(..) | EiiDeclaration(..)),
697+
eii: find_attr!(attrs, EiiImpl(..) | EiiDeclaration(..)),
700698
};
701699
hir::OwnerNode::Item(this.arena.alloc(item))
702700
});
@@ -763,7 +761,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
763761
expr: _,
764762
safety,
765763
define_opaque,
766-
eii_impls: _,
764+
eii_impl: _,
767765
}) => {
768766
let ty = self
769767
.lower_ty_alloc(ty, ImplTraitContext::Disallowed(ImplTraitPosition::StaticTy));

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,13 @@ impl<'a> AstValidator<'a> {
935935
match fn_ctxt {
936936
FnCtxt::Foreign => return,
937937
FnCtxt::Free | FnCtxt::Assoc(_) => {
938+
// Reject `...` without a pattern post-expansion. The varargs_without_pattern
939+
// FCW is already triggered pre-expansion.
940+
if let PatKind::Missing = variadic_param.pat.kind {
941+
self.dcx()
942+
.emit_err(diagnostics::VarargsWithoutPattern { span: variadic_param.span });
943+
}
944+
938945
match self.sess.target.supports_c_variadic_definitions() {
939946
CVariadicStatus::NotSupported => {
940947
self.dcx().emit_err(diagnostics::CVariadicNotSupported {
@@ -1259,10 +1266,10 @@ impl<'a> AstValidator<'a> {
12591266
}
12601267

12611268
// Check EII implementation attributes against an allowlist.
1262-
fn check_eii_impl_attrs(&self, attrs: &[Attribute], eii_impls: &[EiiImpl]) {
1263-
if eii_impls.is_empty() {
1269+
fn check_eii_impl_attrs(&self, attrs: &[Attribute], eii_impl: &Option<Box<EiiImpl>>) {
1270+
let Some(eii_impl) = eii_impl else {
12641271
return;
1265-
}
1272+
};
12661273

12671274
let allowed_attrs: &[Symbol] = &[
12681275
sym::allow,
@@ -1289,14 +1296,12 @@ impl<'a> AstValidator<'a> {
12891296
}
12901297

12911298
let attr_name = pprust::path_to_string(&normal.item.path);
1292-
for eii_impl in eii_impls {
1293-
self.dcx().emit_err(diagnostics::EiiImplAttributeNotSupported {
1294-
attr_span: attr.span,
1295-
attr_name: &attr_name,
1296-
eii_span: eii_impl.span,
1297-
eii_name: pprust::path_to_string(&eii_impl.eii_macro_path),
1298-
});
1299-
}
1299+
self.dcx().emit_err(diagnostics::EiiImplAttributeNotSupported {
1300+
attr_span: attr.span,
1301+
attr_name: &attr_name,
1302+
eii_span: eii_impl.span,
1303+
eii_name: pprust::path_to_string(&eii_impl.eii_macro_path),
1304+
});
13001305
}
13011306
}
13021307
}
@@ -1479,16 +1484,16 @@ impl Visitor<'_> for AstValidator<'_> {
14791484
contract: _,
14801485
body,
14811486
define_opaque: _,
1482-
eii_impls,
1487+
eii_impl,
14831488
},
14841489
) => {
14851490
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
14861491
self.check_defaultness(item.span, *defaultness, AllowDefault::No, AllowFinal::No);
14871492

1488-
for EiiImpl { eii_macro_path, .. } in eii_impls {
1493+
if let Some(EiiImpl { eii_macro_path, .. }) = eii_impl {
14891494
self.visit_path(eii_macro_path);
14901495
}
1491-
self.check_eii_impl_attrs(&item.attrs, eii_impls);
1496+
self.check_eii_impl_attrs(&item.attrs, eii_impl);
14921497

14931498
let is_intrinsic = item.attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic));
14941499
if body.is_none() && !is_intrinsic && !self.is_sdylib_interface {
@@ -1664,9 +1669,9 @@ impl Visitor<'_> for AstValidator<'_> {
16641669

16651670
visit::walk_item(self, item);
16661671
}
1667-
ItemKind::Static(StaticItem { expr, safety, eii_impls, .. }) => {
1672+
ItemKind::Static(StaticItem { expr, safety, eii_impl, .. }) => {
16681673
self.check_item_safety(item.span, *safety);
1669-
self.check_eii_impl_attrs(&item.attrs, eii_impls);
1674+
self.check_eii_impl_attrs(&item.attrs, eii_impl);
16701675
if matches!(safety, Safety::Unsafe(_)) {
16711676
self.dcx().emit_err(diagnostics::UnsafeStatic { span: item.span });
16721677
}

compiler/rustc_ast_passes/src/diagnostics.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,3 +1245,15 @@ pub(crate) enum DeprecatedWhereClauseLocationSugg {
12451245
span: Span,
12461246
},
12471247
}
1248+
1249+
#[derive(Diagnostic)]
1250+
#[diag("missing pattern for `...` argument")]
1251+
pub(crate) struct VarargsWithoutPattern {
1252+
#[suggestion(
1253+
"add a pattern for this argument",
1254+
applicability = "machine-applicable",
1255+
code = "_: ..."
1256+
)]
1257+
#[primary_span]
1258+
pub span: Span,
1259+
}

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a> State<'a> {
4242
expr,
4343
safety,
4444
define_opaque,
45-
eii_impls,
45+
eii_impl,
4646
}) => self.print_item_const(
4747
*ident,
4848
Some(*mutability),
@@ -53,7 +53,7 @@ impl<'a> State<'a> {
5353
*safety,
5454
ast::Defaultness::Implicit,
5555
define_opaque.as_deref(),
56-
eii_impls,
56+
eii_impl.as_deref(),
5757
),
5858
ast::ForeignItemKind::TyAlias(ast::TyAlias {
5959
defaultness,
@@ -94,10 +94,10 @@ impl<'a> State<'a> {
9494
safety: ast::Safety,
9595
defaultness: ast::Defaultness,
9696
define_opaque: Option<&[(ast::NodeId, ast::Path)]>,
97-
eii_impls: &[EiiImpl],
97+
eii_impl: Option<&EiiImpl>,
9898
) {
9999
self.print_define_opaques(define_opaque);
100-
for eii_impl in eii_impls {
100+
if let Some(eii_impl) = eii_impl {
101101
self.print_eii_impl(eii_impl);
102102
}
103103
let (cb, ib) = self.head("");
@@ -196,7 +196,7 @@ impl<'a> State<'a> {
196196
mutability: mutbl,
197197
expr: body,
198198
define_opaque,
199-
eii_impls,
199+
eii_impl,
200200
}) => {
201201
self.print_safety(*safety);
202202
self.print_item_const(
@@ -209,7 +209,7 @@ impl<'a> State<'a> {
209209
ast::Safety::Default,
210210
ast::Defaultness::Implicit,
211211
define_opaque.as_deref(),
212-
eii_impls,
212+
eii_impl.as_deref(),
213213
);
214214
}
215215
ast::ItemKind::ConstBlock(ast::ConstBlockItem { id: _, span: _, block }) => {
@@ -242,7 +242,7 @@ impl<'a> State<'a> {
242242
ast::Safety::Default,
243243
*defaultness,
244244
define_opaque.as_deref(),
245-
&[],
245+
None,
246246
);
247247
}
248248
ast::ItemKind::Fn(func) => {
@@ -631,7 +631,7 @@ impl<'a> State<'a> {
631631
ast::Safety::Default,
632632
*defaultness,
633633
define_opaque.as_deref(),
634-
&[],
634+
None,
635635
);
636636
}
637637
ast::AssocItemKind::Type(ast::TyAlias {
@@ -731,12 +731,12 @@ impl<'a> State<'a> {
731731
}
732732

733733
fn print_fn_full(&mut self, vis: &ast::Visibility, attrs: &[ast::Attribute], func: &ast::Fn) {
734-
let ast::Fn { defaultness, ident, generics, sig, contract, body, define_opaque, eii_impls } =
734+
let ast::Fn { defaultness, ident, generics, sig, contract, body, define_opaque, eii_impl } =
735735
func;
736736

737737
self.print_define_opaques(define_opaque.as_deref());
738738

739-
for eii_impl in eii_impls {
739+
if let Some(eii_impl) = eii_impl {
740740
self.print_eii_impl(eii_impl);
741741
}
742742

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::path::PathBuf;
22

33
use rustc_ast::{LitIntType, LitKind, MetaItemLit};
4+
use rustc_data_structures::fx::FxHashMap;
45
use rustc_feature::AttributeStability;
56
use rustc_hir::LangItem;
67
use rustc_hir::attrs::{
@@ -72,6 +73,18 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser {
7273
return None;
7374
}
7475

76+
if cx.target == Target::Trait {
77+
// Check for duplicates
78+
let mut seen: FxHashMap<Symbol, Span> = FxHashMap::default();
79+
for ident in &fn_names {
80+
if let Some(dup) = seen.insert(ident.name, ident.span) {
81+
cx.emit_err(diagnostics::FunctionNamesDuplicated {
82+
spans: vec![dup, ident.span],
83+
});
84+
}
85+
}
86+
}
87+
7588
Some(AttributeKind::RustcMustImplementOneOf { attr_span: cx.attr_span, fn_names })
7689
}
7790
}

compiler/rustc_attr_parsing/src/diagnostics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ pub(crate) struct MustBeNameOfAssociatedFunction {
5959
pub span: Span,
6060
}
6161

62+
#[derive(Diagnostic)]
63+
#[diag("functions names are duplicated")]
64+
#[note("all `#[rustc_must_implement_one_of]` arguments must be unique")]
65+
pub(crate) struct FunctionNamesDuplicated {
66+
#[primary_span]
67+
pub spans: Vec<Span>,
68+
}
69+
6270
#[derive(Diagnostic)]
6371
#[diag("unsafe attribute used without unsafe")]
6472
pub(crate) struct UnsafeAttrOutsideUnsafeLint {

0 commit comments

Comments
 (0)