Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 34bee19

Browse files
committedMay 6, 2023
Auto merge of #111304 - matthiaskrgr:rollup-b9twh7l, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #111002 (Fix the test directories suggested by `./x.py suggest`) - #111077 (Make more ConstProp tests unit.) - #111151 (check bootstrap scripts syntax) - #111203 (Output LLVM optimization remark kind in `-Cremark` output) - #111237 (asm: loongarch64: Implementation of clobber_abi) - #111274 (Expand the LLVM coverage of `--print target-cpus`) - #111289 (Check arguments length in trivial diagnostic lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a77c552 + 1de257b commit 34bee19

40 files changed

+264
-127
lines changed
 

‎compiler/rustc_codegen_llvm/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ codegen_llvm_prepare_thin_lto_module_with_llvm_err = failed to prepare thin LTO
8282
codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module
8383
codegen_llvm_parse_bitcode_with_llvm_err = failed to parse bitcode for LTO module: {$llvm_err}
8484
85-
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name}: {$message}
85+
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
8686
codegen_llvm_from_llvm_diag = {$message}
8787
8888
codegen_llvm_write_bytecode = failed to write bytecode to {$path}: {$err}

‎compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use rustc_span::symbol::sym;
3131
use rustc_span::InnerSpan;
3232
use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo};
3333

34+
use crate::llvm::diagnostic::OptimizationDiagnosticKind;
3435
use libc::{c_char, c_int, c_uint, c_void, size_t};
3536
use std::ffi::CString;
3637
use std::fs;
@@ -363,6 +364,15 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
363364
line: opt.line,
364365
column: opt.column,
365366
pass_name: &opt.pass_name,
367+
kind: match opt.kind {
368+
OptimizationDiagnosticKind::OptimizationRemark => "success",
369+
OptimizationDiagnosticKind::OptimizationMissed
370+
| OptimizationDiagnosticKind::OptimizationFailure => "missed",
371+
OptimizationDiagnosticKind::OptimizationAnalysis
372+
| OptimizationDiagnosticKind::OptimizationAnalysisFPCommute
373+
| OptimizationDiagnosticKind::OptimizationAnalysisAliasing => "analysis",
374+
OptimizationDiagnosticKind::OptimizationRemarkOther => "other",
375+
},
366376
message: &opt.message,
367377
});
368378
}

‎compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ pub(crate) struct FromLlvmOptimizationDiag<'a> {
196196
pub line: std::ffi::c_uint,
197197
pub column: std::ffi::c_uint,
198198
pub pass_name: &'a str,
199+
pub kind: &'a str,
199200
pub message: &'a str,
200201
}
201202

