Skip to content

Commit 0b63477

Browse files
committed
Auto merge of #134864 - Zalathar:rollup-suc8ay9, r=Zalathar
Rollup of 3 pull requests Successful merges: - #134849 (compiletest: Slightly simplify the handling of debugger directive prefixes) - #134850 (Document virality of `feature(rustc_private)`) - #134852 (Added a codegen test for optimization with const arrays) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b76036c + 0a52407 commit 0b63477

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

src/doc/unstable-book/src/language-features/rustc-private.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The tracking issue for this feature is: [#27812]
66

77
------------------------
88

9-
This feature allows access to unstable internal compiler crates.
9+
This feature allows access to unstable internal compiler crates such as `rustc_driver`.
1010

11-
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`.
11+
The presence of this feature changes the way the linkage format for dylibs is calculated in a way
12+
that is necessary for linking against dylibs that statically link `std` (such as `rustc_driver`).
13+
This makes this feature "viral" in linkage; its use in a given crate makes its use required in
14+
dependent crates which link to it (including integration tests, which are built as separate crates).

src/tools/compiletest/src/runtest/debugger.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands {
1919
}
2020

2121
impl DebuggerCommands {
22-
pub fn parse_from(
23-
file: &Path,
24-
config: &Config,
25-
debugger_prefixes: &[&str],
26-
) -> Result<Self, String> {
27-
let directives = debugger_prefixes
28-
.iter()
29-
.map(|prefix| (format!("{prefix}-command"), format!("{prefix}-check")))
30-
.collect::<Vec<_>>();
22+
pub fn parse_from(file: &Path, config: &Config, debugger_prefix: &str) -> Result<Self, String> {
23+
let command_directive = format!("{debugger_prefix}-command");
24+
let check_directive = format!("{debugger_prefix}-check");
3125

3226
let mut breakpoint_lines = vec![];
3327
let mut commands = vec![];
@@ -48,14 +42,11 @@ impl DebuggerCommands {
4842
continue;
4943
};
5044

51-
for &(ref command_directive, ref check_directive) in &directives {
52-
config
53-
.parse_name_value_directive(&line, command_directive)
54-
.map(|cmd| commands.push(cmd));
55-
56-
config
57-
.parse_name_value_directive(&line, check_directive)
58-
.map(|cmd| check_lines.push((line_no, cmd)));
45+
if let Some(command) = config.parse_name_value_directive(&line, &command_directive) {
46+
commands.push(command);
47+
}
48+
if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) {
49+
check_lines.push((line_no, pattern));
5950
}
6051
}
6152

src/tools/compiletest/src/runtest/debuginfo.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ impl TestCx<'_> {
5959
return;
6060
}
6161

62-
let prefixes = {
63-
static PREFIXES: &[&str] = &["cdb", "cdbg"];
64-
// No "native rust support" variation for CDB yet.
65-
PREFIXES
66-
};
67-
6862
// Parse debugger commands etc from test files
69-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes)
63+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "cdb")
7064
.unwrap_or_else(|e| self.fatal(&e));
7165

7266
// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
@@ -137,7 +131,7 @@ impl TestCx<'_> {
137131
}
138132

139133
fn run_debuginfo_gdb_test_no_opt(&self) {
140-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"])
134+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "gdb")
141135
.unwrap_or_else(|e| self.fatal(&e));
142136
let mut cmds = dbg_cmds.commands.join("\n");
143137

@@ -403,7 +397,7 @@ impl TestCx<'_> {
403397
}
404398

405399
// Parse debugger commands etc from test files
406-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"])
400+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "lldb")
407401
.unwrap_or_else(|e| self.fatal(&e));
408402

409403
// Write debugger script:

tests/codegen/const-array.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -O
2+
3+
#![crate_type = "lib"]
4+
5+
const LUT: [u8; 2] = [1, 1];
6+
7+
// CHECK-LABEL: @decode
8+
#[no_mangle]
9+
pub fn decode(i: u8) -> u8 {
10+
// CHECK: start:
11+
// CHECK-NEXT: icmp
12+
// CHECK-NEXT: select
13+
// CHECK-NEXT: ret
14+
if i < 2 { LUT[i as usize] } else { 2 }
15+
}

0 commit comments

Comments
 (0)