From a625ddd1ed250a32690ce739997706b3bfd7e2ec Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Dec 2024 23:37:48 +1100 Subject: [PATCH 1/4] Remove the unused `cdbg-*` debugger directive prefix There are no tests in `tests/debuginfo` that use this prefix. --- src/tools/compiletest/src/runtest/debuginfo.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index c621c22ac993c..7f1f85ba730d8 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -59,14 +59,8 @@ impl TestCx<'_> { return; } - let prefixes = { - static PREFIXES: &[&str] = &["cdb", "cdbg"]; - // No "native rust support" variation for CDB yet. - PREFIXES - }; - // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes) + let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["cdb"]) .unwrap_or_else(|e| self.fatal(&e)); // https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands From 2f8824a477f8b4ec51a3365c2d68f525032b8241 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Dec 2024 23:43:41 +1100 Subject: [PATCH 2/4] Simplify `DebuggerCommands::parse_from` to only take one prefix --- src/tools/compiletest/src/runtest/debugger.rs | 25 ++++++------------- .../compiletest/src/runtest/debuginfo.rs | 6 ++--- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/tools/compiletest/src/runtest/debugger.rs b/src/tools/compiletest/src/runtest/debugger.rs index c15422fb6f684..d9e5c3fa0d8fa 100644 --- a/src/tools/compiletest/src/runtest/debugger.rs +++ b/src/tools/compiletest/src/runtest/debugger.rs @@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands { } impl DebuggerCommands { - pub fn parse_from( - file: &Path, - config: &Config, - debugger_prefixes: &[&str], - ) -> Result { - let directives = debugger_prefixes - .iter() - .map(|prefix| (format!("{prefix}-command"), format!("{prefix}-check"))) - .collect::>(); + pub fn parse_from(file: &Path, config: &Config, debugger_prefix: &str) -> Result { + let command_directive = format!("{debugger_prefix}-command"); + let check_directive = format!("{debugger_prefix}-check"); let mut breakpoint_lines = vec![]; let mut commands = vec![]; @@ -48,14 +42,11 @@ impl DebuggerCommands { continue; }; - for &(ref command_directive, ref check_directive) in &directives { - config - .parse_name_value_directive(&line, command_directive) - .map(|cmd| commands.push(cmd)); - - config - .parse_name_value_directive(&line, check_directive) - .map(|cmd| check_lines.push((line_no, cmd))); + if let Some(command) = config.parse_name_value_directive(&line, &command_directive) { + commands.push(command); + } + if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) { + check_lines.push((line_no, pattern)); } } diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 7f1f85ba730d8..b236b06756903 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -60,7 +60,7 @@ impl TestCx<'_> { } // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["cdb"]) + let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "cdb") .unwrap_or_else(|e| self.fatal(&e)); // https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands @@ -131,7 +131,7 @@ impl TestCx<'_> { } fn run_debuginfo_gdb_test_no_opt(&self) { - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"]) + let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "gdb") .unwrap_or_else(|e| self.fatal(&e)); let mut cmds = dbg_cmds.commands.join("\n"); @@ -397,7 +397,7 @@ impl TestCx<'_> { } // Parse debugger commands etc from test files - let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"]) + let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "lldb") .unwrap_or_else(|e| self.fatal(&e)); // Write debugger script: From 35e5c7d43808c0dfaffa67abeb16ce58f1ae4695 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sat, 28 Dec 2024 08:44:25 -0500 Subject: [PATCH 3/4] Document virality of `feature(rustc_private)` Since 9cb1998ea15e179482504e07cad8fa121e169a32 this feature is viral. --- .../unstable-book/src/language-features/rustc-private.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/rustc-private.md b/src/doc/unstable-book/src/language-features/rustc-private.md index 97fce5980e40b..3b83a3cf4df8a 100644 --- a/src/doc/unstable-book/src/language-features/rustc-private.md +++ b/src/doc/unstable-book/src/language-features/rustc-private.md @@ -6,6 +6,9 @@ The tracking issue for this feature is: [#27812] ------------------------ -This feature allows access to unstable internal compiler crates. +This feature allows access to unstable internal compiler crates such as `rustc_driver`. -Additionally it changes the linking behavior of crates which have this feature enabled. It will prevent linking to a dylib if there's a static variant of it already statically linked into another dylib dependency. This is required to successfully link to `rustc_driver`. +The presence of this feature changes the way the linkage format for dylibs is calculated in a way +that is necessary for linking against dylibs that statically link `std` (such as `rustc_driver`). +This makes this feature "viral" in linkage; its use in a given crate makes its use required in +dependent crates which link to it (including integration tests, which are built as separate crates). From d6c73ebbf3df1331eb60a6fba1f4b0bd03274f49 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 28 Dec 2024 10:14:46 -0500 Subject: [PATCH 4/4] Added a codegen test for optimization with const arrays Closes #107208 --- tests/codegen/const-array.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/codegen/const-array.rs diff --git a/tests/codegen/const-array.rs b/tests/codegen/const-array.rs new file mode 100644 index 0000000000000..f2b331c315dce --- /dev/null +++ b/tests/codegen/const-array.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -O + +#![crate_type = "lib"] + +const LUT: [u8; 2] = [1, 1]; + +// CHECK-LABEL: @decode +#[no_mangle] +pub fn decode(i: u8) -> u8 { + // CHECK: start: + // CHECK-NEXT: icmp + // CHECK-NEXT: select + // CHECK-NEXT: ret + if i < 2 { LUT[i as usize] } else { 2 } +}