Skip to content

Commit 94722ca

Browse files
committed
Auto merge of #146125 - GuillaumeGomez:rollup-ld81n7e, r=GuillaumeGomez
Rollup of 14 pull requests Successful merges: - #144066 (stabilize c-style varargs for sysv64, win64, efiapi, aapcs) - #145783 (add span to struct pattern rest (..)) - #146034 (Update target spec metadata of Arm64EC Windows and Trusty targets) - #146064 (Add compiler error when trying to use concat metavar expr in repetitions) - #146070 (rustdoc-search: skip loading unneeded fnData) - #146088 (constify impl Try for ControlFlow) - #146089 (fix a constness ordering bug in rustfmt) - #146091 (fix rustdoc `render_call_locations` panicking because of default span `DUMMY_SP` pointing at non local-source file) - #146094 (Make `Parser::parse_for_head` public for rustfmt usage) - #146102 (Remove dead code stemming from an old effects desugaring) - #146115 (Add maintainer for VxWorks) - #146116 (Adjust issue-118306.rs test after LLVM change) - #146117 (Fix search index generation) - #146118 (improve process::abort rendering in Miri backtraces) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a2c8b0b + 16b9a68 commit 94722ca

File tree

106 files changed

+424
-417
lines changed

Some content is hidden

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

106 files changed

+424
-417
lines changed

compiler/rustc_abi/src/extern_abi.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::hash::{Hash, Hasher};
66
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd};
77
#[cfg(feature = "nightly")]
88
use rustc_macros::{Decodable, Encodable};
9+
#[cfg(feature = "nightly")]
10+
use rustc_span::Symbol;
911

1012
use crate::AbiFromStrErr;
1113

@@ -226,6 +228,13 @@ impl StableOrd for ExternAbi {
226228
#[cfg(feature = "nightly")]
227229
rustc_error_messages::into_diag_arg_using_display!(ExternAbi);
228230

231+
#[cfg(feature = "nightly")]
232+
pub enum CVariadicStatus {
233+
NotSupported,
234+
Stable,
235+
Unstable { feature: Symbol },
236+
}
237+
229238
impl ExternAbi {
230239
/// An ABI "like Rust"
231240
///
@@ -238,23 +247,33 @@ impl ExternAbi {
238247
matches!(self, Rust | RustCall | RustCold)
239248
}
240249

241-
pub fn supports_varargs(self) -> bool {
250+
/// Returns whether the ABI supports C variadics. This only controls whether we allow *imports*
251+
/// of such functions via `extern` blocks; there's a separate check during AST construction
252+
/// guarding *definitions* of variadic functions.
253+
#[cfg(feature = "nightly")]
254+
pub fn supports_c_variadic(self) -> CVariadicStatus {
242255
// * C and Cdecl obviously support varargs.
243256
// * C can be based on Aapcs, SysV64 or Win64, so they must support varargs.
244257
// * EfiApi is based on Win64 or C, so it also supports it.
258+
// * System automatically falls back to C when used with variadics, therefore supports it.
245259
//
246260
// * Stdcall does not, because it would be impossible for the callee to clean
247261
// up the arguments. (callee doesn't know how many arguments are there)
248262
// * Same for Fastcall, Vectorcall and Thiscall.
249263
// * Other calling conventions are related to hardware or the compiler itself.
264+
//
265+
// All of the supported ones must have a test in `tests/codegen/cffi/c-variadic-ffi.rs`.
250266
match self {
251267
Self::C { .. }
252268
| Self::Cdecl { .. }
253269
| Self::Aapcs { .. }
254270
| Self::Win64 { .. }
255271
| Self::SysV64 { .. }
256-
| Self::EfiApi => true,
257-
_ => false,
272+
| Self::EfiApi => CVariadicStatus::Stable,
273+
Self::System { .. } => {
274+
CVariadicStatus::Unstable { feature: rustc_span::sym::extern_system_varargs }
275+
}
276+
_ => CVariadicStatus::NotSupported,
258277
}
259278
}
260279
}

compiler/rustc_abi/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ mod tests;
6363

6464
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
6565
pub use canon_abi::{ArmCall, CanonAbi, InterruptKind, X86Call};
66+
#[cfg(feature = "nightly")]
67+
pub use extern_abi::CVariadicStatus;
6668
pub use extern_abi::{ExternAbi, all_names};
6769
#[cfg(feature = "nightly")]
6870
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ pub enum PatKind {
937937
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Walkable)]
938938
pub enum PatFieldsRest {
939939
/// `module::StructName { field, ..}`
940-
Rest,
940+
Rest(Span),
941941
/// `module::StructName { field, syntax error }`
942942
Recovered(ErrorGuaranteed),
943943
/// `module::StructName { field }`
@@ -4051,8 +4051,8 @@ mod size_asserts {
40514051
static_assert_size!(Local, 96);
40524052
static_assert_size!(MetaItemLit, 40);
40534053
static_assert_size!(Param, 40);
4054-
static_assert_size!(Pat, 72);
4055-
static_assert_size!(PatKind, 48);
4054+
static_assert_size!(Pat, 80);
4055+
static_assert_size!(PatKind, 56);
40564056
static_assert_size!(Path, 24);
40574057
static_assert_size!(PathSegment, 24);
40584058
static_assert_size!(Stmt, 32);

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,10 +1434,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
14341434
self.dcx().emit_err(FunctionalRecordUpdateDestructuringAssignment {
14351435
span: e.span,
14361436
});
1437-
true
1437+
Some(self.lower_span(e.span))
14381438
}
1439-
StructRest::Rest(_) => true,
1440-
StructRest::None => false,
1439+
StructRest::Rest(span) => Some(self.lower_span(*span)),
1440+
StructRest::None => None,
14411441
};
14421442
let struct_pat = hir::PatKind::Struct(qpath, field_pats, fields_omitted);
14431443
return self.pat_without_dbm(lhs.span, struct_pat);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20282028

20292029
(
20302030
hir::ParamName::Plain(self.lower_ident(param.ident)),
2031-
hir::GenericParamKind::Const { ty, default, synthetic: false },
2031+
hir::GenericParamKind::Const { ty, default },
20322032
)
20332033
}
20342034
}
@@ -2508,7 +2508,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25082508
fields: &'hir [hir::PatField<'hir>],
25092509
) -> &'hir hir::Pat<'hir> {
25102510
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
2511-
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
2511+
self.pat(span, hir::PatKind::Struct(qpath, fields, None))
25122512
}
25132513

