Skip to content

Commit e93e096

Browse files
committed
Auto merge of #133658 - jieyouxu:rollup-rq7e0gk, r=jieyouxu
Rollup of 10 pull requests Successful merges: - #116161 (Stabilize `extended_varargs_abi_support`) - #132750 ([AIX] handle libunwind native_libs) - #133488 (tests: Add regression test for self referential structs with cow as last field) - #133569 (Bump `ruzstd` to 0.7.3) - #133585 (Do not call `extern_crate` on current trait on crate mismatch errors) - #133587 (Fix target_feature handling in freg of LoongArch inline assembly) - #133599 (Add `+forced-atomics` feature to esp32s2 no_std target) - #133620 (Simplify hir_typeck_pass_to_variadic_function) - #133623 (Improve span handling in `parse_expr_bottom`.) - #133625 (custom MIR: add doc comment for debuginfo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e48ddd8 + 6512836 commit e93e096

File tree

44 files changed

+580
-255
lines changed

Some content is hidden

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

44 files changed

+580
-255
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4713,9 +4713,9 @@ checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
47134713

47144714
[[package]]
47154715
name = "ruzstd"
4716-
version = "0.7.2"
4716+
version = "0.7.3"
47174717
source = "registry+https://github.com/rust-lang/crates.io-index"
4718-
checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21"
4718+
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
47194719
dependencies = [
47204720
"twox-hash",
47214721
]

compiler/rustc_feature/src/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ declare_features! (
193193
(accepted, expr_fragment_specifier_2024, "1.83.0", Some(123742)),
194194
/// Allows arbitrary expressions in key-value attributes at parse time.
195195
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
196+
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
197+
/// convention for functions with varargs.
198+
(accepted, extended_varargs_abi_support, "CURRENT_RUSTC_VERSION", Some(100189)),
196199
/// Allows resolving absolute paths as paths from other crates.
197200
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
198201
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.

compiler/rustc_feature/src/unstable.rs

-3
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ declare_features! (
475475
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
476476
/// Allows explicit tail calls via `become` expression.
477477
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
478-
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
479-
/// for functions with varargs.
480-
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189)),
481478
/// Allows defining `extern type`s.
482479
(unstable, extern_types, "1.23.0", Some(43467)),
483480
/// Allow using 128-bit (quad precision) floating point numbers.

compiler/rustc_hir_analysis/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ hir_analysis_value_of_associated_struct_already_specified =
590590
.label = re-bound here
591591
.previous_bound_label = `{$item_name}` bound here first
592592
593-
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
593+
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
594594
.label = C-variadic function must have a compatible calling convention
595595
596596
hir_analysis_variances_of = {$variances}

compiler/rustc_hir_analysis/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,10 @@ pub(crate) struct MainFunctionGenericParameters {
672672

673673
#[derive(Diagnostic)]
674674
#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
675-
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
675+
pub(crate) struct VariadicFunctionCompatibleConvention {
676676
#[primary_span]
677677
#[label]
678678
pub span: Span,
679-
pub conventions: &'a str,
680679
}
681680

682681
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+2-29
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ use rustc_middle::middle;
9898
use rustc_middle::mir::interpret::GlobalId;
9999
use rustc_middle::query::Providers;
100100
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
101-
use rustc_session::parse::feature_err;
102101
use rustc_span::Span;
103-
use rustc_span::symbol::sym;
104102
use rustc_trait_selection::traits;
105103

106104
use self::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
@@ -113,34 +111,9 @@ fn require_c_abi_if_c_variadic(
113111
abi: ExternAbi,
114112
span: Span,
115113
) {
116-
const CONVENTIONS_UNSTABLE: &str =
117-
"`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`";
118-
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
119-
const UNSTABLE_EXPLAIN: &str =
120-
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";
121-
122-
if !decl.c_variadic || matches!(abi, ExternAbi::C { .. } | ExternAbi::Cdecl { .. }) {
123-
return;
114+
if decl.c_variadic && !abi.supports_varargs() {
115+
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span });
124116
}
125-
126-
let extended_abi_support = tcx.features().extended_varargs_abi_support();
127-
let conventions = match (extended_abi_support, abi.supports_varargs()) {
128-
// User enabled additional ABI support for varargs and function ABI matches those ones.
129-
(true, true) => return,
130-
131-
// Using this ABI would be ok, if the feature for additional ABI support was enabled.
132-
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
133-
(false, true) => {
134-
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
135-
.emit();
136-
CONVENTIONS_STABLE
137-
}
138-
139-
(false, false) => CONVENTIONS_STABLE,
140-
(true, false) => CONVENTIONS_UNSTABLE,
141-
};
142-
143-
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
144117
}
145118