‎compiler/rustc_lint/src/internal.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,10 @@ impl EarlyLintPass for Diagnostics {
478478
}
479479
if !segments.iter().all(|(name, args)| {
480480
let arg = match name.as_str() {
481-
"struct_span_err" | "span_note" | "span_label" | "span_help" => &args[1],
482-
"note" | "help" => &args[0],
481+
"struct_span_err" | "span_note" | "span_label" | "span_help" if args.len() == 2 => {
482+
&args[1]
483+
}
484+
"note" | "help" if args.len() == 1 => &args[0],
483485
_ => {
484486
return false;
485487
}

‎compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ static Reloc::Model fromRust(LLVMRustRelocModel RustReloc) {
297297
report_fatal_error("Bad RelocModel.");
298298
}
299299

300-
#ifdef LLVM_RUSTLLVM
301300
/// getLongestEntryLength - Return the length of the longest entry in the table.
302301
template<typename KV>
303302
static size_t getLongestEntryLength(ArrayRef<KV> Table) {
@@ -312,13 +311,23 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
312311
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
313312
const Triple::ArchType HostArch = Triple(sys::getDefaultTargetTriple()).getArch();
314313
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
314+
315+
#if LLVM_VERSION_GE(17, 0)
316+
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
317+
#elif defined(LLVM_RUSTLLVM)
315318
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
319+
#else
320+
printf("Full target CPU help is not supported by this LLVM version.\n\n");
321+
SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
322+
const ArrayRef<SubtargetSubTypeKV> CPUTable = TargetCPUKV;
323+
#endif
316324
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
317325

318326
printf("Available CPUs for this target:\n");
319327
// Don't print the "native" entry when the user specifies --target with a
320328
// different arch since that could be wrong or misleading.
321329
if (HostArch == TargetArch) {
330+
MaxCPULen = std::max(MaxCPULen, (unsigned) std::strlen("native"));
322331
const StringRef HostCPU = sys::getHostCPUName();
323332
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
324333
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
@@ -338,34 +347,27 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
338347
}
339348

340349
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
350+
#ifdef LLVM_RUSTLLVM
341351
const TargetMachine *Target = unwrap(TM);
342352
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
343353
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
344354
return FeatTable.size();
355+
#else
356+
return 0;
357+
#endif
345358
}
346359

347360
extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
348361
const char** Feature, const char** Desc) {
362+
#ifdef LLVM_RUSTLLVM
349363
const TargetMachine *Target = unwrap(TM);
350364
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
351365
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
352366
const SubtargetFeatureKV Feat = FeatTable[Index];
353367
*Feature = Feat.Key;
354368
*Desc = Feat.Desc;
355-
}
356-
357-
#else
358-
359-
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef) {
360-
printf("Target CPU help is not supported by this LLVM version.\n\n");
361-
}
362-
363-
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef) {
364-
return 0;
365-
}
366-
367-
extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef, const char**, const char**) {}
368369
#endif
370+
}
369371

370372
extern "C" const char* LLVMRustGetHostCPUName(size_t *len) {
371373
StringRef Name = sys::getHostCPUName();

‎compiler/rustc_target/src/asm/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ pub enum InlineAsmClobberAbi {
839839
AArch64,
840840
AArch64NoX18,
841841
RiscV,
842+
LoongArch,
842843
}
843844

844845
impl InlineAsmClobberAbi {
@@ -880,6 +881,10 @@ impl InlineAsmClobberAbi {
880881
"C" | "system" | "efiapi" => Ok(InlineAsmClobberAbi::RiscV),
881882
_ => Err(&["C", "system", "efiapi"]),
882883
},
884+
InlineAsmArch::LoongArch64 => match name {
885+
"C" | "system" | "efiapi" => Ok(InlineAsmClobberAbi::LoongArch),
886+
_ => Err(&["C", "system", "efiapi"]),
887+
},
883888
_ => Err(&[]),
884889
}
885890
}
@@ -1022,6 +1027,21 @@ impl InlineAsmClobberAbi {
10221027
v24, v25, v26, v27, v28, v29, v30, v31,
10231028
}
10241029
},
1030+
InlineAsmClobberAbi::LoongArch => clobbered_regs! {
1031+
LoongArch LoongArchInlineAsmReg {
1032+
// ra
1033+
r1,
1034+
// a0-a7
1035+
r4, r5, r6, r7, r8, r9, r10, r11,
1036+
// t0-t8
1037+
r12, r13, r14, r15, r16, r17, r18, r19, r20,
1038+
// fa0-fa7
1039+
f0, f1, f2, f3, f4, f5, f6, f7,
1040+
// ft0-ft15
1041+
f8, f9, f10, f11, f12, f13, f14, f15,
1042+
f16, f17, f18, f19, f20, f21, f22, f23,
1043+
}
1044+
},
10251045
}
10261046
}
10271047
}