25142514
fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
106106
break hir::PatKind::Struct(
107107
qpath,
108108
fs,
109-
matches!(
110-
etc,
111-
ast::PatFieldsRest::Rest | ast::PatFieldsRest::Recovered(_)
112-
),
109+
match etc {
110+
ast::PatFieldsRest::Rest(sp) => Some(self.lower_span(*sp)),
111+
ast::PatFieldsRest::Recovered(_) => Some(Span::default()),
112+
_ => None,
113+
},
113114
);
114115
}
115116
PatKind::Tuple(pats) => {

compiler/rustc_ast_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetim
5757
.label = {ast_passes_auto_super_lifetime}
5858
.suggestion = remove the super traits or lifetime bounds
5959
60-
ast_passes_bad_c_variadic = only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
60+
ast_passes_bad_c_variadic = defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention
6161
6262
ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
6363
.cannot_have = cannot have a body

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ impl<'a> State<'a> {
17691769
},
17701770
|f| f.pat.span,
17711771
);
1772-
if let ast::PatFieldsRest::Rest | ast::PatFieldsRest::Recovered(_) = etc {
1772+
if let ast::PatFieldsRest::Rest(_) | ast::PatFieldsRest::Recovered(_) = etc {
17731773
if !fields.is_empty() {
17741774
self.word_space(",");
17751775
}

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ fn metavar_expr_concat<'tx>(
556556
};
557557
match &named_matches[*curr_idx] {
558558
// FIXME(c410-f3r) Nested repetitions are unimplemented
559-
MatchedSeq(_) => unimplemented!(),
559+
MatchedSeq(_) => {
560+
return Err(dcx.struct_span_err(
561+
ident.span,
562+
"nested repetitions with `${concat(...)}` metavariable expressions are not yet supported",
563+
));
564+
}
560565
MatchedSingle(pnr) => extract_symbol_from_pnr(dcx, pnr, ident.span)?,
561566
}
562567
}

compiler/rustc_feature/src/accepted.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ declare_features! (
203203
(accepted, expr_fragment_specifier_2024, "1.83.0", Some(123742)),
204204
/// Allows arbitrary expressions in key-value attributes at parse time.
205205
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
206+
/// Allows using `aapcs`, `efiapi`, `sysv64` and `win64` as calling conventions
207+
/// for functions with varargs.
208+
(accepted, extended_varargs_abi_support, "CURRENT_RUSTC_VERSION", Some(100189)),
206209
/// Allows resolving absolute paths as paths from other crates.
207210
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
208211
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.

0 commit comments

Comments
 (0)