146119
pub fn provide(providers: &mut Providers) {

compiler/rustc_hir_typeck/messages.ftl

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value in
146146
147147
hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
148148
.suggestion = cast the value to `{$cast_ty}`
149-
.help = cast the value to `{$cast_ty}`
150149
.teach_help = certain types, like `{$ty}`, must be casted before passing them to a variadic function, because of arcane ABI rules dictated by the C standard
151150
152151
hir_typeck_ptr_cast_add_auto_to_object = adding {$traits_len ->

compiler/rustc_hir_typeck/src/errors.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,8 @@ pub(crate) struct PassToVariadicFunction<'a, 'tcx> {
789789
pub span: Span,
790790
pub ty: Ty<'tcx>,
791791
pub cast_ty: &'a str,
792-
#[suggestion(code = "{replace}", applicability = "machine-applicable")]
793-
pub sugg_span: Option<Span>,
794-
pub replace: String,
795-
#[help]
796-
pub help: bool,
792+
#[suggestion(code = " as {cast_ty}", applicability = "machine-applicable", style = "verbose")]
793+
pub sugg_span: Span,
797794
#[note(hir_typeck_teach_help)]
798795
pub(crate) teach: bool,
799796
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -440,20 +440,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
440440
ty: Ty<'tcx>,
441441
cast_ty: &str,
442442
) {
443-
let (sugg_span, replace, help) =
444-
if let Ok(snippet) = sess.source_map().span_to_snippet(span) {
445-
(Some(span), format!("{snippet} as {cast_ty}"), false)
446-
} else {
447-
(None, "".to_string(), true)
448-
};
449-
450443
sess.dcx().emit_err(errors::PassToVariadicFunction {
451444
span,
452445
ty,
453446
cast_ty,
454-
help,
455-
replace,
456-
sugg_span,
447+
sugg_span: span.shrink_to_hi(),
457448
teach: sess.teach(E0617),
458449
});
459450
}

compiler/rustc_metadata/src/native_libs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ pub fn walk_native_lib_search_dirs<R>(
5454
// The targets here should be in sync with `copy_third_party_objects` in bootstrap.
5555
// FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
5656
// and sanitizers to self-contained directory, and stop adding this search path.
57+
// FIXME: On AIX this also has the side-effect of making the list of library search paths
58+
// non-empty, which is needed or the linker may decide to record the LIBPATH env, if
59+
// defined, as the search path instead of appending the default search paths.
5760
if sess.target.vendor == "fortanix"
5861
|| sess.target.os == "linux"
5962
|| sess.target.os == "fuchsia"
63+
|| sess.target.is_like_aix
6064
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
6165
{
6266
f(&sess.target_tlib_path.dir, false)?;

compiler/rustc_parse/src/parser/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,6 @@ impl<'a> Parser<'a> {
19901990
/// `await? <expr>`, `await(<expr>)`, and `await { <expr> }`.
19911991
pub(super) fn recover_incorrect_await_syntax(
19921992
&mut self,
1993-
lo: Span,
19941993
await_sp: Span,
19951994
) -> PResult<'a, P<Expr>> {
19961995
let (hi, expr, is_question) = if self.token == token::Not {
@@ -1999,8 +1998,8 @@ impl<'a> Parser<'a> {
19991998
} else {
20001999
self.recover_await_prefix(await_sp)?
20012000
};
2002-
let (sp, guar) = self.error_on_incorrect_await(lo, hi, &expr, is_question);
2003-
let expr = self.mk_expr_err(lo.to(sp), guar);
2001+
let (sp, guar) = self.error_on_incorrect_await(await_sp, hi, &expr, is_question);
2002+
let expr = self.mk_expr_err(await_sp.to(sp), guar);
20042003
self.maybe_recover_from_bad_qpath(expr)
20052004
}
20062005

compiler/rustc_parse/src/parser/expr.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -1446,34 +1446,31 @@ impl<'a> Parser<'a> {
14461446
this.parse_expr_closure()
14471447
} else {
14481448
assert!(this.eat_keyword(kw::For));
1449-
this.parse_expr_for(None, this.prev_token.span)
1449+
this.parse_expr_for(None, lo)
14501450
}
14511451
} else if this.eat_keyword(kw::While) {
1452-
this.parse_expr_while(None, this.prev_token.span)
1452+
this.parse_expr_while(None, lo)
14531453
} else if let Some(label) = this.eat_label() {
14541454
this.parse_expr_labeled(label, true)
14551455
} else if this.eat_keyword(kw::Loop) {
1456-
let sp = this.prev_token.span;
1457-
this.parse_expr_loop(None, this.prev_token.span).map_err(|mut err| {
1458-
err.span_label(sp, "while parsing this `loop` expression");
1456+
this.parse_expr_loop(None, lo).map_err(|mut err| {
1457+
err.span_label(lo, "while parsing this `loop` expression");
14591458
err
14601459
})
14611460
} else if this.eat_keyword(kw::Match) {
1462-
let match_sp = this.prev_token.span;
14631461
this.parse_expr_match().map_err(|mut err| {
1464-
err.span_label(match_sp, "while parsing this `match` expression");
1462+
err.span_label(lo, "while parsing this `match` expression");
14651463
err
14661464
})
14671465
} else if this.eat_keyword(kw::Unsafe) {
1468-
let sp = this.prev_token.span;
14691466
this.parse_expr_block(None, lo, BlockCheckMode::Unsafe(ast::UserProvided)).map_err(
14701467
|mut err| {
1471-
err.span_label(sp, "while parsing this `unsafe` expression");
1468+
err.span_label(lo, "while parsing this `unsafe` expression");
14721469
err
14731470
},
14741471
)
14751472
} else if this.check_inline_const(0) {
1476-
this.parse_const_block(lo.to(this.token.span), false)
1473+
this.parse_const_block(lo, false)
14771474
} else if this.may_recover() && this.is_do_catch_block() {
14781475
this.recover_do_catch()
14791476
} else if this.is_try_block() {
@@ -1514,7 +1511,7 @@ impl<'a> Parser<'a> {
15141511
this.parse_expr_closure()
15151512
}
15161513
} else if this.eat_keyword_noexpect(kw::Await) {
1517-
this.recover_incorrect_await_syntax(lo, this.prev_token.span)
1514+
this.recover_incorrect_await_syntax(lo)
15181515
} else {
15191516
this.parse_expr_lit()
15201517
}

compiler/rustc_parse/src/parser/ty.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ impl<'a> Parser<'a> {
274274
// Function pointer type
275275
self.parse_ty_bare_fn(lo, ThinVec::new(), None, recover_return_sign)?
276276
} else if self.check_keyword(kw::For) {
277-
let for_span = self.token.span;
278277
// Function pointer type or bound list (trait object type) starting with a poly-trait.
279278
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
280279
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
@@ -302,7 +301,7 @@ impl<'a> Parser<'a> {
302301
kw: kw.name.as_str(),
303302
sugg: errors::TransposeDynOrImplSugg {
304303
removal_span,
305-
insertion_span: for_span.shrink_to_lo(),
304+
insertion_span: lo.shrink_to_lo(),
306305
kw: kw.name.as_str(),
307306
},
308307
});
@@ -345,16 +344,14 @@ impl<'a> Parser<'a> {
345344
// FIXME(c_variadic): Should we just allow `...` syntactically
346345
// anywhere in a type and use semantic restrictions instead?
347346
// NOTE: This may regress certain MBE calls if done incorrectly.
348-
let guar = self
349-
.dcx()
350-
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
347+
let guar = self.dcx().emit_err(NestedCVariadicType { span: lo });
351348
TyKind::Err(guar)
352349
}
353350
}
354351
} else {
355352
let msg = format!("expected type, found {}", super::token_descr(&self.token));
356-
let mut err = self.dcx().struct_span_err(self.token.span, msg);
357-
err.span_label(self.token.span, "expected type");
353+
let mut err = self.dcx().struct_span_err(lo, msg);
354+
err.span_label(lo, "expected type");
358355
return Err(err);
359356
};
360357

compiler/rustc_target/src/asm/loongarch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl LoongArchInlineAsmRegClass {
3838
) -> &'static [(InlineAsmType, Option<Symbol>)] {
3939
match self {
4040
Self::reg => types! { _: I8, I16, I32, I64, F32, F64; },
41-
Self::freg => types! { _: F32, F64; },
41+
Self::freg => types! { f: F32; d: F64; },
4242
}
4343
}
4444
}

compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub(crate) fn target() -> Target {
1919
cpu: "esp32-s2".into(),
2020
linker: Some("xtensa-esp32s2-elf-gcc".into()),
2121
max_atomic_width: Some(32),
22+
features: "+forced-atomics".into(),
2223
..xtensa::opts()
2324
},
2425
}

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17311731
span.push_span_label(self.tcx.def_span(trait_def_id), "this is the required trait");
17321732
for (sp, label) in [trait_def_id, other_trait_def_id]
17331733
.iter()
1734+
// The current crate-version might depend on another version of the same crate
1735+
// (Think "semver-trick"). Do not call `extern_crate` in that case for the local
1736+
// crate as that doesn't make sense and ICEs (#133563).
1737+
.filter(|def_id| !def_id.is_local())
17341738
.filter_map(|def_id| self.tcx.extern_crate(def_id.krate))
17351739
.map(|data| {
17361740
let dependency = if data.dependency_of == LOCAL_CRATE {

library/core/src/intrinsics/mir.rs

+33
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,39 @@
249249
//! `Call(ret_val = function(arg1, arg2, ...), ReturnTo(next_block), UnwindContinue())`.
250250
//! - [`TailCall`] does not have a return destination or next block, so its syntax is just
251251
//! `TailCall(function(arg1, arg2, ...))`.
252+
//!
253+
//! #### Debuginfo
254+
//!
255+
//! Debuginfo associates source code variable names (of variables that may not exist any more) with
256+
//! MIR expressions that indicate where the value of that variable is stored. The syntax to do so
257+
//! is:
258+
//! ```text
259+
//! debug source_var_name => expression;
260+
//! ```
261+
//! Both places and constants are supported in the `expression`.
262+
//!
263+
//! ```rust
264+
//! #![allow(internal_features)]
265+
//! #![feature(core_intrinsics, custom_mir)]
266+
//!
267+
//! use core::intrinsics::mir::*;
268+
//!
269+
//! #[custom_mir(dialect = "built")]
270+
//! fn debuginfo(arg: Option<&i32>) {
271+
//! mir!(
272+
//! // Debuginfo for a source variable `plain_local` that just duplicates `arg`.
273+
//! debug plain_local => arg;
274+
//! // Debuginfo for a source variable `projection` that can be computed by dereferencing
275+
//! // a field of `arg`.
276+
//! debug projection => *Field::<&i32>(Variant(arg, 1), 0);
277+
//! // Debuginfo for a source variable `constant` that always holds the value `5`.
278+
//! debug constant => 5_usize;
279+
//! {
280+
//! Return()
281+
//! }
282+
//! )
283+
//! }
284+
//! ```
252285
253286
#![unstable(
254287
feature = "custom_mir",

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@
290290
#![feature(doc_masked)]
291291
#![feature(doc_notable_trait)]
292292
#![feature(dropck_eyepatch)]
293-
#![feature(extended_varargs_abi_support)]
294293
#![feature(f128)]
295294
#![feature(f16)]
296295
#![feature(if_let_guard)]

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn copy_third_party_objects(
330330

331331
if target == "x86_64-fortanix-unknown-sgx"
332332
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
333-
&& (target.contains("linux") || target.contains("fuchsia"))
333+
&& (target.contains("linux") || target.contains("fuchsia") || target.contains("aix"))
334334
{
335335
let libunwind_path =
336336
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));

src/doc/unstable-book/src/language-features/extended-varargs-abi-support.md

-10
This file was deleted.

src/tools/run-make-support/src/external_deps/rustc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ impl Rustc {
227227
self
228228
}
229229

230+
/// Normalize the line number in the stderr output
231+
pub fn ui_testing(&mut self) -> &mut Self {
232+
self.cmd.arg(format!("-Zui-testing"));
233+
self
234+
}
235+
230236
/// Specify the target triple, or a path to a custom target json spec file.
231237
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
232238
let target = target.as_ref();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// MIR for `constant` after built
2+
3+
fn constant() -> () {
4+
debug scalar => const 5_usize;
5+
let mut _0: ();
6+
7+
bb0: {
8+
return;
9+
}
10+
}

tests/mir-opt/building/custom/debuginfo.numbered.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
fn numbered(_1: (u32, i32)) -> () {
44
debug first => (_1.0: u32);
5-
debug second => (_1.0: u32);
5+
debug second => (_1.1: i32);
66
let mut _0: ();
77

88
bb0: {

0 commit comments

Comments
 (0)