mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 14:02:57 +00:00
Auto merge of #130934 - matthiaskrgr:rollup-4puticr, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #129087 (Stabilize `option_get_or_insert_default`) - #130435 (Move Apple linker args from `rustc_target` to `rustc_codegen_ssa`) - #130459 (delete sub build directory "debug" to not delete the change-id file) - #130873 (rustc_target: Add powerpc64 atomic-related features) - #130916 (Use `&raw` in the compiler) - #130917 (Fix error span if arg to `asm!()` is a macro call) - #130927 (update outdated comments) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
fa724e5d8c
@ -507,6 +507,7 @@ fn expand_preparsed_asm(
|
||||
|
||||
let msg = "asm template must be a string literal";
|
||||
let template_sp = template_expr.span;
|
||||
let template_is_mac_call = matches!(template_expr.kind, ast::ExprKind::MacCall(_));
|
||||
let (template_str, template_style, template_span) = {
|
||||
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, template_expr, msg) else {
|
||||
return ExpandResult::Retry(());
|
||||
@ -596,7 +597,14 @@ fn expand_preparsed_asm(
|
||||
|
||||
if !parser.errors.is_empty() {
|
||||
let err = parser.errors.remove(0);
|
||||
let err_sp = template_span.from_inner(InnerSpan::new(err.span.start, err.span.end));
|
||||
let err_sp = if template_is_mac_call {
|
||||
// If the template is a macro call we can't reliably point to the error's
|
||||
// span so just use the template's span as the error span (fixes #129503)
|
||||
template_span
|
||||
} else {
|
||||
template_span.from_inner(InnerSpan::new(err.span.start, err.span.end))
|
||||
};
|
||||
|
||||
let msg = format!("invalid asm template string: {}", err.description);
|
||||
let mut e = ecx.dcx().struct_span_err(err_sp, msg);
|
||||
e.span_label(err_sp, err.label + " in asm template string");
|
||||
|
@ -123,7 +123,7 @@ fn get_llvm_object_symbols(
|
||||
llvm::LLVMRustGetSymbols(
|
||||
buf.as_ptr(),
|
||||
buf.len(),
|
||||
std::ptr::addr_of_mut!(*state) as *mut c_void,
|
||||
(&raw mut *state) as *mut c_void,
|
||||
callback,
|
||||
error_callback,
|
||||
)
|
||||
|
@ -167,7 +167,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||
fn print_pass_timings(&self) {
|
||||
unsafe {
|
||||
let mut size = 0;
|
||||
let cstr = llvm::LLVMRustPrintPassTimings(std::ptr::addr_of_mut!(size));
|
||||
let cstr = llvm::LLVMRustPrintPassTimings(&raw mut size);
|
||||
if cstr.is_null() {
|
||||
println!("failed to get pass timings");
|
||||
} else {
|
||||
@ -180,7 +180,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||
fn print_statistics(&self) {
|
||||
unsafe {
|
||||
let mut size = 0;
|
||||
let cstr = llvm::LLVMRustPrintStatistics(std::ptr::addr_of_mut!(size));
|
||||
let cstr = llvm::LLVMRustPrintStatistics(&raw mut size);
|
||||
if cstr.is_null() {
|
||||
println!("failed to get pass stats");
|
||||
} else {
|
||||
|
@ -478,7 +478,7 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut String, sess: &Session) {
|
||||
&tm,
|
||||
cpu_cstring.as_ptr(),
|
||||
callback,
|
||||
std::ptr::addr_of_mut!(out) as *mut c_void,
|
||||
(&raw mut out) as *mut c_void,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ use rustc_target::spec::crt_objects::CrtObjects;
|
||||
use rustc_target::spec::{
|
||||
Cc, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures,
|
||||
LinkerFlavor, LinkerFlavorCli, Lld, PanicStrategy, RelocModel, RelroLevel, SanitizerSet,
|
||||
SplitDebuginfo,
|
||||
SplitDebuginfo, current_apple_deployment_target,
|
||||
};
|
||||
use tempfile::Builder as TempFileBuilder;
|
||||
use tracing::{debug, info, warn};
|
||||
@ -2405,6 +2405,8 @@ fn add_order_independent_options(
|
||||
// Take care of the flavors and CLI options requesting the `lld` linker.
|
||||
add_lld_args(cmd, sess, flavor, self_contained_components);
|
||||
|
||||
add_apple_link_args(cmd, sess, flavor);
|
||||
|
||||
let apple_sdk_root = add_apple_sdk(cmd, sess, flavor);
|
||||
|
||||
add_link_script(cmd, sess, tmpdir, crate_type);
|
||||
@ -2957,6 +2959,135 @@ pub(crate) fn are_upstream_rust_objects_already_included(sess: &Session) -> bool
|
||||
}
|
||||
}
|
||||
|
||||
/// We need to communicate four things to the linker on Apple/Darwin targets:
|
||||
/// - The architecture.
|
||||
/// - The operating system (and that it's an Apple platform).
|
||||
/// - The deployment target.
|
||||
/// - The environment / ABI.
|
||||
fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
if !sess.target.is_like_osx {
|
||||
return;
|
||||
}
|
||||
let LinkerFlavor::Darwin(cc, _) = flavor else {
|
||||
return;
|
||||
};
|
||||
|
||||
// `sess.target.arch` (`target_arch`) is not detailed enough.
|
||||
let llvm_arch = sess.target.llvm_target.split_once('-').expect("LLVM target must have arch").0;
|
||||
let target_os = &*sess.target.os;
|
||||
let target_abi = &*sess.target.abi;
|
||||
|
||||
// The architecture name to forward to the linker.
|
||||
//
|
||||
// Supported architecture names can be found in the source:
|
||||
// https://github.com/apple-oss-distributions/ld64/blob/ld64-951.9/src/abstraction/MachOFileAbstraction.hpp#L578-L648
|
||||
//
|
||||
// Intentially verbose to ensure that the list always matches correctly
|
||||
// with the list in the source above.
|
||||
let ld64_arch = match llvm_arch {
|
||||
"armv7k" => "armv7k",
|
||||
"armv7s" => "armv7s",
|
||||
"arm64" => "arm64",
|
||||
"arm64e" => "arm64e",
|
||||
"arm64_32" => "arm64_32",
|
||||
// ld64 doesn't understand i686, so fall back to i386 instead.
|
||||
//
|
||||
// Same story when linking with cc, since that ends up invoking ld64.
|
||||
"i386" | "i686" => "i386",
|
||||
"x86_64" => "x86_64",
|
||||
"x86_64h" => "x86_64h",
|
||||
_ => bug!("unsupported architecture in Apple target: {}", sess.target.llvm_target),
|
||||
};
|
||||
|
||||
if cc == Cc::No {
|
||||
// From the man page for ld64 (`man ld`):
|
||||
// > The linker accepts universal (multiple-architecture) input files,
|
||||
// > but always creates a "thin" (single-architecture), standard
|
||||
// > Mach-O output file. The architecture for the output file is
|
||||
// > specified using the -arch option.
|
||||
//
|
||||
// The linker has heuristics to determine the desired architecture,
|
||||
// but to be safe, and to avoid a warning, we set the architecture
|
||||
// explicitly.
|
||||
cmd.link_args(&["-arch", ld64_arch]);
|
||||
|
||||
// Man page says that ld64 supports the following platform names:
|
||||
// > - macos
|
||||
// > - ios
|
||||
// > - tvos
|
||||
// > - watchos
|
||||
// > - bridgeos
|
||||
// > - visionos
|
||||
// > - xros
|
||||
// > - mac-catalyst
|
||||
// > - ios-simulator
|
||||
// > - tvos-simulator
|
||||
// > - watchos-simulator
|
||||
// > - visionos-simulator
|
||||
// > - xros-simulator
|
||||
// > - driverkit
|
||||
let platform_name = match (target_os, target_abi) {
|
||||
(os, "") => os,
|
||||
("ios", "macabi") => "mac-catalyst",
|
||||
("ios", "sim") => "ios-simulator",
|
||||
("tvos", "sim") => "tvos-simulator",
|
||||
("watchos", "sim") => "watchos-simulator",
|
||||
("visionos", "sim") => "visionos-simulator",
|
||||
_ => bug!("invalid OS/ABI combination for Apple target: {target_os}, {target_abi}"),
|
||||
};
|
||||
|
||||
let (major, minor, patch) = current_apple_deployment_target(&sess.target);
|
||||
let min_version = format!("{major}.{minor}.{patch}");
|
||||
|
||||
// Lie about the SDK version, we don't know it here
|
||||
let sdk_version = &*min_version;
|
||||
|
||||
// From the man page for ld64 (`man ld`):
|
||||
// > This is set to indicate the platform, oldest supported version of
|
||||
// > that platform that output is to be used on, and the SDK that the
|
||||
// > output was built against.
|
||||
//
|
||||
// Like with `-arch`, the linker can figure out the platform versions
|
||||
// itself from the binaries being linked, but to be safe, we specify
|
||||
// the desired versions here explicitly.
|
||||
cmd.link_args(&["-platform_version", platform_name, &*min_version, sdk_version]);
|
||||
} else {
|
||||
// cc == Cc::Yes
|
||||
// We'd _like_ to use `-target` everywhere, since that can uniquely
|
||||
// communicate all the required details, but that doesn't work on GCC,
|
||||
// and since we don't know whether the `cc` compiler is Clang, GCC, or
|
||||
// something else, we fall back to other options that also work on GCC
|
||||
// when compiling for macOS.
|
||||
//
|
||||
// Targets other than macOS are ill-supported by GCC (it doesn't even
|
||||
// support e.g. `-miphoneos-version-min`), so in those cases we can
|
||||
// fairly safely use `-target`. See also the following, where it is
|
||||
// made explicit that the recommendation by LLVM developers is to use
|
||||
// `-target`: <https://github.com/llvm/llvm-project/issues/88271>
|
||||
if target_os == "macos" {
|
||||
// `-arch` communicates the architecture.
|
||||
//
|
||||
// CC forwards the `-arch` to the linker, so we use the same value
|
||||
// here intentionally.
|
||||
cmd.cc_args(&["-arch", ld64_arch]);
|
||||
|
||||
// The presence of `-mmacosx-version-min` makes CC default to
|
||||
// macOS, and it sets the deployment target.
|
||||
let (major, minor, patch) = current_apple_deployment_target(&sess.target);
|
||||
// Intentionally pass this as a single argument, Clang doesn't
|
||||
// seem to like it otherwise.
|
||||
cmd.cc_arg(&format!("-mmacosx-version-min={major}.{minor}.{patch}"));
|
||||
|
||||
// macOS has no environment, so with these two, we've told CC the
|
||||
// four desired parameters.
|
||||
//
|
||||
// We avoid `-m32`/`-m64`, as this is already encoded by `-arch`.
|
||||
} else {
|
||||
cmd.cc_args(&["-target", &sess.target.llvm_target]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) -> Option<PathBuf> {
|
||||
let arch = &sess.target.arch;
|
||||
let os = &sess.target.os;
|
||||
|
@ -437,7 +437,7 @@ impl<T> RwLock<T> {
|
||||
#[inline(always)]
|
||||
pub fn leak(&self) -> &T {
|
||||
let guard = self.read();
|
||||
let ret = unsafe { &*std::ptr::addr_of!(*guard) };
|
||||
let ret = unsafe { &*(&raw const *guard) };
|
||||
std::mem::forget(guard);
|
||||
ret
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ impl<'sess> OnDiskCache<'sess> {
|
||||
|
||||
for (index, file) in files.iter().enumerate() {
|
||||
let index = SourceFileIndex(index as u32);
|
||||
let file_ptr: *const SourceFile = std::ptr::addr_of!(**file);
|
||||
let file_ptr: *const SourceFile = &raw const **file;
|
||||
file_to_file_index.insert(file_ptr, index);
|
||||
let source_file_id = EncodedSourceFileId::new(tcx, file);
|
||||
file_index_to_stable_id.insert(index, source_file_id);
|
||||
@ -827,7 +827,7 @@ pub struct CacheEncoder<'a, 'tcx> {
|
||||
impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
|
||||
#[inline]
|
||||
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
|
||||
self.file_to_file_index[&std::ptr::addr_of!(*source_file)]
|
||||
self.file_to_file_index[&(&raw const *source_file)]
|
||||
}
|
||||
|
||||
/// Encode something with additional information that allows to do some
|
||||
|
@ -103,13 +103,13 @@ impl<H, T> RawList<H, T> {
|
||||
let mem = arena.dropless.alloc_raw(layout) as *mut RawList<H, T>;
|
||||
unsafe {
|
||||
// Write the header
|
||||
ptr::addr_of_mut!((*mem).skel.header).write(header);
|
||||
(&raw mut (*mem).skel.header).write(header);
|
||||
|
||||
// Write the length
|
||||
ptr::addr_of_mut!((*mem).skel.len).write(slice.len());
|
||||
(&raw mut (*mem).skel.len).write(slice.len());
|
||||
|
||||
// Write the elements
|
||||
ptr::addr_of_mut!((*mem).skel.data)
|
||||
(&raw mut (*mem).skel.data)
|
||||
.cast::<T>()
|
||||
.copy_from_nonoverlapping(slice.as_ptr(), slice.len());
|
||||
|
||||
@ -160,7 +160,7 @@ macro_rules! impl_list_empty {
|
||||
|
||||
// SAFETY: `EMPTY` is sufficiently aligned to be an empty list for all
|
||||
// types with `align_of(T) <= align_of(MaxAlign)`, which we checked above.
|
||||
unsafe { &*(std::ptr::addr_of!(EMPTY) as *const RawList<$header_ty, T>) }
|
||||
unsafe { &*((&raw const EMPTY) as *const RawList<$header_ty, T>) }
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -238,7 +238,7 @@ impl<H, T> Deref for RawList<H, T> {
|
||||
impl<H, T> AsRef<[T]> for RawList<H, T> {
|
||||
#[inline(always)]
|
||||
fn as_ref(&self) -> &[T] {
|
||||
let data_ptr = ptr::addr_of!(self.skel.data).cast::<T>();
|
||||
let data_ptr = (&raw const self.skel.data).cast::<T>();
|
||||
// SAFETY: `data_ptr` has the same provenance as `self` and can therefore
|
||||
// access the `self.skel.len` elements stored at `self.skel.data`.
|
||||
// Note that we specifically don't reborrow `&self.skel.data`, because that
|
||||
|
@ -3,7 +3,6 @@
|
||||
#![feature(iter_intersperse)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(map_many_mut)]
|
||||
#![feature(option_get_or_insert_default)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![warn(unreachable_pub)]
|
||||
// tidy-alphabetical-end
|
||||
|
@ -3,8 +3,8 @@ use std::env;
|
||||
use std::num::ParseIntError;
|
||||
|
||||
use crate::spec::{
|
||||
Cc, DebuginfoKind, FramePointer, LinkArgs, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType,
|
||||
StaticCow, Target, TargetOptions, add_link_args, add_link_args_iter, cvs,
|
||||
Cc, DebuginfoKind, FramePointer, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType, StaticCow,
|
||||
Target, TargetOptions, cvs,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@ -40,25 +40,6 @@ impl Arch {
|
||||
}
|
||||
}
|
||||
|
||||
/// The architecture name to forward to the linker.
|
||||
fn ld_arch(self) -> &'static str {
|
||||
// Supported architecture names can be found in the source:
|
||||
// https://github.com/apple-oss-distributions/ld64/blob/ld64-951.9/src/abstraction/MachOFileAbstraction.hpp#L578-L648
|
||||
match self {
|
||||
Armv7k => "armv7k",
|
||||
Armv7s => "armv7s",
|
||||
Arm64 => "arm64",
|
||||
Arm64e => "arm64e",
|
||||
Arm64_32 => "arm64_32",
|
||||
// ld64 doesn't understand i686, so fall back to i386 instead
|
||||
//
|
||||
// Same story when linking with cc, since that ends up invoking ld64.
|
||||
I386 | I686 => "i386",
|
||||
X86_64 => "x86_64",
|
||||
X86_64h => "x86_64h",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn target_arch(self) -> Cow<'static, str> {
|
||||
Cow::Borrowed(match self {
|
||||
Armv7k | Armv7s => "arm",
|
||||
@ -116,104 +97,6 @@ impl TargetAbi {
|
||||
}
|
||||
}
|
||||
|
||||
fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
|
||||
// From the man page for ld64 (`man ld`):
|
||||
// > The linker accepts universal (multiple-architecture) input files,
|
||||
// > but always creates a "thin" (single-architecture), standard Mach-O
|
||||
// > output file. The architecture for the output file is specified using
|
||||
// > the -arch option.
|
||||
//
|
||||
// The linker has heuristics to determine the desired architecture, but to
|
||||
// be safe, and to avoid a warning, we set the architecture explicitly.
|
||||
let mut args =
|
||||
TargetOptions::link_args(LinkerFlavor::Darwin(Cc::No, Lld::No), &["-arch", arch.ld_arch()]);
|
||||
|
||||
// From the man page for ld64 (`man ld`):
|
||||
// > This is set to indicate the platform, oldest supported version of
|
||||
// > that platform that output is to be used on, and the SDK that the
|
||||
// > output was built against. platform [...] may be one of the following
|
||||
// > strings:
|
||||
// > - macos
|
||||
// > - ios
|
||||
// > - tvos
|
||||
// > - watchos
|
||||
// > - bridgeos
|
||||
// > - visionos
|
||||
// > - xros
|
||||
// > - mac-catalyst
|
||||
// > - ios-simulator
|
||||
// > - tvos-simulator
|
||||
// > - watchos-simulator
|
||||
// > - visionos-simulator
|
||||
// > - xros-simulator
|
||||
// > - driverkit
|
||||
//
|
||||
// Like with `-arch`, the linker can figure out the platform versions
|
||||
// itself from the binaries being linked, but to be safe, we specify the
|
||||
// desired versions here explicitly.
|
||||
let platform_name: StaticCow<str> = match abi {
|
||||
TargetAbi::Normal => os.into(),
|
||||
TargetAbi::Simulator => format!("{os}-simulator").into(),
|
||||
TargetAbi::MacCatalyst => "mac-catalyst".into(),
|
||||
};
|
||||
let min_version: StaticCow<str> = {
|
||||
let (major, minor, patch) = deployment_target(os, arch, abi);
|
||||
format!("{major}.{minor}.{patch}").into()
|
||||
};
|
||||
// Lie about the SDK version, we don't know it here
|
||||
let sdk_version = min_version.clone();
|
||||
add_link_args_iter(
|
||||
&mut args,
|
||||
LinkerFlavor::Darwin(Cc::No, Lld::No),
|
||||
["-platform_version".into(), platform_name, min_version, sdk_version].into_iter(),
|
||||
);
|
||||
|
||||
// We need to communicate four things to the C compiler to be able to link:
|
||||
// - The architecture.
|
||||
// - The operating system (and that it's an Apple platform).
|
||||
// - The deployment target.
|
||||
// - The environment / ABI.
|
||||
//
|
||||
// We'd like to use `-target` everywhere, since that can uniquely
|
||||
// communicate all of these, but that doesn't work on GCC, and since we
|
||||
// don't know whether the `cc` compiler is Clang, GCC, or something else,
|
||||
// we fall back to other options that also work on GCC when compiling for
|
||||
// macOS.
|
||||
//
|
||||
// Targets other than macOS are ill-supported by GCC (it doesn't even
|
||||
// support e.g. `-miphoneos-version-min`), so in those cases we can fairly
|
||||
// safely use `-target`. See also the following, where it is made explicit
|
||||
// that the recommendation by LLVM developers is to use `-target`:
|
||||
// <https://github.com/llvm/llvm-project/issues/88271>
|
||||
if os == "macos" {
|
||||
// `-arch` communicates the architecture.
|
||||
//
|
||||
// CC forwards the `-arch` to the linker, so we use the same value
|
||||
// here intentionally.
|
||||
add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &[
|
||||
"-arch",
|
||||
arch.ld_arch(),
|
||||
]);
|
||||
// The presence of `-mmacosx-version-min` makes CC default to macOS,
|
||||
// and it sets the deployment target.
|
||||
let (major, minor, patch) = deployment_target(os, arch, abi);
|
||||
let opt = format!("-mmacosx-version-min={major}.{minor}.{patch}").into();
|
||||
add_link_args_iter(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), [opt].into_iter());
|
||||
// macOS has no environment, so with these two, we've told CC all the
|
||||
// desired parameters.
|
||||
//
|
||||
// We avoid `-m32`/`-m64`, as this is already encoded by `-arch`.
|
||||
} else {
|
||||
add_link_args_iter(
|
||||
&mut args,
|
||||
LinkerFlavor::Darwin(Cc::Yes, Lld::No),
|
||||
["-target".into(), llvm_target(os, arch, abi)].into_iter(),
|
||||
);
|
||||
}
|
||||
|
||||
args
|
||||
}
|
||||
|
||||
/// Get the base target options, LLVM target and `target_arch` from the three
|
||||
/// things that uniquely identify Rust's Apple targets: The OS, the
|
||||
/// architecture, and the ABI.
|
||||
@ -232,7 +115,6 @@ pub(crate) fn base(
|
||||
// macOS has -dead_strip, which doesn't rely on function_sections
|
||||
function_sections: false,
|
||||
dynamic_linking: true,
|
||||
pre_link_args: pre_link_args(os, arch, abi),
|
||||
families: cvs!["unix"],
|
||||
is_like_osx: true,
|
||||
// LLVM notes that macOS 10.11+ and iOS 9+ default
|
||||
|
@ -352,11 +352,13 @@ const HEXAGON_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
||||
const POWERPC_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
||||
// tidy-alphabetical-start
|
||||
("altivec", Unstable(sym::powerpc_target_feature), &[]),
|
||||
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
|
||||
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
|
||||
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
|
||||
("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
|
||||
("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
|
||||
("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
|
||||
("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
|
||||
("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
@ -668,8 +668,8 @@ impl<I: Interner> fmt::Debug for ProjectionPredicate<I> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Used by the new solver. Unlike a `ProjectionPredicate` this can only be
|
||||
/// proven by actually normalizing `alias`.
|
||||
/// Used by the new solver to normalize an alias. This always expects the `term` to
|
||||
/// be an unconstrained inference variable which is used as the output.
|
||||
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
|
||||
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
|
||||
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
|
||||
|
@ -74,13 +74,13 @@ pub enum PredicateKind<I: Interner> {
|
||||
Ambiguous,
|
||||
|
||||
/// This should only be used inside of the new solver for `AliasRelate` and expects
|
||||
/// the `term` to be an unconstrained inference variable.
|
||||
/// the `term` to be always be an unconstrained inference variable. It is used to
|
||||
/// normalize `alias` as much as possible. In case the alias is rigid - i.e. it cannot
|
||||
/// be normalized in the current environment - this constrains `term` to be equal to
|
||||
/// the alias itself.
|
||||
///
|
||||
/// The alias normalizes to `term`. Unlike `Projection`, this always fails if the
|
||||
/// alias cannot be normalized in the current context. For the rigid alias
|
||||
/// `T as Trait>::Assoc`, `Projection(<T as Trait>::Assoc, ?x)` constrains `?x`
|
||||
/// to `<T as Trait>::Assoc` while `NormalizesTo(<T as Trait>::Assoc, ?x)`
|
||||
/// results in `NoSolution`.
|
||||
/// It is likely more useful to think of this as a function `normalizes_to(alias)`,
|
||||
/// whose return value is written into `term`.
|
||||
NormalizesTo(ty::NormalizesTo<I>),
|
||||
|
||||
/// Separate from `ClauseKind::Projection` which is used for normalization in new solver.
|
||||
|
@ -255,7 +255,7 @@ where
|
||||
if TLV.is_set() {
|
||||
Err(Error::from("StableMIR already running"))
|
||||
} else {
|
||||
let ptr: *const () = std::ptr::addr_of!(context) as _;
|
||||
let ptr: *const () = (&raw const context) as _;
|
||||
TLV.set(&Cell::new(ptr), || Ok(f()))
|
||||
}
|
||||
}
|
||||
|
@ -1639,8 +1639,6 @@ impl<T> Option<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(option_get_or_insert_default)]
|
||||
///
|
||||
/// let mut x = None;
|
||||
///
|
||||
/// {
|
||||
@ -1653,7 +1651,7 @@ impl<T> Option<T> {
|
||||
/// assert_eq!(x, Some(7));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "option_get_or_insert_default", issue = "82901")]
|
||||
#[stable(feature = "option_get_or_insert_default", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn get_or_insert_default(&mut self) -> &mut T
|
||||
where
|
||||
T: Default,
|
||||
|
@ -625,9 +625,9 @@ class RustBuild(object):
|
||||
try:
|
||||
# FIXME: A cheap workaround for https://github.com/rust-lang/rust/issues/125578,
|
||||
# remove this once the issue is closed.
|
||||
bootstrap_out = self.bootstrap_out()
|
||||
if os.path.exists(bootstrap_out):
|
||||
shutil.rmtree(bootstrap_out)
|
||||
bootstrap_build_artifacts = os.path.join(self.bootstrap_out(), "debug")
|
||||
if os.path.exists(bootstrap_build_artifacts):
|
||||
shutil.rmtree(bootstrap_build_artifacts)
|
||||
|
||||
p.map(unpack_component, tarballs_download_info)
|
||||
finally:
|
||||
|
@ -1,7 +0,0 @@
|
||||
//@ known-bug: rust-lang/rust#129503
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
unsafe fn f6() {
|
||||
asm!(concat!(r#"lJÆ<F0908FBF>.<>"#, "r} {}"));
|
||||
}
|
26
tests/ui/asm/ice-bad-err-span-in-template-129503.rs
Normal file
26
tests/ui/asm/ice-bad-err-span-in-template-129503.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Regression test for ICE #129503
|
||||
|
||||
|
||||
// Tests that we come up with decent error spans
|
||||
// when the template fed to `asm!()` is itself a
|
||||
// macro call like `concat!()` and should not ICE
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
fn main() {
|
||||
// Should not ICE
|
||||
asm!(concat!(r#"lJÆ<F0908FBF>.<>"#, "r} {}"));
|
||||
//~^ ERROR invalid asm template string: unmatched `}` found
|
||||
|
||||
|
||||
// Macro call template: should point to
|
||||
// everything within `asm!()` as error span
|
||||
asm!(concat!("abc", "r} {}"));
|
||||
//~^ ERROR invalid asm template string: unmatched `}` found
|
||||
|
||||
|
||||
// Literal template: should point precisely to
|
||||
// just the `}` as error span
|
||||
asm!("abc", "r} {}");
|
||||
//~^ ERROR invalid asm template string: unmatched `}` found
|
||||
}
|
28
tests/ui/asm/ice-bad-err-span-in-template-129503.stderr
Normal file
28
tests/ui/asm/ice-bad-err-span-in-template-129503.stderr
Normal file
@ -0,0 +1,28 @@
|
||||
error: invalid asm template string: unmatched `}` found
|
||||
--> $DIR/ice-bad-err-span-in-template-129503.rs:12:10
|
||||
|
|
||||
LL | asm!(concat!(r#"lJÆ<F0908FBF>.<>"#, "r} {}"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string
|
||||
|
|
||||
= note: if you intended to print `}`, you can escape it using `}}`
|
||||
= note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: invalid asm template string: unmatched `}` found
|
||||
--> $DIR/ice-bad-err-span-in-template-129503.rs:18:10
|
||||
|
|
||||
LL | asm!(concat!("abc", "r} {}"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string
|
||||
|
|
||||
= note: if you intended to print `}`, you can escape it using `}}`
|
||||
= note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: invalid asm template string: unmatched `}` found
|
||||
--> $DIR/ice-bad-err-span-in-template-129503.rs:24:19
|
||||
|
|
||||
LL | asm!("abc", "r} {}");
|
||||
| ^ unmatched `}` in asm template string
|
||||
|
|
||||
= note: if you intended to print `}`, you can escape it using `}}`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra`
|
||||
LL | cfg!(target_feature = "zebra");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 239 more
|
||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 241 more
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
warning: 27 warnings emitted
|
||||
|
@ -174,7 +174,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
||||
LL | target_feature = "_UNEXPECTED_VALUE",
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
|
||||
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
||||
|
Loading…
Reference in New Issue
Block a user