Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b980396

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

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 2 additions & 29 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 5 deletions
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

Lines changed: 1 addition & 10 deletions
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

Lines changed: 4 additions & 0 deletions
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)?;

0 commit comments

Comments
 (0)