Skip to content

Commit

Permalink
Auto merge of rust-lang#133658 - jieyouxu:rollup-rq7e0gk, r=jieyouxu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 30, 2024
2 parents 76f3ff6 + 6512836 commit b980396
Show file tree
Hide file tree
Showing 44 changed files with 580 additions and 255 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4713,9 +4713,9 @@ checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"

[[package]]
name = "ruzstd"
version = "0.7.2"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21"
checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f"
dependencies = [
"twox-hash",
]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ declare_features! (
(accepted, expr_fragment_specifier_2024, "1.83.0", Some(123742)),
/// Allows arbitrary expressions in key-value attributes at parse time.
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
/// convention for functions with varargs.
(accepted, extended_varargs_abi_support, "CURRENT_RUSTC_VERSION", Some(100189)),
/// Allows resolving absolute paths as paths from other crates.
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,6 @@ declare_features! (
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
/// Allows explicit tail calls via `become` expression.
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
/// for functions with varargs.
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189)),
/// Allows defining `extern type`s.
(unstable, extern_types, "1.23.0", Some(43467)),
/// Allow using 128-bit (quad precision) floating point numbers.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ hir_analysis_value_of_associated_struct_already_specified =
.label = re-bound here
.previous_bound_label = `{$item_name}` bound here first
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
.label = C-variadic function must have a compatible calling convention
hir_analysis_variances_of = {$variances}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,10 @@ pub(crate) struct MainFunctionGenericParameters {

#[derive(Diagnostic)]
#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
pub(crate) struct VariadicFunctionCompatibleConvention {
#[primary_span]
#[label]
pub span: Span,
pub conventions: &'a str,
}

#[derive(Diagnostic)]
Expand Down
31 changes: 2 additions & 29 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ use rustc_middle::middle;
use rustc_middle::mir::interpret::GlobalId;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
use rustc_session::parse::feature_err;
use rustc_span::Span;
use rustc_span::symbol::sym;
use rustc_trait_selection::traits;

use self::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
Expand All @@ -113,34 +111,9 @@ fn require_c_abi_if_c_variadic(
abi: ExternAbi,
span: Span,
) {
const CONVENTIONS_UNSTABLE: &str =
"`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`";
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
const UNSTABLE_EXPLAIN: &str =
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";

if !decl.c_variadic || matches!(abi, ExternAbi::C { .. } | ExternAbi::Cdecl { .. }) {
return;
if decl.c_variadic && !abi.supports_varargs() {
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span });
}

let extended_abi_support = tcx.features().extended_varargs_abi_support();
let conventions = match (extended_abi_support, abi.supports_varargs()) {
// User enabled additional ABI support for varargs and function ABI matches those ones.
(true, true) => return,

// Using this ABI would be ok, if the feature for additional ABI support was enabled.
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
(false, true) => {
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
.emit();
CONVENTIONS_STABLE
}

(false, false) => CONVENTIONS_STABLE,
(true, false) => CONVENTIONS_UNSTABLE,
};

tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
}

