mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #127216 - GuillaumeGomez:rollup-iw9f2ed, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #126732 (Stabilize `PanicInfo::message()` and `PanicMessage`) - #126753 (Add nightly style guide section for `precise_capturing` `use<>` syntax) - #126832 (linker: Refactor interface for passing arguments to linker) - #126880 (Migrate `volatile-intrinsics`, `weird-output-filenames`, `wasm-override-linker`, `wasm-exceptions-nostd` to `rmake`) - #127128 (Stabilize `duration_abs_diff`) - #127129 (Use full expr span for return suggestion on type error/ambiguity) - #127188 ( improve the way bootstrap handles rustlib components) - #127201 (Improve run-make-support API) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
cf2df68d1f
@ -45,7 +45,7 @@ use tempfile::Builder as TempFileBuilder;
|
||||
|
||||
use itertools::Itertools;
|
||||
use std::collections::BTreeSet;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::ffi::OsString;
|
||||
use std::fs::{read, File, OpenOptions};
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::ops::Deref;
|
||||
@ -1306,12 +1306,12 @@ fn link_sanitizer_runtime(
|
||||
let filename = format!("rustc{channel}_rt.{name}");
|
||||
let path = find_sanitizer_runtime(sess, &filename);
|
||||
let rpath = path.to_str().expect("non-utf8 component in path");
|
||||
linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
|
||||
linker.cc_args(&["-Wl,-rpath", "-Xlinker", rpath]);
|
||||
linker.link_dylib_by_name(&filename, false, true);
|
||||
} else if sess.target.is_like_msvc && flavor == LinkerFlavor::Msvc(Lld::No) && name == "asan" {
|
||||
// MSVC provides the `/INFERASANLIBS` argument to automatically find the
|
||||
// compatible ASAN library.
|
||||
linker.arg("/INFERASANLIBS");
|
||||
linker.link_arg("/INFERASANLIBS");
|
||||
} else {
|
||||
let filename = format!("librustc{channel}_rt.{name}.a");
|
||||
let path = find_sanitizer_runtime(sess, &filename).join(&filename);
|
||||
@ -1888,9 +1888,9 @@ fn add_post_link_objects(
|
||||
/// FIXME: Determine where exactly these args need to be inserted.
|
||||
fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
if let Some(args) = sess.target.pre_link_args.get(&flavor) {
|
||||
cmd.args(args.iter().map(Deref::deref));
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
cmd.args(&sess.opts.unstable_opts.pre_link_args);
|
||||
cmd.verbatim_args(&sess.opts.unstable_opts.pre_link_args);
|
||||
}
|
||||
|
||||
/// Add a link script embedded in the target, if applicable.
|
||||
@ -1908,8 +1908,7 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty
|
||||
sess.dcx().emit_fatal(errors::LinkScriptWriteFailure { path, error });
|
||||
}
|
||||
|
||||
cmd.arg("--script");
|
||||
cmd.arg(path);
|
||||
cmd.link_arg("--script").link_arg(path);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -1918,7 +1917,7 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty
|
||||
/// Add arbitrary "user defined" args defined from command line.
|
||||
/// FIXME: Determine where exactly these args need to be inserted.
|
||||
fn add_user_defined_link_args(cmd: &mut dyn Linker, sess: &Session) {
|
||||
cmd.args(&sess.opts.cg.link_args);
|
||||
cmd.verbatim_args(&sess.opts.cg.link_args);
|
||||
}
|
||||
|
||||
/// Add arbitrary "late link" args defined by the target spec.
|
||||
@ -1936,15 +1935,15 @@ fn add_late_link_args(
|
||||
});
|
||||
if any_dynamic_crate {
|
||||
if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
|
||||
cmd.args(args.iter().map(Deref::deref));
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else {
|
||||
if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
cmd.args(args.iter().map(Deref::deref));
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
}
|
||||
if let Some(args) = sess.target.late_link_args.get(&flavor) {
|
||||
cmd.args(args.iter().map(Deref::deref));
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1952,7 +1951,7 @@ fn add_late_link_args(
|
||||
/// FIXME: Determine where exactly these args need to be inserted.
|
||||
fn add_post_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
if let Some(args) = sess.target.post_link_args.get(&flavor) {
|
||||
cmd.args(args.iter().map(Deref::deref));
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2097,6 +2096,10 @@ fn add_rpath_args(
|
||||
codegen_results: &CodegenResults,
|
||||
out_filename: &Path,
|
||||
) {
|
||||
if !sess.target.has_rpath {
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME (#2397): At some point we want to rpath our guesses as to
|
||||
// where extern libraries might live, based on the
|
||||
// add_lib_search_paths
|
||||
@ -2115,11 +2118,10 @@ fn add_rpath_args(
|
||||
let rpath_config = RPathConfig {
|
||||
libs: &*libs,
|
||||
out_filename: out_filename.to_path_buf(),
|
||||
has_rpath: sess.target.has_rpath,
|
||||
is_like_osx: sess.target.is_like_osx,
|
||||
linker_is_gnu: sess.target.linker_flavor.is_gnu(),
|
||||
};
|
||||
cmd.args(&rpath::get_rpath_flags(&rpath_config));
|
||||
cmd.cc_args(&rpath::get_rpath_flags(&rpath_config));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2378,7 +2380,7 @@ fn add_order_independent_options(
|
||||
} else {
|
||||
""
|
||||
};
|
||||
cmd.arg(format!("--dynamic-linker={prefix}ld.so.1"));
|
||||
cmd.link_arg(format!("--dynamic-linker={prefix}ld.so.1"));
|
||||
}
|
||||
|
||||
if sess.target.eh_frame_header {
|
||||
@ -2393,8 +2395,7 @@ fn add_order_independent_options(
|
||||
}
|
||||
|
||||
if sess.target.os == "emscripten" {
|
||||
cmd.arg("-s");
|
||||
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
|
||||
cmd.cc_arg("-s").cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
|
||||
"DISABLE_EXCEPTION_CATCHING=1"
|
||||
} else {
|
||||
"DISABLE_EXCEPTION_CATCHING=0"
|
||||
@ -2402,22 +2403,21 @@ fn add_order_independent_options(
|
||||
}
|
||||
|
||||
if flavor == LinkerFlavor::Llbc {
|
||||
cmd.arg("--target");
|
||||
cmd.arg(sess.target.llvm_target.as_ref());
|
||||
cmd.arg("--target-cpu");
|
||||
cmd.arg(&codegen_results.crate_info.target_cpu);
|
||||
cmd.link_args(&[
|
||||
"--target",
|
||||
sess.target.llvm_target.as_ref(),
|
||||
"--target-cpu",
|
||||
&codegen_results.crate_info.target_cpu,
|
||||
]);
|
||||
} else if flavor == LinkerFlavor::Ptx {
|
||||
cmd.arg("--fallback-arch");
|
||||
cmd.arg(&codegen_results.crate_info.target_cpu);
|
||||
cmd.link_args(&["--fallback-arch", &codegen_results.crate_info.target_cpu]);
|
||||
} else if flavor == LinkerFlavor::Bpf {
|
||||
cmd.arg("--cpu");
|
||||
cmd.arg(&codegen_results.crate_info.target_cpu);
|
||||
cmd.link_args(&["--cpu", &codegen_results.crate_info.target_cpu]);
|
||||
if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features]
|
||||
.into_iter()
|
||||
.find(|feat| !feat.is_empty())
|
||||
{
|
||||
cmd.arg("--cpu-features");
|
||||
cmd.arg(feat);
|
||||
cmd.link_args(&["--cpu-features", feat]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2618,7 +2618,11 @@ fn add_native_libs_from_crate(
|
||||
NativeLibKind::WasmImportModule => {}
|
||||
NativeLibKind::LinkArg => {
|
||||
if link_static {
|
||||
cmd.linker_arg(OsStr::new(name), verbatim);
|
||||
if verbatim {
|
||||
cmd.verbatim_arg(name);
|
||||
} else {
|
||||
cmd.link_arg(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3012,10 +3016,10 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
// This is admittedly a bit strange, as on most targets
|
||||
// `-isysroot` only applies to include header files, but on Apple
|
||||
// targets this also applies to libraries and frameworks.
|
||||
cmd.args(&["-isysroot", &sdk_root]);
|
||||
cmd.cc_args(&["-isysroot", &sdk_root]);
|
||||
}
|
||||
LinkerFlavor::Darwin(Cc::No, _) => {
|
||||
cmd.args(&["-syslibroot", &sdk_root]);
|
||||
cmd.link_args(&["-syslibroot", &sdk_root]);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@ -3026,8 +3030,9 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
// search path.
|
||||
|
||||
// The flags are called `-L` and `-F` both in Clang, ld64 and ldd.
|
||||
cmd.arg(format!("-L{sdk_root}/System/iOSSupport/usr/lib"));
|
||||
cmd.arg(format!("-F{sdk_root}/System/iOSSupport/System/Library/Frameworks"));
|
||||
let sdk_root = Path::new(&sdk_root);
|
||||
cmd.include_path(&sdk_root.join("System/iOSSupport/usr/lib"));
|
||||
cmd.framework_path(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3142,7 +3147,7 @@ fn add_lld_args(
|
||||
for path in sess.get_tools_search_paths(false) {
|
||||
let linker_path = path.join("gcc-ld");
|
||||
linker_path_exists |= linker_path.exists();
|
||||
cmd.arg({
|
||||
cmd.cc_arg({
|
||||
let mut arg = OsString::from("-B");
|
||||
arg.push(linker_path);
|
||||
arg
|
||||
@ -3162,7 +3167,7 @@ fn add_lld_args(
|
||||
// is to use LLD but the `wasm32-wasip2` target relies on a wrapper around
|
||||
// this, `wasm-component-ld`, which is overridden if this option is passed.
|
||||
if !sess.target.is_like_wasm {
|
||||
cmd.arg("-fuse-ld=lld");
|
||||
cmd.cc_arg("-fuse-ld=lld");
|
||||
}
|
||||
|
||||
if !flavor.is_gnu() {
|
||||
@ -3186,7 +3191,7 @@ fn add_lld_args(
|
||||
// targeting a different linker flavor on macOS, and that's also always
|
||||
// the case when targeting WASM.
|
||||
if sess.target.linker_flavor != sess.host.linker_flavor {
|
||||
cmd.arg(format!("--target={}", sess.target.llvm_target));
|
||||
cmd.cc_arg(format!("--target={}", sess.target.llvm_target));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,16 +9,10 @@ pub struct RPathConfig<'a> {
|
||||
pub libs: &'a [&'a Path],
|
||||
pub out_filename: PathBuf,
|
||||
pub is_like_osx: bool,
|
||||
pub has_rpath: bool,
|
||||
pub linker_is_gnu: bool,
|
||||
}
|
||||
|
||||
pub fn get_rpath_flags(config: &RPathConfig<'_>) -> Vec<OsString> {
|
||||
// No rpath on windows
|
||||
if !config.has_rpath {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
debug!("preparing the RPATH!");
|
||||
|
||||
let rpaths = get_rpaths(config);
|
||||
|
@ -37,7 +37,6 @@ fn test_rpath_relative() {
|
||||
if cfg!(target_os = "macos") {
|
||||
let config = &mut RPathConfig {
|
||||
libs: &[],
|
||||
has_rpath: true,
|
||||
is_like_osx: true,
|
||||
linker_is_gnu: false,
|
||||
out_filename: PathBuf::from("bin/rustc"),
|
||||
@ -48,7 +47,6 @@ fn test_rpath_relative() {
|
||||
let config = &mut RPathConfig {
|
||||
libs: &[],
|
||||
out_filename: PathBuf::from("bin/rustc"),
|
||||
has_rpath: true,
|
||||
is_like_osx: false,
|
||||
linker_is_gnu: true,
|
||||
};
|
||||
@ -62,7 +60,6 @@ fn test_rpath_relative_issue_119571() {
|
||||
let config = &mut RPathConfig {
|
||||
libs: &[],
|
||||
out_filename: PathBuf::from("rustc"),
|
||||
has_rpath: true,
|
||||
is_like_osx: false,
|
||||
linker_is_gnu: true,
|
||||
};
|
||||
|
@ -2042,7 +2042,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
if block_num > 1 && found_semi {
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_lo(),
|
||||
// use the span of the *whole* expr
|
||||
self.tcx.hir().span(binding_hir_id).shrink_to_lo(),
|
||||
"you might have meant to return this to infer its type parameters",
|
||||
"return ",
|
||||
Applicability::MaybeIncorrect,
|
||||
|
@ -12,7 +12,7 @@ use crate::any::Any;
|
||||
pub use self::location::Location;
|
||||
#[stable(feature = "panic_hooks", since = "1.10.0")]
|
||||
pub use self::panic_info::PanicInfo;
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub use self::panic_info::PanicMessage;
|
||||
#[stable(feature = "catch_unwind", since = "1.9.0")]
|
||||
pub use self::unwind_safe::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
|
||||
|
@ -24,7 +24,7 @@ pub struct PanicInfo<'a> {
|
||||
/// that were given to the `panic!()` macro.
|
||||
///
|
||||
/// See [`PanicInfo::message`].
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub struct PanicMessage<'a> {
|
||||
message: fmt::Arguments<'a>,
|
||||
}
|
||||
@ -57,7 +57,7 @@ impl<'a> PanicInfo<'a> {
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn message(&self) -> PanicMessage<'_> {
|
||||
PanicMessage { message: self.message }
|
||||
}
|
||||
@ -164,7 +164,7 @@ impl<'a> PanicMessage<'a> {
|
||||
/// For most cases with placeholders, this function will return `None`.
|
||||
///
|
||||
/// See [`fmt::Arguments::as_str`] for details.
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_arguments_as_str", issue = "103900")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
@ -173,7 +173,7 @@ impl<'a> PanicMessage<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl Display for PanicMessage<'_> {
|
||||
#[inline]
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@ -181,7 +181,7 @@ impl Display for PanicMessage<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "panic_info_message", issue = "66745")]
|
||||
#[stable(feature = "panic_info_message", since = "CURRENT_RUSTC_VERSION")]
|
||||
impl fmt::Debug for PanicMessage<'_> {
|
||||
#[inline]
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -620,13 +620,14 @@ impl Duration {
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(duration_abs_diff)]
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0));
|
||||
/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000));
|
||||
/// ```
|
||||
#[unstable(feature = "duration_abs_diff", issue = "117618")]
|
||||
#[stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(const_option)]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
@ -30,7 +30,6 @@
|
||||
#![feature(core_private_bignum)]
|
||||
#![feature(core_private_diy_float)]
|
||||
#![feature(dec2flt)]
|
||||
#![feature(duration_abs_diff)]
|
||||
#![feature(duration_consts_float)]
|
||||
#![feature(duration_constants)]
|
||||
#![feature(duration_constructors)]
|
||||
|
@ -339,7 +339,6 @@
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(maybe_uninit_write_slice)]
|
||||
#![feature(panic_can_unwind)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(panic_internals)]
|
||||
#![feature(pointer_is_aligned_to)]
|
||||
#![feature(portable_simd)]
|
||||
|
@ -161,9 +161,10 @@ impl Step for Std {
|
||||
// This check is specific to testing std itself; see `test::Std` for more details.
|
||||
&& !self.force_recompile
|
||||
{
|
||||
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
|
||||
cp_rustc_component_to_ci_sysroot(
|
||||
builder,
|
||||
compiler,
|
||||
&sysroot,
|
||||
builder.config.ci_rust_std_contents(),
|
||||
);
|
||||
return;
|
||||
@ -797,12 +798,7 @@ impl Step for StartupObjects {
|
||||
}
|
||||
}
|
||||
|
||||
fn cp_rustc_component_to_ci_sysroot(
|
||||
builder: &Builder<'_>,
|
||||
compiler: Compiler,
|
||||
contents: Vec<String>,
|
||||
) {
|
||||
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
|
||||
fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, contents: Vec<String>) {
|
||||
let ci_rustc_dir = builder.config.ci_rustc_dir();
|
||||
|
||||
for file in contents {
|
||||
@ -881,13 +877,7 @@ impl Step for Rustc {
|
||||
// NOTE: the ABI of the beta compiler is different from the ABI of the downloaded compiler,
|
||||
// so its artifacts can't be reused.
|
||||
if builder.download_rustc() && compiler.stage != 0 {
|
||||
// Copy the existing artifacts instead of rebuilding them.
|
||||
// NOTE: this path is only taken for tools linking to rustc-dev (including ui-fulldeps tests).
|
||||
cp_rustc_component_to_ci_sysroot(
|
||||
builder,
|
||||
compiler,
|
||||
builder.config.ci_rustc_dev_contents(),
|
||||
);
|
||||
builder.ensure(Sysroot { compiler, force_recompile: false });
|
||||
return compiler.stage;
|
||||
}
|
||||
|
||||
@ -1634,31 +1624,44 @@ impl Step for Sysroot {
|
||||
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
|
||||
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
|
||||
eprintln!(
|
||||
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
|
||||
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
|
||||
sysroot_lib_rustlib_src_rust.display(),
|
||||
builder.src.display(),
|
||||
e,
|
||||
);
|
||||
if builder.config.rust_remap_debuginfo {
|
||||
eprintln!(
|
||||
"WARNING: some `tests/ui` tests will fail when lacking `{}`",
|
||||
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
|
||||
sysroot_lib_rustlib_src_rust.display(),
|
||||
);
|
||||
}
|
||||
build_helper::exit!(1);
|
||||
}
|
||||
// Same for the rustc-src component.
|
||||
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
|
||||
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
|
||||
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
|
||||
if let Err(e) =
|
||||
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
|
||||
{
|
||||
eprintln!(
|
||||
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
|
||||
sysroot_lib_rustlib_rustcsrc_rust.display(),
|
||||
builder.src.display(),
|
||||
e,
|
||||
|
||||
// Unlike rust-src component, we have to handle rustc-src a bit differently.
|
||||
// When using CI rustc, we copy rustc-src component from its sysroot,
|
||||
// otherwise we handle it in a similar way what we do for rust-src above.
|
||||
if builder.download_rustc() {
|
||||
cp_rustc_component_to_ci_sysroot(
|
||||
builder,
|
||||
&sysroot,
|
||||
builder.config.ci_rustc_dev_contents(),
|
||||
);
|
||||
} else {
|
||||
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
|
||||
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
|
||||
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
|
||||
if let Err(e) =
|
||||
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
|
||||
{
|
||||
eprintln!(
|
||||
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
|
||||
sysroot_lib_rustlib_rustcsrc_rust.display(),
|
||||
builder.src.display(),
|
||||
e,
|
||||
);
|
||||
build_helper::exit!(1);
|
||||
}
|
||||
}
|
||||
|
||||
sysroot
|
||||
|
@ -5,3 +5,15 @@ This chapter documents style and formatting for nightly-only syntax. The rest of
|
||||
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.
|
||||
|
||||
There is no guarantee of the stability of this chapter in contrast to the rest of the style guide. Refer to the style team policy for nightly formatting procedure regarding breaking changes to this chapter.
|
||||
|
||||
### `feature(precise_capturing)`
|
||||
|
||||
A `use<'a, T>` precise capturing bound is formatted as if it were a single path segment with non-turbofished angle-bracketed args, like a trait bound whose identifier is `use`.
|
||||
|
||||
```
|
||||
fn foo() -> impl Sized + use<'a> {}
|
||||
|
||||
// is formatted analogously to:
|
||||
|
||||
fn foo() -> impl Sized + Use<'a> {}
|
||||
```
|
||||
|
@ -185,14 +185,14 @@ impl CompletedProcess {
|
||||
/// Checks that `stdout` does not contain `unexpected`.
|
||||
#[track_caller]
|
||||
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
||||
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
|
||||
assert_not_contains(&self.stdout_utf8(), unexpected);
|
||||
self
|
||||
}
|
||||
|
||||
/// Checks that `stdout` contains `expected`.
|
||||
#[track_caller]
|
||||
pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
||||
assert_contains(&self.stdout_utf8(), expected.as_ref());
|
||||
assert_contains(&self.stdout_utf8(), expected);
|
||||
self
|
||||
}
|
||||
|
||||
@ -206,14 +206,14 @@ impl CompletedProcess {
|
||||
/// Checks that `stderr` contains `expected`.
|
||||
#[track_caller]
|
||||
pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
||||
assert_contains(&self.stderr_utf8(), expected.as_ref());
|
||||
assert_contains(&self.stderr_utf8(), expected);
|
||||
self
|
||||
}
|
||||
|
||||
/// Checks that `stderr` does not contain `unexpected`.
|
||||
#[track_caller]
|
||||
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
||||
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
|
||||
assert_not_contains(&self.stdout_utf8(), unexpected);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {
|
||||
|
||||
/// Check that `actual` is equal to `expected`. Panic otherwise.
|
||||
#[track_caller]
|
||||
pub fn assert_equals(actual: &str, expected: &str) {
|
||||
pub fn assert_equals<S1: AsRef<str>, S2: AsRef<str>>(actual: S1, expected: S2) {
|
||||
let actual = actual.as_ref();
|
||||
let expected = expected.as_ref();
|
||||
if actual != expected {
|
||||
eprintln!("=== ACTUAL TEXT ===");
|
||||
eprintln!("{}", actual);
|
||||
@ -421,7 +423,9 @@ pub fn assert_equals(actual: &str, expected: &str) {
|
||||
|
||||
/// Check that `haystack` contains `needle`. Panic otherwise.
|
||||
#[track_caller]
|
||||
pub fn assert_contains(haystack: &str, needle: &str) {
|
||||
pub fn assert_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
|
||||
let haystack = haystack.as_ref();
|
||||
let needle = needle.as_ref();
|
||||
if !haystack.contains(needle) {
|
||||
eprintln!("=== HAYSTACK ===");
|
||||
eprintln!("{}", haystack);
|
||||
@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {
|
||||
|
||||
/// Check that `haystack` does not contain `needle`. Panic otherwise.
|
||||
#[track_caller]
|
||||
pub fn assert_not_contains(haystack: &str, needle: &str) {
|
||||
pub fn assert_not_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
|
||||
let haystack = haystack.as_ref();
|
||||
let needle = needle.as_ref();
|
||||
if haystack.contains(needle) {
|
||||
eprintln!("=== HAYSTACK ===");
|
||||
eprintln!("{}", haystack);
|
||||
|
@ -201,7 +201,8 @@ impl Rustc {
|
||||
}
|
||||
|
||||
/// Specify the target triple, or a path to a custom target json spec file.
|
||||
pub fn target(&mut self, target: &str) -> &mut Self {
|
||||
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
|
||||
let target = target.as_ref();
|
||||
self.cmd.arg(format!("--target={target}"));
|
||||
self
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ impl Rustdoc {
|
||||
}
|
||||
|
||||
/// Specify the target triple, or a path to a custom target json spec file.
|
||||
pub fn target(&mut self, target: &str) -> &mut Self {
|
||||
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
|
||||
let target = target.as_ref();
|
||||
self.cmd.arg(format!("--target={target}"));
|
||||
self
|
||||
}
|
||||
|
@ -175,8 +175,4 @@ run-make/track-pgo-dep-info/Makefile
|
||||
run-make/translation/Makefile
|
||||
run-make/type-mismatch-same-crate-name/Makefile
|
||||
run-make/unstable-flag-required/Makefile
|
||||
run-make/volatile-intrinsics/Makefile
|
||||
run-make/wasm-exceptions-nostd/Makefile
|
||||
run-make/wasm-override-linker/Makefile
|
||||
run-make/weird-output-filenames/Makefile
|
||||
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile
|
||||
|
@ -21,7 +21,7 @@ fn main() {
|
||||
.stdin("fn main() {}")
|
||||
.emit("link,obj")
|
||||
.arg("-Csave-temps")
|
||||
.target(&target)
|
||||
.target(target)
|
||||
.run();
|
||||
|
||||
// Check linked output has a `.comment` section with the expected content.
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
// FIXME: This test isn't comprehensive and isn't covering all possible combinations.
|
||||
|
||||
use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
|
||||
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc};
|
||||
|
||||
fn check_compression(compression: &str, to_find: &str) {
|
||||
run_in_tmpdir(|| {
|
||||
@ -19,12 +19,11 @@ fn check_compression(compression: &str, to_find: &str) {
|
||||
.run();
|
||||
let stderr = out.stderr_utf8();
|
||||
if stderr.is_empty() {
|
||||
// FIXME: `readelf` might need to be replaced with `llvm-readelf`.
|
||||
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
|
||||
llvm_readobj().arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
|
||||
} else {
|
||||
assert_contains(
|
||||
&stderr,
|
||||
&format!("unknown debuginfo compression algorithm {compression}"),
|
||||
stderr,
|
||||
format!("unknown debuginfo compression algorithm {compression}"),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ fn main() {
|
||||
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
|
||||
// so that it can't create `tmp`.
|
||||
rustc()
|
||||
.target(&target())
|
||||
.target(target())
|
||||
.input("program.rs")
|
||||
.arg("-Ztemps-dir=inaccessible/tmp")
|
||||
.run_fail()
|
||||
|
@ -51,7 +51,7 @@ fn test(compiler: &str) {
|
||||
|
||||
rustc()
|
||||
.input("test-aslr.rs")
|
||||
.target(&target())
|
||||
.target(target())
|
||||
.linker(compiler)
|
||||
.arg("-Clinker-flavor=gcc")
|
||||
.arg("-Ctarget-feature=+crt-static")
|
||||
|
@ -1,10 +0,0 @@
|
||||
# ignore-cross-compile
|
||||
include ../tools.mk
|
||||
|
||||
all:
|
||||
# The tests must pass...
|
||||
$(RUSTC) main.rs
|
||||
$(call RUN,main)
|
||||
# ... and the loads/stores must not be optimized out.
|
||||
$(RUSTC) main.rs --emit=llvm-ir
|
||||
$(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll
|
18
tests/run-make/volatile-intrinsics/rmake.rs
Normal file
18
tests/run-make/volatile-intrinsics/rmake.rs
Normal file
@ -0,0 +1,18 @@
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::fs_wrapper::read;
|
||||
use run_make_support::{assert_contains, run, rustc};
|
||||
|
||||
fn main() {
|
||||
// The tests must pass...
|
||||
rustc().input("main.rs").run();
|
||||
run("main");
|
||||
|
||||
// ... and the loads/stores must not be optimized out.
|
||||
rustc().input("main.rs").emit("llvm-ir").run();
|
||||
|
||||
let raw_llvm_ir = read("main.ll");
|
||||
let llvm_ir = String::from_utf8_lossy(&raw_llvm_ir);
|
||||
assert_contains(&llvm_ir, "load volatile");
|
||||
assert_contains(&llvm_ir, "store volatile");
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
//@ only-wasm32-wasip1
|
||||
//@ needs-wasmtime
|
||||
|
||||
use run_make_support::rustc;
|
||||
use run_make_support::{cmd, rustc};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
@ -19,14 +18,12 @@ fn main() {
|
||||
}
|
||||
|
||||
fn run(file: &Path, method: &str, expected_output: &str) {
|
||||
let output = Command::new("wasmtime")
|
||||
cmd("wasmtime")
|
||||
.arg("run")
|
||||
.arg("--preload=host=host.wat")
|
||||
.arg("--invoke")
|
||||
.arg(method)
|
||||
.arg(file)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
assert_eq!(expected_output, String::from_utf8_lossy(&output.stdout));
|
||||
.run()
|
||||
.assert_stdout_equals(expected_output);
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
# Add a few command line args to make exceptions work
|
||||
RUSTC := $(RUSTC) -C llvm-args=-wasm-enable-eh
|
||||
RUSTC := $(RUSTC) -C target-feature=+exception-handling
|
||||
RUSTC := $(RUSTC) -C panic=unwind
|
||||
|
||||
all:
|
||||
$(RUSTC) src/lib.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify.mjs $(TMPDIR)/lib.wasm
|
18
tests/run-make/wasm-exceptions-nostd/rmake.rs
Normal file
18
tests/run-make/wasm-exceptions-nostd/rmake.rs
Normal file
@ -0,0 +1,18 @@
|
||||
//@ only-wasm32-bare
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use run_make_support::{cmd, env_var, rustc};
|
||||
|
||||
fn main() {
|
||||
// Add a few command line args to make exceptions work
|
||||
rustc()
|
||||
.input(Path::new("src").join("lib.rs"))
|
||||
.target("wasm32-unknown-unknown")
|
||||
.panic("unwind")
|
||||
.arg("-Cllvm-args=-wasm-enable-eh")
|
||||
.arg("-Ctarget-feature=+exception-handling")
|
||||
.run();
|
||||
|
||||
cmd(&env_var("NODE")).arg("verify.mjs").arg("lib.wasm").run();
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(link_llvm_intrinsics)]
|
||||
#![feature(panic_info_message)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
@ -17,8 +17,8 @@ fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::ToString;
|
||||
|
||||
let msg = info.message().map(|msg| msg.to_string()).unwrap_or("(no message)".to_string());
|
||||
let exception = Box::new(msg.to_string());
|
||||
let msg = info.message().to_string();
|
||||
let exception = Box::new(msg);
|
||||
unsafe {
|
||||
let exception_raw = Box::into_raw(exception);
|
||||
wasm_throw(exception_raw as *mut u8);
|
||||
|
@ -1,16 +0,0 @@
|
||||
# needs-force-clang-based-tests
|
||||
|
||||
# FIXME(#126180): This test doesn't actually run anywhere, because the only
|
||||
# CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests.
|
||||
|
||||
include ../tools.mk
|
||||
|
||||
ifeq ($(TARGET),wasm32-unknown-unknown)
|
||||
all:
|
||||
$(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG)
|
||||
else ifeq ($(TARGET),wasm64-unknown-unknown)
|
||||
all:
|
||||
$(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG)
|
||||
else
|
||||
all:
|
||||
endif
|
17
tests/run-make/wasm-override-linker/rmake.rs
Normal file
17
tests/run-make/wasm-override-linker/rmake.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// How to run this
|
||||
// $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/
|
||||
|
||||
//@ needs-force-clang-based-tests
|
||||
|
||||
use run_make_support::{env_var, rustc, target};
|
||||
|
||||
fn main() {
|
||||
if matches!(target().as_str(), "wasm32-unknown-unknown" | "wasm64-unknown-unknown") {
|
||||
rustc()
|
||||
.input("foo.rs")
|
||||
.crate_type("cdylib")
|
||||
.target(&target())
|
||||
.linker(&env_var("CLANG"))
|
||||
.run();
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
all:
|
||||
cp foo.rs $(TMPDIR)/.foo.rs
|
||||
$(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \
|
||||
| $(CGREP) -e "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/.foo.bar
|
||||
$(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \
|
||||
| $(CGREP) -e "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/+foo+bar.rs
|
||||
$(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \
|
||||
| $(CGREP) -e "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/-foo.rs
|
||||
$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
|
||||
| $(CGREP) 'crate names cannot start with a `-`'
|
19
tests/run-make/weird-output-filenames/rmake.rs
Normal file
19
tests/run-make/weird-output-filenames/rmake.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use run_make_support::fs_wrapper::copy;
|
||||
use run_make_support::regex::Regex;
|
||||
use run_make_support::{cwd, rustc};
|
||||
|
||||
fn main() {
|
||||
let invalid_characters = [".foo.rs", ".foo.bar", "+foo+bar.rs"];
|
||||
let re = Regex::new(r"invalid character.*in crate name:").unwrap();
|
||||
for f in invalid_characters {
|
||||
copy("foo.rs", f);
|
||||
let stderr = rustc().input(f).run_fail().stderr_utf8();
|
||||
assert!(re.is_match(&stderr));
|
||||
}
|
||||
|
||||
copy("foo.rs", "-foo.rs");
|
||||
rustc()
|
||||
.input(cwd().join("-foo.rs"))
|
||||
.run_fail()
|
||||
.assert_stderr_contains("crate names cannot start with a `-`");
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
//@ edition:2018
|
||||
|
||||
// > Suggest returning tail expressions that match return type
|
||||
// >
|
||||
// > Some newcomers are confused by the behavior of tail expressions,
|
||||
@ -8,24 +10,24 @@
|
||||
//
|
||||
// This test was amended to also serve as a regression test for #92308, where
|
||||
// this suggestion would not trigger with async functions.
|
||||
//
|
||||
//@ edition:2018
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
fn foo(x: bool) -> Result<f64, i32> {
|
||||
if x {
|
||||
Err(42) //~ ERROR mismatched types
|
||||
//| HELP you might have meant to return this value
|
||||
Err(42)
|
||||
//~^ ERROR mismatched types
|
||||
//~| HELP you might have meant to return this value
|
||||
}
|
||||
Ok(42.0)
|
||||
}
|
||||
|
||||
async fn bar(x: bool) -> Result<f64, i32> {
|
||||
if x {
|
||||
Err(42) //~ ERROR mismatched types
|
||||
//| HELP you might have meant to return this value
|
||||
Err(42)
|
||||
//~^ ERROR mismatched types
|
||||
//~| HELP you might have meant to return this value
|
||||
}
|
||||
Ok(42.0)
|
||||
}
|
||||
@ -40,8 +42,26 @@ impl<T> Identity for T {
|
||||
|
||||
async fn foo2() -> i32 {
|
||||
if true {
|
||||
1i32 //~ ERROR mismatched types
|
||||
//| HELP you might have meant to return this value
|
||||
1i32
|
||||
//~^ ERROR mismatched types
|
||||
//~| HELP you might have meant to return this value
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
struct Receiver;
|
||||
impl Receiver {
|
||||
fn generic<T>(self) -> Option<T> {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn method() -> Option<i32> {
|
||||
if true {
|
||||
Receiver.generic();
|
||||
//~^ ERROR type annotations needed
|
||||
//~| HELP consider specifying the generic argument
|
||||
//~| HELP you might have meant to return this to infer its type parameters
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/tail-expr-as-potential-return.rs:27:9
|
||||
--> $DIR/tail-expr-as-potential-return.rs:28:9
|
||||
|
|
||||
LL | / if x {
|
||||
LL | | Err(42)
|
||||
| | ^^^^^^^ expected `()`, found `Result<_, {integer}>`
|
||||
LL | | //| HELP you might have meant to return this value
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_____- expected this to be `()`
|
||||
|
|
||||
@ -16,12 +17,13 @@ LL | return Err(42);
|
||||
| ++++++ +
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/tail-expr-as-potential-return.rs:43:9
|
||||
--> $DIR/tail-expr-as-potential-return.rs:45:9
|
||||
|
|
||||
LL | / if true {
|
||||
LL | | 1i32
|
||||
| | ^^^^ expected `()`, found `i32`
|
||||
LL | | //| HELP you might have meant to return this value
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_____- expected this to be `()`
|
||||
|
|
||||
@ -36,7 +38,8 @@ error[E0308]: mismatched types
|
||||
LL | / if x {
|
||||
LL | | Err(42)
|
||||
| | ^^^^^^^ expected `()`, found `Result<_, {integer}>`
|
||||
LL | | //| HELP you might have meant to return this value
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_____- expected this to be `()`
|
||||
|
|
||||
@ -47,6 +50,22 @@ help: you might have meant to return this value
|
||||
LL | return Err(42);
|
||||
| ++++++ +
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/tail-expr-as-potential-return.rs:60:18
|
||||
|
|
||||
LL | Receiver.generic();
|
||||
| ^^^^^^^ cannot infer type of the type parameter `T` declared on the method `generic`
|
||||
|
|
||||
help: consider specifying the generic argument
|
||||
|
|
||||
LL | Receiver.generic::<T>();
|
||||
| +++++
|
||||
help: you might have meant to return this to infer its type parameters
|
||||
|
|
||||
LL | return Receiver.generic();
|
||||
| ++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0308.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
Loading…
Reference in New Issue
Block a user