From 5824ab178b0b28c948798576de78625ba8209adc Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Wed, 26 Jun 2024 14:02:52 +0000 Subject: [PATCH 01/12] Support lists and stylings in more places for `rustc --explain` --- .../src/error_codes/E0373.md | 2 +- .../src/error_codes/E0378.md | 2 +- compiler/rustc_errors/src/lib.rs | 1 + compiler/rustc_errors/src/markdown/parse.rs | 62 ++++++++++-------- .../rustc_errors/src/markdown/tests/parse.rs | 65 +++++++++++++++++-- 5 files changed, 96 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0373.md b/compiler/rustc_error_codes/src/error_codes/E0373.md index effa597aad918..d4d26007aa50e 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0373.md +++ b/compiler/rustc_error_codes/src/error_codes/E0373.md @@ -70,4 +70,4 @@ fn spawn(future: F) { Similarly to closures, `async` blocks are not executed immediately and may capture closed-over data by reference. For more information, see -https://rust-lang.github.io/async-book/03_async_await/01_chapter.html. +. diff --git a/compiler/rustc_error_codes/src/error_codes/E0378.md b/compiler/rustc_error_codes/src/error_codes/E0378.md index c6fe997f3dcfc..7d939b99b04eb 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0378.md +++ b/compiler/rustc_error_codes/src/error_codes/E0378.md @@ -20,7 +20,7 @@ where The `DispatchFromDyn` trait currently can only be implemented for builtin pointer types and structs that are newtype wrappers around them -— that is, the struct must have only one field (except for`PhantomData`), +— that is, the struct must have only one field (except for `PhantomData`), and that field must itself implement `DispatchFromDyn`. ``` diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 91112a572770e..76045c69cc1c6 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -15,6 +15,7 @@ #![feature(box_patterns)] #![feature(error_reporter)] #![feature(extract_if)] +#![feature(if_let_guard)] #![feature(let_chains)] #![feature(negative_impls)] #![feature(never_type)] diff --git a/compiler/rustc_errors/src/markdown/parse.rs b/compiler/rustc_errors/src/markdown/parse.rs index 67e4963fddf7f..69e7120e7149b 100644 --- a/compiler/rustc_errors/src/markdown/parse.rs +++ b/compiler/rustc_errors/src/markdown/parse.rs @@ -10,15 +10,15 @@ const CBK: &[u8] = b"```"; const CIL: &[u8] = b"`"; const CMT_E: &[u8] = b"-->"; const CMT_S: &[u8] = b" $DIR/closure-no-fn-3.rs:6:33 + | +LL | let baz: fn() -> u8 = (|| { b }) as fn() -> u8; + | ^ `b` captured here error: aborting due to 1 previous error From 84eee6890d49e067a86f2e844e2d3db2d3b395f2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 11:51:30 +0200 Subject: [PATCH 09/12] Add `run_make_support::build_native_static_lib` function From 5257ca7f4fcfe55d021d6d30a429b89aaf52a07a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 11:53:00 +0200 Subject: [PATCH 10/12] Migrate `run-make/issue-15460` to `rmake.rs` --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/issue-15460/Makefile | 7 ------- tests/run-make/issue-15460/rmake.rs | 12 ++++++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/issue-15460/Makefile create mode 100644 tests/run-make/issue-15460/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index d6da40d3d78f0..3224fdb6933b3 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -27,7 +27,6 @@ run-make/foreign-rust-exceptions/Makefile run-make/incr-add-rust-src-component/Makefile run-make/incr-foreign-head-span/Makefile run-make/interdependent-c-libraries/Makefile -run-make/issue-15460/Makefile run-make/issue-35164/Makefile run-make/issue-36710/Makefile run-make/issue-47551/Makefile diff --git a/tests/run-make/issue-15460/Makefile b/tests/run-make/issue-15460/Makefile deleted file mode 100644 index a36a085fa6f18..0000000000000 --- a/tests/run-make/issue-15460/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/tests/run-make/issue-15460/rmake.rs b/tests/run-make/issue-15460/rmake.rs new file mode 100644 index 0000000000000..6f2c0d4e59536 --- /dev/null +++ b/tests/run-make/issue-15460/rmake.rs @@ -0,0 +1,12 @@ +//@ ignore-cross-compile + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("foo"); + + rustc().input("foo.rs").extra_filename("-383hf8").arg("-Cprefer-dynamic").run(); + rustc().input("bar.rs").run(); + + run("bar"); +} From 3de52521aea47df85394c69559008f555fb3ed40 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 2 Jun 2024 14:20:39 +0200 Subject: [PATCH 11/12] Rename `tests/run-make/issue-15460` into `tests/run-make/link-native-static-lib-to-dylib` --- .../{issue-15460 => link-native-static-lib-to-dylib}/bar.rs | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/foo.c | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/foo.rs | 0 .../{issue-15460 => link-native-static-lib-to-dylib}/rmake.rs | 2 ++ 4 files changed, 2 insertions(+) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/bar.rs (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/foo.c (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/foo.rs (100%) rename tests/run-make/{issue-15460 => link-native-static-lib-to-dylib}/rmake.rs (78%) diff --git a/tests/run-make/issue-15460/bar.rs b/tests/run-make/link-native-static-lib-to-dylib/bar.rs similarity index 100% rename from tests/run-make/issue-15460/bar.rs rename to tests/run-make/link-native-static-lib-to-dylib/bar.rs diff --git a/tests/run-make/issue-15460/foo.c b/tests/run-make/link-native-static-lib-to-dylib/foo.c similarity index 100% rename from tests/run-make/issue-15460/foo.c rename to tests/run-make/link-native-static-lib-to-dylib/foo.c diff --git a/tests/run-make/issue-15460/foo.rs b/tests/run-make/link-native-static-lib-to-dylib/foo.rs similarity index 100% rename from tests/run-make/issue-15460/foo.rs rename to tests/run-make/link-native-static-lib-to-dylib/foo.rs diff --git a/tests/run-make/issue-15460/rmake.rs b/tests/run-make/link-native-static-lib-to-dylib/rmake.rs similarity index 78% rename from tests/run-make/issue-15460/rmake.rs rename to tests/run-make/link-native-static-lib-to-dylib/rmake.rs index 6f2c0d4e59536..0746c3963143b 100644 --- a/tests/run-make/issue-15460/rmake.rs +++ b/tests/run-make/link-native-static-lib-to-dylib/rmake.rs @@ -1,3 +1,5 @@ +// Regression test for . + //@ ignore-cross-compile use run_make_support::{build_native_static_lib, run, rustc}; From d4f3673a54fecf005920ef2fffd5e1f78cc87b85 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Tue, 23 Jul 2024 18:02:01 +0300 Subject: [PATCH 12/12] make it possible to disable download-rustc if it's incompatible Primarily needed by CI runners to avoid handling download-rustc incompatible options one by one on shell scripts. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/config/config.rs | 36 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f96633b059a17..a78a213f53082 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1570,11 +1570,22 @@ impl Config { let mut is_user_configured_rust_channel = false; if let Some(rust) = toml.rust { - config.download_rustc_commit = - config.download_ci_rustc_commit(rust.download_rustc.clone()); - - if config.download_rustc_commit.is_some() { - check_incompatible_options_for_ci_rustc(&rust); + if let Some(commit) = config.download_ci_rustc_commit(rust.download_rustc.clone()) { + // Primarily used by CI runners to avoid handling download-rustc incompatible + // options one by one on shell scripts. + let disable_ci_rustc_if_incompatible = + env::var_os("DISABLE_CI_RUSTC_IF_INCOMPATIBLE") + .is_some_and(|s| s == "1" || s == "true"); + + if let Err(e) = check_incompatible_options_for_ci_rustc(&rust) { + if disable_ci_rustc_if_incompatible { + config.download_rustc_commit = None; + } else { + panic!("{}", e); + } + } else { + config.download_rustc_commit = Some(commit); + } } let Rust { @@ -2614,14 +2625,15 @@ impl Config { /// Checks the CI rustc incompatible options by destructuring the `Rust` instance /// and makes sure that no rust options from config.toml are missed. -fn check_incompatible_options_for_ci_rustc(rust: &Rust) { +fn check_incompatible_options_for_ci_rustc(rust: &Rust) -> Result<(), String> { macro_rules! err { ($name:expr) => { - assert!( - $name.is_none(), - "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.", - stringify!($name).replace("_", "-") - ); + if $name.is_some() { + return Err(format!( + "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`.", + stringify!($name).replace("_", "-") + )); + } }; } @@ -2717,6 +2729,8 @@ fn check_incompatible_options_for_ci_rustc(rust: &Rust) { warn!(channel); warn!(description); warn!(incremental); + + Ok(()) } fn set(field: &mut T, val: Option) {