pub fn provide(providers: &mut Providers) {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value in
hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
.suggestion = cast the value to `{$cast_ty}`
.help = cast the value to `{$cast_ty}`
.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
hir_typeck_ptr_cast_add_auto_to_object = adding {$traits_len ->
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,8 @@ pub(crate) struct PassToVariadicFunction<'a, 'tcx> {
pub span: Span,
pub ty: Ty<'tcx>,
pub cast_ty: &'a str,
#[suggestion(code = "{replace}", applicability = "machine-applicable")]
pub sugg_span: Option<Span>,
pub replace: String,
#[help]
pub help: bool,
#[suggestion(code = " as {cast_ty}", applicability = "machine-applicable", style = "verbose")]
pub sugg_span: Span,
#[note(hir_typeck_teach_help)]
pub(crate) teach: bool,
}
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,20 +440,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty: Ty<'tcx>,
cast_ty: &str,
) {
let (sugg_span, replace, help) =
if let Ok(snippet) = sess.source_map().span_to_snippet(span) {
(Some(span), format!("{snippet} as {cast_ty}"), false)
} else {
(None, "".to_string(), true)
};

sess.dcx().emit_err(errors::PassToVariadicFunction {
span,
ty,
cast_ty,
help,
replace,
sugg_span,
sugg_span: span.shrink_to_hi(),
teach: sess.teach(E0617),
});
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ pub fn walk_native_lib_search_dirs<R>(
// The targets here should be in sync with `copy_third_party_objects` in bootstrap.
// FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
// and sanitizers to self-contained directory, and stop adding this search path.
// FIXME: On AIX this also has the side-effect of making the list of library search paths
// non-empty, which is needed or the linker may decide to record the LIBPATH env, if
// defined, as the search path instead of appending the default search paths.
if sess.target.vendor == "fortanix"
|| sess.target.os == "linux"
|| sess.target.os == "fuchsia"
|| sess.target.is_like_aix
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
{
f(&sess.target_tlib_path.dir, false)?;
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,6 @@ impl<'a> Parser<'a> {
/// `await? <expr>`, `await(<expr>)`, and `await { <expr> }`.
pub(super) fn recover_incorrect_await_syntax(
&mut self,
lo: Span,
await_sp: Span,
) -> PResult<'a, P<Expr>> {
let (hi, expr, is_question) = if self.token == token::Not {
Expand All @@ -1999,8 +1998,8 @@ impl<'a> Parser<'a> {
} else {
self.recover_await_prefix(await_sp)?
};
let (sp, guar) = self.error_on_incorrect_await(lo, hi, &expr, is_question);
let expr = self.mk_expr_err(lo.to(sp), guar);
let (sp, guar) = self.error_on_incorrect_await(await_sp, hi, &expr, is_question);
let expr = self.mk_expr_err(await_sp.to(sp), guar);
self.maybe_recover_from_bad_qpath(expr)
}

Expand Down
19 changes: 8 additions & 11 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,34 +1446,31 @@ impl<'a> Parser<'a> {
this.parse_expr_closure()
} else {
assert!(this.eat_keyword(kw::For));
this.parse_expr_for(None, this.prev_token.span)
this.parse_expr_for(None, lo)
}
} else if this.eat_keyword(kw::While) {
this.parse_expr_while(None, this.prev_token.span)
this.parse_expr_while(None, lo)
} else if let Some(label) = this.eat_label() {
this.parse_expr_labeled(label, true)
} else if this.eat_keyword(kw::Loop) {
let sp = this.prev_token.span;
this.parse_expr_loop(None, this.prev_token.span).map_err(|mut err| {
err.span_label(sp, "while parsing this `loop` expression");
this.parse_expr_loop(None, lo).map_err(|mut err| {
err.span_label(lo, "while parsing this `loop` expression");
err
})
} else if this.eat_keyword(kw::Match) {
let match_sp = this.prev_token.span;
this.parse_expr_match().map_err(|mut err| {
err.span_label(match_sp, "while parsing this `match` expression");
err.span_label(lo, "while parsing this `match` expression");
err
})
} else if this.eat_keyword(kw::Unsafe) {
let sp = this.prev_token.span;
this.parse_expr_block(None, lo, BlockCheckMode::Unsafe(ast::UserProvided)).map_err(
|mut err| {
err.span_label(sp, "while parsing this `unsafe` expression");
err.span_label(lo, "while parsing this `unsafe` expression");
err
},
)
} else if this.check_inline_const(0) {
this.parse_const_block(lo.to(this.token.span), false)
this.parse_const_block(lo, false)
} else if this.may_recover() && this.is_do_catch_block() {
this.recover_do_catch()
} else if this.is_try_block() {
Expand Down Expand Up @@ -1514,7 +1511,7 @@ impl<'a> Parser<'a> {
this.parse_expr_closure()
}
} else if this.eat_keyword_noexpect(kw::Await) {
this.recover_incorrect_await_syntax(lo, this.prev_token.span)
this.recover_incorrect_await_syntax(lo)
} else {
this.parse_expr_lit()
}
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ impl<'a> Parser<'a> {
// Function pointer type
self.parse_ty_bare_fn(lo, ThinVec::new(), None, recover_return_sign)?
} else if self.check_keyword(kw::For) {
let for_span = self.token.span;
// Function pointer type or bound list (trait object type) starting with a poly-trait.
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
Expand Down Expand Up @@ -302,7 +301,7 @@ impl<'a> Parser<'a> {
kw: kw.name.as_str(),
sugg: errors::TransposeDynOrImplSugg {
removal_span,
insertion_span: for_span.shrink_to_lo(),
insertion_span: lo.shrink_to_lo(),
kw: kw.name.as_str(),
},
});
Expand Down Expand Up @@ -345,16 +344,14 @@ impl<'a> Parser<'a> {
// FIXME(c_variadic): Should we just allow `...` syntactically
// anywhere in a type and use semantic restrictions instead?
// NOTE: This may regress certain MBE calls if done incorrectly.
let guar = self
.dcx()
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
let guar = self.dcx().emit_err(NestedCVariadicType { span: lo });
TyKind::Err(guar)
}
}
} else {
let msg = format!("expected type, found {}", super::token_descr(&self.token));
let mut err = self.dcx().struct_span_err(self.token.span, msg);
err.span_label(self.token.span, "expected type");
let mut err = self.dcx().struct_span_err(lo, msg);
err.span_label(lo, "expected type");
return Err(err);
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/asm/loongarch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl LoongArchInlineAsmRegClass {
) -> &'static [(InlineAsmType, Option<Symbol>)] {
match self {
Self::reg => types! { _: I8, I16, I32, I64, F32, F64; },
Self::freg => types! { _: F32, F64; },
Self::freg => types! { f: F32; d: F64; },
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(crate) fn target() -> Target {
cpu: "esp32-s2".into(),
linker: Some("xtensa-esp32s2-elf-gcc".into()),
max_atomic_width: Some(32),
features: "+forced-atomics".into(),
..xtensa::opts()
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
span.push_span_label(self.tcx.def_span(trait_def_id), "this is the required trait");
for (sp, label) in [trait_def_id, other_trait_def_id]
.iter()
// The current crate-version might depend on another version of the same crate
// (Think "semver-trick"). Do not call `extern_crate` in that case for the local
// crate as that doesn't make sense and ICEs (#133563).
.filter(|def_id| !def_id.is_local())
.filter_map(|def_id| self.tcx.extern_crate(def_id.krate))
.map(|data| {
let dependency = if data.dependency_of == LOCAL_CRATE {
Expand Down
33 changes: 33 additions & 0 deletions library/core/src/intrinsics/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,39 @@
//! `Call(ret_val = function(arg1, arg2, ...), ReturnTo(next_block), UnwindContinue())`.
//! - [`TailCall`] does not have a return destination or next block, so its syntax is just
//! `TailCall(function(arg1, arg2, ...))`.
//!
//! #### Debuginfo
//!
//! Debuginfo associates source code variable names (of variables that may not exist any more) with
//! MIR expressions that indicate where the value of that variable is stored. The syntax to do so
//! is:
//! ```text
//! debug source_var_name => expression;
//! ```
//! Both places and constants are supported in the `expression`.
//!
//! ```rust
//! #![allow(internal_features)]
//! #![feature(core_intrinsics, custom_mir)]
//!
//! use core::intrinsics::mir::*;
//!
//! #[custom_mir(dialect = "built")]
//! fn debuginfo(arg: Option<&i32>) {
//! mir!(
//! // Debuginfo for a source variable `plain_local` that just duplicates `arg`.
//! debug plain_local => arg;
//! // Debuginfo for a source variable `projection` that can be computed by dereferencing
//! // a field of `arg`.
//! debug projection => *Field::<&i32>(Variant(arg, 1), 0);
//! // Debuginfo for a source variable `constant` that always holds the value `5`.
//! debug constant => 5_usize;
//! {
//! Return()
//! }
//! )
//! }
//! ```
#![unstable(
feature = "custom_mir",
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@
#![feature(doc_masked)]
#![feature(doc_notable_trait)]
#![feature(dropck_eyepatch)]
#![feature(extended_varargs_abi_support)]
#![feature(f128)]
#![feature(f16)]
#![feature(if_let_guard)]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn copy_third_party_objects(

if target == "x86_64-fortanix-unknown-sgx"
|| builder.config.llvm_libunwind(target) == LlvmLibunwind::InTree
&& (target.contains("linux") || target.contains("fuchsia"))
&& (target.contains("linux") || target.contains("fuchsia") || target.contains("aix"))
{
let libunwind_path =
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/external_deps/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ impl Rustc {
self
}

/// Normalize the line number in the stderr output
pub fn ui_testing(&mut self) -> &mut Self {
self.cmd.arg(format!("-Zui-testing"));
self
}

/// Specify the target triple, or a path to a custom target json spec file.
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
let target = target.as_ref();
Expand Down
10 changes: 10 additions & 0 deletions tests/mir-opt/building/custom/debuginfo.constant.built.after.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// MIR for `constant` after built

fn constant() -> () {
debug scalar => const 5_usize;
let mut _0: ();

bb0: {
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

fn numbered(_1: (u32, i32)) -> () {
debug first => (_1.0: u32);
debug second => (_1.0: u32);
debug second => (_1.1: i32);
let mut _0: ();

bb0: {
Expand Down
Loading

0 comments on commit b980396

Please sign in to comment.