‎src/tools/suggest-tests/src/static_suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static_suggestions! {
1515

1616
"compiler/*" => [
1717
sug!("check"),
18-
sug!("test", 1, ["src/test/ui", "src/test/run-make"])
18+
sug!("test", 1, ["tests/ui", "tests/run-make"])
1919
],
2020

2121
"src/librustdoc/*" => [

‎src/tools/suggest-tests/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ macro_rules! sugg_test {
1212

1313
sugg_test! {
1414
test_error_code_docs: ["compiler/rustc_error_codes/src/error_codes/E0000.md"] =>
15-
["check N/A", "test compiler/rustc_error_codes N/A", "test linkchecker 0", "test src/test/ui src/test/run-make 1"],
15+
["check N/A", "test compiler/rustc_error_codes N/A", "test linkchecker 0", "test tests/ui tests/run-make 1"],
1616

1717
test_rustdoc: ["src/librustdoc/src/lib.rs"] => ["test rustdoc 1"],
1818

‎tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@
1818
}
1919

2020
bb0: {
21+
StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10
2122
_1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14
2223
StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11
23-
- _4 = Eq(_1, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
24+
StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
25+
- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
26+
- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
2427
- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
28+
+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
2529
+ _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
2630
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
2731
}
2832

2933
bb1: {
30-
- _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
34+
- _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3135
- _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3236
- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
33-
- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
37+
- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3438
+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3539
+ _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3640
+ _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
37-
+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
41+
+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
3842
}
3943

4044
bb2: {
41-
- _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
42-
+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
45+
_2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19
46+
StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19
47+
_0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+0:11: +3:2
4348
StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2
49+
StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2
4450
return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2
4551
}
4652
}

‎tests/mir-opt/const_prop/bad_op_mod_by_zero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
23
// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff
34
#[allow(unconditional_panic)]

‎tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,49 @@
66
let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
77
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
88
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
9-
let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
10-
let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
11-
let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
12-
let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
9+
let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35
10+
let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
11+
let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
12+
let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
13+
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
1314
scope 1 {
1415
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
1516
scope 2 {
16-
let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
17+
let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
1718
scope 3 {
18-
debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
19+
debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
1920
}
2021
}
2122
}
2223

2324
bb0: {
2425
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
2526
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
26-
_8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
27+
StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
28+
_9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
2729
// mir::Constant
28-
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35
30+
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35
2931
// + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
30-
_2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
32+
_3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
33+
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
3134
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
3235
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35
33-
StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
34-
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
35-
_5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
36-
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
37-
- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
38-
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
39-
+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
40-
+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
36+
StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36
37+
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
38+
StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
39+
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
40+
_7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
41+
- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
42+
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
43+
+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
44+
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
4145
}
4246

4347
bb1: {
44-
_4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
45-
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
46-
StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
48+
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
49+
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
50+
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6
51+
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
4752
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2
4853
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2
4954
}

‎tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,49 @@
66
let _1: *const [i32]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
77
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
88
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
9-
let _5: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
10-
let mut _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
11-
let mut _7: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
12-
let mut _8: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
9+
let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:26: +1:35
10+
let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
11+
let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
12+
let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
13+
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
1314
scope 1 {
1415
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
1516
scope 2 {
16-
let _4: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
17+
let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
1718
scope 3 {
18-
debug _b => _4; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
19+
debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
1920
}
2021
}
2122
}
2223

2324
bb0: {
2425
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10
2526
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
26-
_8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
27+
StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
28+
_9 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
2729
// mir::Constant
28-
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:25: 6:35
30+
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:9:25: 9:35
2931
// + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
30-
_2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
32+
_3 = &(*_9); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
33+
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
3134
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35
3235
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35
33-
StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
34-
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
35-
_5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
36-
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
37-
- _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
38-
- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
39-
+ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
40-
+ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
36+
StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36
37+
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15
38+
StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
39+
_6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24
40+
_7 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
41+
- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
42+
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
43+
+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
44+
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
4145
}
4246

4347
bb1: {
44-
_4 = (*_1)[_5]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
45-
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
46-
StorageDead(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
48+
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25
49+
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:25: +3:26
50+
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+2:5: +4:6
51+
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+4:5: +4:6
4752
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:1: +5:2
4853
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+5:2: +5:2
4954
}

‎tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
3+
// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
4+
25
// EMIT_MIR_FOR_EACH_BIT_WIDTH
36
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
47
#[allow(unconditional_panic)]

‎tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
let mut _2: main::InvalidChar; // in scope 0 at $DIR/invalid_constant.rs:+6:34: +6:63
88
let mut _4: E; // in scope 0 at $DIR/invalid_constant.rs:+13:25: +13:59
99
let mut _5: main::InvalidTag; // in scope 0 at $DIR/invalid_constant.rs:+13:34: +13:55
10+
let mut _7: Empty; // in scope 0 at $DIR/invalid_constant.rs:+20:35: +20:73
11+
let mut _8: main::NoVariants; // in scope 0 at $DIR/invalid_constant.rs:+20:44: +20:65
1012
scope 1 {
1113
debug _invalid_char => _1; // in scope 1 at $DIR/invalid_constant.rs:+6:9: +6:22
1214
let _3: [E; 1]; // in scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21
1315
scope 3 {
1416
debug _invalid_tag => _3; // in scope 3 at $DIR/invalid_constant.rs:+13:9: +13:21
17+
let _6: [Empty; 1]; // in scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31
1518
scope 5 {
1619
debug _enum_without_variants => const [ZeroSized: Empty]; // in scope 5 at $DIR/invalid_constant.rs:+20:9: +20:31
20+
let _9: main::Str<"���">; // in scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22
1721
scope 7 {
1822
debug _non_utf8_str => const Str::<"���">; // in scope 7 at $DIR/invalid_constant.rs:+24:9: +24:22
1923
}
@@ -39,17 +43,25 @@
3943
StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55
4044
_5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55
4145
- _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57
42-
- _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60
4346
+ _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57
4447
+ // mir::Constant
4548
+ // + span: no-location
4649
+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) }
47-
+ _3 = [const Scalar(0x00000004): E]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60
48-
+ // mir::Constant
49-
+ // + span: no-location
50-
+ // + literal: Const { ty: E, val: Value(Scalar(0x00000004)) }
50+
_3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60
5151
StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60
5252
StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61
53+
nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31
54+
nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73
55+
StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65
56+
_8 = NoVariants { int: const 0_u32 }; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65
57+
nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71
58+
nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74
59+
nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74
60+
StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75
61+
nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22
62+
nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2
63+
nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2
64+
nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2
5365
StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2
5466
StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2
5567
return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2

‎tests/mir-opt/const_prop/invalid_constant.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: ConstProp
2+
// compile-flags: -Zmir-enable-passes=+RemoveZsts
13
// Verify that we can pretty print invalid constants.
24

35
#![feature(adt_const_params)]

‎tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.diff

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818
_2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29
1919
StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
2020
_3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
21-
_4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
21+
- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2323
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
24+
+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2425
+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
25-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2627
}
2728

2829
bb1: {
2930
_1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
3031
StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
3132
StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
33+
_0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2
3234
StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2
3335
return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2
3436
}

‎tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.diff

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818
_2 = [const 0_u8; 5000]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:29
1919
StorageLive(_3); // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
2020
_3 = const 2_usize; // scope 0 at $DIR/large_array_index.rs:+2:30: +2:31
21-
_4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
21+
- _4 = Len(_2); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2323
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
24+
+ _4 = const 5000_usize; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2425
+ _5 = const true; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
25-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
2627
}
2728

2829
bb1: {
2930
_1 = _2[_3]; // scope 0 at $DIR/large_array_index.rs:+2:17: +2:32
3031
StorageDead(_3); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
3132
StorageDead(_2); // scope 0 at $DIR/large_array_index.rs:+2:32: +2:33
33+
_0 = const (); // scope 0 at $DIR/large_array_index.rs:+0:11: +3:2
3234
StorageDead(_1); // scope 0 at $DIR/large_array_index.rs:+3:1: +3:2
3335
return; // scope 0 at $DIR/large_array_index.rs:+3:2: +3:2
3436
}

‎tests/mir-opt/const_prop/large_array_index.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
3+
// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
24
// EMIT_MIR_FOR_EACH_BIT_WIDTH
35

46
// EMIT_MIR large_array_index.main.ConstProp.diff

‎tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33

44
fn main() -> () {
55
let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +0:11
6-
let mut _1: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
7-
let mut _2: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
6+
let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
7+
let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
8+
let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
89
scope 1 {
910
}
1011

1112
bb0: {
12-
StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
13-
StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
14-
_2 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
13+
StorageLive(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
14+
StorageLive(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
15+
StorageLive(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
16+
_3 = main as fn() (Pointer(ReifyFnPointer)); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:17
1517
// mir::Constant
16-
// + span: $DIR/reify_fn_ptr.rs:4:13: 4:17
18+
// + span: $DIR/reify_fn_ptr.rs:5:13: 5:17
1719
// + literal: Const { ty: fn() {main}, val: Value(<ZST>) }
18-
_1 = move _2 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
19-
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26
20-
StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41
20+
_2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:26
21+
StorageDead(_3); // scope 0 at $DIR/reify_fn_ptr.rs:+1:25: +1:26
22+
_1 = move _2 as *const fn() (PointerFromExposedAddress); // scope 0 at $DIR/reify_fn_ptr.rs:+1:13: +1:41
23+
StorageDead(_2); // scope 0 at $DIR/reify_fn_ptr.rs:+1:40: +1:41
24+
StorageDead(_1); // scope 0 at $DIR/reify_fn_ptr.rs:+1:41: +1:42
25+
_0 = const (); // scope 0 at $DIR/reify_fn_ptr.rs:+0:11: +2:2
2126
return; // scope 0 at $DIR/reify_fn_ptr.rs:+2:2: +2:2
2227
}
2328
}

‎tests/mir-opt/const_prop/reify_fn_ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// EMIT_MIR reify_fn_ptr.main.ConstProp.diff
23

34
fn main() {

‎tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.diff

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
_3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25
2121
StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27
2222
_4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27
23-
_5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
23+
- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2424
- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2525
- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
26+
+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2627
+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
27-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
28+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2829
}
2930

3031
bb1: {
@@ -35,6 +36,7 @@
3536
StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32
3637
StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
3738
StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
39+
_0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2
3840
StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2
3941
return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2
4042
}

‎tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.diff

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
_3 = [const 42_u32; 8]; // scope 0 at $DIR/repeat.rs:+1:18: +1:25
2121
StorageLive(_4); // scope 0 at $DIR/repeat.rs:+1:26: +1:27
2222
_4 = const 2_usize; // scope 0 at $DIR/repeat.rs:+1:26: +1:27
23-
_5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
23+
- _5 = Len(_3); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2424
- _6 = Lt(_4, _5); // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2525
- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
26+
+ _5 = const 8_usize; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2627
+ _6 = const true; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
27-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
28+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; // scope 0 at $DIR/repeat.rs:+1:18: +1:28
2829
}
2930

3031
bb1: {
@@ -35,6 +36,7 @@
3536
StorageDead(_2); // scope 0 at $DIR/repeat.rs:+1:31: +1:32
3637
StorageDead(_4); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
3738
StorageDead(_3); // scope 0 at $DIR/repeat.rs:+1:32: +1:33
39+
_0 = const (); // scope 0 at $DIR/repeat.rs:+0:11: +2:2
3840
StorageDead(_1); // scope 0 at $DIR/repeat.rs:+2:1: +2:2
3941
return; // scope 0 at $DIR/repeat.rs:+2:2: +2:2
4042
}

‎tests/mir-opt/const_prop/repeat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
2-
// compile-flags: -O
3-
3+
// compile-flags: -Zmir-enable-passes=+NormalizeArrayLen
44
// EMIT_MIR_FOR_EACH_BIT_WIDTH
5+
56
// EMIT_MIR repeat.main.ConstProp.diff
67
fn main() {
78
let x: u32 = [42; 8][2] + 0;

‎tests/mir-opt/const_prop/return_place.add.PreCodegen.before.mir

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
fn add() -> u32 {
44
let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:+0:13: +0:16
5+
let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:+1:5: +1:10
56

67
bb0: {
8+
_1 = const (4_u32, false); // scope 0 at $DIR/return_place.rs:+1:5: +1:10
9+
assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; // scope 0 at $DIR/return_place.rs:+1:5: +1:10
10+
}
11+
12+
bb1: {
713
_0 = const 4_u32; // scope 0 at $DIR/return_place.rs:+1:5: +1:10
814
return; // scope 0 at $DIR/return_place.rs:+2:2: +2:2
915
}

‎tests/mir-opt/const_prop/return_place.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
23
// compile-flags: -C overflow-checks=on
34

‎tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@
1111
}
1212

1313
bb0: {
14+
StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10
1415
_1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14
15-
- _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
16-
+ _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
16+
StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
17+
StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
18+
- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
19+
+ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14
20+
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15
1721
// mir::Constant
18-
// + span: $DIR/scalar_literal_propagation.rs:5:5: 5:12
22+
// + span: $DIR/scalar_literal_propagation.rs:6:5: 6:12
1923
// + literal: Const { ty: fn(u32) {consume}, val: Value(<ZST>) }
2024
}
2125

2226
bb1: {
27+
StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15
28+
StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16
29+
_0 = const (); // scope 0 at $DIR/scalar_literal_propagation.rs:+0:11: +3:2
30+
StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2
2331
return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2
2432
}
2533
}

‎tests/mir-opt/const_prop/scalar_literal_propagation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
23
// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff
34
fn main() {

‎tests/mir-opt/const_prop/switch_int.main.ConstProp.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
bb1: {
1616
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21
1717
// mir::Constant
18-
// + span: $DIR/switch_int.rs:10:14: 10:17
18+
// + span: $DIR/switch_int.rs:12:14: 12:17
1919
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
2020
}
2121

2222
bb2: {
2323
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20
2424
// mir::Constant
25-
// + span: $DIR/switch_int.rs:9:14: 9:17
25+
// + span: $DIR/switch_int.rs:11:14: 11:17
2626
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
2727
}
2828

‎tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
bb1: {
1616
_0 = foo(const -1_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+3:14: +3:21
1717
// mir::Constant
18-
// + span: $DIR/switch_int.rs:10:14: 10:17
18+
// + span: $DIR/switch_int.rs:12:14: 12:17
1919
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
2020
}
2121

2222
bb2: {
2323
_0 = foo(const 0_i32) -> bb3; // scope 0 at $DIR/switch_int.rs:+2:14: +2:20
2424
// mir::Constant
25-
// + span: $DIR/switch_int.rs:9:14: 9:17
25+
// + span: $DIR/switch_int.rs:11:14: 11:17
2626
// + literal: Const { ty: fn(i32) {foo}, val: Value(<ZST>) }
2727
}
2828

‎tests/mir-opt/const_prop/switch_int.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: ConstProp
2+
// compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop
13
// ignore-wasm32 compiled with panic=abort by default
24
#[inline(never)]
35
fn foo(_: i32) { }

‎tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@
1111
}
1212

1313
bb0: {
14+
StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10
1415
- _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19
1516
+ _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19
16-
_2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15
17+
StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15
18+
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
19+
- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
20+
+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14
21+
_2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15
1722
// mir::Constant
18-
// + span: $DIR/tuple_literal_propagation.rs:6:5: 6:12
23+
// + span: $DIR/tuple_literal_propagation.rs:7:5: 7:12
1924
// + literal: Const { ty: fn((u32, u32)) {consume}, val: Value(<ZST>) }
2025
}
2126

2227
bb1: {
28+
StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15
29+
StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16
30+
_0 = const (); // scope 0 at $DIR/tuple_literal_propagation.rs:+0:11: +4:2
31+
StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2
2332
return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2
2433
}
2534
}

‎tests/mir-opt/const_prop/tuple_literal_propagation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// ignore-wasm32 compiled with panic=abort by default
23
// EMIT_MIR tuple_literal_propagation.main.ConstProp.diff
34
fn main() {

‎tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff renamed to ‎tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
fn change_loop_body() -> () {
55
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:+0:27: +0:27
66
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
7-
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32
8-
let mut _3: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25
7+
let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:+0:1: +6:2
8+
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:+2:28: +2:32
9+
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:+2:15: +2:25
10+
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:+2:33: +5:6
11+
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
12+
let _7: (); // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
13+
let mut _8: !; // in scope 0 at $DIR/while_let_loops.rs:+2:5: +5:6
914
scope 1 {
1015
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:+1:9: +1:15
1116
scope 2 {
@@ -15,29 +20,33 @@
1520
bb0: {
1621
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15
1722
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19
18-
StorageLive(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
19-
_2 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
20-
- _3 = discriminant(_2); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
21-
- switchInt(move _3) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
22-
+ _3 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
23+
StorageLive(_3); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
24+
_3 = Option::<u32>::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32
25+
- _4 = discriminant(_3); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
26+
- switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
27+
+ _4 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
2328
+ switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
2429
}
2530

2631
bb1: {
27-
switchInt(((_2 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
32+
switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25
2833
}
2934

3035
bb2: {
3136
_1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15
37+
_0 = const (); // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14
3238
goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14
3339
}
3440

3541
bb3: {
42+
StorageLive(_7); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6
43+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:+2:5: +5:6
44+
StorageDead(_7); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6
3645
goto -> bb4; // scope 1 at no-location
3746
}
3847

3948
bb4: {
40-
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6
49+
StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6
4150
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2
4251
return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2
4352
}

‎tests/mir-opt/while_let_loops.rs renamed to ‎tests/mir-opt/const_prop/while_let_loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// unit-test: ConstProp
12
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
2-
// EMIT_MIR while_let_loops.change_loop_body.PreCodegen.after.mir
33

44
pub fn change_loop_body() {
55
let mut _x = 0;

‎tests/mir-opt/while_let_loops.change_loop_body.PreCodegen.after.mir

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// compile-flags: -Zunstable-options
2+
3+
pub fn issue_111280() {
4+
struct_span_err(msg).emit(); //~ ERROR cannot find value `msg`
5+
//~^ ERROR cannot find function `struct_span_err`
6+
}
7+
8+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0425]: cannot find value `msg` in this scope
2+
--> $DIR/trivial-diagnostics.rs:4:21
3+
|
4+
LL | struct_span_err(msg).emit();
5+
| ^^^ not found in this scope
6+
7+
error[E0425]: cannot find function `struct_span_err` in this scope
8+
--> $DIR/trivial-diagnostics.rs:4:5
9+
|
10+
LL | struct_span_err(msg).emit();
11+
| ^^^^^^^^^^^^^^^ not found in this scope
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0425`.

‎tests/ui/optimization-remark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// [merge1] compile-flags: -Cremark=all -Cremark=giraffe
1414
// [merge2] compile-flags: -Cremark=inline -Cremark=giraffe
1515
//
16-
// error-pattern: inline: 'f' not inlined into 'g'
16+
// error-pattern: inline (missed): 'f' not inlined into 'g'
1717
// dont-check-compiler-stderr
1818

1919
#[no_mangle]

‎x

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
set -eu
99

10+
# syntax check
11+
sh -n $0
12+
1013
realpath() {
1114
if [ -d "$1" ]; then
12-
CDPATH='' command cd "$1" && pwd -P
15+
CDPATH='' command cd "$1" && pwd -P
1316
else
1417
echo "$(realpath "$(dirname "$1")")/$(basename "$1")"
1518
fi

‎x.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
# See ./x for why these scripts exist.
44

5+
$ErrorActionPreference = "Stop"
6+
7+
# syntax check
8+
Get-Command -syntax ${PSCommandPath}
9+
510
$xpy = Join-Path $PSScriptRoot x.py
611
# Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?)
712
# Double-quote all the arguments so it doesn't do that.

0 commit comments

Comments
 (0)
Please sign in to comment.