From e75aa44977bd5a9731580ac1ebd398d599aae73c Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Mon, 2 Dec 2024 01:07:16 -0600 Subject: [PATCH 01/59] include LLDB and GDB visualizers in MSVC distribution --- src/bootstrap/src/core/build_steps/dist.rs | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index a636c4a9ef13..0c739115165e 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -549,24 +549,24 @@ impl Step for DebuggerScripts { cp_debugger_script("natvis/liballoc.natvis"); cp_debugger_script("natvis/libcore.natvis"); cp_debugger_script("natvis/libstd.natvis"); - } else { - cp_debugger_script("rust_types.py"); - - // gdb debugger scripts - builder.install(&builder.src.join("src/etc/rust-gdb"), &sysroot.join("bin"), 0o755); - builder.install(&builder.src.join("src/etc/rust-gdbgui"), &sysroot.join("bin"), 0o755); - - cp_debugger_script("gdb_load_rust_pretty_printers.py"); - cp_debugger_script("gdb_lookup.py"); - cp_debugger_script("gdb_providers.py"); - - // lldb debugger scripts - builder.install(&builder.src.join("src/etc/rust-lldb"), &sysroot.join("bin"), 0o755); - - cp_debugger_script("lldb_lookup.py"); - cp_debugger_script("lldb_providers.py"); - cp_debugger_script("lldb_commands") } + + cp_debugger_script("rust_types.py"); + + // gdb debugger scripts + builder.install(&builder.src.join("src/etc/rust-gdb"), &sysroot.join("bin"), 0o755); + builder.install(&builder.src.join("src/etc/rust-gdbgui"), &sysroot.join("bin"), 0o755); + + cp_debugger_script("gdb_load_rust_pretty_printers.py"); + cp_debugger_script("gdb_lookup.py"); + cp_debugger_script("gdb_providers.py"); + + // lldb debugger scripts + builder.install(&builder.src.join("src/etc/rust-lldb"), &sysroot.join("bin"), 0o755); + + cp_debugger_script("lldb_lookup.py"); + cp_debugger_script("lldb_providers.py"); + cp_debugger_script("lldb_commands") } } From a3175a33aa20128a287a2632e4e1777797e0e0aa Mon Sep 17 00:00:00 2001 From: rustbot <47979223+rustbot@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:00:34 -0500 Subject: [PATCH 02/59] Update books --- src/doc/book | 2 +- src/doc/reference | 2 +- src/doc/rustc-dev-guide | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/book b/src/doc/book index e16dd73690a6..614c19cb4025 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit e16dd73690a6cc3ecdc5f5d94bbc3ce158a42e16 +Subproject commit 614c19cb4025636eb2ba68ebb3d44e3bd3a5e6e4 diff --git a/src/doc/reference b/src/doc/reference index 5c86c739ec71..8a0b8a4158d9 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 5c86c739ec71b8bc839310ff47fa94e94635bba9 +Subproject commit 8a0b8a4158d9aa961de423b7afcd95521c5deb6a diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 787b4166ccc6..b21d99b770f9 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 787b4166ccc67bd8f72a6e3ef6685ce9ce82909a +Subproject commit b21d99b770f9aceb0810c843847c52f86f45d2ed From 9d1f790594cc58187aaca5cb64b4e324b331a565 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 9 Nov 2023 17:37:27 +0100 Subject: [PATCH 03/59] Add warn-by-default lint against unpredictable fn pointer comparisons --- compiler/rustc_lint/messages.ftl | 6 + compiler/rustc_lint/src/lints.rs | 36 ++++ compiler/rustc_lint/src/types.rs | 138 +++++++++++++- tests/ui/lint/fn-ptr-comparisons-weird.rs | 15 ++ tests/ui/lint/fn-ptr-comparisons-weird.stderr | 43 +++++ tests/ui/lint/fn-ptr-comparisons.fixed | 58 ++++++ tests/ui/lint/fn-ptr-comparisons.rs | 58 ++++++ tests/ui/lint/fn-ptr-comparisons.stderr | 171 ++++++++++++++++++ 8 files changed, 521 insertions(+), 4 deletions(-) create mode 100644 tests/ui/lint/fn-ptr-comparisons-weird.rs create mode 100644 tests/ui/lint/fn-ptr-comparisons-weird.stderr create mode 100644 tests/ui/lint/fn-ptr-comparisons.fixed create mode 100644 tests/ui/lint/fn-ptr-comparisons.rs create mode 100644 tests/ui/lint/fn-ptr-comparisons.stderr diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 4aeaf6168160..54039d56929c 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -882,6 +882,12 @@ lint_unnameable_test_items = cannot test inner items lint_unnecessary_qualification = unnecessary qualification .suggestion = remove the unnecessary path segments +lint_unpredictable_fn_pointer_comparisons = function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + .note_duplicated_fn = the address of the same function can vary between different codegen units + .note_deduplicated_fn = furthermore, different functions could have the same address after being merged together + .note_visit_fn_addr_eq = for more information visit + .fn_addr_eq_suggestion = refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + lint_unqualified_local_imports = `use` of a local item without leading `self::`, `super::`, or `crate::` lint_unsafe_attr_outside_unsafe = unsafe attribute used without unsafe diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 3a854796f673..5721ef644da4 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1810,6 +1810,42 @@ pub(crate) enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> { }, } +#[derive(LintDiagnostic)] +pub(crate) enum UnpredictableFunctionPointerComparisons<'a> { + #[diag(lint_unpredictable_fn_pointer_comparisons)] + #[note(lint_note_duplicated_fn)] + #[note(lint_note_deduplicated_fn)] + #[note(lint_note_visit_fn_addr_eq)] + Suggestion { + #[subdiagnostic] + sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a>, + }, + #[diag(lint_unpredictable_fn_pointer_comparisons)] + #[note(lint_note_duplicated_fn)] + #[note(lint_note_deduplicated_fn)] + #[note(lint_note_visit_fn_addr_eq)] + Warn, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion( + lint_fn_addr_eq_suggestion, + style = "verbose", + applicability = "maybe-incorrect" +)] +pub(crate) struct UnpredictableFunctionPointerComparisonsSuggestion<'a> { + pub ne: &'a str, + pub cast_right: String, + pub deref_left: &'a str, + pub deref_right: &'a str, + #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")] + pub left: Span, + #[suggestion_part(code = ", {deref_right}")] + pub middle: Span, + #[suggestion_part(code = "{cast_right})")] + pub right: Span, +} + pub(crate) struct ImproperCTypes<'a> { pub ty: Ty<'a>, pub desc: &'a str, diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index b1d7d4ab6895..33650be056dd 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -23,7 +23,9 @@ use crate::lints::{ AmbiguousWidePointerComparisons, AmbiguousWidePointerComparisonsAddrMetadataSuggestion, AmbiguousWidePointerComparisonsAddrSuggestion, AtomicOrderingFence, AtomicOrderingLoad, AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons, - InvalidNanComparisonsSuggestion, UnusedComparisons, VariantSizeDifferencesDiag, + InvalidNanComparisonsSuggestion, UnpredictableFunctionPointerComparisons, + UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, + VariantSizeDifferencesDiag, }; use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent}; @@ -166,6 +168,35 @@ declare_lint! { "detects ambiguous wide pointer comparisons" } +declare_lint! { + /// The `unpredictable_function_pointer_comparisons` lint checks comparison + /// of function pointer as the operands. + /// + /// ### Example + /// + /// ```rust + /// fn a() {} + /// fn b() {} + /// + /// let f: fn() = a; + /// let g: fn() = b; + /// + /// let _ = f == g; + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Function pointers comparisons do not produce meaningful result since + /// they are never guaranteed to be unique and could vary between different + /// code generation units. Furthermore, different functions could have the + /// same address after being merged together. + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + Warn, + "detects unpredictable function pointer comparisons" +} + #[derive(Copy, Clone, Default)] pub(crate) struct TypeLimits { /// Id of the last visited negated expression @@ -178,7 +209,8 @@ impl_lint_pass!(TypeLimits => [ UNUSED_COMPARISONS, OVERFLOWING_LITERALS, INVALID_NAN_COMPARISONS, - AMBIGUOUS_WIDE_POINTER_COMPARISONS + AMBIGUOUS_WIDE_POINTER_COMPARISONS, + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS ]); impl TypeLimits { @@ -255,7 +287,7 @@ fn lint_nan<'tcx>( cx.emit_span_lint(INVALID_NAN_COMPARISONS, e.span, lint); } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Copy, Clone)] enum ComparisonOp { BinOp(hir::BinOpKind), Other, @@ -383,6 +415,100 @@ fn lint_wide_pointer<'tcx>( ); } +fn lint_fn_pointer<'tcx>( + cx: &LateContext<'tcx>, + e: &'tcx hir::Expr<'tcx>, + cmpop: ComparisonOp, + l: &'tcx hir::Expr<'tcx>, + r: &'tcx hir::Expr<'tcx>, +) { + let peel_refs = |mut ty: Ty<'tcx>| -> (Ty<'tcx>, usize) { + let mut refs = 0; + + while let ty::Ref(_, inner_ty, _) = ty.kind() { + ty = *inner_ty; + refs += 1; + } + + (ty, refs) + }; + + // Left and right operands can have borrows, remove them + let l = l.peel_borrows(); + let r = r.peel_borrows(); + + let Some(l_ty) = cx.typeck_results().expr_ty_opt(l) else { return }; + let Some(r_ty) = cx.typeck_results().expr_ty_opt(r) else { return }; + + // Remove any references as `==` will deref through them (and count the + // number of references removed, for latter). + let (l_ty, l_ty_refs) = peel_refs(l_ty); + let (r_ty, r_ty_refs) = peel_refs(r_ty); + + if !l_ty.is_fn() || !r_ty.is_fn() { + return; + } + + // Let's try to suggest `ptr::fn_addr_eq` if/when possible. + + let is_eq_ne = matches!(cmpop, ComparisonOp::BinOp(hir::BinOpKind::Eq | hir::BinOpKind::Ne)); + + if !is_eq_ne { + // Neither `==` nor `!=`, we can't suggest `ptr::fn_addr_eq`, just show the warning. + return cx.emit_span_lint( + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + e.span, + UnpredictableFunctionPointerComparisons::Warn, + ); + } + + let (Some(l_span), Some(r_span)) = + (l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span)) + else { + // No appropriate spans for the left and right operands, just show the warning. + return cx.emit_span_lint( + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + e.span, + UnpredictableFunctionPointerComparisons::Warn, + ); + }; + + let ne = if cmpop == ComparisonOp::BinOp(hir::BinOpKind::Ne) { "!" } else { "" }; + + // `ptr::fn_addr_eq` only works with raw pointer, deref any references. + let deref_left = &*"*".repeat(l_ty_refs); + let deref_right = &*"*".repeat(r_ty_refs); + + let left = e.span.shrink_to_lo().until(l_span.shrink_to_lo()); + let middle = l_span.shrink_to_hi().until(r_span.shrink_to_lo()); + let right = r_span.shrink_to_hi().until(e.span.shrink_to_hi()); + + // We only check for a right cast as `FnDef` == `FnPtr` is not possible, + // only `FnPtr == FnDef` is possible. + let cast_right = if !r_ty.is_fn_ptr() { + let fn_sig = r_ty.fn_sig(cx.tcx); + format!(" as {fn_sig}") + } else { + String::new() + }; + + cx.emit_span_lint( + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + e.span, + UnpredictableFunctionPointerComparisons::Suggestion { + sugg: UnpredictableFunctionPointerComparisonsSuggestion { + ne, + deref_left, + deref_right, + left, + middle, + right, + cast_right, + }, + }, + ); +} + impl<'tcx> LateLintPass<'tcx> for TypeLimits { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) { match e.kind { @@ -399,7 +525,9 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { cx.emit_span_lint(UNUSED_COMPARISONS, e.span, UnusedComparisons); } else { lint_nan(cx, e, binop, l, r); - lint_wide_pointer(cx, e, ComparisonOp::BinOp(binop.node), l, r); + let cmpop = ComparisonOp::BinOp(binop.node); + lint_wide_pointer(cx, e, cmpop, l, r); + lint_fn_pointer(cx, e, cmpop, l, r); } } } @@ -411,6 +539,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { && let Some(cmpop) = diag_item_cmpop(diag_item) => { lint_wide_pointer(cx, e, cmpop, l, r); + lint_fn_pointer(cx, e, cmpop, l, r); } hir::ExprKind::MethodCall(_, l, [r], _) if let Some(def_id) = cx.typeck_results().type_dependent_def_id(e.hir_id) @@ -418,6 +547,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { && let Some(cmpop) = diag_item_cmpop(diag_item) => { lint_wide_pointer(cx, e, cmpop, l, r); + lint_fn_pointer(cx, e, cmpop, l, r); } _ => {} }; diff --git a/tests/ui/lint/fn-ptr-comparisons-weird.rs b/tests/ui/lint/fn-ptr-comparisons-weird.rs new file mode 100644 index 000000000000..171fbfb87279 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-weird.rs @@ -0,0 +1,15 @@ +//@ check-pass + +fn main() { + let f: fn() = main; + let g: fn() = main; + + let _ = f > g; + //~^ WARN function pointer comparisons + let _ = f >= g; + //~^ WARN function pointer comparisons + let _ = f <= g; + //~^ WARN function pointer comparisons + let _ = f < g; + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons-weird.stderr b/tests/ui/lint/fn-ptr-comparisons-weird.stderr new file mode 100644 index 000000000000..f23716639223 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-weird.stderr @@ -0,0 +1,43 @@ +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-weird.rs:7:13 + | +LL | let _ = f > g; + | ^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-weird.rs:9:13 + | +LL | let _ = f >= g; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-weird.rs:11:13 + | +LL | let _ = f <= g; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-weird.rs:13:13 + | +LL | let _ = f < g; + | ^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + +warning: 4 warnings emitted + diff --git a/tests/ui/lint/fn-ptr-comparisons.fixed b/tests/ui/lint/fn-ptr-comparisons.fixed new file mode 100644 index 000000000000..22f16177a044 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons.fixed @@ -0,0 +1,58 @@ +//@ check-pass +//@ run-rustfix + +extern "C" { + fn test(); +} + +fn a() {} + +extern "C" fn c() {} + +extern "C" fn args(_a: i32) -> i32 { 0 } + +#[derive(PartialEq, Eq)] +struct A { + f: fn(), +} + +fn main() { + let f: fn() = a; + let g: fn() = f; + + let a1 = A { f }; + let a2 = A { f }; + + let _ = std::ptr::fn_addr_eq(f, a as fn()); + //~^ WARN function pointer comparisons + let _ = !std::ptr::fn_addr_eq(f, a as fn()); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(f, g); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(f, f); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(g, g); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(g, g); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(g, g); + //~^ WARN function pointer comparisons + let _ = std::ptr::fn_addr_eq(a as fn(), g); + //~^ WARN function pointer comparisons + + let cfn: extern "C" fn() = c; + let _ = std::ptr::fn_addr_eq(cfn, c as extern "C" fn()); + //~^ WARN function pointer comparisons + + let argsfn: extern "C" fn(i32) -> i32 = args; + let _ = std::ptr::fn_addr_eq(argsfn, args as extern "C" fn(i32) -> i32); + //~^ WARN function pointer comparisons + + let t: unsafe extern "C" fn() = test; + let _ = std::ptr::fn_addr_eq(t, test as unsafe extern "C" fn()); + //~^ WARN function pointer comparisons + + let _ = a1 == a2; // should not warn + let _ = std::ptr::fn_addr_eq(a1.f, a2.f); + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons.rs b/tests/ui/lint/fn-ptr-comparisons.rs new file mode 100644 index 000000000000..90a8ab5c926b --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons.rs @@ -0,0 +1,58 @@ +//@ check-pass +//@ run-rustfix + +extern "C" { + fn test(); +} + +fn a() {} + +extern "C" fn c() {} + +extern "C" fn args(_a: i32) -> i32 { 0 } + +#[derive(PartialEq, Eq)] +struct A { + f: fn(), +} + +fn main() { + let f: fn() = a; + let g: fn() = f; + + let a1 = A { f }; + let a2 = A { f }; + + let _ = f == a; + //~^ WARN function pointer comparisons + let _ = f != a; + //~^ WARN function pointer comparisons + let _ = f == g; + //~^ WARN function pointer comparisons + let _ = f == f; + //~^ WARN function pointer comparisons + let _ = g == g; + //~^ WARN function pointer comparisons + let _ = g == g; + //~^ WARN function pointer comparisons + let _ = &g == &g; + //~^ WARN function pointer comparisons + let _ = a as fn() == g; + //~^ WARN function pointer comparisons + + let cfn: extern "C" fn() = c; + let _ = cfn == c; + //~^ WARN function pointer comparisons + + let argsfn: extern "C" fn(i32) -> i32 = args; + let _ = argsfn == args; + //~^ WARN function pointer comparisons + + let t: unsafe extern "C" fn() = test; + let _ = t == test; + //~^ WARN function pointer comparisons + + let _ = a1 == a2; // should not warn + let _ = a1.f == a2.f; + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons.stderr b/tests/ui/lint/fn-ptr-comparisons.stderr new file mode 100644 index 000000000000..eaba23a461ab --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons.stderr @@ -0,0 +1,171 @@ +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:26:13 + | +LL | let _ = f == a; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(f, a as fn()); + | +++++++++++++++++++++ ~ ++++++++ + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:28:13 + | +LL | let _ = f != a; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = !std::ptr::fn_addr_eq(f, a as fn()); + | ++++++++++++++++++++++ ~ ++++++++ + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:30:13 + | +LL | let _ = f == g; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(f, g); + | +++++++++++++++++++++ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:32:13 + | +LL | let _ = f == f; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(f, f); + | +++++++++++++++++++++ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:34:13 + | +LL | let _ = g == g; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(g, g); + | +++++++++++++++++++++ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:36:13 + | +LL | let _ = g == g; + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(g, g); + | +++++++++++++++++++++ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:38:13 + | +LL | let _ = &g == &g; + | ^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(g, g); + | ~~~~~~~~~~~~~~~~~~~~~ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:40:13 + | +LL | let _ = a as fn() == g; + | ^^^^^^^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(a as fn(), g); + | +++++++++++++++++++++ ~ + + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:44:13 + | +LL | let _ = cfn == c; + | ^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(cfn, c as extern "C" fn()); + | +++++++++++++++++++++ ~ +++++++++++++++++++ + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:48:13 + | +LL | let _ = argsfn == args; + | ^^^^^^^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(argsfn, args as extern "C" fn(i32) -> i32); + | +++++++++++++++++++++ ~ +++++++++++++++++++++++++++++ + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:52:13 + | +LL | let _ = t == test; + | ^^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(t, test as unsafe extern "C" fn()); + | +++++++++++++++++++++ ~ ++++++++++++++++++++++++++ + +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons.rs:56:13 + | +LL | let _ = a1.f == a2.f; + | ^^^^^^^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit +help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint + | +LL | let _ = std::ptr::fn_addr_eq(a1.f, a2.f); + | +++++++++++++++++++++ ~ + + +warning: 12 warnings emitted + From 5e34c2e43c9110ac91579cb1b6d44ebdba0b5712 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 10 Dec 2023 18:16:53 +0100 Subject: [PATCH 04/59] Drop uplifted `clippy::fn_address_comparisons` --- .../clippy/clippy_lints/src/declared_lints.rs | 1 - .../clippy_lints/src/deprecated_lints.rs | 2 + src/tools/clippy/clippy_lints/src/lib.rs | 2 - .../clippy_lints/src/unnamed_address.rs | 60 -------- .../clippy/tests/ui/fn_address_comparisons.rs | 23 --- .../tests/ui/fn_address_comparisons.stderr | 17 --- src/tools/clippy/tests/ui/rename.fixed | 2 + src/tools/clippy/tests/ui/rename.rs | 2 + src/tools/clippy/tests/ui/rename.stderr | 140 +++++++++--------- 9 files changed, 79 insertions(+), 170 deletions(-) delete mode 100644 src/tools/clippy/clippy_lints/src/unnamed_address.rs delete mode 100644 src/tools/clippy/tests/ui/fn_address_comparisons.rs delete mode 100644 src/tools/clippy/tests/ui/fn_address_comparisons.stderr diff --git a/src/tools/clippy/clippy_lints/src/declared_lints.rs b/src/tools/clippy/clippy_lints/src/declared_lints.rs index c4a0c8f18651..022ed180ed8c 100644 --- a/src/tools/clippy/clippy_lints/src/declared_lints.rs +++ b/src/tools/clippy/clippy_lints/src/declared_lints.rs @@ -744,7 +744,6 @@ pub static LINTS: &[&crate::LintInfo] = &[ crate::unit_types::LET_UNIT_VALUE_INFO, crate::unit_types::UNIT_ARG_INFO, crate::unit_types::UNIT_CMP_INFO, - crate::unnamed_address::FN_ADDRESS_COMPARISONS_INFO, crate::unnecessary_box_returns::UNNECESSARY_BOX_RETURNS_INFO, crate::unnecessary_literal_bound::UNNECESSARY_LITERAL_BOUND_INFO, crate::unnecessary_map_on_constructor::UNNECESSARY_MAP_ON_CONSTRUCTOR_INFO, diff --git a/src/tools/clippy/clippy_lints/src/deprecated_lints.rs b/src/tools/clippy/clippy_lints/src/deprecated_lints.rs index 77dbe9b78a18..3ea792d8b835 100644 --- a/src/tools/clippy/clippy_lints/src/deprecated_lints.rs +++ b/src/tools/clippy/clippy_lints/src/deprecated_lints.rs @@ -74,6 +74,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[ #[clippy::version = "1.53.0"] ("clippy::filter_map", "clippy::manual_filter_map"), #[clippy::version = ""] + ("clippy::fn_address_comparisons", "unpredictable_function_pointer_comparisons"), + #[clippy::version = ""] ("clippy::identity_conversion", "clippy::useless_conversion"), #[clippy::version = "pre 1.29.0"] ("clippy::if_let_redundant_pattern_matching", "clippy::redundant_pattern_matching"), diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index c9064df25ac8..e80cca6e7db4 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -363,7 +363,6 @@ mod uninhabited_references; mod uninit_vec; mod unit_return_expecting_ord; mod unit_types; -mod unnamed_address; mod unnecessary_box_returns; mod unnecessary_literal_bound; mod unnecessary_map_on_constructor; @@ -786,7 +785,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap)); store.register_late_pass(move |_| Box::new(wildcard_imports::WildcardImports::new(conf))); store.register_late_pass(|_| Box::::default()); - store.register_late_pass(|_| Box::new(unnamed_address::UnnamedAddress)); store.register_late_pass(|_| Box::>::default()); store.register_late_pass(|_| Box::new(option_if_let_else::OptionIfLetElse)); store.register_late_pass(|_| Box::new(future_not_send::FutureNotSend)); diff --git a/src/tools/clippy/clippy_lints/src/unnamed_address.rs b/src/tools/clippy/clippy_lints/src/unnamed_address.rs deleted file mode 100644 index cd2dacc9f099..000000000000 --- a/src/tools/clippy/clippy_lints/src/unnamed_address.rs +++ /dev/null @@ -1,60 +0,0 @@ -use clippy_utils::diagnostics::span_lint; -use rustc_hir::{BinOpKind, Expr, ExprKind}; -use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty; -use rustc_session::declare_lint_pass; - -declare_clippy_lint! { - /// ### What it does - /// Checks for comparisons with an address of a function item. - /// - /// ### Why is this bad? - /// Function item address is not guaranteed to be unique and could vary - /// between different code generation units. Furthermore different function items could have - /// the same address after being merged together. - /// - /// ### Example - /// ```no_run - /// type F = fn(); - /// fn a() {} - /// let f: F = a; - /// if f == a { - /// // ... - /// } - /// ``` - #[clippy::version = "1.44.0"] - pub FN_ADDRESS_COMPARISONS, - correctness, - "comparison with an address of a function item" -} - -declare_lint_pass!(UnnamedAddress => [FN_ADDRESS_COMPARISONS]); - -impl LateLintPass<'_> for UnnamedAddress { - fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { - fn is_comparison(binop: BinOpKind) -> bool { - matches!( - binop, - BinOpKind::Eq | BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ne | BinOpKind::Ge | BinOpKind::Gt - ) - } - - fn is_fn_def(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - matches!(cx.typeck_results().expr_ty(expr).kind(), ty::FnDef(..)) - } - - if let ExprKind::Binary(binop, left, right) = expr.kind - && is_comparison(binop.node) - && cx.typeck_results().expr_ty_adjusted(left).is_fn_ptr() - && cx.typeck_results().expr_ty_adjusted(right).is_fn_ptr() - && (is_fn_def(cx, left) || is_fn_def(cx, right)) - { - span_lint( - cx, - FN_ADDRESS_COMPARISONS, - expr.span, - "comparing with a non-unique address of a function item", - ); - } - } -} diff --git a/src/tools/clippy/tests/ui/fn_address_comparisons.rs b/src/tools/clippy/tests/ui/fn_address_comparisons.rs deleted file mode 100644 index 35535bd4fddd..000000000000 --- a/src/tools/clippy/tests/ui/fn_address_comparisons.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::fmt::Debug; -use std::ptr; -use std::rc::Rc; -use std::sync::Arc; - -fn a() {} - -#[warn(clippy::fn_address_comparisons)] -fn main() { - type F = fn(); - let f: F = a; - let g: F = f; - - // These should fail: - let _ = f == a; - //~^ ERROR: comparing with a non-unique address of a function item - //~| NOTE: `-D clippy::fn-address-comparisons` implied by `-D warnings` - let _ = f != a; - //~^ ERROR: comparing with a non-unique address of a function item - - // These should be fine: - let _ = f == g; -} diff --git a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr b/src/tools/clippy/tests/ui/fn_address_comparisons.stderr deleted file mode 100644 index e6de7e358075..000000000000 --- a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: comparing with a non-unique address of a function item - --> tests/ui/fn_address_comparisons.rs:15:13 - | -LL | let _ = f == a; - | ^^^^^^ - | - = note: `-D clippy::fn-address-comparisons` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::fn_address_comparisons)]` - -error: comparing with a non-unique address of a function item - --> tests/ui/fn_address_comparisons.rs:18:13 - | -LL | let _ = f != a; - | ^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index 0d6e07aa546c..47149622ef7c 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -59,6 +59,7 @@ #![allow(unknown_lints)] #![allow(unused_labels)] #![allow(ambiguous_wide_pointer_comparisons)] +#![allow(unpredictable_function_pointer_comparisons)] #![allow(clippy::reversed_empty_ranges)] #![warn(clippy::almost_complete_range)] //~ ERROR: lint `clippy::almost_complete_letter_range` #![warn(clippy::disallowed_names)] //~ ERROR: lint `clippy::blacklisted_name` @@ -74,6 +75,7 @@ #![warn(clippy::mixed_read_write_in_expression)] //~ ERROR: lint `clippy::eval_order_dependence` #![warn(clippy::manual_find_map)] //~ ERROR: lint `clippy::find_map` #![warn(clippy::manual_filter_map)] //~ ERROR: lint `clippy::filter_map` +#![warn(unpredictable_function_pointer_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons` #![warn(clippy::useless_conversion)] //~ ERROR: lint `clippy::identity_conversion` #![warn(clippy::redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching` #![warn(clippy::match_result_ok)] //~ ERROR: lint `clippy::if_let_some_result` diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index 2ac59718786b..7a78a5d280dd 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -59,6 +59,7 @@ #![allow(unknown_lints)] #![allow(unused_labels)] #![allow(ambiguous_wide_pointer_comparisons)] +#![allow(unpredictable_function_pointer_comparisons)] #![allow(clippy::reversed_empty_ranges)] #![warn(clippy::almost_complete_letter_range)] //~ ERROR: lint `clippy::almost_complete_letter_range` #![warn(clippy::blacklisted_name)] //~ ERROR: lint `clippy::blacklisted_name` @@ -74,6 +75,7 @@ #![warn(clippy::eval_order_dependence)] //~ ERROR: lint `clippy::eval_order_dependence` #![warn(clippy::find_map)] //~ ERROR: lint `clippy::find_map` #![warn(clippy::filter_map)] //~ ERROR: lint `clippy::filter_map` +#![warn(clippy::fn_address_comparisons)] //~ ERROR: lint `clippy::fn_address_comparisons` #![warn(clippy::identity_conversion)] //~ ERROR: lint `clippy::identity_conversion` #![warn(clippy::if_let_redundant_pattern_matching)] //~ ERROR: lint `clippy::if_let_redundant_pattern_matching` #![warn(clippy::if_let_some_result)] //~ ERROR: lint `clippy::if_let_some_result` diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index a5ae727b7ee8..dc24bc16d0ea 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` - --> tests/ui/rename.rs:63:9 + --> tests/ui/rename.rs:64:9 | LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` @@ -8,394 +8,400 @@ LL | #![warn(clippy::almost_complete_letter_range)] = help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]` error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` - --> tests/ui/rename.rs:64:9 + --> tests/ui/rename.rs:65:9 | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_conditions` - --> tests/ui/rename.rs:65:9 + --> tests/ui/rename.rs:66:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_conditions` - --> tests/ui/rename.rs:66:9 + --> tests/ui/rename.rs:67:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::blocks_in_if_conditions` has been renamed to `clippy::blocks_in_conditions` - --> tests/ui/rename.rs:67:9 + --> tests/ui/rename.rs:68:9 | LL | #![warn(clippy::blocks_in_if_conditions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` - --> tests/ui/rename.rs:68:9 + --> tests/ui/rename.rs:69:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - --> tests/ui/rename.rs:69:9 + --> tests/ui/rename.rs:70:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` - --> tests/ui/rename.rs:70:9 + --> tests/ui/rename.rs:71:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` - --> tests/ui/rename.rs:71:9 + --> tests/ui/rename.rs:72:9 | LL | #![warn(clippy::derive_hash_xor_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` - --> tests/ui/rename.rs:72:9 + --> tests/ui/rename.rs:73:9 | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` - --> tests/ui/rename.rs:73:9 + --> tests/ui/rename.rs:74:9 | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` - --> tests/ui/rename.rs:74:9 + --> tests/ui/rename.rs:75:9 | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` error: lint `clippy::find_map` has been renamed to `clippy::manual_find_map` - --> tests/ui/rename.rs:75:9 + --> tests/ui/rename.rs:76:9 | LL | #![warn(clippy::find_map)] | ^^^^^^^^^^^^^^^^ help: use the new name: `clippy::manual_find_map` error: lint `clippy::filter_map` has been renamed to `clippy::manual_filter_map` - --> tests/ui/rename.rs:76:9 + --> tests/ui/rename.rs:77:9 | LL | #![warn(clippy::filter_map)] | ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::manual_filter_map` +error: lint `clippy::fn_address_comparisons` has been renamed to `unpredictable_function_pointer_comparisons` + --> tests/ui/rename.rs:78:9 + | +LL | #![warn(clippy::fn_address_comparisons)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unpredictable_function_pointer_comparisons` + error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` - --> tests/ui/rename.rs:77:9 + --> tests/ui/rename.rs:79:9 | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` error: lint `clippy::if_let_redundant_pattern_matching` has been renamed to `clippy::redundant_pattern_matching` - --> tests/ui/rename.rs:78:9 + --> tests/ui/rename.rs:80:9 | LL | #![warn(clippy::if_let_redundant_pattern_matching)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_pattern_matching` error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` - --> tests/ui/rename.rs:79:9 + --> tests/ui/rename.rs:81:9 | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` error: lint `clippy::incorrect_clone_impl_on_copy_type` has been renamed to `clippy::non_canonical_clone_impl` - --> tests/ui/rename.rs:80:9 + --> tests/ui/rename.rs:82:9 | LL | #![warn(clippy::incorrect_clone_impl_on_copy_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_clone_impl` error: lint `clippy::incorrect_partial_ord_impl_on_ord_type` has been renamed to `clippy::non_canonical_partial_ord_impl` - --> tests/ui/rename.rs:81:9 + --> tests/ui/rename.rs:83:9 | LL | #![warn(clippy::incorrect_partial_ord_impl_on_ord_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_partial_ord_impl` error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects` - --> tests/ui/rename.rs:82:9 + --> tests/ui/rename.rs:84:9 | LL | #![warn(clippy::integer_arithmetic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects` error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` - --> tests/ui/rename.rs:83:9 + --> tests/ui/rename.rs:85:9 | LL | #![warn(clippy::logic_bug)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` - --> tests/ui/rename.rs:84:9 + --> tests/ui/rename.rs:86:9 | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` - --> tests/ui/rename.rs:85:9 + --> tests/ui/rename.rs:87:9 | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` - --> tests/ui/rename.rs:86:9 + --> tests/ui/rename.rs:88:9 | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` - --> tests/ui/rename.rs:87:9 + --> tests/ui/rename.rs:89:9 | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> tests/ui/rename.rs:88:9 + --> tests/ui/rename.rs:90:9 | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` - --> tests/ui/rename.rs:89:9 + --> tests/ui/rename.rs:91:9 | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::overflow_check_conditional` has been renamed to `clippy::panicking_overflow_checks` - --> tests/ui/rename.rs:90:9 + --> tests/ui/rename.rs:92:9 | LL | #![warn(clippy::overflow_check_conditional)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::panicking_overflow_checks` error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` - --> tests/ui/rename.rs:91:9 + --> tests/ui/rename.rs:93:9 | LL | #![warn(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow` error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` - --> tests/ui/rename.rs:92:9 + --> tests/ui/rename.rs:94:9 | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> tests/ui/rename.rs:93:9 + --> tests/ui/rename.rs:95:9 | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` - --> tests/ui/rename.rs:94:9 + --> tests/ui/rename.rs:96:9 | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` - --> tests/ui/rename.rs:95:9 + --> tests/ui/rename.rs:97:9 | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` - --> tests/ui/rename.rs:96:9 + --> tests/ui/rename.rs:98:9 | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` error: lint `clippy::thread_local_initializer_can_be_made_const` has been renamed to `clippy::missing_const_for_thread_local` - --> tests/ui/rename.rs:97:9 + --> tests/ui/rename.rs:99:9 | LL | #![warn(clippy::thread_local_initializer_can_be_made_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::missing_const_for_thread_local` error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` - --> tests/ui/rename.rs:98:9 + --> tests/ui/rename.rs:100:9 | LL | #![warn(clippy::to_string_in_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl` error: lint `clippy::unwrap_or_else_default` has been renamed to `clippy::unwrap_or_default` - --> tests/ui/rename.rs:99:9 + --> tests/ui/rename.rs:101:9 | LL | #![warn(clippy::unwrap_or_else_default)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_or_default` error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` - --> tests/ui/rename.rs:100:9 + --> tests/ui/rename.rs:102:9 | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting` - --> tests/ui/rename.rs:101:9 + --> tests/ui/rename.rs:103:9 | LL | #![warn(clippy::cast_ref_to_mut)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting` error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op` - --> tests/ui/rename.rs:102:9 + --> tests/ui/rename.rs:104:9 | LL | #![warn(clippy::clone_double_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op` error: lint `clippy::cmp_nan` has been renamed to `invalid_nan_comparisons` - --> tests/ui/rename.rs:103:9 + --> tests/ui/rename.rs:105:9 | LL | #![warn(clippy::cmp_nan)] | ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons` error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` - --> tests/ui/rename.rs:104:9 + --> tests/ui/rename.rs:106:9 | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types` - --> tests/ui/rename.rs:105:9 + --> tests/ui/rename.rs:107:9 | LL | #![warn(clippy::drop_copy)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types` error: lint `clippy::drop_ref` has been renamed to `dropping_references` - --> tests/ui/rename.rs:106:9 + --> tests/ui/rename.rs:108:9 | LL | #![warn(clippy::drop_ref)] | ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references` error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks` - --> tests/ui/rename.rs:107:9 + --> tests/ui/rename.rs:109:9 | LL | #![warn(clippy::fn_null_check)] | ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks` error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` - --> tests/ui/rename.rs:108:9 + --> tests/ui/rename.rs:110:9 | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` - --> tests/ui/rename.rs:109:9 + --> tests/ui/rename.rs:111:9 | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` - --> tests/ui/rename.rs:110:9 + --> tests/ui/rename.rs:112:9 | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types` - --> tests/ui/rename.rs:111:9 + --> tests/ui/rename.rs:113:9 | LL | #![warn(clippy::forget_copy)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types` error: lint `clippy::forget_ref` has been renamed to `forgetting_references` - --> tests/ui/rename.rs:112:9 + --> tests/ui/rename.rs:114:9 | LL | #![warn(clippy::forget_ref)] | ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` - --> tests/ui/rename.rs:113:9 + --> tests/ui/rename.rs:115:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` - --> tests/ui/rename.rs:114:9 + --> tests/ui/rename.rs:116:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::invalid_ref` has been renamed to `invalid_value` - --> tests/ui/rename.rs:115:9 + --> tests/ui/rename.rs:117:9 | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` error: lint `clippy::invalid_utf8_in_unchecked` has been renamed to `invalid_from_utf8_unchecked` - --> tests/ui/rename.rs:116:9 + --> tests/ui/rename.rs:118:9 | LL | #![warn(clippy::invalid_utf8_in_unchecked)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_from_utf8_unchecked` error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` - --> tests/ui/rename.rs:117:9 + --> tests/ui/rename.rs:119:9 | LL | #![warn(clippy::let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` error: lint `clippy::maybe_misused_cfg` has been renamed to `unexpected_cfgs` - --> tests/ui/rename.rs:118:9 + --> tests/ui/rename.rs:120:9 | LL | #![warn(clippy::maybe_misused_cfg)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unexpected_cfgs` error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` - --> tests/ui/rename.rs:119:9 + --> tests/ui/rename.rs:121:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` error: lint `clippy::mismatched_target_os` has been renamed to `unexpected_cfgs` - --> tests/ui/rename.rs:120:9 + --> tests/ui/rename.rs:122:9 | LL | #![warn(clippy::mismatched_target_os)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unexpected_cfgs` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` - --> tests/ui/rename.rs:121:9 + --> tests/ui/rename.rs:123:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` - --> tests/ui/rename.rs:122:9 + --> tests/ui/rename.rs:124:9 | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `dangling_pointers_from_temporaries` - --> tests/ui/rename.rs:123:9 + --> tests/ui/rename.rs:125:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `dangling_pointers_from_temporaries` error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops` - --> tests/ui/rename.rs:124:9 + --> tests/ui/rename.rs:126:9 | LL | #![warn(clippy::undropped_manually_drops)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `undropped_manually_drops` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` - --> tests/ui/rename.rs:125:9 + --> tests/ui/rename.rs:127:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::unused_label` has been renamed to `unused_labels` - --> tests/ui/rename.rs:126:9 + --> tests/ui/rename.rs:128:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons` - --> tests/ui/rename.rs:127:9 + --> tests/ui/rename.rs:129:9 | LL | #![warn(clippy::vtable_address_comparisons)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons` error: lint `clippy::reverse_range_loop` has been renamed to `clippy::reversed_empty_ranges` - --> tests/ui/rename.rs:128:9 + --> tests/ui/rename.rs:130:9 | LL | #![warn(clippy::reverse_range_loop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::reversed_empty_ranges` -error: aborting due to 66 previous errors +error: aborting due to 67 previous errors From 8ce63576bddc95e99b54ebf8ec9da6f52a647ad2 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 10 Dec 2023 15:51:06 +0100 Subject: [PATCH 05/59] Allow fn pointers comparisons lint in UI tests --- src/tools/miri/tests/pass/function_pointers.rs | 2 ++ src/tools/miri/tests/pass/issues/issue-91636.rs | 2 ++ tests/ui/binop/binary-op-on-fn-ptr-eq.rs | 3 +++ tests/ui/box/unit/unique-ffi-symbols.rs | 3 +++ tests/ui/consts/const-extern-function.rs | 2 ++ tests/ui/cross-crate/const-cross-crate-extern.rs | 2 ++ tests/ui/extern/extern-compare-with-return-type.rs | 1 + tests/ui/extern/extern-take-value.rs | 2 ++ .../function-pointer-comparison-issue-54685.rs | 2 ++ tests/ui/issues/issue-54696.rs | 2 ++ .../mir/validate/issue-95978-validator-lifetime-comparison.rs | 2 ++ 11 files changed, 23 insertions(+) diff --git a/src/tools/miri/tests/pass/function_pointers.rs b/src/tools/miri/tests/pass/function_pointers.rs index a5c4bc5e0d95..7145be334a13 100644 --- a/src/tools/miri/tests/pass/function_pointers.rs +++ b/src/tools/miri/tests/pass/function_pointers.rs @@ -1,3 +1,5 @@ +#![allow(unpredictable_function_pointer_comparisons)] + use std::mem; trait Answer { diff --git a/src/tools/miri/tests/pass/issues/issue-91636.rs b/src/tools/miri/tests/pass/issues/issue-91636.rs index 00370165812f..d0cadcd2c70a 100644 --- a/src/tools/miri/tests/pass/issues/issue-91636.rs +++ b/src/tools/miri/tests/pass/issues/issue-91636.rs @@ -1,3 +1,5 @@ +#![allow(unpredictable_function_pointer_comparisons)] + type BuiltIn = for<'a> fn(&str); struct Function { diff --git a/tests/ui/binop/binary-op-on-fn-ptr-eq.rs b/tests/ui/binop/binary-op-on-fn-ptr-eq.rs index a5ec63587f96..47b79f3855f6 100644 --- a/tests/ui/binop/binary-op-on-fn-ptr-eq.rs +++ b/tests/ui/binop/binary-op-on-fn-ptr-eq.rs @@ -1,6 +1,9 @@ //@ run-pass // Tests equality between supertype and subtype of a function // See the issue #91636 + +#![allow(unpredictable_function_pointer_comparisons)] + fn foo(_a: &str) {} fn main() { diff --git a/tests/ui/box/unit/unique-ffi-symbols.rs b/tests/ui/box/unit/unique-ffi-symbols.rs index 65a9a32b2bb0..75877f8397ef 100644 --- a/tests/ui/box/unit/unique-ffi-symbols.rs +++ b/tests/ui/box/unit/unique-ffi-symbols.rs @@ -1,6 +1,9 @@ //@ run-pass // We used to have a __rust_abi shim that resulted in duplicated symbols // whenever the item path wasn't enough to disambiguate between them. + +#![allow(unpredictable_function_pointer_comparisons)] + fn main() { let a = { extern "C" fn good() -> i32 { return 0; } diff --git a/tests/ui/consts/const-extern-function.rs b/tests/ui/consts/const-extern-function.rs index acc438189cb8..7629d63266ac 100644 --- a/tests/ui/consts/const-extern-function.rs +++ b/tests/ui/consts/const-extern-function.rs @@ -1,5 +1,7 @@ //@ run-pass + #![allow(non_upper_case_globals)] +#![allow(unpredictable_function_pointer_comparisons)] extern "C" fn foopy() {} diff --git a/tests/ui/cross-crate/const-cross-crate-extern.rs b/tests/ui/cross-crate/const-cross-crate-extern.rs index 8d48a6a52060..0ec8753c30f2 100644 --- a/tests/ui/cross-crate/const-cross-crate-extern.rs +++ b/tests/ui/cross-crate/const-cross-crate-extern.rs @@ -1,6 +1,8 @@ //@ run-pass //@ aux-build:cci_const.rs + #![allow(non_upper_case_globals)] +#![allow(unpredictable_function_pointer_comparisons)] extern crate cci_const; use cci_const::bar; diff --git a/tests/ui/extern/extern-compare-with-return-type.rs b/tests/ui/extern/extern-compare-with-return-type.rs index 316e8b2fc736..7d1027d5e776 100644 --- a/tests/ui/extern/extern-compare-with-return-type.rs +++ b/tests/ui/extern/extern-compare-with-return-type.rs @@ -2,6 +2,7 @@ // Tests that we can compare various kinds of extern fn signatures. #![allow(non_camel_case_types)] +#![allow(unpredictable_function_pointer_comparisons)] // `dbg!()` differentiates these functions to ensure they won't be merged. extern "C" fn voidret1() { dbg!() } diff --git a/tests/ui/extern/extern-take-value.rs b/tests/ui/extern/extern-take-value.rs index 56ed3328614c..f3df82b26109 100644 --- a/tests/ui/extern/extern-take-value.rs +++ b/tests/ui/extern/extern-take-value.rs @@ -1,6 +1,8 @@ //@ run-pass //@ aux-build:extern-take-value.rs +#![allow(unpredictable_function_pointer_comparisons)] + extern crate extern_take_value; pub fn main() { diff --git a/tests/ui/function-pointer/function-pointer-comparison-issue-54685.rs b/tests/ui/function-pointer/function-pointer-comparison-issue-54685.rs index 2e1c863e0f4c..3ec958f2ebff 100644 --- a/tests/ui/function-pointer/function-pointer-comparison-issue-54685.rs +++ b/tests/ui/function-pointer/function-pointer-comparison-issue-54685.rs @@ -1,6 +1,8 @@ //@ compile-flags: -C opt-level=3 //@ run-pass +#![allow(unpredictable_function_pointer_comparisons)] + fn foo(_i: i32) -> i32 { 1 } diff --git a/tests/ui/issues/issue-54696.rs b/tests/ui/issues/issue-54696.rs index 75b1824f0b38..63ffbe42bcc9 100644 --- a/tests/ui/issues/issue-54696.rs +++ b/tests/ui/issues/issue-54696.rs @@ -1,5 +1,7 @@ //@ run-pass +#![allow(unpredictable_function_pointer_comparisons)] + fn main() { // We shouldn't promote this let _ = &(main as fn() == main as fn()); diff --git a/tests/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs b/tests/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs index 44b7fae351cd..45d519739eba 100644 --- a/tests/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs +++ b/tests/ui/mir/validate/issue-95978-validator-lifetime-comparison.rs @@ -1,6 +1,8 @@ //@ check-pass //@ compile-flags: -Zvalidate-mir +#![allow(unpredictable_function_pointer_comparisons)] + fn foo(_a: &str) {} fn main() { From 7b06fcf55900cbc31c58d62793a40e808cefe68e Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 12 Dec 2023 13:10:13 +0100 Subject: [PATCH 06/59] Allow fn pointers comparisons lint in library --- library/core/tests/ptr.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index 7e9773f2fb95..454b13a7ee38 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -304,6 +304,7 @@ fn test_const_nonnull_new() { #[test] #[cfg(unix)] // printf may not be available on other platforms #[allow(deprecated)] // For SipHasher +#[cfg_attr(not(bootstrap), allow(unpredictable_function_pointer_comparisons))] pub fn test_variadic_fnptr() { use core::ffi; use core::hash::{Hash, SipHasher}; From cb9838c7ade5f172a95c6d3acb07d335e9079e68 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Mon, 2 Dec 2024 19:06:20 +0000 Subject: [PATCH 07/59] rustdoc: Rename set_back_info to restore_module_data. --- src/librustdoc/formats/renderer.rs | 25 +++++++++++++------------ src/librustdoc/html/render/context.rs | 2 +- src/librustdoc/json/mod.rs | 9 ++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 582ef7d2c482..5e4e6f27a154 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -17,17 +17,18 @@ pub(crate) trait FormatRenderer<'tcx>: Sized { /// /// This is true for html, and false for json. See #80664 const RUN_ON_MODULE: bool; + /// This associated type is the type where the current module information is stored. /// /// For each module, we go through their items by calling for each item: /// - /// 1. save_module_data - /// 2. item - /// 3. set_back_info + /// 1. `save_module_data` + /// 2. `item` + /// 3. `restore_module_data` /// - /// However,the `item` method might update information in `self` (for example if the child is - /// a module). To prevent it to impact the other children of the current module, we need to - /// reset the information between each call to `item` by using `set_back_info`. + /// This is because the `item` method might update information in `self` (for example if the child + /// is a module). To prevent it from impacting the other children of the current module, we need to + /// reset the information between each call to `item` by using `restore_module_data`. type ModuleData; /// Sets up any state required for the renderer. When this is called the cache has already been @@ -41,18 +42,18 @@ pub(crate) trait FormatRenderer<'tcx>: Sized { /// This method is called right before call [`Self::item`]. This method returns a type /// containing information that needs to be reset after the [`Self::item`] method has been - /// called with the [`Self::set_back_info`] method. + /// called with the [`Self::restore_module_data`] method. /// /// In short it goes like this: /// /// ```ignore (not valid code) - /// let reset_data = type.save_module_data(); - /// type.item(item)?; - /// type.set_back_info(reset_data); + /// let reset_data = renderer.save_module_data(); + /// renderer.item(item)?; + /// renderer.restore_module_data(reset_data); /// ``` fn save_module_data(&mut self) -> Self::ModuleData; /// Used to reset current module's information. - fn set_back_info(&mut self, info: Self::ModuleData); + fn restore_module_data(&mut self, info: Self::ModuleData); /// Renders a single non-module item. This means no recursive sub-item rendering is required. fn item(&mut self, item: clean::Item) -> Result<(), Error>; @@ -91,7 +92,7 @@ fn run_format_inner<'tcx, T: FormatRenderer<'tcx>>( for it in module.items { let info = cx.save_module_data(); run_format_inner(cx, it, prof)?; - cx.set_back_info(info); + cx.restore_module_data(info); } cx.mod_item_out()?; diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 40468aef4db3..2d5df75e7dc1 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -601,7 +601,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { self.info } - fn set_back_info(&mut self, info: Self::ModuleData) { + fn restore_module_data(&mut self, info: Self::ModuleData) { self.info = info; } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 9efcf6b4983b..789a56149675 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -163,11 +163,10 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { } fn save_module_data(&mut self) -> Self::ModuleData { - unreachable!("RUN_ON_MODULE = false should never call save_module_data") + unreachable!("RUN_ON_MODULE = false, should never call save_module_data") } - - fn set_back_info(&mut self, _info: Self::ModuleData) { - unreachable!("RUN_ON_MODULE = false should never call set_back_info") + fn restore_module_data(&mut self, _info: Self::ModuleData) { + unreachable!("RUN_ON_MODULE = false, should never call set_back_info") } /// Inserts an item into the index. This should be used rather than directly calling insert on @@ -248,7 +247,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { } fn mod_item_in(&mut self, _item: &clean::Item) -> Result<(), Error> { - unreachable!("RUN_ON_MODULE = false should never call mod_item_in") + unreachable!("RUN_ON_MODULE = false, should never call mod_item_in") } fn after_krate(&mut self) -> Result<(), Error> { From 67defd72e6a39a3a339ebe925ffb6f5a35f5a04e Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 3 Dec 2024 13:42:43 +0100 Subject: [PATCH 08/59] update instrumentation --- compiler/rustc_borrowck/src/region_infer/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 99af5500ac63..f4f87fa9f650 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -981,8 +981,6 @@ impl<'tcx> RegionInferenceContext<'tcx> { return false; }; - debug!("subject = {:?}", subject); - let r_scc = self.constraint_sccs.scc(*lower_bound); debug!( @@ -1063,7 +1061,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// variables in the type `T` with an equal universal region from the /// closure signature. /// This is not always possible, so this is a fallible process. - #[instrument(level = "debug", skip(self, infcx))] + #[instrument(level = "debug", skip(self, infcx), ret)] fn try_promote_type_test_subject( &self, infcx: &InferCtxt<'tcx>, From 8a47b442c431efcaba7e257c509b9b8d2337e37a Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 3 Dec 2024 13:49:12 +0100 Subject: [PATCH 09/59] closure requirements: don't replace bivariant opaque args It is unnecessary, these get constrained when checking that the opaque type is well-formed. It also results in the opaque type no longer being well formed. If you've got `fn foo<'a>() -> impl Sized + 'a` the opaque is `type Opaque<'a, 'aDummy> where 'a: 'aDummy, 'aDummy: 'a` where `'aDummy` is bivariant. If we call `foo::<'b>()` inside of a closure and its return type ends up in a type test, we start out with the WF `Opaque<'b, 'b>`, and then replace the bivariant `'b` with `'static`. `Opaque<'b, 'static>` is no longer well-formed. Given how these type tests are used, I don't think this caused any practical issues. --- .../rustc_borrowck/src/region_infer/mod.rs | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index f4f87fa9f650..691709e53ee6 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1068,37 +1068,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { ty: Ty<'tcx>, ) -> Option> { let tcx = infcx.tcx; - - // Opaque types' args may include useless lifetimes. - // We will replace them with ReStatic. - struct OpaqueFolder<'tcx> { - tcx: TyCtxt<'tcx>, - } - impl<'tcx> ty::TypeFolder> for OpaqueFolder<'tcx> { - fn cx(&self) -> TyCtxt<'tcx> { - self.tcx - } - fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - use ty::TypeSuperFoldable as _; - let tcx = self.tcx; - let &ty::Alias(ty::Opaque, ty::AliasTy { args, def_id, .. }) = t.kind() else { - return t.super_fold_with(self); - }; - let args = std::iter::zip(args, tcx.variances_of(def_id)).map(|(arg, v)| { - match (arg.unpack(), v) { - (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => { - tcx.lifetimes.re_static.into() - } - _ => arg.fold_with(self), - } - }); - Ty::new_opaque(tcx, def_id, tcx.mk_args_from_iter(args)) - } - } - - let ty = ty.fold_with(&mut OpaqueFolder { tcx }); let mut failed = false; - let ty = fold_regions(tcx, ty, |r, _depth| { let r_vid = self.to_region_vid(r); let r_scc = self.constraint_sccs.scc(r_vid); From 65d0b5dc2eb6074579f9a17a6349073066209538 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 3 Dec 2024 14:06:46 +0100 Subject: [PATCH 10/59] small code cleanup --- compiler/rustc_borrowck/src/region_infer/mod.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 691709e53ee6..0eecf98a6ede 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -973,23 +973,20 @@ impl<'tcx> RegionInferenceContext<'tcx> { propagated_outlives_requirements: &mut Vec>, ) -> bool { let tcx = infcx.tcx; - - let TypeTest { generic_kind, lower_bound, span: _, verify_bound: _ } = type_test; + let TypeTest { generic_kind, lower_bound, span: blame_span, ref verify_bound } = *type_test; let generic_ty = generic_kind.to_ty(tcx); let Some(subject) = self.try_promote_type_test_subject(infcx, generic_ty) else { return false; }; - let r_scc = self.constraint_sccs.scc(*lower_bound); - + let r_scc = self.constraint_sccs.scc(lower_bound); debug!( "lower_bound = {:?} r_scc={:?} universe={:?}", lower_bound, r_scc, self.constraint_sccs.annotation(r_scc).min_universe() ); - // If the type test requires that `T: 'a` where `'a` is a // placeholder from another universe, that effectively requires // `T: 'static`, so we have to propagate that requirement. @@ -1002,7 +999,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { propagated_outlives_requirements.push(ClosureOutlivesRequirement { subject, outlived_free_region: static_r, - blame_span: type_test.span, + blame_span, category: ConstraintCategory::Boring, }); @@ -1029,12 +1026,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { // where `ur` is a local bound -- we are sometimes in a // position to prove things that our caller cannot. See // #53570 for an example. - if self.eval_verify_bound(infcx, generic_ty, ur, &type_test.verify_bound) { + if self.eval_verify_bound(infcx, generic_ty, ur, &verify_bound) { continue; } let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur); - debug!("try_promote_type_test: non_local_ub={:?}", non_local_ub); + debug!(?non_local_ub); // This is slightly too conservative. To show T: '1, given `'2: '1` // and `'3: '1` we only need to prove that T: '2 *or* T: '3, but to @@ -1047,10 +1044,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { let requirement = ClosureOutlivesRequirement { subject, outlived_free_region: upper_bound, - blame_span: type_test.span, + blame_span, category: ConstraintCategory::Boring, }; - debug!("try_promote_type_test: pushing {:#?}", requirement); + debug!(?requirement, "adding closure requirement"); propagated_outlives_requirements.push(requirement); } } From 605306efeff9b95f137e4f21bbdcf9038da68357 Mon Sep 17 00:00:00 2001 From: DianQK Date: Tue, 3 Dec 2024 21:12:47 +0800 Subject: [PATCH 11/59] Update LLVM to 19.1.5 --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 33ea0f53cf13..07fd44c2b2da 100644 --- a/.gitmodules +++ b/.gitmodules @@ -33,7 +33,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/19.1-2024-09-17 + branch = rustc/19.1-2024-12-03 shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/src/llvm-project b/src/llvm-project index 104d0d16c3c7..1268e87bdbae 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 104d0d16c3c7c3fef2435fef6efb2d57b70fff73 +Subproject commit 1268e87bdbaed0693a9d782ccd5a21e2cab2de33 From a2eca35c15a1d594dea89543baa38499249f50ee Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 2 Dec 2024 18:36:29 -0800 Subject: [PATCH 12/59] Visit BinOp span in MutVisitor::visit_expr --- compiler/rustc_ast/src/mut_visit.rs | 3 ++- tests/ui-fulldeps/pprust-parenthesis-insertion.rs | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 0aceed45028a..1e02dc8fb245 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1628,9 +1628,10 @@ pub fn walk_expr(vis: &mut T, Expr { kind, id, span, attrs, token visit_thin_exprs(vis, call_args); vis.visit_span(span); } - ExprKind::Binary(_binop, lhs, rhs) => { + ExprKind::Binary(binop, lhs, rhs) => { vis.visit_expr(lhs); vis.visit_expr(rhs); + vis.visit_span(&mut binop.span); } ExprKind::Unary(_unop, ohs) => vis.visit_expr(ohs), ExprKind::Cast(expr, ty) => { diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index fd6644d73c16..75caea057ed7 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -165,13 +165,6 @@ impl MutVisitor for Normalize { *span = DUMMY_SP; } - fn visit_expr(&mut self, expr: &mut P) { - if let ExprKind::Binary(binop, _left, _right) = &mut expr.kind { - self.visit_span(&mut binop.span); - } - mut_visit::walk_expr(self, expr); - } - fn flat_map_stmt(&mut self, mut stmt: Stmt) -> SmallVec<[Stmt; 1]> { self.visit_span(&mut stmt.span); mut_visit::walk_flat_map_stmt(self, stmt) From a3cfe2fd083408b53fa02a90af718b49d2bbe83a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 2 Dec 2024 18:38:45 -0800 Subject: [PATCH 13/59] Visit Stmt span in MutVisitor::flat_map_stmt --- compiler/rustc_ast/src/mut_visit.rs | 13 +++++++------ tests/ui-fulldeps/pprust-parenthesis-insertion.rs | 9 +-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 1e02dc8fb245..0c2fe61a698f 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1789,20 +1789,21 @@ pub fn noop_filter_map_expr(vis: &mut T, mut e: P) -> Optio pub fn walk_flat_map_stmt( vis: &mut T, - Stmt { kind, mut span, mut id }: Stmt, + Stmt { kind, span, mut id }: Stmt, ) -> SmallVec<[Stmt; 1]> { vis.visit_id(&mut id); - let stmts: SmallVec<_> = walk_flat_map_stmt_kind(vis, kind) + let mut stmts: SmallVec<[Stmt; 1]> = walk_flat_map_stmt_kind(vis, kind) .into_iter() .map(|kind| Stmt { id, kind, span }) .collect(); - if stmts.len() > 1 { - panic!( + match stmts.len() { + 0 => {} + 1 => vis.visit_span(&mut stmts[0].span), + 2.. => panic!( "cloning statement `NodeId`s is prohibited by default, \ the visitor should implement custom statement visiting" - ); + ), } - vis.visit_span(&mut span); stmts } diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index 75caea057ed7..b83e576076dd 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -36,12 +36,11 @@ extern crate rustc_errors; extern crate rustc_parse; extern crate rustc_session; extern crate rustc_span; -extern crate smallvec; use std::mem; use std::process::ExitCode; -use rustc_ast::ast::{DUMMY_NODE_ID, Expr, ExprKind, Stmt}; +use rustc_ast::ast::{DUMMY_NODE_ID, Expr, ExprKind}; use rustc_ast::mut_visit::{self, DummyAstNode as _, MutVisitor}; use rustc_ast::node_id::NodeId; use rustc_ast::ptr::P; @@ -50,7 +49,6 @@ use rustc_errors::Diag; use rustc_parse::parser::Recovery; use rustc_session::parse::ParseSess; use rustc_span::{DUMMY_SP, FileName, Span}; -use smallvec::SmallVec; // Every parenthesis in the following expressions is re-inserted by the // pretty-printer. @@ -164,11 +162,6 @@ impl MutVisitor for Normalize { fn visit_span(&mut self, span: &mut Span) { *span = DUMMY_SP; } - - fn flat_map_stmt(&mut self, mut stmt: Stmt) -> SmallVec<[Stmt; 1]> { - self.visit_span(&mut stmt.span); - mut_visit::walk_flat_map_stmt(self, stmt) - } } fn parse_expr(psess: &ParseSess, source_code: &str) -> Option> { From 2e1f25bb1c322c4e77d746a940d2c3ff1895f3ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 3 Dec 2024 17:26:31 +0100 Subject: [PATCH 14/59] Improve code for FileName retrieval in rustdoc --- src/librustdoc/html/sources.rs | 49 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index c37506e35883..4b05e7c427c6 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::{FileName, sym}; +use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, sym}; use tracing::info; use crate::clean; @@ -50,8 +50,14 @@ struct LocalSourcesCollector<'a, 'tcx> { src_root: &'a Path, } -fn is_real_and_local(span: clean::Span, sess: &Session) -> bool { - span.cnum(sess) == LOCAL_CRATE && span.filename(sess).is_real() +fn is_real_and_local(span: clean::Span, sess: &Session) -> Option { + if span.cnum(sess) == LOCAL_CRATE + && let FileName::Real(file) = span.filename(sess) + { + Some(file) + } else { + None + } } impl LocalSourcesCollector<'_, '_> { @@ -60,16 +66,7 @@ impl LocalSourcesCollector<'_, '_> { let span = item.span(self.tcx); let Some(span) = span else { return }; // skip all synthetic "files" - if !is_real_and_local(span, sess) { - return; - } - let filename = span.filename(sess); - let p = if let FileName::Real(file) = filename { - match file.into_local_path() { - Some(p) => p, - None => return, - } - } else { + let Some(p) = is_real_and_local(span, sess).and_then(|file| file.into_local_path()) else { return; }; if self.local_sources.contains_key(&*p) { @@ -135,8 +132,7 @@ impl DocVisitor<'_> for SourceCollector<'_, '_> { // If we're not rendering sources, there's nothing to do. // If we're including source files, and we haven't seen this file yet, // then we need to render it out to the filesystem. - if is_real_and_local(span, sess) { - let filename = span.filename(sess); + if let Some(filename) = is_real_and_local(span, sess) { let span = span.inner(); let pos = sess.source_map().lookup_source_file(span.lo()); let file_span = span.with_lo(pos.start_pos).with_hi(pos.end_position()); @@ -152,7 +148,7 @@ impl DocVisitor<'_> for SourceCollector<'_, '_> { span, format!( "failed to render source code for `{filename}`: {e}", - filename = filename.prefer_local(), + filename = filename.to_string_lossy(FileNameDisplayPreference::Local), ), ); false @@ -168,18 +164,13 @@ impl SourceCollector<'_, '_> { /// Renders the given filename into its corresponding HTML source file. fn emit_source( &mut self, - filename: &FileName, + file: &RealFileName, file_span: rustc_span::Span, ) -> Result<(), Error> { - let p = match *filename { - FileName::Real(ref file) => { - if let Some(local_path) = file.local_path() { - local_path.to_path_buf() - } else { - unreachable!("only the current crate should have sources emitted"); - } - } - _ => return Ok(()), + let p = if let Some(local_path) = file.local_path() { + local_path.to_path_buf() + } else { + unreachable!("only the current crate should have sources emitted"); }; if self.emitted_local_sources.contains(&*p) { // We've already emitted this source @@ -233,8 +224,10 @@ impl SourceCollector<'_, '_> { cur.push(&fname); let title = format!("{} - source", src_fname.to_string_lossy()); - let desc = - format!("Source of the Rust file `{}`.", filename.prefer_remapped_unconditionaly()); + let desc = format!( + "Source of the Rust file `{}`.", + file.to_string_lossy(FileNameDisplayPreference::Remapped) + ); let page = layout::Page { title: &title, css_class: "src", From 1c96ddde11ad3ef054228322ed144742cecb8643 Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 3 Dec 2024 17:26:43 +0100 Subject: [PATCH 15/59] closure-requirements: add regression tests --- .../thread_scope_correct_implied_bound.rs | 23 +++++++++++++++++++ .../thread_scope_incorrect_implied_bound.rs | 21 +++++++++++++++++ ...hread_scope_incorrect_implied_bound.stderr | 17 ++++++++++++++ .../ty-outlives/projection-implied-bounds.rs | 2 -- .../projection-implied-bounds.stderr | 2 +- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 tests/ui/nll/closure-requirements/thread_scope_correct_implied_bound.rs create mode 100644 tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.rs create mode 100644 tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.stderr diff --git a/tests/ui/nll/closure-requirements/thread_scope_correct_implied_bound.rs b/tests/ui/nll/closure-requirements/thread_scope_correct_implied_bound.rs new file mode 100644 index 000000000000..e2b3b051ea81 --- /dev/null +++ b/tests/ui/nll/closure-requirements/thread_scope_correct_implied_bound.rs @@ -0,0 +1,23 @@ +// This example broke while refactoring the way closure +// requirements are handled. The setup here matches +// `thread::scope`. + +//@ check-pass + +struct Outlives<'hr, 'scope: 'hr>(*mut (&'scope (), &'hr ())); +impl<'hr, 'scope> Outlives<'hr, 'scope> { + fn outlives_hr(self) {} +} + +fn takes_closure_implied_bound<'scope>(f: impl for<'hr> FnOnce(Outlives<'hr, 'scope>)) {} + +fn requires_external_outlives_hr() { + // implied bounds: + // - `T: 'scope` as `'scope` is local to this function + // - `'scope: 'hr` as it's an implied bound of `Outlives` + // + // need to prove `T: 'hr` :> + takes_closure_implied_bound(|proof| proof.outlives_hr::()); +} + +fn main() {} diff --git a/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.rs b/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.rs new file mode 100644 index 000000000000..cfc8980410ad --- /dev/null +++ b/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.rs @@ -0,0 +1,21 @@ +// This example incorrectly compiled while refactoring the way +// closure requirements are handled. + +struct Outlives<'hr: 'scope, 'scope>(*mut (&'scope (), &'hr ())); +impl<'hr, 'scope> Outlives<'hr, 'scope> { + fn outlives_hr(self) {} +} + +fn takes_closure_implied_bound<'scope>(f: impl for<'hr> FnOnce(Outlives<'hr, 'scope>)) {} + +fn requires_external_outlives_hr() { + // implied bounds: + // - `T: 'scope` as `'scope` is local to this function + // - `'hr: 'scope` as it's an implied bound of `Outlives` + // + // need to prove `T: 'hr` :< + takes_closure_implied_bound(|proof| proof.outlives_hr::()); + //~^ ERROR the parameter type `T` may not live long enough +} + +fn main() {} diff --git a/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.stderr b/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.stderr new file mode 100644 index 000000000000..e22673c249f3 --- /dev/null +++ b/tests/ui/nll/closure-requirements/thread_scope_incorrect_implied_bound.stderr @@ -0,0 +1,17 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/thread_scope_incorrect_implied_bound.rs:17:47 + | +LL | takes_closure_implied_bound(|proof| proof.outlives_hr::()); + | ^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound + | +LL | fn requires_external_outlives_hr() { + | +++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/nll/ty-outlives/projection-implied-bounds.rs b/tests/ui/nll/ty-outlives/projection-implied-bounds.rs index 7d983adfe889..c6572d60bb07 100644 --- a/tests/ui/nll/ty-outlives/projection-implied-bounds.rs +++ b/tests/ui/nll/ty-outlives/projection-implied-bounds.rs @@ -1,8 +1,6 @@ // Test that we can deduce when projections like `T::Item` outlive the // function body. Test that this does not imply that `T: 'a` holds. -//@ compile-flags:-Zverbose-internals - use std::cell::Cell; fn twice(mut value: T, mut f: F) diff --git a/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr b/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr index 2aab03ee7b76..5d5b890151d9 100644 --- a/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/tests/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/projection-implied-bounds.rs:30:36 + --> $DIR/projection-implied-bounds.rs:28:36 | LL | twice(value, |value_ref, item| invoke2(value_ref, item)); | ^^^^^^^^^^^^^^^^^^^^^^^^ From 7afce4f06a56dc1344f54e179a0785b95700df5f Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 21 Nov 2024 09:15:22 -0800 Subject: [PATCH 16/59] Update `NonZero` and `NonNull` to not field-project (per MCP807) --- library/core/src/num/nonzero.rs | 34 +++- library/core/src/ptr/non_null.rs | 53 ++--- ...d_constant.main.GVN.32bit.panic-abort.diff | 12 +- ..._constant.main.GVN.32bit.panic-unwind.diff | 12 +- ...d_constant.main.GVN.64bit.panic-abort.diff | 12 +- ..._constant.main.GVN.64bit.panic-unwind.diff | 12 +- ...ated_loop.PreCodegen.after.panic-abort.mir | 184 +++++++++--------- ...ted_loop.PreCodegen.after.panic-unwind.mir | 134 +++++++------ ...ward_loop.PreCodegen.after.panic-abort.mir | 118 +++++------ ...ard_loop.PreCodegen.after.panic-unwind.mir | 118 +++++------ ...erse_loop.PreCodegen.after.panic-abort.mir | 132 +++++++------ ...rse_loop.PreCodegen.after.panic-unwind.mir | 132 +++++++------ ..._is_empty.PreCodegen.after.panic-abort.mir | 12 +- ...is_empty.PreCodegen.after.panic-unwind.mir | 12 +- ..._to_slice.PreCodegen.after.panic-abort.mir | 62 +++--- ...to_slice.PreCodegen.after.panic-unwind.mir | 62 +++--- 16 files changed, 587 insertions(+), 514 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index b883a0c2ec7f..135c700a494c 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -37,6 +37,8 @@ pub unsafe trait ZeroablePrimitive: Sized + Copy + private::Sealed { macro_rules! impl_zeroable_primitive { ($($NonZeroInner:ident ( $primitive:ty )),+ $(,)?) => { mod private { + use super::*; + #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", @@ -45,7 +47,11 @@ macro_rules! impl_zeroable_primitive { pub trait Sealed {} $( - #[derive(Debug, Clone, Copy, PartialEq)] + // This inner type is never shown directly, so intentionally does not have Debug + #[expect(missing_debug_implementations)] + // Since this struct is non-generic and derives Copy, + // the derived Clone is `*self` and thus doesn't field-project. + #[derive(Clone, Copy)] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] @@ -55,6 +61,16 @@ macro_rules! impl_zeroable_primitive { issue = "none" )] pub struct $NonZeroInner($primitive); + + // This is required to allow matching a constant. We don't get it from a derive + // because the derived `PartialEq` would do a field projection, which is banned + // by . + #[unstable( + feature = "nonzero_internals", + reason = "implementation detail which may disappear or be replaced at any time", + issue = "none" + )] + impl StructuralPartialEq for $NonZeroInner {} )+ } @@ -172,7 +188,7 @@ where { #[inline] fn clone(&self) -> Self { - Self(self.0) + *self } } @@ -440,15 +456,21 @@ where #[rustc_const_stable(feature = "const_nonzero_get", since = "1.34.0")] #[inline] pub const fn get(self) -> T { - // FIXME: This can be changed to simply `self.0` once LLVM supports `!range` metadata - // for function arguments: https://github.com/llvm/llvm-project/issues/76628 - // // Rustc can set range metadata only if it loads `self` from // memory somewhere. If the value of `self` was from by-value argument // of some not-inlined function, LLVM don't have range metadata // to understand that the value cannot be zero. // - // For now, using the transmute `assume`s the range at runtime. + // Using the transmute `assume`s the range at runtime. + // + // Even once LLVM supports `!range` metadata for function arguments + // (see ), this can't + // be `.0` because MCP#807 bans field-projecting into `scalar_valid_range` + // types, and it arguably wouldn't want to be anyway because if this is + // MIR-inlined, there's no opportunity to put that argument metadata anywhere. + // + // The good answer here will eventually be pattern types, which will hopefully + // allow it to go back to `.0`, maybe with a cast of some sort. // // SAFETY: `ZeroablePrimitive` guarantees that the size and bit validity // of `.0` is such that this transmute is sound. diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index b69f8a4b9d3e..9873752d548a 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -7,7 +7,7 @@ use crate::pin::PinCoerceUnsized; use crate::ptr::Unique; use crate::slice::{self, SliceIndex}; use crate::ub_checks::assert_unsafe_precondition; -use crate::{fmt, hash, intrinsics, ptr}; +use crate::{fmt, hash, intrinsics, mem, ptr}; /// `*mut T` but non-zero and [covariant]. /// @@ -69,6 +69,8 @@ use crate::{fmt, hash, intrinsics, ptr}; #[rustc_nonnull_optimization_guaranteed] #[rustc_diagnostic_item = "NonNull"] pub struct NonNull { + // Remember to use `.as_ptr()` instead of `.pointer`, as field projecting to + // this is banned by . pointer: *const T, } @@ -282,7 +284,7 @@ impl NonNull { pub fn addr(self) -> NonZero { // SAFETY: The pointer is guaranteed by the type to be non-null, // meaning that the address will be non-zero. - unsafe { NonZero::new_unchecked(self.pointer.addr()) } + unsafe { NonZero::new_unchecked(self.as_ptr().addr()) } } /// Creates a new pointer with the given address and the [provenance][crate::ptr#provenance] of @@ -296,7 +298,7 @@ impl NonNull { #[stable(feature = "strict_provenance", since = "CURRENT_RUSTC_VERSION")] pub fn with_addr(self, addr: NonZero) -> Self { // SAFETY: The result of `ptr::from::with_addr` is non-null because `addr` is guaranteed to be non-zero. - unsafe { NonNull::new_unchecked(self.pointer.with_addr(addr.get()) as *mut _) } + unsafe { NonNull::new_unchecked(self.as_ptr().with_addr(addr.get()) as *mut _) } } /// Creates a new pointer by mapping `self`'s address to a new one, preserving the @@ -335,7 +337,12 @@ impl NonNull { #[must_use] #[inline(always)] pub const fn as_ptr(self) -> *mut T { - self.pointer as *mut T + // This is a transmute for the same reasons as `NonZero::get`. + + // SAFETY: `NonNull` is `transparent` over a `*const T`, and `*const T` + // and `*mut T` have the same layout, so transitively we can transmute + // our `NonNull` to a `*mut T` directly. + unsafe { mem::transmute::(self) } } /// Returns a shared reference to the value. If the value may be uninitialized, [`as_uninit_ref`] @@ -484,7 +491,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.pointer, count) } } + unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } } /// Calculates the offset from a pointer in bytes. @@ -508,7 +515,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_offset(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_offset(count) } } } /// Adds an offset to a pointer (convenience for `.offset(count as isize)`). @@ -560,7 +567,7 @@ impl NonNull { // Additionally safety contract of `offset` guarantees that the resulting pointer is // pointing to an allocation, there can't be an allocation at null, thus it's safe to // construct `NonNull`. - unsafe { NonNull { pointer: intrinsics::offset(self.pointer, count) } } + unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } } } /// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`). @@ -584,7 +591,7 @@ impl NonNull { // Additionally safety contract of `add` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_add(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_add(count) } } } /// Subtracts an offset from a pointer (convenience for @@ -667,7 +674,7 @@ impl NonNull { // Additionally safety contract of `sub` guarantees that the resulting pointer is pointing // to an allocation, there can't be an allocation at null, thus it's safe to construct // `NonNull`. - unsafe { NonNull { pointer: self.pointer.byte_sub(count) } } + unsafe { NonNull { pointer: self.as_ptr().byte_sub(count) } } } /// Calculates the distance between two pointers within the same allocation. The returned value is in @@ -764,7 +771,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `offset_from`. - unsafe { self.pointer.offset_from(origin.pointer) } + unsafe { self.as_ptr().offset_from(origin.as_ptr()) } } /// Calculates the distance between two pointers within the same allocation. The returned value is in @@ -782,7 +789,7 @@ impl NonNull { #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] pub const unsafe fn byte_offset_from(self, origin: NonNull) -> isize { // SAFETY: the caller must uphold the safety contract for `byte_offset_from`. - unsafe { self.pointer.byte_offset_from(origin.pointer) } + unsafe { self.as_ptr().byte_offset_from(origin.as_ptr()) } } // N.B. `wrapping_offset``, `wrapping_add`, etc are not implemented because they can wrap to null @@ -857,7 +864,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { self.pointer.sub_ptr(subtracted.pointer) } + unsafe { self.as_ptr().sub_ptr(subtracted.as_ptr()) } } /// Calculates the distance between two pointers within the same allocation, *where it's known that @@ -876,7 +883,7 @@ impl NonNull { #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] pub const unsafe fn byte_sub_ptr(self, origin: NonNull) -> usize { // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`. - unsafe { self.pointer.byte_sub_ptr(origin.pointer) } + unsafe { self.as_ptr().byte_sub_ptr(origin.as_ptr()) } } /// Reads the value from `self` without moving it. This leaves the @@ -894,7 +901,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read`. - unsafe { ptr::read(self.pointer) } + unsafe { ptr::read(self.as_ptr()) } } /// Performs a volatile read of the value from `self` without moving it. This @@ -915,7 +922,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read_volatile`. - unsafe { ptr::read_volatile(self.pointer) } + unsafe { ptr::read_volatile(self.as_ptr()) } } /// Reads the value from `self` without moving it. This leaves the @@ -935,7 +942,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `read_unaligned`. - unsafe { ptr::read_unaligned(self.pointer) } + unsafe { ptr::read_unaligned(self.as_ptr()) } } /// Copies `count * size_of` bytes from `self` to `dest`. The source @@ -955,7 +962,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy`. - unsafe { ptr::copy(self.pointer, dest.as_ptr(), count) } + unsafe { ptr::copy(self.as_ptr(), dest.as_ptr(), count) } } /// Copies `count * size_of` bytes from `self` to `dest`. The source @@ -975,7 +982,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy_nonoverlapping`. - unsafe { ptr::copy_nonoverlapping(self.pointer, dest.as_ptr(), count) } + unsafe { ptr::copy_nonoverlapping(self.as_ptr(), dest.as_ptr(), count) } } /// Copies `count * size_of` bytes from `src` to `self`. The source @@ -995,7 +1002,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy`. - unsafe { ptr::copy(src.pointer, self.as_ptr(), count) } + unsafe { ptr::copy(src.as_ptr(), self.as_ptr(), count) } } /// Copies `count * size_of` bytes from `src` to `self`. The source @@ -1015,7 +1022,7 @@ impl NonNull { T: Sized, { // SAFETY: the caller must uphold the safety contract for `copy_nonoverlapping`. - unsafe { ptr::copy_nonoverlapping(src.pointer, self.as_ptr(), count) } + unsafe { ptr::copy_nonoverlapping(src.as_ptr(), self.as_ptr(), count) } } /// Executes the destructor (if any) of the pointed-to value. @@ -1202,7 +1209,7 @@ impl NonNull { { // SAFETY: `align` has been checked to be a power of 2 above. - unsafe { ptr::align_offset(self.pointer, align) } + unsafe { ptr::align_offset(self.as_ptr(), align) } } } @@ -1230,7 +1237,7 @@ impl NonNull { where T: Sized, { - self.pointer.is_aligned() + self.as_ptr().is_aligned() } /// Returns whether the pointer is aligned to `align`. @@ -1267,7 +1274,7 @@ impl NonNull { #[must_use] #[unstable(feature = "pointer_is_aligned_to", issue = "96284")] pub fn is_aligned_to(self, align: usize) -> bool { - self.pointer.is_aligned_to(align) + self.as_ptr().is_aligned_to(align) } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 87fbcca91773..027c71dfaae4 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -31,7 +31,6 @@ } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { - let mut _17: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { @@ -102,16 +101,9 @@ StorageDead(_16); StorageDead(_12); StorageDead(_6); -- StorageLive(_17); -+ nop; - _17 = copy (_5.0: *const [u8]); -- _4 = move _17 as *mut [u8] (PtrToPtr); -- StorageDead(_17); -+ _4 = copy _17 as *mut [u8] (PtrToPtr); -+ nop; + _4 = copy _5 as *mut [u8] (Transmute); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = copy _17 as *mut u8 (PtrToPtr); + _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 5fcece2280d4..88bd4628c297 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -20,7 +20,6 @@ scope 5 (inlined ::allocate) { } scope 6 (inlined NonNull::<[u8]>::as_ptr) { - let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { @@ -45,16 +44,9 @@ bb1: { StorageDead(_6); -- StorageLive(_12); -+ nop; - _12 = copy (_5.0: *const [u8]); -- _4 = move _12 as *mut [u8] (PtrToPtr); -- StorageDead(_12); -+ _4 = copy _12 as *mut [u8] (PtrToPtr); -+ nop; + _4 = copy _5 as *mut [u8] (Transmute); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = copy _12 as *mut u8 (PtrToPtr); + _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 13258c171605..ebf305a6f1b1 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -31,7 +31,6 @@ } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { - let mut _17: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { @@ -102,16 +101,9 @@ StorageDead(_16); StorageDead(_12); StorageDead(_6); -- StorageLive(_17); -+ nop; - _17 = copy (_5.0: *const [u8]); -- _4 = move _17 as *mut [u8] (PtrToPtr); -- StorageDead(_17); -+ _4 = copy _17 as *mut [u8] (PtrToPtr); -+ nop; + _4 = copy _5 as *mut [u8] (Transmute); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = copy _17 as *mut u8 (PtrToPtr); + _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 0821ea272bf5..0c52f1e05836 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -20,7 +20,6 @@ scope 5 (inlined ::allocate) { } scope 6 (inlined NonNull::<[u8]>::as_ptr) { - let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { @@ -45,16 +44,9 @@ bb1: { StorageDead(_6); -- StorageLive(_12); -+ nop; - _12 = copy (_5.0: *const [u8]); -- _4 = move _12 as *mut [u8] (PtrToPtr); -- StorageDead(_12); -+ _4 = copy _12 as *mut [u8] (PtrToPtr); -+ nop; + _4 = copy _5 as *mut [u8] (Transmute); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = copy _12 as *mut u8 (PtrToPtr); + _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index bd56ab67e002..a3308cc5df19 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -4,28 +4,28 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::iter::Enumerate>; - let mut _13: std::iter::Enumerate>; - let mut _21: std::option::Option<(usize, &T)>; - let mut _24: &impl Fn(usize, &T); - let mut _25: (usize, &T); - let _26: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate>; + let mut _15: std::iter::Enumerate>; + let mut _23: std::option::Option<(usize, &T)>; + let mut _26: &impl Fn(usize, &T); + let mut _27: (usize, &T); + let _28: (); scope 1 { - debug iter => _13; - let _22: usize; - let _23: &T; + debug iter => _15; + let _24: usize; + let _25: &T; scope 2 { - debug i => _22; - debug x => _23; + debug i => _24; + debug x => _25; } scope 18 (inlined > as Iterator>::next) { - let mut _14: &mut std::slice::Iter<'_, T>; - let mut _15: std::option::Option<&T>; - let mut _19: (usize, bool); - let mut _20: (usize, &T); + let mut _16: &mut std::slice::Iter<'_, T>; + let mut _17: std::option::Option<&T>; + let mut _21: (usize, bool); + let mut _22: (usize, &T); scope 19 { - let _18: usize; + let _20: usize; scope 24 { } } @@ -40,8 +40,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 25 (inlined as Try>::branch) { - let mut _16: isize; - let _17: &T; + let mut _18: isize; + let _19: &T; scope 26 { } } @@ -50,13 +50,14 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -72,7 +73,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -87,76 +89,82 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - StorageLive(_11); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); - _12 = Enumerate::> { iter: copy _11, count: const 0_usize }; + StorageLive(_12); + _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); StorageDead(_11); - StorageLive(_13); - _13 = copy _12; + StorageDead(_8); + StorageDead(_3); + _14 = Enumerate::> { iter: copy _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { + StorageLive(_23); + StorageLive(_20); StorageLive(_21); - StorageLive(_18); - StorageLive(_19); - StorageLive(_15); - StorageLive(_14); - _14 = &mut (_13.0: std::slice::Iter<'_, T>); - _15 = as Iterator>::next(move _14) -> [return: bb5, unwind unreachable]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut (_15.0: std::slice::Iter<'_, T>); + _17 = as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_14); - StorageLive(_16); - _16 = discriminant(_15); - switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb11]; + StorageDead(_16); + StorageLive(_18); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb11]; } bb6: { - StorageDead(_16); - StorageDead(_15); - StorageDead(_19); StorageDead(_18); + StorageDead(_17); StorageDead(_21); - StorageDead(_13); + StorageDead(_20); + StorageDead(_23); + StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -165,35 +173,35 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _17 = move ((_15 as Some).0: &T); - StorageDead(_16); - StorageDead(_15); - _18 = copy (_13.1: usize); - _19 = AddWithOverflow(copy (_13.1: usize), const 1_usize); - assert(!move (_19.1: bool), "attempt to compute `{} + {}`, which would overflow", copy (_13.1: usize), const 1_usize) -> [success: bb9, unwind unreachable]; + _19 = move ((_17 as Some).0: &T); + StorageDead(_18); + StorageDead(_17); + _20 = copy (_15.1: usize); + _21 = AddWithOverflow(copy (_15.1: usize), const 1_usize); + assert(!move (_21.1: bool), "attempt to compute `{} + {}`, which would overflow", copy (_15.1: usize), const 1_usize) -> [success: bb9, unwind unreachable]; } bb9: { - (_13.1: usize) = move (_19.0: usize); - StorageLive(_20); - _20 = (copy _18, copy _17); - _21 = Option::<(usize, &T)>::Some(move _20); + (_15.1: usize) = move (_21.0: usize); + StorageLive(_22); + _22 = (copy _20, copy _19); + _23 = Option::<(usize, &T)>::Some(move _22); + StorageDead(_22); + StorageDead(_21); StorageDead(_20); - StorageDead(_19); - StorageDead(_18); - _22 = copy (((_21 as Some).0: (usize, &T)).0: usize); - _23 = copy (((_21 as Some).0: (usize, &T)).1: &T); - StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _22, copy _23); - _26 = >::call(move _24, move _25) -> [return: bb10, unwind unreachable]; + _24 = copy (((_23 as Some).0: (usize, &T)).0: usize); + _25 = copy (((_23 as Some).0: (usize, &T)).1: &T); + StorageLive(_26); + _26 = &_2; + StorageLive(_27); + _27 = (copy _24, copy _25); + _28 = >::call(move _26, move _27) -> [return: bb10, unwind unreachable]; } bb10: { - StorageDead(_25); - StorageDead(_24); - StorageDead(_21); + StorageDead(_27); + StorageDead(_26); + StorageDead(_23); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 57f09a4631b5..2a837fabd4c2 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -4,34 +4,35 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::iter::Enumerate>; - let mut _13: std::iter::Enumerate>; - let mut _14: &mut std::iter::Enumerate>; - let mut _15: std::option::Option<(usize, &T)>; - let mut _16: isize; - let mut _19: &impl Fn(usize, &T); - let mut _20: (usize, &T); - let _21: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate>; + let mut _15: std::iter::Enumerate>; + let mut _16: &mut std::iter::Enumerate>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _13; - let _17: usize; - let _18: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _17; - debug x => _18; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -47,7 +48,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -62,66 +64,72 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - StorageLive(_11); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); - _12 = Enumerate::> { iter: copy _11, count: const 0_usize }; + StorageLive(_12); + _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); StorageDead(_11); - StorageLive(_13); - _13 = copy _12; + StorageDead(_8); + StorageDead(_3); + _14 = Enumerate::> { iter: copy _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - StorageLive(_15); - _14 = &mut _13; - _15 = > as Iterator>::next(move _14) -> [return: bb5, unwind: bb11]; + StorageLive(_17); + _16 = &mut _15; + _17 = > as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - _16 = discriminant(_15); - switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10]; + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { + StorageDead(_17); StorageDead(_15); - StorageDead(_13); drop(_2) -> [return: bb7, unwind continue]; } @@ -130,19 +138,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _17 = copy (((_15 as Some).0: (usize, &T)).0: usize); - _18 = copy (((_15 as Some).0: (usize, &T)).1: &T); - StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (copy _17, copy _18); - _21 = >::call(move _19, move _20) -> [return: bb9, unwind: bb11]; + _19 = copy (((_17 as Some).0: (usize, &T)).0: usize); + _20 = copy (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (copy _19, copy _20); + _23 = >::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_20); - StorageDead(_19); - StorageDead(_15); + StorageDead(_22); + StorageDead(_21); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 4050304f4698..063045caebb5 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -4,31 +4,32 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::slice::Iter<'_, T>; - let mut _13: &mut std::slice::Iter<'_, T>; - let mut _14: std::option::Option<&T>; - let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _12; - let _16: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _16; + debug x => _18; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -44,7 +45,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -56,62 +58,68 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); StorageLive(_12); _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageLive(_14); + _14 = copy _13; goto -> bb4; } bb4: { - StorageLive(_14); - _13 = &mut _12; - _14 = as Iterator>::next(move _13) -> [return: bb5, unwind unreachable]; + StorageLive(_16); + _15 = &mut _14; + _16 = as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { + StorageDead(_16); StorageDead(_14); - StorageDead(_12); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -120,18 +128,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _16 = copy ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (copy _16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind unreachable]; + _18 = copy ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (copy _18,); + _21 = >::call(move _19, move _20) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_18); - StorageDead(_17); - StorageDead(_14); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 2c3d7ab1e4a8..d401ed8fcf3c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -4,31 +4,32 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::slice::Iter<'_, T>; - let mut _13: &mut std::slice::Iter<'_, T>; - let mut _14: std::option::Option<&T>; - let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _12; - let _16: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _16; + debug x => _18; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -44,7 +45,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -56,62 +58,68 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); StorageLive(_12); _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageLive(_14); + _14 = copy _13; goto -> bb4; } bb4: { - StorageLive(_14); - _13 = &mut _12; - _14 = as Iterator>::next(move _13) -> [return: bb5, unwind: bb11]; + StorageLive(_16); + _15 = &mut _14; + _16 = as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { + StorageDead(_16); StorageDead(_14); - StorageDead(_12); drop(_2) -> [return: bb7, unwind continue]; } @@ -120,18 +128,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _16 = copy ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (copy _16,); - _19 = >::call(move _17, move _18) -> [return: bb9, unwind: bb11]; + _18 = copy ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (copy _18,); + _21 = >::call(move _19, move _20) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_18); - StorageDead(_17); - StorageDead(_14); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index a6ccd435c40e..deb12c4f1c22 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -4,34 +4,35 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::iter::Rev>; - let mut _13: std::iter::Rev>; - let mut _15: std::option::Option<&T>; - let mut _16: isize; - let mut _18: &impl Fn(&T); - let mut _19: (&T,); - let _20: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev>; + let mut _15: std::iter::Rev>; + let mut _17: std::option::Option<&T>; + let mut _18: isize; + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); scope 1 { - debug iter => _13; - let _17: &T; + debug iter => _15; + let _19: &T; scope 2 { - debug x => _17; + debug x => _19; } scope 18 (inlined > as Iterator>::next) { - let mut _14: &mut std::slice::Iter<'_, T>; + let mut _16: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -47,7 +48,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -62,68 +64,74 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_11); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); - _12 = Rev::> { iter: copy _11 }; + StorageLive(_12); + _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); StorageDead(_11); - StorageLive(_13); - _13 = copy _12; + StorageDead(_8); + StorageDead(_3); + _14 = Rev::> { iter: copy _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - StorageLive(_15); - StorageLive(_14); - _14 = &mut (_13.0: std::slice::Iter<'_, T>); - _15 = as DoubleEndedIterator>::next_back(move _14) -> [return: bb5, unwind unreachable]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut (_15.0: std::slice::Iter<'_, T>); + _17 = as DoubleEndedIterator>::next_back(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_14); - _16 = discriminant(_15); - switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { + StorageDead(_17); StorageDead(_15); - StorageDead(_13); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -132,18 +140,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _17 = copy ((_15 as Some).0: &T); - StorageLive(_18); - _18 = &_2; - StorageLive(_19); - _19 = (copy _17,); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind unreachable]; + _19 = copy ((_17 as Some).0: &T); + StorageLive(_20); + _20 = &_2; + StorageLive(_21); + _21 = (copy _19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_19); - StorageDead(_18); - StorageDead(_15); + StorageDead(_21); + StorageDead(_20); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index df11c8e3b496..acd5323eb7ac 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -4,34 +4,35 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::iter::Rev>; - let mut _13: std::iter::Rev>; - let mut _15: std::option::Option<&T>; - let mut _16: isize; - let mut _18: &impl Fn(&T); - let mut _19: (&T,); - let _20: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev>; + let mut _15: std::iter::Rev>; + let mut _17: std::option::Option<&T>; + let mut _18: isize; + let mut _20: &impl Fn(&T); + let mut _21: (&T,); + let _22: (); scope 1 { - debug iter => _13; - let _17: &T; + debug iter => _15; + let _19: &T; scope 2 { - debug x => _17; + debug x => _19; } scope 18 (inlined > as Iterator>::next) { - let mut _14: &mut std::slice::Iter<'_, T>; + let mut _16: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::::iter) { scope 4 (inlined std::slice::Iter::<'_, T>::new) { let _3: usize; - let mut _7: *mut T; - let mut _8: *mut T; - let mut _10: *const T; + let mut _5: std::ptr::NonNull<[T]>; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { - let _6: std::ptr::NonNull; + let _8: std::ptr::NonNull; scope 6 { - let _9: *const T; + let _11: *const T; scope 7 { } scope 12 (inlined without_provenance::) { @@ -47,7 +48,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 10 (inlined NonNull::<[T]>::cast::) { - let mut _5: *const T; + let mut _6: *mut [T]; + let mut _7: *const T; scope 11 (inlined NonNull::<[T]>::as_ptr) { } } @@ -62,68 +64,74 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb0: { - StorageLive(_11); + StorageLive(_13); StorageLive(_3); - StorageLive(_6); - StorageLive(_4); - StorageLive(_5); + StorageLive(_8); _3 = PtrMetadata(copy _1); + StorageLive(_5); + StorageLive(_4); _4 = &raw const (*_1); - _5 = copy _4 as *const T (PtrToPtr); - _6 = NonNull:: { pointer: copy _5 }; - StorageLive(_9); + _5 = NonNull::<[T]> { pointer: move _4 }; + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _6 = copy _5 as *mut [T] (Transmute); + _7 = copy _6 as *const T (PtrToPtr); + _8 = NonNull:: { pointer: move _7 }; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageLive(_11); switchInt(const ::IS_ZST) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_8); - StorageLive(_7); - _7 = copy _4 as *mut T (PtrToPtr); - _8 = Offset(copy _7, copy _3); - StorageDead(_7); - _9 = move _8 as *const T (PtrToPtr); - StorageDead(_8); + StorageLive(_10); + StorageLive(_9); + _9 = copy _8 as *mut T (Transmute); + _10 = Offset(copy _9, copy _3); + StorageDead(_9); + _11 = move _10 as *const T (PtrToPtr); + StorageDead(_10); goto -> bb3; } bb2: { - _9 = copy _3 as *const T (Transmute); + _11 = copy _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageLive(_10); - _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); - StorageDead(_9); - StorageDead(_5); - StorageDead(_4); - StorageDead(_6); - StorageDead(_3); - _12 = Rev::> { iter: copy _11 }; + StorageLive(_12); + _12 = copy _11; + _13 = std::slice::Iter::<'_, T> { ptr: copy _8, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); StorageDead(_11); - StorageLive(_13); - _13 = copy _12; + StorageDead(_8); + StorageDead(_3); + _14 = Rev::> { iter: copy _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = copy _14; goto -> bb4; } bb4: { - StorageLive(_15); - StorageLive(_14); - _14 = &mut (_13.0: std::slice::Iter<'_, T>); - _15 = as DoubleEndedIterator>::next_back(move _14) -> [return: bb5, unwind: bb11]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut (_15.0: std::slice::Iter<'_, T>); + _17 = as DoubleEndedIterator>::next_back(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_14); - _16 = discriminant(_15); - switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { + StorageDead(_17); StorageDead(_15); - StorageDead(_13); drop(_2) -> [return: bb7, unwind continue]; } @@ -132,18 +140,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _17 = copy ((_15 as Some).0: &T); - StorageLive(_18); - _18 = &_2; - StorageLive(_19); - _19 = (copy _17,); - _20 = >::call(move _18, move _19) -> [return: bb9, unwind: bb11]; + _19 = copy ((_17 as Some).0: &T); + StorageLive(_20); + _20 = &_2; + StorageLive(_21); + _21 = (copy _19,); + _22 = >::call(move _20, move _21) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_19); - StorageDead(_18); - StorageDead(_15); + StorageDead(_21); + StorageDead(_20); + StorageDead(_17); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir index f8b0e749bfc0..22be48c47b27 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-abort.mir @@ -15,11 +15,11 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool { scope 4 { scope 8 (inlined as PartialEq>::eq) { let mut _5: std::ptr::NonNull; + let mut _6: *mut T; + let mut _7: *mut T; scope 9 (inlined NonNull::::as_ptr) { - let mut _6: *const T; } scope 10 (inlined NonNull::::as_ptr) { - let mut _7: *const T; } } } @@ -48,13 +48,13 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool { _4 = copy (*_3); StorageDead(_3); StorageLive(_6); - StorageLive(_7); StorageLive(_5); _5 = copy ((*_1).0: std::ptr::NonNull); - _6 = copy (_5.0: *const T); + _6 = copy _5 as *mut T (Transmute); StorageDead(_5); - _7 = copy (_4.0: *const T); - _0 = Eq(copy _6, copy _7); + StorageLive(_7); + _7 = copy _4 as *mut T (Transmute); + _0 = Eq(move _6, move _7); StorageDead(_7); StorageDead(_6); goto -> bb3; diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir index f8b0e749bfc0..22be48c47b27 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_generic_is_empty.PreCodegen.after.panic-unwind.mir @@ -15,11 +15,11 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool { scope 4 { scope 8 (inlined as PartialEq>::eq) { let mut _5: std::ptr::NonNull; + let mut _6: *mut T; + let mut _7: *mut T; scope 9 (inlined NonNull::::as_ptr) { - let mut _6: *const T; } scope 10 (inlined NonNull::::as_ptr) { - let mut _7: *const T; } } } @@ -48,13 +48,13 @@ fn slice_iter_generic_is_empty(_1: &std::slice::Iter<'_, T>) -> bool { _4 = copy (*_3); StorageDead(_3); StorageLive(_6); - StorageLive(_7); StorageLive(_5); _5 = copy ((*_1).0: std::ptr::NonNull); - _6 = copy (_5.0: *const T); + _6 = copy _5 as *mut T (Transmute); StorageDead(_5); - _7 = copy (_4.0: *const T); - _0 = Eq(copy _6, copy _7); + StorageLive(_7); + _7 = copy _4 as *mut T (Transmute); + _0 = Eq(move _6, move _7); StorageDead(_7); StorageDead(_6); goto -> bb3; diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir index c3091bd43957..2efbb6d99042 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir @@ -7,16 +7,18 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { debug self => _1; scope 2 (inlined Vec::::as_slice) { debug self => _1; - let mut _7: usize; + let mut _9: *const u8; + let mut _10: usize; scope 3 (inlined Vec::::as_ptr) { debug self => _1; let mut _2: &alloc::raw_vec::RawVec; + let mut _8: *mut u8; scope 4 (inlined alloc::raw_vec::RawVec::::ptr) { debug self => _2; let mut _3: &alloc::raw_vec::RawVecInner; scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { debug self => _3; - let mut _6: std::ptr::NonNull; + let mut _7: std::ptr::NonNull; scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { debug self => _3; let mut _4: std::ptr::NonNull; @@ -25,27 +27,28 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { debug ((self: Unique).1: std::marker::PhantomData) => const PhantomData::; scope 8 (inlined NonNull::::cast::) { debug self => _4; + let mut _5: *mut u8; + let mut _6: *const u8; scope 9 (inlined NonNull::::as_ptr) { debug self => _4; - let mut _5: *const u8; } } } scope 10 (inlined Unique::::as_non_null_ptr) { - debug ((self: Unique).0: std::ptr::NonNull) => _6; + debug ((self: Unique).0: std::ptr::NonNull) => _7; debug ((self: Unique).1: std::marker::PhantomData) => const PhantomData::; } } scope 11 (inlined NonNull::::as_ptr) { - debug self => _6; + debug self => _7; } } } } scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) { - debug data => _5; - debug len => _7; - let _8: *const [u8]; + debug data => _9; + debug len => _10; + let _11: *const [u8]; scope 13 (inlined core::ub_checks::check_language_ub) { scope 14 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -55,11 +58,11 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 16 (inlined align_of::) { } scope 17 (inlined slice_from_raw_parts::) { - debug data => _5; - debug len => _7; + debug data => _9; + debug len => _10; scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) { - debug data_pointer => _5; - debug metadata => _7; + debug data_pointer => _9; + debug metadata => _10; } } } @@ -67,26 +70,37 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { } bb0: { + StorageLive(_8); + StorageLive(_9); StorageLive(_2); _2 = &((*_1).0: alloc::raw_vec::RawVec); StorageLive(_3); _3 = &(((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); - StorageLive(_6); + StorageLive(_7); StorageLive(_4); _4 = copy (((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); - _5 = copy (_4.0: *const u8); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + _5 = copy _4 as *mut u8 (Transmute); + _6 = copy _5 as *const u8 (PtrToPtr); + _7 = NonNull:: { pointer: move _6 }; StorageDead(_6); - StorageDead(_3); - StorageDead(_2); - StorageLive(_7); - _7 = copy ((*_1).1: usize); - StorageLive(_8); - _8 = *const [u8] from (copy _5, copy _7); - _0 = &(*_8); - StorageDead(_8); + StorageDead(_5); + StorageDead(_4); + _8 = copy _7 as *mut u8 (Transmute); StorageDead(_7); + StorageDead(_3); + _9 = copy _8 as *const u8 (PtrToPtr); + StorageDead(_2); + StorageLive(_10); + _10 = copy ((*_1).1: usize); + StorageLive(_11); + _11 = *const [u8] from (copy _9, copy _10); + _0 = &(*_11); + StorageDead(_11); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); return; } } diff --git a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir index c3091bd43957..2efbb6d99042 100644 --- a/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir @@ -7,16 +7,18 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { debug self => _1; scope 2 (inlined Vec::::as_slice) { debug self => _1; - let mut _7: usize; + let mut _9: *const u8; + let mut _10: usize; scope 3 (inlined Vec::::as_ptr) { debug self => _1; let mut _2: &alloc::raw_vec::RawVec; + let mut _8: *mut u8; scope 4 (inlined alloc::raw_vec::RawVec::::ptr) { debug self => _2; let mut _3: &alloc::raw_vec::RawVecInner; scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::) { debug self => _3; - let mut _6: std::ptr::NonNull; + let mut _7: std::ptr::NonNull; scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::) { debug self => _3; let mut _4: std::ptr::NonNull; @@ -25,27 +27,28 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { debug ((self: Unique).1: std::marker::PhantomData) => const PhantomData::; scope 8 (inlined NonNull::::cast::) { debug self => _4; + let mut _5: *mut u8; + let mut _6: *const u8; scope 9 (inlined NonNull::::as_ptr) { debug self => _4; - let mut _5: *const u8; } } } scope 10 (inlined Unique::::as_non_null_ptr) { - debug ((self: Unique).0: std::ptr::NonNull) => _6; + debug ((self: Unique).0: std::ptr::NonNull) => _7; debug ((self: Unique).1: std::marker::PhantomData) => const PhantomData::; } } scope 11 (inlined NonNull::::as_ptr) { - debug self => _6; + debug self => _7; } } } } scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) { - debug data => _5; - debug len => _7; - let _8: *const [u8]; + debug data => _9; + debug len => _10; + let _11: *const [u8]; scope 13 (inlined core::ub_checks::check_language_ub) { scope 14 (inlined core::ub_checks::check_language_ub::runtime) { } @@ -55,11 +58,11 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { scope 16 (inlined align_of::) { } scope 17 (inlined slice_from_raw_parts::) { - debug data => _5; - debug len => _7; + debug data => _9; + debug len => _10; scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) { - debug data_pointer => _5; - debug metadata => _7; + debug data_pointer => _9; + debug metadata => _10; } } } @@ -67,26 +70,37 @@ fn vec_deref_to_slice(_1: &Vec) -> &[u8] { } bb0: { + StorageLive(_8); + StorageLive(_9); StorageLive(_2); _2 = &((*_1).0: alloc::raw_vec::RawVec); StorageLive(_3); _3 = &(((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner); - StorageLive(_6); + StorageLive(_7); StorageLive(_4); _4 = copy (((((*_1).0: alloc::raw_vec::RawVec).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique).0: std::ptr::NonNull); - _5 = copy (_4.0: *const u8); - _6 = NonNull:: { pointer: copy _5 }; - StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + _5 = copy _4 as *mut u8 (Transmute); + _6 = copy _5 as *const u8 (PtrToPtr); + _7 = NonNull:: { pointer: move _6 }; StorageDead(_6); - StorageDead(_3); - StorageDead(_2); - StorageLive(_7); - _7 = copy ((*_1).1: usize); - StorageLive(_8); - _8 = *const [u8] from (copy _5, copy _7); - _0 = &(*_8); - StorageDead(_8); + StorageDead(_5); + StorageDead(_4); + _8 = copy _7 as *mut u8 (Transmute); StorageDead(_7); + StorageDead(_3); + _9 = copy _8 as *const u8 (PtrToPtr); + StorageDead(_2); + StorageLive(_10); + _10 = copy ((*_1).1: usize); + StorageLive(_11); + _11 = *const [u8] from (copy _9, copy _10); + _0 = &(*_11); + StorageDead(_11); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); return; } } From 2997ec51a69ba02df1b9782c0a3d4dad0939d32e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 3 Dec 2024 22:27:14 +0100 Subject: [PATCH 17/59] Rename `is_real_and_local` function into `filename_real_and_local` --- src/librustdoc/html/sources.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 4b05e7c427c6..9827f97d28df 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -50,7 +50,7 @@ struct LocalSourcesCollector<'a, 'tcx> { src_root: &'a Path, } -fn is_real_and_local(span: clean::Span, sess: &Session) -> Option { +fn filename_real_and_local(span: clean::Span, sess: &Session) -> Option { if span.cnum(sess) == LOCAL_CRATE && let FileName::Real(file) = span.filename(sess) { @@ -66,7 +66,8 @@ impl LocalSourcesCollector<'_, '_> { let span = item.span(self.tcx); let Some(span) = span else { return }; // skip all synthetic "files" - let Some(p) = is_real_and_local(span, sess).and_then(|file| file.into_local_path()) else { + let Some(p) = filename_real_and_local(span, sess).and_then(|file| file.into_local_path()) + else { return; }; if self.local_sources.contains_key(&*p) { @@ -132,7 +133,7 @@ impl DocVisitor<'_> for SourceCollector<'_, '_> { // If we're not rendering sources, there's nothing to do. // If we're including source files, and we haven't seen this file yet, // then we need to render it out to the filesystem. - if let Some(filename) = is_real_and_local(span, sess) { + if let Some(filename) = filename_real_and_local(span, sess) { let span = span.inner(); let pos = sess.source_map().lookup_source_file(span.lo()); let file_span = span.with_lo(pos.start_pos).with_hi(pos.end_position()); From 244afb94d4c4098882d924db7f4e6129eabacade Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 3 Dec 2024 16:46:51 -0500 Subject: [PATCH 18/59] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 4c39aaff6686..05f54fdc3431 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 4c39aaff66862cc0da52fe529aa1990bb8bb9a22 +Subproject commit 05f54fdc34310f458033af8a63ce1d699fae8bf6 From ec036cda3fee341d938336b64bc38cd11df7231d Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 30 Nov 2024 19:31:06 +0000 Subject: [PATCH 19/59] Don't try and handle unfed `type_of` on anon consts --- compiler/rustc_hir_analysis/src/collect.rs | 5 +- .../rustc_hir_analysis/src/collect/type_of.rs | 243 +----------------- .../coroutine-in-orphaned-anon-const.rs | 2 - .../coroutine-in-orphaned-anon-const.stderr | 10 +- .../bound/unknown-assoc-with-const-arg.rs | 2 - .../bound/unknown-assoc-with-const-arg.stderr | 22 +- 6 files changed, 14 insertions(+), 270 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 8d5824130d85..a4636da3f621 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -309,10 +309,10 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { self.tcx.ensure().type_of(param.def_id); if let Some(default) = default { // need to store default and type of default + self.tcx.ensure().const_param_default(param.def_id); if let hir::ConstArgKind::Anon(ac) = default.kind { self.tcx.ensure().type_of(ac.def_id); } - self.tcx.ensure().const_param_default(param.def_id); } } } @@ -1817,7 +1817,6 @@ fn const_param_default<'tcx>( ), }; let icx = ItemCtxt::new(tcx, def_id); - // FIXME(const_generics): investigate which places do and don't need const ty feeding - let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::No); + let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::Param(def_id.to_def_id())); ty::EarlyBinder::bind(ct) } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 7cf99bebd36a..72d5b3ac4f5e 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -12,7 +12,6 @@ use rustc_middle::ty::{self, Article, IsSuggestable, Ty, TyCtxt, TypeVisitableEx use rustc_middle::{bug, span_bug}; use rustc_span::symbol::Ident; use rustc_span::{DUMMY_SP, Span}; -use tracing::debug; use super::{ItemCtxt, bad_placeholder}; use crate::errors::TypeofReservedKeywordUsed; @@ -138,252 +137,26 @@ fn const_arg_anon_type_of<'tcx>(tcx: TyCtxt<'tcx>, arg_hir_id: HirId, span: Span use hir::*; use rustc_middle::ty::Ty; - let parent_node_id = tcx.parent_hir_id(arg_hir_id); - let parent_node = tcx.hir_node(parent_node_id); - - let (generics, arg_idx) = match parent_node { - // Easy case: arrays repeat expressions. + match tcx.parent_hir_node(arg_hir_id) { + // Array length const arguments do not have `type_of` fed as there is never a corresponding + // generic parameter definition. Node::Ty(&hir::Ty { kind: TyKind::Array(_, ref constant), .. }) | Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. }) if constant.hir_id == arg_hir_id => { return tcx.types.usize; } - Node::GenericParam(&GenericParam { - def_id: param_def_id, - kind: GenericParamKind::Const { default: Some(ct), .. }, - .. - }) if ct.hir_id == arg_hir_id => { - return tcx - .type_of(param_def_id) - .no_bound_vars() - .expect("const parameter types cannot be generic"); - } - // This match arm is for when the def_id appears in a GAT whose - // path can't be resolved without typechecking e.g. - // - // trait Foo { - // type Assoc; - // fn foo() -> Self::Assoc<3>; - // } - // - // In the above code we would call this query with the def_id of 3 and - // the parent_node we match on would be the hir node for Self::Assoc<3> - // - // `Self::Assoc<3>` cant be resolved without typechecking here as we - // didnt write ::Assoc<3>. If we did then another match - // arm would handle this. - // - // I believe this match arm is only needed for GAT but I am not 100% sure - BoxyUwU - Node::Ty(hir_ty @ hir::Ty { kind: TyKind::Path(QPath::TypeRelative(ty, segment)), .. }) => { - // Find the Item containing the associated type so we can create an ItemCtxt. - // Using the ItemCtxt lower the HIR for the unresolved assoc type into a - // ty which is a fully resolved projection. - // For the code example above, this would mean lowering `Self::Assoc<3>` - // to a ty::Alias(ty::Projection, `::Assoc<3>`). - let item_def_id = tcx.hir().get_parent_item(ty.hir_id).def_id; - let ty = ItemCtxt::new(tcx, item_def_id).lower_ty(hir_ty); - - // Iterate through the generics of the projection to find the one that corresponds to - // the def_id that this query was called with. We filter to only type and const args here - // as a precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't - // but it can't hurt to be safe ^^ - if let ty::Alias(ty::Projection | ty::Inherent, projection) = ty.kind() { - let generics = tcx.generics_of(projection.def_id); - - let arg_index = segment - .args - .and_then(|args| { - args.args - .iter() - .filter(|arg| arg.is_ty_or_const()) - .position(|arg| arg.hir_id() == arg_hir_id) - }) - .unwrap_or_else(|| { - bug!("no arg matching AnonConst in segment"); - }); - - (generics, arg_index) - } else { - // I dont think it's possible to reach this but I'm not 100% sure - BoxyUwU - return Ty::new_error_with_message( - tcx, - span, - "unexpected non-GAT usage of an anon const", - ); - } - } - Node::Expr(&Expr { - kind: - ExprKind::MethodCall(segment, ..) | ExprKind::Path(QPath::TypeRelative(_, segment)), - .. - }) => { - let body_owner = tcx.hir().enclosing_body_owner(arg_hir_id); - let tables = tcx.typeck(body_owner); - // This may fail in case the method/path does not actually exist. - // As there is no relevant param for `def_id`, we simply return - // `None` here. - let Some(type_dependent_def) = tables.type_dependent_def_id(parent_node_id) else { - return Ty::new_error_with_message( - tcx, - span, - format!("unable to find type-dependent def for {parent_node_id:?}"), - ); - }; - let idx = segment - .args - .and_then(|args| { - args.args - .iter() - .filter(|arg| arg.is_ty_or_const()) - .position(|arg| arg.hir_id() == arg_hir_id) - }) - .unwrap_or_else(|| { - bug!("no arg matching ConstArg in segment"); - }); - - (tcx.generics_of(type_dependent_def), idx) - } - - Node::Ty(&hir::Ty { kind: TyKind::Path(_), .. }) - | Node::Expr(&Expr { kind: ExprKind::Path(_) | ExprKind::Struct(..), .. }) - | Node::TraitRef(..) - | Node::Pat(_) => { - let path = match parent_node { - Node::Ty(&hir::Ty { kind: TyKind::Path(QPath::Resolved(_, path)), .. }) - | Node::TraitRef(&TraitRef { path, .. }) => &*path, - Node::Expr(&Expr { - kind: - ExprKind::Path(QPath::Resolved(_, path)) - | ExprKind::Struct(&QPath::Resolved(_, path), ..), - .. - }) => { - let body_owner = tcx.hir().enclosing_body_owner(arg_hir_id); - let _tables = tcx.typeck(body_owner); - &*path - } - Node::Pat(pat) => { - if let Some(path) = get_path_containing_arg_in_pat(pat, arg_hir_id) { - path - } else { - return Ty::new_error_with_message( - tcx, - span, - format!("unable to find const parent for {arg_hir_id} in pat {pat:?}"), - ); - } - } - _ => { - return Ty::new_error_with_message( - tcx, - span, - format!("unexpected const parent path {parent_node:?}"), - ); - } - }; - - // We've encountered an `AnonConst` in some path, so we need to - // figure out which generic parameter it corresponds to and return - // the relevant type. - let Some((arg_index, segment)) = path.segments.iter().find_map(|seg| { - let args = seg.args?; - args.args - .iter() - .filter(|arg| arg.is_ty_or_const()) - .position(|arg| arg.hir_id() == arg_hir_id) - .map(|index| (index, seg)) - .or_else(|| { - args.constraints - .iter() - .copied() - .filter_map(AssocItemConstraint::ct) - .position(|ct| ct.hir_id == arg_hir_id) - .map(|idx| (idx, seg)) - }) - }) else { - return Ty::new_error_with_message(tcx, span, "no arg matching AnonConst in path"); - }; - - let generics = match tcx.res_generics_def_id(segment.res) { - Some(def_id) => tcx.generics_of(def_id), - None => { - return Ty::new_error_with_message( - tcx, - span, - format!("unexpected anon const res {:?} in path: {:?}", segment.res, path), - ); - } - }; - - (generics, arg_index) - } - - _ => { - return Ty::new_error_with_message( - tcx, - span, - format!("unexpected const arg parent in type_of(): {parent_node:?}"), - ); - } - }; - - debug!(?parent_node); - debug!(?generics, ?arg_idx); - if let Some(param_def_id) = generics - .own_params - .iter() - .filter(|param| param.kind.is_ty_or_const()) - .nth(match generics.has_self && generics.parent.is_none() { - true => arg_idx + 1, - false => arg_idx, - }) - .and_then(|param| match param.kind { - ty::GenericParamDefKind::Const { .. } => { - debug!(?param); - Some(param.def_id) - } - _ => None, - }) - { - tcx.type_of(param_def_id).no_bound_vars().expect("const parameter types cannot be generic") - } else { - return Ty::new_error_with_message( + // This is not a `bug!` as const arguments in path segments that did not resolve to anything + // will result in `type_of` never being fed. + _ => Ty::new_error_with_message( tcx, span, - format!("const generic parameter not found in {generics:?} at position {arg_idx:?}"), - ); + "`type_of` called on const argument's anon const before the const argument was lowered", + ), } } -fn get_path_containing_arg_in_pat<'hir>( - pat: &'hir hir::Pat<'hir>, - arg_id: HirId, -) -> Option<&'hir hir::Path<'hir>> { - use hir::*; - - let is_arg_in_path = |p: &hir::Path<'_>| { - p.segments - .iter() - .filter_map(|seg| seg.args) - .flat_map(|args| args.args) - .any(|arg| arg.hir_id() == arg_id) - }; - let mut arg_path = None; - pat.walk(|pat| match pat.kind { - PatKind::Struct(QPath::Resolved(_, path), _, _) - | PatKind::TupleStruct(QPath::Resolved(_, path), _, _) - | PatKind::Path(QPath::Resolved(_, path)) - if is_arg_in_path(path) => - { - arg_path = Some(path); - false - } - _ => true, - }); - arg_path -} - pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, Ty<'_>> { use rustc_hir::*; use rustc_middle::ty::Ty; diff --git a/tests/ui/coroutine/coroutine-in-orphaned-anon-const.rs b/tests/ui/coroutine/coroutine-in-orphaned-anon-const.rs index 07c13239a2ce..c98ec1de17e3 100644 --- a/tests/ui/coroutine/coroutine-in-orphaned-anon-const.rs +++ b/tests/ui/coroutine/coroutine-in-orphaned-anon-const.rs @@ -3,8 +3,6 @@ trait X { fn test() -> Self::Assoc<{ async {} }>; //~^ ERROR associated type `Assoc` not found for `Self` - //~| ERROR associated type `Assoc` not found for `Self` - } pub fn main() {} diff --git a/tests/ui/coroutine/coroutine-in-orphaned-anon-const.stderr b/tests/ui/coroutine/coroutine-in-orphaned-anon-const.stderr index 864c6556d799..585537287532 100644 --- a/tests/ui/coroutine/coroutine-in-orphaned-anon-const.stderr +++ b/tests/ui/coroutine/coroutine-in-orphaned-anon-const.stderr @@ -4,14 +4,6 @@ error[E0220]: associated type `Assoc` not found for `Self` LL | fn test() -> Self::Assoc<{ async {} }>; | ^^^^^ associated type `Assoc` not found -error[E0220]: associated type `Assoc` not found for `Self` - --> $DIR/coroutine-in-orphaned-anon-const.rs:4:24 - | -LL | fn test() -> Self::Assoc<{ async {} }>; - | ^^^^^ associated type `Assoc` not found - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs b/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs index 48a98efea5ef..0da68afb5926 100644 --- a/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs +++ b/tests/ui/traits/bound/unknown-assoc-with-const-arg.rs @@ -3,7 +3,6 @@ trait X { fn a() -> T::unknown<{}> {} //~^ ERROR: associated type `unknown` not found for `T` - //~| ERROR: associated type `unknown` not found for `T` } trait Y { @@ -14,7 +13,6 @@ trait Y { trait Z { fn a() -> T::unknown<{}> {} //~^ ERROR: associated type `unknown` not found for `T` - //~| ERROR: associated type `unknown` not found for `T` } fn main() {} diff --git a/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr b/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr index 9598c373e6e8..49e41f75ff35 100644 --- a/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr +++ b/tests/ui/traits/bound/unknown-assoc-with-const-arg.stderr @@ -5,34 +5,18 @@ LL | fn a() -> T::unknown<{}> {} | ^^^^^^^ associated type `unknown` not found error[E0220]: associated type `unknown` not found for `T` - --> $DIR/unknown-assoc-with-const-arg.rs:15:18 + --> $DIR/unknown-assoc-with-const-arg.rs:14:18 | LL | fn a() -> T::unknown<{}> {} | ^^^^^^^ associated type `unknown` not found -error[E0220]: associated type `unknown` not found for `T` - --> $DIR/unknown-assoc-with-const-arg.rs:4:21 - | -LL | fn a() -> T::unknown<{}> {} - | ^^^^^^^ associated type `unknown` not found - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0220]: associated type `unknown` not found for `T` - --> $DIR/unknown-assoc-with-const-arg.rs:15:18 - | -LL | fn a() -> T::unknown<{}> {} - | ^^^^^^^ associated type `unknown` not found - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error[E0433]: failed to resolve: use of undeclared type `NOT_EXIST` - --> $DIR/unknown-assoc-with-const-arg.rs:10:15 + --> $DIR/unknown-assoc-with-const-arg.rs:9:15 | LL | fn a() -> NOT_EXIST::unknown<{}> {} | ^^^^^^^^^ use of undeclared type `NOT_EXIST` -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0220, E0433. For more information about an error, try `rustc --explain E0220`. From 3fadb87d7696b82f17c6a98b0a78dd5f79369d79 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 3 Dec 2024 20:21:19 +0000 Subject: [PATCH 20/59] bootstrap: `println!` -> `eprintln!` --- src/bootstrap/src/bin/main.rs | 20 +++---- src/bootstrap/src/bin/rustc.rs | 2 +- src/bootstrap/src/core/build_steps/check.rs | 2 +- src/bootstrap/src/core/build_steps/compile.rs | 10 ++-- src/bootstrap/src/core/build_steps/dist.rs | 2 +- src/bootstrap/src/core/build_steps/format.rs | 6 +- src/bootstrap/src/core/build_steps/setup.rs | 40 ++++++------- src/bootstrap/src/core/build_steps/suggest.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 6 +- src/bootstrap/src/core/builder/cargo.rs | 2 +- src/bootstrap/src/core/builder/mod.rs | 14 +++-- src/bootstrap/src/core/config/config.rs | 60 +++++++++---------- src/bootstrap/src/core/config/flags.rs | 4 +- src/bootstrap/src/core/download.rs | 26 ++++---- src/bootstrap/src/core/sanity.rs | 4 +- src/bootstrap/src/lib.rs | 28 ++++----- src/bootstrap/src/utils/cc_detect.rs | 10 ++-- src/bootstrap/src/utils/helpers.rs | 6 +- src/bootstrap/src/utils/metrics.rs | 2 +- src/bootstrap/src/utils/render_tests.rs | 36 +++++------ src/bootstrap/src/utils/tarball.rs | 2 +- 21 files changed, 144 insertions(+), 140 deletions(-) diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index ee813de1c9e2..74dfe2e7ec80 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -48,9 +48,9 @@ fn main() { err => { drop(err); if let Ok(pid) = pid { - println!("WARNING: build directory locked by process {pid}, waiting for lock"); + eprintln!("WARNING: build directory locked by process {pid}, waiting for lock"); } else { - println!("WARNING: build directory locked, waiting for lock"); + eprintln!("WARNING: build directory locked, waiting for lock"); } let mut lock = t!(build_lock.write()); t!(lock.write(process::id().to_string().as_ref())); @@ -70,13 +70,13 @@ fn main() { // changelog warning, not the `x.py setup` message. let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. }); if suggest_setup { - println!("WARNING: you have not made a `config.toml`"); - println!( + eprintln!("WARNING: you have not made a `config.toml`"); + eprintln!( "HELP: consider running `./x.py setup` or copying `config.example.toml` by running \ `cp config.example.toml config.toml`" ); } else if let Some(suggestion) = &changelog_suggestion { - println!("{suggestion}"); + eprintln!("{suggestion}"); } let pre_commit = config.src.join(".git").join("hooks").join("pre-commit"); @@ -86,13 +86,13 @@ fn main() { Build::new(config).build(); if suggest_setup { - println!("WARNING: you have not made a `config.toml`"); - println!( + eprintln!("WARNING: you have not made a `config.toml`"); + eprintln!( "HELP: consider running `./x.py setup` or copying `config.example.toml` by running \ `cp config.example.toml config.toml`" ); } else if let Some(suggestion) = &changelog_suggestion { - println!("{suggestion}"); + eprintln!("{suggestion}"); } // Give a warning if the pre-commit script is in pre-commit and not pre-push. @@ -102,14 +102,14 @@ fn main() { if fs::read_to_string(pre_commit).is_ok_and(|contents| { contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570") }) { - println!( + eprintln!( "WARNING: You have the pre-push script installed to .git/hooks/pre-commit. \ Consider moving it to .git/hooks/pre-push instead, which runs less often." ); } if suggest_setup || changelog_suggestion.is_some() { - println!("NOTE: this message was printed twice to make it more likely to be seen"); + eprintln!("NOTE: this message was printed twice to make it more likely to be seen"); } if dump_bootstrap_shims { diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index 88595ff7e519..e57ed488f973 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -306,7 +306,7 @@ fn main() { // should run on success, after this block. } if verbose > 0 { - println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------"); + eprintln!("\nDid not run successfully: {status}\n{cmd:?}\n-------------"); } if let Some(mut on_fail) = on_fail { diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index d46c0ab7fefc..2af2e83db8f7 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -287,7 +287,7 @@ impl Step for CodegenBackend { fn run(self, builder: &Builder<'_>) { // FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved if builder.build.config.vendor && self.backend == "gcc" { - println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); + eprintln!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); return; } diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 0cacd6e4f37a..4419b11ac197 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1611,7 +1611,7 @@ impl Step for Sysroot { let sysroot = sysroot_dir(compiler.stage); builder - .verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display())); + .verbose(|| eprintln!("Removing sysroot {} to avoid caching bugs", sysroot.display())); let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); @@ -1681,7 +1681,7 @@ impl Step for Sysroot { return true; } if !filtered_files.iter().all(|f| f != path.file_name().unwrap()) { - builder.verbose_than(1, || println!("ignoring {}", path.display())); + builder.verbose_than(1, || eprintln!("ignoring {}", path.display())); false } else { true @@ -2240,7 +2240,7 @@ pub fn stream_cargo( cargo.arg(arg); } - builder.verbose(|| println!("running: {cargo:?}")); + builder.verbose(|| eprintln!("running: {cargo:?}")); if builder.config.dry_run() { return true; @@ -2261,12 +2261,12 @@ pub fn stream_cargo( Ok(msg) => { if builder.config.json_output { // Forward JSON to stdout. - println!("{line}"); + eprintln!("{line}"); } cb(msg) } // If this was informational, just print it out and continue - Err(_) => println!("{line}"), + Err(_) => eprintln!("{line}"), } } diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index a636c4a9ef13..b1401431f2c4 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -2080,7 +2080,7 @@ fn maybe_install_llvm( { let mut cmd = command(llvm_config); cmd.arg("--libfiles"); - builder.verbose(|| println!("running {cmd:?}")); + builder.verbose(|| eprintln!("running {cmd:?}")); let files = cmd.run_capture_stdout(builder).stdout(); let build_llvm_out = &builder.llvm_out(builder.config.build); let target_llvm_out = &builder.llvm_out(target); diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index 29a96f776728..d32e06d8748a 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -107,10 +107,10 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) { if let Some(adjective) = adjective { format!("{adjective} ") } else { String::new() }; if len <= 10 { for path in paths { - println!("fmt: {verb} {adjective}file {path}"); + eprintln!("fmt: {verb} {adjective}file {path}"); } } else { - println!("fmt: {verb} {len} {adjective}files"); + eprintln!("fmt: {verb} {len} {adjective}files"); } } @@ -199,7 +199,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { match get_modified_rs_files(build) { Ok(Some(files)) => { if files.is_empty() { - println!("fmt info: No modified files detected for formatting."); + eprintln!("fmt info: No modified files detected for formatting."); return; } diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 3a8f9e48c0da..1af7b954f5ed 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -134,7 +134,7 @@ impl Step for Profile { t!(fs::remove_file(path)); } _ => { - println!("Exiting."); + eprintln!("Exiting."); crate::exit!(1); } } @@ -184,15 +184,15 @@ pub fn setup(config: &Config, profile: Profile) { Profile::Dist => &["dist", "build"], }; - println!(); + eprintln!(); - println!("To get started, try one of the following commands:"); + eprintln!("To get started, try one of the following commands:"); for cmd in suggestions { - println!("- `x.py {cmd}`"); + eprintln!("- `x.py {cmd}`"); } if profile != Profile::Dist { - println!( + eprintln!( "For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html" ); } @@ -224,7 +224,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) { t!(fs::write(path, settings)); let include_path = profile.include_path(&config.src); - println!("`x.py` will now use the configuration at {}", include_path.display()); + eprintln!("`x.py` will now use the configuration at {}", include_path.display()); } /// Creates a toolchain link for stage1 using `rustup` @@ -256,7 +256,7 @@ impl Step for Link { } if !rustup_installed(builder) { - println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking."); + eprintln!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking."); return; } @@ -296,7 +296,7 @@ fn attempt_toolchain_link(builder: &Builder<'_>, stage_path: &str) { } if try_link_toolchain(builder, stage_path) { - println!( + eprintln!( "Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain" ); } else { @@ -321,14 +321,14 @@ fn toolchain_is_linked(builder: &Builder<'_>) -> bool { return false; } // The toolchain has already been linked. - println!( + eprintln!( "`stage1` toolchain already linked; not attempting to link `stage1` toolchain" ); } None => { // In this case, we don't know if the `stage1` toolchain has been linked; // but `rustup` failed, so let's not go any further. - println!( + eprintln!( "`rustup` failed to list current toolchains; not attempting to link `stage1` toolchain" ); } @@ -389,9 +389,9 @@ pub fn interactive_path() -> io::Result { input.parse() } - println!("Welcome to the Rust project! What do you want to do with x.py?"); + eprintln!("Welcome to the Rust project! What do you want to do with x.py?"); for ((letter, _), profile) in abbrev_all() { - println!("{}) {}: {}", letter, profile, profile.purpose()); + eprintln!("{}) {}: {}", letter, profile, profile.purpose()); } let template = loop { print!( @@ -488,7 +488,7 @@ fn install_git_hook_maybe(builder: &Builder<'_>, config: &Config) -> io::Result< return Ok(()); } - println!( + eprintln!( "\nRust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality. If you'd like, x.py can install a git hook for you that will automatically run `test tidy` before pushing your code to ensure your code is up to par. If you decide later that this behavior is @@ -496,7 +496,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." ); if prompt_user("Would you like to install the git hook?: [y/N]")? != Some(PromptResult::Yes) { - println!("Ok, skipping installation!"); + eprintln!("Ok, skipping installation!"); return Ok(()); } if !hooks_dir.exists() { @@ -513,7 +513,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." ); return Err(e); } - Ok(_) => println!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"), + Ok(_) => eprintln!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"), }; Ok(()) } @@ -654,7 +654,7 @@ impl Step for Editor { if let Some(editor_kind) = editor_kind { while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {} } else { - println!("Ok, skipping editor setup!"); + eprintln!("Ok, skipping editor setup!"); } } Err(e) => eprintln!("Could not determine the editor: {e}"), @@ -687,7 +687,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu mismatched_settings = Some(false); } } - println!( + eprintln!( "\nx.py can automatically install the recommended `{settings_filename}` file for rustc development" ); @@ -706,7 +706,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu Some(PromptResult::Yes) => true, Some(PromptResult::Print) => false, _ => { - println!("Ok, skipping settings!"); + eprintln!("Ok, skipping settings!"); return Ok(true); } }; @@ -733,9 +733,9 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu _ => "Created", }; fs::write(&settings_path, editor.settings_template())?; - println!("{verb} `{}`", settings_filename); + eprintln!("{verb} `{}`", settings_filename); } else { - println!("\n{}", editor.settings_template()); + eprintln!("\n{}", editor.settings_template()); } Ok(should_create) } diff --git a/src/bootstrap/src/core/build_steps/suggest.rs b/src/bootstrap/src/core/build_steps/suggest.rs index ba9b1b2fc331..7b2d9fff8f5f 100644 --- a/src/bootstrap/src/core/build_steps/suggest.rs +++ b/src/bootstrap/src/core/build_steps/suggest.rs @@ -66,6 +66,6 @@ pub fn suggest(builder: &Builder<'_>, run: bool) { build.build(); } } else { - println!("HELP: consider using the `--run` flag to automatically run suggested tests"); + eprintln!("HELP: consider using the `--run` flag to automatically run suggested tests"); } } diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 4fa91c1a5714..5abd7ff75f10 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -471,11 +471,11 @@ impl Miri { // We re-use the `cargo` from above. cargo.arg("--print-sysroot"); - builder.verbose(|| println!("running: {cargo:?}")); + builder.verbose(|| eprintln!("running: {cargo:?}")); let stdout = cargo.run_capture_stdout(builder).stdout(); // Output is "\n". let sysroot = stdout.trim_end(); - builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}")); + builder.verbose(|| eprintln!("`cargo miri setup --print-sysroot` said: {sysroot:?}")); PathBuf::from(sysroot) } } @@ -2478,7 +2478,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> } } - builder.verbose(|| println!("doc tests for: {}", markdown.display())); + builder.verbose(|| eprintln!("doc tests for: {}", markdown.display())); let mut cmd = builder.rustdoc_cmd(compiler); builder.add_rust_test_threads(&mut cmd); // allow for unstable options such as new editions diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index dd138508bea6..130f50e0a0ff 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -523,7 +523,7 @@ impl Builder<'_> { let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8"); if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) { - println!("using sysroot {sysroot_str}"); + eprintln!("using sysroot {sysroot_str}"); } let mut rustflags = Rustflags::new(target); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 026c26479d35..ffe3e053e724 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -392,14 +392,14 @@ impl StepDescription { fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool { if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) { if !matches!(builder.config.dry_run, DryRun::SelfCheck) { - println!("Skipping {pathset:?} because it is excluded"); + eprintln!("Skipping {pathset:?} because it is excluded"); } return true; } if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) { builder.verbose(|| { - println!( + eprintln!( "{:?} not skipped for {:?} -- not in {:?}", pathset, self.name, builder.config.skip ) @@ -1437,11 +1437,11 @@ impl<'a> Builder<'a> { panic!("{}", out); } if let Some(out) = self.cache.get(&step) { - self.verbose_than(1, || println!("{}c {:?}", " ".repeat(stack.len()), step)); + self.verbose_than(1, || eprintln!("{}c {:?}", " ".repeat(stack.len()), step)); return out; } - self.verbose_than(1, || println!("{}> {:?}", " ".repeat(stack.len()), step)); + self.verbose_than(1, || eprintln!("{}> {:?}", " ".repeat(stack.len()), step)); stack.push(Box::new(step.clone())); } @@ -1462,7 +1462,7 @@ impl<'a> Builder<'a> { let step_string = format!("{step:?}"); let brace_index = step_string.find('{').unwrap_or(0); let type_string = type_name::(); - println!( + eprintln!( "[TIMING] {} {} -- {}.{:03}", &type_string.strip_prefix("bootstrap::").unwrap_or(type_string), &step_string[brace_index..], @@ -1479,7 +1479,9 @@ impl<'a> Builder<'a> { let cur_step = stack.pop().expect("step stack empty"); assert_eq!(cur_step.downcast_ref(), Some(&step)); } - self.verbose_than(1, || println!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); + self.verbose_than(1, || { + eprintln!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step) + }); self.cache.put(step, out.clone()); out } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b06147055f2a..aa5cce2fb1b6 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1293,7 +1293,7 @@ impl Config { .map(|change_id| change_id.inner.map(crate::find_recent_config_change_ids)) { if !changes.is_empty() { - println!( + eprintln!( "WARNING: There have been changes to x.py since you last updated:\n{}", crate::human_readable_changes(&changes) ); @@ -1559,7 +1559,7 @@ impl Config { } if cargo_clippy.is_some() && rustc.is_none() { - println!( + eprintln!( "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." ); } @@ -1841,7 +1841,7 @@ impl Config { // FIXME: Remove this option at the end of 2024. if parallel_compiler.is_some() { - println!( + eprintln!( "WARNING: The `rust.parallel-compiler` option is deprecated and does nothing. The parallel compiler (with one thread) is now the default" ); } @@ -1873,7 +1873,7 @@ impl Config { if available_backends.contains(&backend) { panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'."); } else { - println!("HELP: '{s}' for 'rust.codegen-backends' might fail. \ + eprintln!("HELP: '{s}' for 'rust.codegen-backends' might fail. \ Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \ In this case, it would be referred to as '{backend}'."); } @@ -1902,7 +1902,7 @@ impl Config { // tests may fail due to using a different channel than the one used by the compiler during tests. if let Some(commit) = &config.download_rustc_commit { if is_user_configured_rust_channel { - println!( + eprintln!( "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." ); @@ -1992,10 +1992,10 @@ impl Config { if config.llvm_from_ci { let warn = |option: &str| { - println!( + eprintln!( "WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build." ); - println!( + eprintln!( "HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false." ); }; @@ -2014,12 +2014,12 @@ impl Config { // if they've chosen a different value. if libzstd.is_some() { - println!( + eprintln!( "WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \ like almost all `llvm.*` options, will be ignored and set by the LLVM CI \ artifacts builder config." ); - println!( + eprintln!( "HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false." ); } @@ -2088,7 +2088,7 @@ impl Config { if available_backends.contains(&backend) { panic!("Invalid value '{s}' for 'target.{triple}.codegen-backends'. Instead, please use '{backend}'."); } else { - println!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \ + eprintln!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \ Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \ In this case, it would be referred to as '{backend}'."); } @@ -2304,7 +2304,7 @@ impl Config { if self.dry_run() { return Ok(()); } - self.verbose(|| println!("running: {cmd:?}")); + self.verbose(|| eprintln!("running: {cmd:?}")); build_helper::util::try_run(cmd, self.is_verbose()) } @@ -2479,7 +2479,7 @@ impl Config { // This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error // to not break CI. For non-CI environments, we should return an error. if CiEnv::is_ci() { - println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled."); + eprintln!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled."); return None; } else { panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used."); @@ -2490,8 +2490,8 @@ impl Config { let ci_config_toml = match self.get_builder_toml("ci-rustc") { Ok(ci_config_toml) => ci_config_toml, Err(e) if e.to_string().contains("unknown field") => { - println!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled."); - println!("HELP: Consider rebasing to a newer commit if available."); + eprintln!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled."); + eprintln!("HELP: Consider rebasing to a newer commit if available."); return None; }, Err(e) => { @@ -2516,7 +2516,7 @@ impl Config { .is_some_and(|s| s == "1" || s == "true"); if disable_ci_rustc_if_incompatible && res.is_err() { - println!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env."); + eprintln!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env."); return None; } @@ -2701,7 +2701,7 @@ impl Config { return; } - println!("Updating submodule {relative_path}"); + eprintln!("Updating submodule {relative_path}"); self.check_run( helpers::git(Some(&self.src)) .run_always() @@ -2824,7 +2824,7 @@ impl Config { Some(StringOrBool::Bool(true)) => false, Some(StringOrBool::String(s)) if s == "if-unchanged" => { if !self.rust_info.is_managed_git_subrepository() { - println!( + eprintln!( "ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources." ); crate::exit!(1); @@ -2857,10 +2857,10 @@ impl Config { if if_unchanged { return None; } - println!("ERROR: could not find commit hash for downloading rustc"); - println!("HELP: maybe your repository history is too shallow?"); - println!("HELP: consider setting `rust.download-rustc=false` in config.toml"); - println!("HELP: or fetch enough history to include one upstream commit"); + eprintln!("ERROR: could not find commit hash for downloading rustc"); + eprintln!("HELP: maybe your repository history is too shallow?"); + eprintln!("HELP: consider setting `rust.download-rustc=false` in config.toml"); + eprintln!("HELP: or fetch enough history to include one upstream commit"); crate::exit!(1); } }; @@ -2899,7 +2899,7 @@ impl Config { let if_unchanged = || { if self.rust_info.is_from_tarball() { // Git is needed for running "if-unchanged" logic. - println!( + eprintln!( "WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`." ); return false; @@ -2948,10 +2948,10 @@ impl Config { // Only commits merged by bors will have CI artifacts. let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap(); if commit.is_empty() { - println!("error: could not find commit hash for downloading components from CI"); - println!("help: maybe your repository history is too shallow?"); - println!("help: consider disabling `{option_name}`"); - println!("help: or fetch enough history to include one upstream commit"); + eprintln!("error: could not find commit hash for downloading components from CI"); + eprintln!("help: maybe your repository history is too shallow?"); + eprintln!("help: consider disabling `{option_name}`"); + eprintln!("help: or fetch enough history to include one upstream commit"); crate::exit!(1); } @@ -2963,14 +2963,14 @@ impl Config { if has_changes { if if_unchanged { if self.is_verbose() { - println!( + eprintln!( "warning: saw changes to one of {modified_paths:?} since {commit}; \ ignoring `{option_name}`" ); } return None; } - println!( + eprintln!( "warning: `{option_name}` is enabled, but there are changes to one of {modified_paths:?}" ); } @@ -3007,7 +3007,7 @@ pub(crate) fn check_incompatible_options_for_ci_llvm( ($current:expr, $expected:expr) => { if let Some(current) = &$current { if Some(current) != $expected.as_ref() { - println!( + eprintln!( "WARNING: `llvm.{}` has no effect with `llvm.download-ci-llvm`. \ Current value: {:?}, Expected value(s): {}{:?}", stringify!($expected).replace("_", "-"), @@ -3112,7 +3112,7 @@ fn check_incompatible_options_for_ci_rustc( ($current:expr, $expected:expr, $config_section:expr) => { if let Some(current) = &$current { if Some(current) != $expected.as_ref() { - println!( + eprintln!( "WARNING: `{}` has no effect with `rust.download-rustc`. \ Current value: {:?}, Expected value(s): {}{:?}", format!("{}.{}", $config_section, stringify!($expected).replace("_", "-")), diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index bfeb811508c0..66b9f5ed84e6 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -196,12 +196,12 @@ impl Flags { if let Ok(HelpVerboseOnly { help: true, verbose: 1.., cmd: subcommand }) = HelpVerboseOnly::try_parse_from(normalize_args(args)) { - println!("NOTE: updating submodules before printing available paths"); + eprintln!("NOTE: updating submodules before printing available paths"); let config = Config::parse(Self::parse(&[String::from("build")])); let build = Build::new(config); let paths = Builder::get_help(&build, subcommand); if let Some(s) = paths { - println!("{s}"); + eprintln!("{s}"); } else { panic!("No paths available for subcommand `{}`", subcommand.as_str()); } diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index db35e6907e66..05b91c518cf4 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -77,7 +77,7 @@ impl Config { if self.dry_run() && !cmd.run_always { return true; } - self.verbose(|| println!("running: {cmd:?}")); + self.verbose(|| eprintln!("running: {cmd:?}")); check_run(cmd, self.is_verbose()) } @@ -144,7 +144,7 @@ impl Config { /// Please see for more information fn fix_bin_or_dylib(&self, fname: &Path) { assert_eq!(SHOULD_FIX_BINS_AND_DYLIBS.get(), Some(&true)); - println!("attempting to patch {}", fname.display()); + eprintln!("attempting to patch {}", fname.display()); // Only build `.nix-deps` once. static NIX_DEPS_DIR: OnceLock = OnceLock::new(); @@ -206,7 +206,7 @@ impl Config { } fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { - self.verbose(|| println!("download {url}")); + self.verbose(|| eprintln!("download {url}")); // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. let tempfile = self.tempdir().join(dest_path.file_name().unwrap()); // While bootstrap itself only supports http and https downloads, downstream forks might @@ -226,7 +226,7 @@ impl Config { } fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { - println!("downloading {url}"); + eprintln!("downloading {url}"); // Try curl. If that fails and we are on windows, fallback to PowerShell. // options should be kept in sync with // src/bootstrap/src/core/download.rs @@ -341,7 +341,7 @@ impl Config { short_path = short_path.strip_prefix(pattern).unwrap_or(short_path); let dst_path = dst.join(short_path); self.verbose(|| { - println!("extracting {} to {}", original_path.display(), dst.display()) + eprintln!("extracting {} to {}", original_path.display(), dst.display()) }); if !t!(member.unpack_in(dst)) { panic!("path traversal attack ??"); @@ -365,7 +365,7 @@ impl Config { pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool { use sha2::Digest; - self.verbose(|| println!("verifying {}", path.display())); + self.verbose(|| eprintln!("verifying {}", path.display())); if self.dry_run() { return false; @@ -391,7 +391,7 @@ impl Config { let verified = checksum == expected; if !verified { - println!( + eprintln!( "invalid checksum: \n\ found: {checksum}\n\ expected: {expected}", @@ -421,7 +421,7 @@ enum DownloadSource { /// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions. impl Config { pub(crate) fn download_clippy(&self) -> PathBuf { - self.verbose(|| println!("downloading stage0 clippy artifacts")); + self.verbose(|| eprintln!("downloading stage0 clippy artifacts")); let date = &self.stage0_metadata.compiler.date; let version = &self.stage0_metadata.compiler.version; @@ -518,7 +518,7 @@ impl Config { } pub(crate) fn download_ci_rustc(&self, commit: &str) { - self.verbose(|| println!("using downloaded stage2 artifacts from CI (commit {commit})")); + self.verbose(|| eprintln!("using downloaded stage2 artifacts from CI (commit {commit})")); let version = self.artifact_version_part(commit); // download-rustc doesn't need its own cargo, it can just use beta's. But it does need the @@ -539,7 +539,7 @@ impl Config { #[cfg(not(feature = "bootstrap-self-test"))] pub(crate) fn download_beta_toolchain(&self) { - self.verbose(|| println!("downloading stage0 beta artifacts")); + self.verbose(|| eprintln!("downloading stage0 beta artifacts")); let date = &self.stage0_metadata.compiler.date; let version = &self.stage0_metadata.compiler.version; @@ -677,7 +677,7 @@ impl Config { return; } else { self.verbose(|| { - println!( + eprintln!( "ignoring cached file {} due to failed verification", tarball.display() ) @@ -776,10 +776,10 @@ download-rustc = false t!(check_incompatible_options_for_ci_llvm(current_config_toml, ci_config_toml)); } Err(e) if e.to_string().contains("unknown field") => { - println!( + eprintln!( "WARNING: CI LLVM has some fields that are no longer supported in bootstrap; download-ci-llvm will be disabled." ); - println!("HELP: Consider rebasing to a newer commit if available."); + eprintln!("HELP: Consider rebasing to a newer commit if available."); } Err(e) => { eprintln!("ERROR: Failed to parse CI LLVM config.toml: {e}"); diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index dcf68cbeeda7..71e7f40f0320 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -237,11 +237,11 @@ than building it. stage0_supported_target_list.intersection(&missing_targets_hashset).collect(); if !duplicated_targets.is_empty() { - println!( + eprintln!( "Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list." ); for duplicated_target in duplicated_targets { - println!(" {duplicated_target}"); + eprintln!(" {duplicated_target}"); } std::process::exit(1); } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 0ecf61ffcd90..5f778223d7da 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -406,11 +406,11 @@ impl Build { .unwrap() .trim(); if local_release.split('.').take(2).eq(version.split('.').take(2)) { - build.verbose(|| println!("auto-detected local-rebuild {local_release}")); + build.verbose(|| eprintln!("auto-detected local-rebuild {local_release}")); build.local_rebuild = true; } - build.verbose(|| println!("finding compilers")); + build.verbose(|| eprintln!("finding compilers")); utils::cc_detect::find(&build); // When running `setup`, the profile is about to change, so any requirements we have now may // be different on the next invocation. Don't check for them until the next time x.py is @@ -418,7 +418,7 @@ impl Build { // // Similarly, for `setup` we don't actually need submodules or cargo metadata. if !matches!(build.config.cmd, Subcommand::Setup { .. }) { - build.verbose(|| println!("running sanity check")); + build.verbose(|| eprintln!("running sanity check")); crate::core::sanity::check(&mut build); // Make sure we update these before gathering metadata so we don't get an error about missing @@ -436,7 +436,7 @@ impl Build { // Now, update all existing submodules. build.update_existing_submodules(); - build.verbose(|| println!("learning about cargo")); + build.verbose(|| eprintln!("learning about cargo")); crate::core::metadata::build(&mut build); } @@ -605,7 +605,7 @@ impl Build { let stamp = dir.join(".stamp"); let mut cleared = false; if mtime(&stamp) < mtime(input) { - self.verbose(|| println!("Dirty - {}", dir.display())); + self.verbose(|| eprintln!("Dirty - {}", dir.display())); let _ = fs::remove_dir_all(dir); cleared = true; } else if stamp.exists() { @@ -890,7 +890,7 @@ impl Build { let executed_at = std::panic::Location::caller(); self.verbose(|| { - println!("running: {command:?} (created at {created_at}, executed at {executed_at})") + eprintln!("running: {command:?} (created at {created_at}, executed at {executed_at})") }); let cmd = command.as_command_mut(); @@ -947,7 +947,7 @@ Executed at: {executed_at}"#, let fail = |message: &str, output: CommandOutput| -> ! { if self.is_verbose() { - println!("{message}"); + eprintln!("{message}"); } else { let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present()); // If the command captures output, the user would not see any indication that @@ -957,16 +957,16 @@ Executed at: {executed_at}"#, if let Some(stdout) = output.stdout_if_present().take_if(|s| !s.trim().is_empty()) { - println!("STDOUT:\n{stdout}\n"); + eprintln!("STDOUT:\n{stdout}\n"); } if let Some(stderr) = output.stderr_if_present().take_if(|s| !s.trim().is_empty()) { - println!("STDERR:\n{stderr}\n"); + eprintln!("STDERR:\n{stderr}\n"); } - println!("Command {command:?} has failed. Rerun with -v to see more details."); + eprintln!("Command {command:?} has failed. Rerun with -v to see more details."); } else { - println!("Command has failed. Rerun with -v to see more details."); + eprintln!("Command has failed. Rerun with -v to see more details."); } } exit!(1); @@ -1011,7 +1011,7 @@ Executed at: {executed_at}"#, match self.config.dry_run { DryRun::SelfCheck => (), DryRun::Disabled | DryRun::UserSelected => { - println!("{msg}"); + eprintln!("{msg}"); } } } @@ -1666,7 +1666,7 @@ Executed at: {executed_at}"#, if self.config.dry_run() { return; } - self.verbose_than(1, || println!("Copy/Link {src:?} to {dst:?}")); + self.verbose_than(1, || eprintln!("Copy/Link {src:?} to {dst:?}")); if src == dst { return; } @@ -1775,7 +1775,7 @@ Executed at: {executed_at}"#, return; } let dst = dstdir.join(src.file_name().unwrap()); - self.verbose_than(1, || println!("Install {src:?} to {dst:?}")); + self.verbose_than(1, || eprintln!("Install {src:?} to {dst:?}")); t!(fs::create_dir_all(dstdir)); if !src.exists() { panic!("ERROR: File \"{}\" not found!", src.display()); diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 0df004694522..e8d5b60948aa 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -155,15 +155,15 @@ pub fn find_target(build: &Build, target: TargetSelection) { build.cxx.borrow_mut().insert(target, compiler); } - build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target))); - build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple)); + build.verbose(|| eprintln!("CC_{} = {:?}", target.triple, build.cc(target))); + build.verbose(|| eprintln!("CFLAGS_{} = {cflags:?}", target.triple)); if let Ok(cxx) = build.cxx(target) { let cxxflags = build.cflags(target, GitRepo::Rustc, CLang::Cxx); - build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple)); - build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple)); + build.verbose(|| eprintln!("CXX_{} = {cxx:?}", target.triple)); + build.verbose(|| eprintln!("CXXFLAGS_{} = {cxxflags:?}", target.triple)); } if let Some(ar) = ar { - build.verbose(|| println!("AR_{} = {ar:?}", target.triple)); + build.verbose(|| eprintln!("AR_{} = {ar:?}", target.triple)); build.ar.borrow_mut().insert(target, ar); } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 923cc2dfc28c..c0d52fd34305 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -135,7 +135,7 @@ impl Drop for TimeIt { fn drop(&mut self) { let time = self.1.elapsed(); if !self.0 { - println!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis()); + eprintln!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis()); } } } @@ -267,12 +267,12 @@ pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool { let status = match cmd.as_command_mut().status() { Ok(status) => status, Err(e) => { - println!("failed to execute command: {cmd:?}\nERROR: {e}"); + eprintln!("failed to execute command: {cmd:?}\nERROR: {e}"); return false; } }; if !status.success() && print_cmd_on_fail { - println!( + eprintln!( "\n\ncommand did not execute successfully: {cmd:?}\n\ expected success, got: {status}\n\n" ); diff --git a/src/bootstrap/src/utils/metrics.rs b/src/bootstrap/src/utils/metrics.rs index 3b31fa36e889..2b393215f911 100644 --- a/src/bootstrap/src/utils/metrics.rs +++ b/src/bootstrap/src/utils/metrics.rs @@ -184,7 +184,7 @@ impl BuildMetrics { if version.format_version == CURRENT_FORMAT_VERSION { t!(serde_json::from_slice::(&contents)).invocations } else { - println!( + eprintln!( "WARNING: overriding existing build/metrics.json, as it's not \ compatible with build metrics format version {CURRENT_FORMAT_VERSION}." ); diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index eb2c8254dc0f..27e1c5d01b77 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -56,7 +56,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> let cmd = cmd.as_command_mut(); cmd.stdout(Stdio::piped()); - builder.verbose(|| println!("running: {cmd:?}")); + builder.verbose(|| eprintln!("running: {cmd:?}")); let mut process = cmd.spawn().unwrap(); @@ -71,7 +71,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> let result = process.wait_with_output().unwrap(); if !result.status.success() && builder.is_verbose() { - println!( + eprintln!( "\n\ncommand did not execute successfully: {cmd:?}\n\ expected success, got: {}", result.status @@ -135,7 +135,9 @@ impl<'a> Renderer<'a> { if self.up_to_date_tests > 0 { let n = self.up_to_date_tests; let s = if n > 1 { "s" } else { "" }; - println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n"); + eprintln!( + "help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n" + ); } } @@ -190,7 +192,7 @@ impl<'a> Renderer<'a> { if let Some(exec_time) = test.exec_time { print!(" ({exec_time:.2?})"); } - println!(); + eprintln!(); } fn render_test_outcome_terse(&mut self, outcome: Outcome<'_>, test: &TestOutcome) { @@ -200,7 +202,7 @@ impl<'a> Renderer<'a> { let executed = format!("{:>width$}", self.executed_tests - 1, width = total.len()); print!(" {executed}/{total}"); } - println!(); + eprintln!(); self.terse_tests_in_line = 0; } @@ -212,31 +214,31 @@ impl<'a> Renderer<'a> { fn render_suite_outcome(&self, outcome: Outcome<'_>, suite: &SuiteOutcome) { // The terse output doesn't end with a newline, so we need to add it ourselves. if !self.builder.config.verbose_tests { - println!(); + eprintln!(); } if !self.failures.is_empty() { - println!("\nfailures:\n"); + eprintln!("\nfailures:\n"); for failure in &self.failures { if failure.stdout.is_some() || failure.message.is_some() { - println!("---- {} stdout ----", failure.name); + eprintln!("---- {} stdout ----", failure.name); if let Some(stdout) = &failure.stdout { - println!("{stdout}"); + eprintln!("{stdout}"); } if let Some(message) = &failure.message { - println!("NOTE: {message}"); + eprintln!("NOTE: {message}"); } } } - println!("\nfailures:"); + eprintln!("\nfailures:"); for failure in &self.failures { - println!(" {}", failure.name); + eprintln!(" {}", failure.name); } } if !self.benches.is_empty() { - println!("\nbenchmarks:"); + eprintln!("\nbenchmarks:"); let mut rows = Vec::new(); for bench in &self.benches { @@ -251,13 +253,13 @@ impl<'a> Renderer<'a> { let max_1 = rows.iter().map(|r| r.1.len()).max().unwrap_or(0); let max_2 = rows.iter().map(|r| r.2.len()).max().unwrap_or(0); for row in &rows { - println!(" {:max_1$} {:>max_2$}", row.0, row.1, row.2); + eprintln!(" {:max_1$} {:>max_2$}", row.0, row.1, row.2); } } print!("\ntest result: "); self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap(); - println!( + eprintln!( ". {} passed; {} failed; {} ignored; {} measured; {} filtered out{time}\n", suite.passed, suite.failed, @@ -274,7 +276,7 @@ impl<'a> Renderer<'a> { fn render_message(&mut self, message: Message) { match message { Message::Suite(SuiteMessage::Started { test_count }) => { - println!("\nrunning {test_count} tests"); + eprintln!("\nrunning {test_count} tests"); self.executed_tests = 0; self.terse_tests_in_line = 0; self.tests_count = Some(test_count); @@ -314,7 +316,7 @@ impl<'a> Renderer<'a> { self.failures.push(outcome); } Message::Test(TestMessage::Timeout { name }) => { - println!("test {name} has been running for a long time"); + eprintln!("test {name} has been running for a long time"); } Message::Test(TestMessage::Started) => {} // Not useful } diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index 3c6c7a7fa180..f60498a4872c 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -344,7 +344,7 @@ impl<'a> Tarball<'a> { // For `x install` tarball files aren't needed, so we can speed up the process by not producing them. let compression_profile = if self.builder.kind == Kind::Install { self.builder.verbose(|| { - println!("Forcing dist.compression-profile = 'no-op' for `x install`.") + eprintln!("Forcing dist.compression-profile = 'no-op' for `x install`.") }); // "no-op" indicates that the rust-installer won't produce compressed tarball sources. "no-op" From 23725619c416a62508cc9b1876b0ee9080dabfbe Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 3 Dec 2024 20:21:51 +0000 Subject: [PATCH 21/59] compiletest: `println!` -> `eprintln!` --- src/tools/compiletest/src/compute_diff.rs | 2 +- src/tools/compiletest/src/debuggers.rs | 6 +-- src/tools/compiletest/src/lib.rs | 10 ++-- src/tools/compiletest/src/runtest.rs | 50 +++++++++---------- .../compiletest/src/runtest/codegen_units.rs | 22 ++++---- .../compiletest/src/runtest/debuginfo.rs | 10 ++-- .../compiletest/src/runtest/rustdoc_json.rs | 2 +- src/tools/compiletest/src/runtest/ui.rs | 4 +- src/tools/compiletest/src/util.rs | 2 +- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/tools/compiletest/src/compute_diff.rs b/src/tools/compiletest/src/compute_diff.rs index 92c80c27de03..3ace6c5b6d71 100644 --- a/src/tools/compiletest/src/compute_diff.rs +++ b/src/tools/compiletest/src/compute_diff.rs @@ -144,7 +144,7 @@ where } if !wrote_data { - println!("note: diff is identical to nightly rustdoc"); + eprintln!("note: diff is identical to nightly rustdoc"); assert!(diff_output.metadata().unwrap().len() == 0); return false; } else if verbose { diff --git a/src/tools/compiletest/src/debuggers.rs b/src/tools/compiletest/src/debuggers.rs index b605bc813f19..e75c8a5993e5 100644 --- a/src/tools/compiletest/src/debuggers.rs +++ b/src/tools/compiletest/src/debuggers.rs @@ -20,7 +20,7 @@ pub(crate) fn configure_gdb(config: &Config) -> Option> { } if config.remote_test_client.is_some() && !config.target.contains("android") { - println!( + eprintln!( "WARNING: debuginfo tests are not available when \ testing with remote" ); @@ -28,7 +28,7 @@ pub(crate) fn configure_gdb(config: &Config) -> Option> { } if config.target.contains("android") { - println!( + eprintln!( "{} debug-info test uses tcp 5039 port.\ please reserve it", config.target @@ -50,7 +50,7 @@ pub(crate) fn configure_lldb(config: &Config) -> Option> { config.lldb_python_dir.as_ref()?; if let Some(350) = config.lldb_version { - println!( + eprintln!( "WARNING: The used version of LLDB (350) has a \ known issue that breaks debuginfo tests. See \ issue #32520 for more information. Skipping all \ diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index bf4a3124075e..447568065f51 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -188,8 +188,8 @@ pub fn parse_config(args: Vec) -> Config { let (argv0, args_) = args.split_first().unwrap(); if args.len() == 1 || args[1] == "-h" || args[1] == "--help" { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - println!("{}", opts.usage(&message)); - println!(); + eprintln!("{}", opts.usage(&message)); + eprintln!(); panic!() } @@ -200,8 +200,8 @@ pub fn parse_config(args: Vec) -> Config { if matches.opt_present("h") || matches.opt_present("help") { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - println!("{}", opts.usage(&message)); - println!(); + eprintln!("{}", opts.usage(&message)); + eprintln!(); panic!() } @@ -501,7 +501,7 @@ pub fn run_tests(config: Arc) { // easy to miss which tests failed, and as such fail to reproduce // the failure locally. - println!( + eprintln!( "Some tests failed in compiletest suite={}{} mode={} host={} target={}", config.suite, config diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7be9e2f2d577..7098b9449a3f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -771,20 +771,20 @@ impl<'test> TestCx<'test> { unexpected.len(), not_found.len() )); - println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline); + eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline); if !unexpected.is_empty() { - println!("{}", "--- unexpected errors (from JSON output) ---".green()); + eprintln!("{}", "--- unexpected errors (from JSON output) ---".green()); for error in &unexpected { - println!("{}", error.render_for_expected()); + eprintln!("{}", error.render_for_expected()); } - println!("{}", "---".green()); + eprintln!("{}", "---".green()); } if !not_found.is_empty() { - println!("{}", "--- not found errors (from test file) ---".red()); + eprintln!("{}", "--- not found errors (from test file) ---".red()); for error in ¬_found { - println!("{}", error.render_for_expected()); + eprintln!("{}", error.render_for_expected()); } - println!("{}", "---\n".red()); + eprintln!("{}", "---\n".red()); } panic!("errors differ from expected"); } @@ -1873,18 +1873,18 @@ impl<'test> TestCx<'test> { fn maybe_dump_to_stdout(&self, out: &str, err: &str) { if self.config.verbose { - println!("------stdout------------------------------"); - println!("{}", out); - println!("------stderr------------------------------"); - println!("{}", err); - println!("------------------------------------------"); + eprintln!("------stdout------------------------------"); + eprintln!("{}", out); + eprintln!("------stderr------------------------------"); + eprintln!("{}", err); + eprintln!("------------------------------------------"); } } fn error(&self, err: &str) { match self.revision { - Some(rev) => println!("\nerror in revision `{}`: {}", rev, err), - None => println!("\nerror: {}", err), + Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err), + None => eprintln!("\nerror: {}", err), } } @@ -1969,7 +1969,7 @@ impl<'test> TestCx<'test> { if !self.config.has_html_tidy { return; } - println!("info: generating a diff against nightly rustdoc"); + eprintln!("info: generating a diff against nightly rustdoc"); let suffix = self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly"); @@ -2079,7 +2079,7 @@ impl<'test> TestCx<'test> { .output() .unwrap(); assert!(output.status.success()); - println!("{}", String::from_utf8_lossy(&output.stdout)); + eprintln!("{}", String::from_utf8_lossy(&output.stdout)); eprintln!("{}", String::from_utf8_lossy(&output.stderr)); } else { use colored::Colorize; @@ -2479,7 +2479,7 @@ impl<'test> TestCx<'test> { )"# ) .replace_all(&output, |caps: &Captures<'_>| { - println!("{}", &caps[0]); + eprintln!("{}", &caps[0]); caps[0].replace(r"\", "/") }) .replace("\r\n", "\n") @@ -2578,16 +2578,16 @@ impl<'test> TestCx<'test> { if let Err(err) = fs::write(&actual_path, &actual) { self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",)); } - println!("Saved the actual {stream} to {actual_path:?}"); + eprintln!("Saved the actual {stream} to {actual_path:?}"); let expected_path = expected_output_path(self.testpaths, self.revision, &self.config.compare_mode, stream); if !self.config.bless { if expected.is_empty() { - println!("normalized {}:\n{}\n", stream, actual); + eprintln!("normalized {}:\n{}\n", stream, actual); } else { - println!("diff of {stream}:\n"); + eprintln!("diff of {stream}:\n"); if let Some(diff_command) = self.config.diff_command.as_deref() { let mut args = diff_command.split_whitespace(); let name = args.next().unwrap(); @@ -2622,10 +2622,10 @@ impl<'test> TestCx<'test> { if let Err(err) = fs::write(&expected_path, &actual) { self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}")); } - println!("Blessing the {stream} of {test_name} in {expected_path:?}"); + eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}"); } - println!("\nThe actual {0} differed from the expected {0}.", stream); + eprintln!("\nThe actual {0} differed from the expected {0}.", stream); if self.config.bless { 0 } else { 1 } } @@ -2704,7 +2704,7 @@ impl<'test> TestCx<'test> { fs::create_dir_all(&incremental_dir).unwrap(); if self.config.verbose { - println!("init_incremental_test: incremental_dir={}", incremental_dir.display()); + eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display()); } } @@ -2762,7 +2762,7 @@ impl ProcRes { } } - println!( + eprintln!( "status: {}\ncommand: {}\n{}\n{}\n", self.status, self.cmdline, @@ -2773,7 +2773,7 @@ impl ProcRes { pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! { if let Some(e) = err { - println!("\nerror: {}", e); + eprintln!("\nerror: {}", e); } self.print_info(); on_failure(); diff --git a/src/tools/compiletest/src/runtest/codegen_units.rs b/src/tools/compiletest/src/runtest/codegen_units.rs index 6c866cbef21a..6acd140183d4 100644 --- a/src/tools/compiletest/src/runtest/codegen_units.rs +++ b/src/tools/compiletest/src/runtest/codegen_units.rs @@ -64,13 +64,13 @@ impl TestCx<'_> { if !missing.is_empty() { missing.sort(); - println!("\nThese items should have been contained but were not:\n"); + eprintln!("\nThese items should have been contained but were not:\n"); for item in &missing { - println!("{}", item); + eprintln!("{}", item); } - println!("\n"); + eprintln!("\n"); } if !unexpected.is_empty() { @@ -80,24 +80,24 @@ impl TestCx<'_> { sorted }; - println!("\nThese items were contained but should not have been:\n"); + eprintln!("\nThese items were contained but should not have been:\n"); for item in sorted { - println!("{}", item); + eprintln!("{}", item); } - println!("\n"); + eprintln!("\n"); } if !wrong_cgus.is_empty() { wrong_cgus.sort_by_key(|pair| pair.0.name.clone()); - println!("\nThe following items were assigned to wrong codegen units:\n"); + eprintln!("\nThe following items were assigned to wrong codegen units:\n"); for &(ref expected_item, ref actual_item) in &wrong_cgus { - println!("{}", expected_item.name); - println!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units)); - println!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units)); - println!(); + eprintln!("{}", expected_item.name); + eprintln!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units)); + eprintln!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units)); + eprintln!(); } } diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index c621c22ac993..7322e730e53f 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -260,7 +260,7 @@ impl TestCx<'_> { cmdline, }; if adb.kill().is_err() { - println!("Adb process is already finished."); + eprintln!("Adb process is already finished."); } } else { let rust_src_root = @@ -275,7 +275,7 @@ impl TestCx<'_> { match self.config.gdb_version { Some(version) => { - println!("NOTE: compiletest thinks it is using GDB version {}", version); + eprintln!("NOTE: compiletest thinks it is using GDB version {}", version); if version > extract_gdb_version("7.4").unwrap() { // Add the directory containing the pretty printers to @@ -297,7 +297,7 @@ impl TestCx<'_> { } } _ => { - println!( + eprintln!( "NOTE: compiletest does not know which version of \ GDB it is using" ); @@ -392,10 +392,10 @@ impl TestCx<'_> { match self.config.lldb_version { Some(ref version) => { - println!("NOTE: compiletest thinks it is using LLDB version {}", version); + eprintln!("NOTE: compiletest thinks it is using LLDB version {}", version); } _ => { - println!( + eprintln!( "NOTE: compiletest does not know which version of \ LLDB it is using" ); diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index 31fdb0a5d13b..84376d346af3 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -29,7 +29,7 @@ impl TestCx<'_> { if !res.status.success() { self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| { - println!("Rustdoc Output:"); + eprintln!("Rustdoc Output:"); proc_res.print_info(); }) } diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index bb747c680292..414f1a6adb33 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -109,10 +109,10 @@ impl TestCx<'_> { } if errors > 0 { - println!("To update references, rerun the tests and pass the `--bless` flag"); + eprintln!("To update references, rerun the tests and pass the `--bless` flag"); let relative_path_to_file = self.testpaths.relative_dir.join(self.testpaths.file.file_name().unwrap()); - println!( + eprintln!( "To only update this specific test, also pass `--test-args {}`", relative_path_to_file.display(), ); diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index bff02f1db9f0..7b50e62c29bb 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -30,7 +30,7 @@ fn path_div() -> &'static str { pub fn logv(config: &Config, s: String) { debug!("{}", s); if config.verbose { - println!("{}", s); + eprintln!("{}", s); } } From 8374f7ceb5d81cc0c540444cfce55594bad33d33 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Tue, 3 Dec 2024 20:23:14 +0000 Subject: [PATCH 22/59] tidy: `println!` -> `eprintln!` --- src/tools/tidy/src/error_codes.rs | 6 +++--- src/tools/tidy/src/features.rs | 8 ++++---- src/tools/tidy/src/unstable_book.rs | 8 ++++---- src/tools/tidy/src/x_version.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs index e2d1b85797ff..9dc49b57d599 100644 --- a/src/tools/tidy/src/error_codes.rs +++ b/src/tools/tidy/src/error_codes.rs @@ -38,7 +38,7 @@ const IGNORE_UI_TEST_CHECK: &[&str] = macro_rules! verbose_print { ($verbose:expr, $($fmt:tt)*) => { if $verbose { - println!("{}", format_args!($($fmt)*)); + eprintln!("{}", format_args!($($fmt)*)); } }; } @@ -49,8 +49,8 @@ pub fn check(root_path: &Path, search_paths: &[&Path], verbose: bool, bad: &mut // Stage 1: create list let error_codes = extract_error_codes(root_path, &mut errors); if verbose { - println!("Found {} error codes", error_codes.len()); - println!("Highest error code: `{}`", error_codes.iter().max().unwrap()); + eprintln!("Found {} error codes", error_codes.len()); + eprintln!("Highest error code: `{}`", error_codes.iter().max().unwrap()); } // Stage 2: check list has docs diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4f24eb212420..4607d0415770 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -158,14 +158,14 @@ pub fn check( .collect::>(); for &(name, _) in gate_untested.iter() { - println!("Expected a gate test for the feature '{name}'."); - println!( + eprintln!("Expected a gate test for the feature '{name}'."); + eprintln!( "Hint: create a failing test file named 'tests/ui/feature-gates/feature-gate-{}.rs',\ \n with its failures due to missing usage of `#![feature({})]`.", name.replace("_", "-"), name ); - println!( + eprintln!( "Hint: If you already have such a test and don't want to rename it,\ \n you can also add a // gate-test-{} line to the test file.", name @@ -218,7 +218,7 @@ pub fn check( lines.sort(); for line in lines { - println!("* {line}"); + eprintln!("* {line}"); } } diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index 8be25b98df0d..06d238ef5e47 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -118,16 +118,16 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) { // List unstable features that don't have Unstable Book sections. // Remove the comment marker if you want the list printed. /* - println!("Lib features without unstable book sections:"); + eprintln!("Lib features without unstable book sections:"); for feature_name in &unstable_lang_feature_names - &unstable_book_lang_features_section_file_names { - println!(" * {} {:?}", feature_name, lib_features[&feature_name].tracking_issue); + eprintln!(" * {} {:?}", feature_name, lib_features[&feature_name].tracking_issue); } - println!("Lang features without unstable book sections:"); + eprintln!("Lang features without unstable book sections:"); for feature_name in &unstable_lib_feature_names- &unstable_book_lib_features_section_file_names { - println!(" * {} {:?}", feature_name, lang_features[&feature_name].tracking_issue); + eprintln!(" * {} {:?}", feature_name, lang_features[&feature_name].tracking_issue); } // */ } diff --git a/src/tools/tidy/src/x_version.rs b/src/tools/tidy/src/x_version.rs index 489343561e18..b43d56202c99 100644 --- a/src/tools/tidy/src/x_version.rs +++ b/src/tools/tidy/src/x_version.rs @@ -42,7 +42,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) { if let Some(expected) = get_x_wrapper_version(root, cargo) { if installed < expected { - return println!( + return eprintln!( "Current version of x is {installed}, but the latest version is {expected}\nConsider updating to the newer version of x by running `cargo install --path src/tools/x`" ); } From 52d1c30d3ee692c47691c8c96dd62368af2de9c5 Mon Sep 17 00:00:00 2001 From: Boxy Date: Wed, 4 Dec 2024 00:19:26 +0000 Subject: [PATCH 23/59] Add comment to test --- tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs index d163238c6d53..5a67d34d6e5a 100644 --- a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs +++ b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs @@ -1,6 +1,7 @@ //@ check-pass -// Regression test for #128176. +// Regression test for #128176. Previously we would call `type_of` on the `1` anon const +// before the anon const had been lowered and had the `type_of` fed with a result. #![feature(generic_const_exprs)] #![feature(dyn_compatible_for_dispatch)] From 2a3b4a0afd84933b94b0181f421c0f0446b4bed7 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 16 Oct 2024 21:25:09 +1100 Subject: [PATCH 24/59] coverage: Extract `subtracted_sum` in counter creation --- .../rustc_mir_transform/src/coverage/counters.rs | 16 ++++++++-------- tests/coverage/branch/guard.cov-map | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index cf9f6981c5a2..c1c2d4b96c66 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -182,6 +182,12 @@ impl CoverageCounters { .reduce(|accum, counter| self.make_expression(accum, Op::Add, counter)) } + /// Creates a counter whose value is `lhs - SUM(rhs)`. + fn make_subtracted_sum(&mut self, lhs: BcbCounter, rhs: &[BcbCounter]) -> BcbCounter { + let Some(rhs_sum) = self.make_sum(rhs) else { return lhs }; + self.make_expression(lhs, Op::Subtract, rhs_sum) + } + pub(super) fn num_counters(&self) -> usize { self.counter_increment_sites.len() } @@ -338,8 +344,7 @@ impl<'a> CountersBuilder<'a> { }; // For each out-edge other than the one that was chosen to get an expression, - // ensure that it has a counter (existing counter/expression or a new counter), - // and accumulate the corresponding counters into a single sum expression. + // ensure that it has a counter (existing counter/expression or a new counter). let other_out_edge_counters = successors .iter() .copied() @@ -347,15 +352,10 @@ impl<'a> CountersBuilder<'a> { .filter(|&edge_target_bcb| edge_target_bcb != target_bcb) .map(|to_bcb| self.get_or_make_edge_counter(from_bcb, to_bcb)) .collect::>(); - let Some(sum_of_all_other_out_edges) = self.counters.make_sum(&other_out_edge_counters) - else { - return; - }; // Now create an expression for the chosen edge, by taking the counter // for its source node and subtracting the sum of its sibling out-edges. - let expression = - self.counters.make_expression(node_counter, Op::Subtract, sum_of_all_other_out_edges); + let expression = self.counters.make_subtracted_sum(node_counter, &other_out_edge_counters); debug!("{target_bcb:?} gets an expression: {expression:?}"); self.counters.set_edge_counter(from_bcb, target_bcb, expression); diff --git a/tests/coverage/branch/guard.cov-map b/tests/coverage/branch/guard.cov-map index 0f33ed17a0ac..e87b389c1ac5 100644 --- a/tests/coverage/branch/guard.cov-map +++ b/tests/coverage/branch/guard.cov-map @@ -1,5 +1,5 @@ Function name: guard::branch_match_guard -Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 1d, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 1d, 00, 14, 00, 19, 20, 11, 09, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02] +Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 02, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 02, 00, 14, 00, 19, 20, 11, 09, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 6 @@ -11,7 +11,8 @@ Number of expressions: 6 - expression 5 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 13 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) -- Code(Counter(7)) at (prev + 3, 11) to (start + 0, 12) +- Code(Expression(0, Sub)) at (prev + 3, 11) to (start + 0, 12) + = (c6 - c3) - Code(Counter(5)) at (prev + 1, 20) to (start + 2, 10) - Code(Counter(3)) at (prev + 3, 14) to (start + 0, 15) - Code(Counter(6)) at (prev + 0, 20) to (start + 0, 25) @@ -20,7 +21,8 @@ Number of file 0 mappings: 13 false = (c6 - c3) - Code(Counter(3)) at (prev + 0, 29) to (start + 2, 10) - Code(Counter(4)) at (prev + 3, 14) to (start + 0, 15) -- Code(Counter(7)) at (prev + 0, 20) to (start + 0, 25) +- Code(Expression(0, Sub)) at (prev + 0, 20) to (start + 0, 25) + = (c6 - c3) - Branch { true: Counter(4), false: Counter(2) } at (prev + 0, 20) to (start + 0, 30) true = c4 false = c2 @@ -29,5 +31,5 @@ Number of file 0 mappings: 13 = (c1 + c2) - Code(Expression(2, Add)) at (prev + 4, 1) to (start + 0, 2) = ((((c1 + c2) + c3) + c4) + c5) -Highest counter ID seen: c7 +Highest counter ID seen: c6 From 7ecc677f5b35e18967af9b8a18d6b432a2c1ed36 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 27 Nov 2024 13:21:03 +1100 Subject: [PATCH 25/59] coverage: Rename `CounterIncrementSite` to just `Site` A "site" is a node or edge in the coverage graph. --- .../src/coverage/counters.rs | 17 +++++++++-------- .../rustc_mir_transform/src/coverage/mod.rs | 10 +++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index c1c2d4b96c66..fa0d9fc6f726 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -43,8 +43,9 @@ struct BcbExpression { rhs: BcbCounter, } -#[derive(Debug)] -pub(super) enum CounterIncrementSite { +/// Enum representing either a node or an edge in the coverage graph. +#[derive(Clone, Copy, Debug)] +pub(super) enum Site { Node { bcb: BasicCoverageBlock }, Edge { from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock }, } @@ -54,7 +55,7 @@ pub(super) enum CounterIncrementSite { pub(super) struct CoverageCounters { /// List of places where a counter-increment statement should be injected /// into MIR, each with its corresponding counter ID. - counter_increment_sites: IndexVec, + counter_increment_sites: IndexVec, /// Coverage counters/expressions that are associated with individual BCBs. node_counters: IndexVec>, @@ -98,14 +99,14 @@ impl CoverageCounters { /// Shared helper used by [`Self::make_phys_node_counter`] and /// [`Self::make_phys_edge_counter`]. Don't call this directly. - fn make_counter_inner(&mut self, site: CounterIncrementSite) -> BcbCounter { + fn make_counter_inner(&mut self, site: Site) -> BcbCounter { let id = self.counter_increment_sites.push(site); BcbCounter::Counter { id } } /// Creates a new physical counter for a BCB node. fn make_phys_node_counter(&mut self, bcb: BasicCoverageBlock) -> BcbCounter { - self.make_counter_inner(CounterIncrementSite::Node { bcb }) + self.make_counter_inner(Site::Node { bcb }) } /// Creates a new physical counter for a BCB edge. @@ -114,7 +115,7 @@ impl CoverageCounters { from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock, ) -> BcbCounter { - self.make_counter_inner(CounterIncrementSite::Edge { from_bcb, to_bcb }) + self.make_counter_inner(Site::Edge { from_bcb, to_bcb }) } fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter { @@ -224,8 +225,8 @@ impl CoverageCounters { /// each site's corresponding counter ID. pub(super) fn counter_increment_sites( &self, - ) -> impl Iterator { - self.counter_increment_sites.iter_enumerated() + ) -> impl Iterator + Captures<'_> { + self.counter_increment_sites.iter_enumerated().map(|(id, &site)| (id, site)) } /// Returns an iterator over the subset of BCB nodes that have been associated diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs index e8b3d80be021..241c3c79114a 100644 --- a/compiler/rustc_mir_transform/src/coverage/mod.rs +++ b/compiler/rustc_mir_transform/src/coverage/mod.rs @@ -25,7 +25,7 @@ use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, Pos, SourceFile, Span}; use tracing::{debug, debug_span, trace}; -use crate::coverage::counters::{CounterIncrementSite, CoverageCounters}; +use crate::coverage::counters::{CoverageCounters, Site}; use crate::coverage::graph::CoverageGraph; use crate::coverage::mappings::ExtractedMappings; @@ -265,13 +265,13 @@ fn inject_coverage_statements<'tcx>( coverage_counters: &CoverageCounters, ) { // Inject counter-increment statements into MIR. - for (id, counter_increment_site) in coverage_counters.counter_increment_sites() { + for (id, site) in coverage_counters.counter_increment_sites() { // Determine the block to inject a counter-increment statement into. // For BCB nodes this is just their first block, but for edges we need // to create a new block between the two BCBs, and inject into that. - let target_bb = match *counter_increment_site { - CounterIncrementSite::Node { bcb } => basic_coverage_blocks[bcb].leader_bb(), - CounterIncrementSite::Edge { from_bcb, to_bcb } => { + let target_bb = match site { + Site::Node { bcb } => basic_coverage_blocks[bcb].leader_bb(), + Site::Edge { from_bcb, to_bcb } => { // Create a new block between the last block of `from_bcb` and // the first block of `to_bcb`. let from_bb = basic_coverage_blocks[from_bcb].last_bb(); From aca6dba6d10ac09da782ec2ea7ddd32b694f5d6b Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 1 Dec 2024 15:42:59 +1100 Subject: [PATCH 26/59] coverage: Use a single `make_phys_counter` method This is more convenient for subsequent patches. --- .../src/coverage/counters.rs | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index fa0d9fc6f726..3927c18da4ce 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -97,27 +97,12 @@ impl CoverageCounters { } } - /// Shared helper used by [`Self::make_phys_node_counter`] and - /// [`Self::make_phys_edge_counter`]. Don't call this directly. - fn make_counter_inner(&mut self, site: Site) -> BcbCounter { + /// Creates a new physical counter for a BCB node or edge. + fn make_phys_counter(&mut self, site: Site) -> BcbCounter { let id = self.counter_increment_sites.push(site); BcbCounter::Counter { id } } - /// Creates a new physical counter for a BCB node. - fn make_phys_node_counter(&mut self, bcb: BasicCoverageBlock) -> BcbCounter { - self.make_counter_inner(Site::Node { bcb }) - } - - /// Creates a new physical counter for a BCB edge. - fn make_phys_edge_counter( - &mut self, - from_bcb: BasicCoverageBlock, - to_bcb: BasicCoverageBlock, - ) -> BcbCounter { - self.make_counter_inner(Site::Edge { from_bcb, to_bcb }) - } - fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter { let new_expr = BcbExpression { lhs, op, rhs }; *self @@ -391,7 +376,7 @@ impl<'a> CountersBuilder<'a> { // leading to infinite recursion. if predecessors.len() <= 1 || predecessors.contains(&bcb) { debug!(?bcb, ?predecessors, "node has <=1 predecessors or is its own predecessor"); - let counter = self.counters.make_phys_node_counter(bcb); + let counter = self.counters.make_phys_counter(Site::Node { bcb }); debug!(?bcb, ?counter, "node gets a physical counter"); return counter; } @@ -448,7 +433,7 @@ impl<'a> CountersBuilder<'a> { } // Make a new counter to count this edge. - let counter = self.counters.make_phys_edge_counter(from_bcb, to_bcb); + let counter = self.counters.make_phys_counter(Site::Edge { from_bcb, to_bcb }); debug!(?from_bcb, ?to_bcb, ?counter, "edge gets a physical counter"); counter } From 44e4e4515c877093379e368b591b6aae3545f77c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 29 Nov 2024 12:58:35 +1100 Subject: [PATCH 27/59] coverage: Add an extra "transcribe" step after counter creation --- .../src/coverage/counters.rs | 132 ++++- .../src/coverage/counters/tests.rs | 41 ++ tests/coverage/abort.cov-map | 26 +- tests/coverage/assert.cov-map | 31 +- tests/coverage/async.cov-map | 27 +- tests/coverage/branch/guard.cov-map | 6 +- tests/coverage/branch/if.cov-map | 28 +- tests/coverage/branch/lazy-boolean.cov-map | 170 +++--- tests/coverage/branch/match-arms.cov-map | 76 ++- tests/coverage/branch/no-mir-spans.cov-map | 14 +- tests/coverage/branch/while.cov-map | 43 +- tests/coverage/closure_macro.cov-map | 8 +- tests/coverage/closure_macro_async.cov-map | 8 +- tests/coverage/condition/conditions.cov-map | 73 ++- tests/coverage/conditions.cov-map | 508 ++++++++++-------- tests/coverage/continue.cov-map | 18 +- tests/coverage/coroutine.cov-map | 18 +- tests/coverage/inline-dead.cov-map | 8 +- tests/coverage/inline.cov-map | 17 +- tests/coverage/issue-84561.cov-map | 192 +++---- tests/coverage/lazy_boolean.cov-map | 40 +- tests/coverage/loops_branches.cov-map | 223 ++++---- tests/coverage/mcdc/condition-limit.cov-map | 156 +++--- tests/coverage/mcdc/if.cov-map | 262 ++++----- .../coverage/mcdc/inlined_expressions.cov-map | 13 +- tests/coverage/mcdc/nested_if.cov-map | 268 ++++----- tests/coverage/mcdc/non_control_flow.cov-map | 143 +++-- tests/coverage/nested_loops.cov-map | 76 ++- tests/coverage/overflow.cov-map | 31 +- tests/coverage/panic_unwind.cov-map | 31 +- tests/coverage/simple_match.cov-map | 20 +- tests/coverage/try_error_result.cov-map | 242 ++++----- tests/coverage/unicode.cov-map | 24 +- tests/coverage/unused.cov-map | 20 +- tests/coverage/while_early_ret.cov-map | 19 +- tests/coverage/yield.cov-map | 24 +- ...ch_match_arms.main.InstrumentCoverage.diff | 14 +- 37 files changed, 1609 insertions(+), 1441 deletions(-) create mode 100644 compiler/rustc_mir_transform/src/coverage/counters/tests.rs diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 3927c18da4ce..4e543fc99189 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -1,3 +1,4 @@ +use std::cmp::Ordering; use std::fmt::{self, Debug}; use rustc_data_structures::captures::Captures; @@ -10,9 +11,12 @@ use tracing::{debug, debug_span, instrument}; use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverageGraphWithLoops}; +#[cfg(test)] +mod tests; + /// The coverage counter or counter expression associated with a particular /// BCB node or BCB edge. -#[derive(Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] enum BcbCounter { Counter { id: CounterId }, Expression { id: ExpressionId }, @@ -44,7 +48,7 @@ struct BcbExpression { } /// Enum representing either a node or an edge in the coverage graph. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub(super) enum Site { Node { bcb: BasicCoverageBlock }, Edge { from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock }, @@ -84,7 +88,7 @@ impl CoverageCounters { let mut builder = CountersBuilder::new(graph, bcb_needs_counter); builder.make_bcb_counters(); - builder.counters + builder.into_coverage_counters() } fn with_num_bcbs(num_bcbs: usize) -> Self { @@ -496,4 +500,126 @@ impl<'a> CountersBuilder<'a> { None } + + fn into_coverage_counters(self) -> CoverageCounters { + Transcriber::new(&self).transcribe_counters() + } +} + +/// Helper struct for converting `CountersBuilder` into a final `CoverageCounters`. +struct Transcriber<'a> { + old: &'a CountersBuilder<'a>, + new: CoverageCounters, + phys_counter_for_site: FxHashMap, +} + +impl<'a> Transcriber<'a> { + fn new(old: &'a CountersBuilder<'a>) -> Self { + Self { + old, + new: CoverageCounters::with_num_bcbs(old.graph.num_nodes()), + phys_counter_for_site: FxHashMap::default(), + } + } + + fn transcribe_counters(mut self) -> CoverageCounters { + for bcb in self.old.bcb_needs_counter.iter() { + let site = Site::Node { bcb }; + let Some(old_counter) = self.old.counters.node_counters[bcb] else { continue }; + + // Resolve the old counter into flat lists of nodes/edges whose + // physical counts contribute to the counter for this node. + // Distinguish between counts that will be added vs subtracted. + let mut pos = vec![]; + let mut neg = vec![]; + self.push_resolved_sites(old_counter, &mut pos, &mut neg); + + // Simplify by cancelling out sites that appear on both sides. + let (mut pos, mut neg) = sort_and_cancel(pos, neg); + + if pos.is_empty() { + // If we somehow end up with no positive terms after cancellation, + // fall back to creating a physical counter. There's no known way + // for this to happen, but it's hard to confidently rule it out. + debug_assert!(false, "{site:?} has no positive counter terms"); + pos = vec![Some(site)]; + neg = vec![]; + } + + let mut new_counters_for_sites = |sites: Vec>| { + sites + .into_iter() + .filter_map(|id| try { self.ensure_phys_counter(id?) }) + .collect::>() + }; + let mut pos = new_counters_for_sites(pos); + let mut neg = new_counters_for_sites(neg); + + pos.sort(); + neg.sort(); + + let pos_counter = self.new.make_sum(&pos).expect("`pos` should not be empty"); + let new_counter = self.new.make_subtracted_sum(pos_counter, &neg); + self.new.set_node_counter(bcb, new_counter); + } + + self.new + } + + fn ensure_phys_counter(&mut self, site: Site) -> BcbCounter { + *self.phys_counter_for_site.entry(site).or_insert_with(|| self.new.make_phys_counter(site)) + } + + /// Resolves the given counter into flat lists of nodes/edges, whose counters + /// will then be added and subtracted to form a counter expression. + fn push_resolved_sites(&self, counter: BcbCounter, pos: &mut Vec, neg: &mut Vec) { + match counter { + BcbCounter::Counter { id } => pos.push(self.old.counters.counter_increment_sites[id]), + BcbCounter::Expression { id } => { + let BcbExpression { lhs, op, rhs } = self.old.counters.expressions[id]; + self.push_resolved_sites(lhs, pos, neg); + match op { + Op::Add => self.push_resolved_sites(rhs, pos, neg), + // Swap `neg` and `pos` so that the counter is subtracted. + Op::Subtract => self.push_resolved_sites(rhs, neg, pos), + } + } + } + } +} + +/// Given two lists: +/// - Sorts each list. +/// - Converts each list to `Vec>`. +/// - Scans for values that appear in both lists, and cancels them out by +/// replacing matching pairs of values with `None`. +fn sort_and_cancel(mut pos: Vec, mut neg: Vec) -> (Vec>, Vec>) { + pos.sort(); + neg.sort(); + + // Convert to `Vec>`. If `T` has a niche, this should be zero-cost. + let mut pos = pos.into_iter().map(Some).collect::>(); + let mut neg = neg.into_iter().map(Some).collect::>(); + + // Scan through the lists using two cursors. When either cursor reaches the + // end of its list, there can be no more equal pairs, so stop. + let mut p = 0; + let mut n = 0; + while p < pos.len() && n < neg.len() { + // If the values are equal, remove them and advance both cursors. + // Otherwise, advance whichever cursor points to the lesser value. + // (Choosing which cursor to advance relies on both lists being sorted.) + match pos[p].cmp(&neg[n]) { + Ordering::Less => p += 1, + Ordering::Equal => { + pos[p] = None; + neg[n] = None; + p += 1; + n += 1; + } + Ordering::Greater => n += 1, + } + } + + (pos, neg) } diff --git a/compiler/rustc_mir_transform/src/coverage/counters/tests.rs b/compiler/rustc_mir_transform/src/coverage/counters/tests.rs new file mode 100644 index 000000000000..794d4358f823 --- /dev/null +++ b/compiler/rustc_mir_transform/src/coverage/counters/tests.rs @@ -0,0 +1,41 @@ +use std::fmt::Debug; + +use super::sort_and_cancel; + +fn flatten(input: Vec>) -> Vec { + input.into_iter().flatten().collect() +} + +fn sort_and_cancel_and_flatten(pos: Vec, neg: Vec) -> (Vec, Vec) { + let (pos_actual, neg_actual) = sort_and_cancel(pos, neg); + (flatten(pos_actual), flatten(neg_actual)) +} + +#[track_caller] +fn check_test_case( + pos: Vec, + neg: Vec, + pos_expected: Vec, + neg_expected: Vec, +) { + eprintln!("pos = {pos:?}; neg = {neg:?}"); + let output = sort_and_cancel_and_flatten(pos, neg); + assert_eq!(output, (pos_expected, neg_expected)); +} + +#[test] +fn cancellation() { + let cases: &[(Vec, Vec, Vec, Vec)] = &[ + (vec![], vec![], vec![], vec![]), + (vec![4, 2, 1, 5, 3], vec![], vec![1, 2, 3, 4, 5], vec![]), + (vec![5, 5, 5, 5, 5], vec![5], vec![5, 5, 5, 5], vec![]), + (vec![1, 1, 2, 2, 3, 3], vec![1, 2, 3], vec![1, 2, 3], vec![]), + (vec![1, 1, 2, 2, 3, 3], vec![2, 4, 2], vec![1, 1, 3, 3], vec![4]), + ]; + + for (pos, neg, pos_expected, neg_expected) in cases { + check_test_case(pos.to_vec(), neg.to_vec(), pos_expected.to_vec(), neg_expected.to_vec()); + // Same test case, but with its inputs flipped and its outputs flipped. + check_test_case(neg.to_vec(), pos.to_vec(), neg_expected.to_vec(), pos_expected.to_vec()); + } +} diff --git a/tests/coverage/abort.cov-map b/tests/coverage/abort.cov-map index c121fa551dcf..396edec275d7 100644 --- a/tests/coverage/abort.cov-map +++ b/tests/coverage/abort.cov-map @@ -1,34 +1,34 @@ Function name: abort::main -Raw bytes (89): 0x[01, 01, 0a, 01, 27, 05, 09, 03, 0d, 22, 11, 03, 0d, 03, 0d, 22, 15, 03, 0d, 03, 0d, 05, 09, 0d, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 22, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 0e, 02, 09, 00, 0a, 22, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 1a, 00, 30, 00, 31, 22, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 30, 00, 31, 27, 01, 09, 00, 17, 0d, 02, 05, 01, 02] +Raw bytes (89): 0x[01, 01, 0a, 07, 09, 01, 05, 03, 0d, 03, 13, 0d, 11, 03, 0d, 03, 1f, 0d, 15, 03, 0d, 05, 09, 0d, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 22, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 0e, 02, 09, 00, 0a, 22, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 1a, 00, 30, 00, 31, 22, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 30, 00, 31, 27, 01, 09, 00, 17, 0d, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 10 -- expression 0 operands: lhs = Counter(0), rhs = Expression(9, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Expression(8, Sub), rhs = Counter(4) -- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Expression(0, Add), rhs = Expression(4, Add) +- expression 4 operands: lhs = Counter(3), rhs = Counter(4) - expression 5 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 6 operands: lhs = Expression(8, Sub), rhs = Counter(5) -- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 6 operands: lhs = Expression(0, Add), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(3), rhs = Counter(5) - expression 8 operands: lhs = Expression(0, Add), rhs = Counter(3) - expression 9 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 13 - Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) - = (c0 + (c1 + c2)) + = ((c0 + c1) + c2) - Code(Expression(8, Sub)) at (prev + 1, 12) to (start + 0, 25) - = ((c0 + (c1 + c2)) - c3) + = (((c0 + c1) + c2) - c3) - Code(Counter(4)) at (prev + 0, 26) to (start + 2, 10) - Code(Expression(3, Sub)) at (prev + 2, 9) to (start + 0, 10) - = (((c0 + (c1 + c2)) - c3) - c4) + = (((c0 + c1) + c2) - (c3 + c4)) - Code(Expression(8, Sub)) at (prev + 2, 12) to (start + 0, 25) - = ((c0 + (c1 + c2)) - c3) + = (((c0 + c1) + c2) - c3) - Code(Counter(5)) at (prev + 0, 26) to (start + 0, 49) - Code(Expression(6, Sub)) at (prev + 0, 48) to (start + 0, 49) - = (((c0 + (c1 + c2)) - c3) - c5) + = (((c0 + c1) + c2) - (c3 + c5)) - Code(Expression(8, Sub)) at (prev + 4, 12) to (start + 0, 25) - = ((c0 + (c1 + c2)) - c3) + = (((c0 + c1) + c2) - c3) - Code(Counter(1)) at (prev + 0, 26) to (start + 0, 49) - Code(Counter(2)) at (prev + 0, 48) to (start + 0, 49) - Code(Expression(9, Add)) at (prev + 1, 9) to (start + 0, 23) diff --git a/tests/coverage/assert.cov-map b/tests/coverage/assert.cov-map index b3cec3901197..3bbf7a43e6d8 100644 --- a/tests/coverage/assert.cov-map +++ b/tests/coverage/assert.cov-map @@ -1,29 +1,30 @@ Function name: assert::main -Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 09, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 09, 00, 0a, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Raw bytes (67): 0x[01, 01, 09, 07, 0d, 0b, 09, 01, 05, 03, 11, 17, 11, 1b, 0d, 01, 09, 23, 0d, 05, 09, 09, 01, 09, 01, 01, 1b, 03, 02, 0b, 00, 18, 0e, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 09, 00, 0a, 1f, 01, 09, 00, 17, 11, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) -- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +Number of expressions: 9 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) -- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(4) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3) +- expression 6 operands: lhs = Counter(0), rhs = Counter(2) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 9, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) - = (c0 + (c1 + (c2 + c3))) -- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) - = ((c0 + (c1 + (c2 + c3))) - c4) + = (((c0 + c1) + c2) + c3) +- Code(Expression(3, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((((c0 + c1) + c2) + c3) - c4) - Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10) - Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32) - = (((c0 + (c1 + (c2 + c3))) - c4) - c1) + = (((c0 + c2) + c3) - c4) - Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10) - Code(Counter(3)) at (prev + 2, 9) to (start + 0, 10) -- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) - = (c1 + (c2 + c3)) +- Code(Expression(7, Add)) at (prev + 1, 9) to (start + 0, 23) + = ((c1 + c2) + c3) - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) Highest counter ID seen: c4 diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map index 9a67cefcf985..c51bc6eb621a 100644 --- a/tests/coverage/async.cov-map +++ b/tests/coverage/async.cov-map @@ -155,25 +155,25 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: async::i::{closure#0} -Raw bytes (63): 0x[01, 01, 02, 07, 19, 11, 15, 0b, 01, 2d, 13, 04, 0c, 09, 05, 09, 00, 0a, 01, 00, 0e, 00, 18, 05, 00, 1c, 00, 21, 09, 00, 27, 00, 30, 15, 01, 09, 00, 0a, 0d, 00, 0e, 00, 17, 1d, 00, 1b, 00, 20, 15, 00, 24, 00, 26, 19, 01, 0e, 00, 10, 03, 02, 01, 00, 02] +Raw bytes (63): 0x[01, 01, 02, 07, 15, 0d, 11, 0b, 01, 2d, 13, 04, 0c, 09, 05, 09, 00, 0a, 01, 00, 0e, 00, 18, 05, 00, 1c, 00, 21, 09, 00, 27, 00, 30, 11, 01, 09, 00, 0a, 19, 00, 0e, 00, 17, 1d, 00, 1b, 00, 20, 11, 00, 24, 00, 26, 15, 01, 0e, 00, 10, 03, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 -- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(6) -- expression 1 operands: lhs = Counter(4), rhs = Counter(5) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(5) +- expression 1 operands: lhs = Counter(3), rhs = Counter(4) Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 45, 19) to (start + 4, 12) - Code(Counter(2)) at (prev + 5, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 0, 14) to (start + 0, 24) - Code(Counter(1)) at (prev + 0, 28) to (start + 0, 33) - Code(Counter(2)) at (prev + 0, 39) to (start + 0, 48) -- Code(Counter(5)) at (prev + 1, 9) to (start + 0, 10) -- Code(Counter(3)) at (prev + 0, 14) to (start + 0, 23) +- Code(Counter(4)) at (prev + 1, 9) to (start + 0, 10) +- Code(Counter(6)) at (prev + 0, 14) to (start + 0, 23) - Code(Counter(7)) at (prev + 0, 27) to (start + 0, 32) -- Code(Counter(5)) at (prev + 0, 36) to (start + 0, 38) -- Code(Counter(6)) at (prev + 1, 14) to (start + 0, 16) +- Code(Counter(4)) at (prev + 0, 36) to (start + 0, 38) +- Code(Counter(5)) at (prev + 1, 14) to (start + 0, 16) - Code(Expression(0, Add)) at (prev + 2, 1) to (start + 0, 2) - = ((c4 + c5) + c6) + = ((c3 + c4) + c5) Highest counter ID seen: c7 Function name: async::j @@ -243,22 +243,19 @@ Number of file 0 mappings: 5 Highest counter ID seen: (none) Function name: async::l -Raw bytes (37): 0x[01, 01, 04, 01, 07, 05, 09, 0f, 02, 09, 05, 05, 01, 52, 01, 01, 0c, 02, 02, 0e, 00, 10, 05, 01, 0e, 00, 10, 09, 01, 0e, 00, 10, 0b, 02, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 02, 01, 07, 05, 09, 05, 01, 52, 01, 01, 0c, 02, 02, 0e, 00, 10, 09, 01, 0e, 00, 10, 05, 01, 0e, 00, 10, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) - expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Expression(3, Add), rhs = Expression(0, Sub) -- expression 3 operands: lhs = Counter(2), rhs = Counter(1) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 82, 1) to (start + 1, 12) - Code(Expression(0, Sub)) at (prev + 2, 14) to (start + 0, 16) = (c0 - (c1 + c2)) -- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16) - Code(Counter(2)) at (prev + 1, 14) to (start + 0, 16) -- Code(Expression(2, Add)) at (prev + 2, 1) to (start + 0, 2) - = ((c2 + c1) + (c0 - (c1 + c2))) +- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 16) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c2 Function name: async::m diff --git a/tests/coverage/branch/guard.cov-map b/tests/coverage/branch/guard.cov-map index e87b389c1ac5..1ba1c6e1228c 100644 --- a/tests/coverage/branch/guard.cov-map +++ b/tests/coverage/branch/guard.cov-map @@ -1,5 +1,5 @@ Function name: guard::branch_match_guard -Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 02, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 02, 00, 14, 00, 19, 20, 11, 09, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02] +Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 02, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 02, 00, 14, 00, 19, 20, 11, 05, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 6 @@ -23,9 +23,9 @@ Number of file 0 mappings: 13 - Code(Counter(4)) at (prev + 3, 14) to (start + 0, 15) - Code(Expression(0, Sub)) at (prev + 0, 20) to (start + 0, 25) = (c6 - c3) -- Branch { true: Counter(4), false: Counter(2) } at (prev + 0, 20) to (start + 0, 30) +- Branch { true: Counter(4), false: Counter(1) } at (prev + 0, 20) to (start + 0, 30) true = c4 - false = c2 + false = c1 - Code(Counter(4)) at (prev + 0, 29) to (start + 2, 10) - Code(Expression(5, Add)) at (prev + 3, 14) to (start + 2, 10) = (c1 + c2) diff --git a/tests/coverage/branch/if.cov-map b/tests/coverage/branch/if.cov-map index 0ad78a720a79..bab982dd44c9 100644 --- a/tests/coverage/branch/if.cov-map +++ b/tests/coverage/branch/if.cov-map @@ -1,12 +1,14 @@ Function name: if::branch_and -Raw bytes (56): 0x[01, 01, 04, 05, 09, 0d, 02, 11, 0f, 0d, 02, 08, 01, 2b, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 00, 0d, 00, 0e, 20, 11, 0d, 00, 0d, 00, 0e, 11, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (60): 0x[01, 01, 06, 05, 09, 0b, 09, 05, 11, 13, 09, 17, 11, 05, 0d, 08, 01, 2b, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 00, 0d, 00, 0e, 20, 0d, 11, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 06, 02, 0c, 02, 06, 0e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 6 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(3), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(4), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(3), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(4) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(2) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(4) +- expression 5 operands: lhs = Counter(1), rhs = Counter(3) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 43, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9) @@ -14,14 +16,14 @@ Number of file 0 mappings: 8 true = c2 false = (c1 - c2) - Code(Counter(2)) at (prev + 0, 13) to (start + 0, 14) -- Branch { true: Counter(4), false: Counter(3) } at (prev + 0, 13) to (start + 0, 14) - true = c4 - false = c3 -- Code(Counter(4)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(3, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c3 + (c1 - c2)) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c4 + (c3 + (c1 - c2))) +- Branch { true: Counter(3), false: Counter(4) } at (prev + 0, 13) to (start + 0, 14) + true = c3 + false = c4 +- Code(Counter(3)) at (prev + 0, 15) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c1 + c4) - c2) +- Code(Expression(3, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c1 + c3) + c4) - c2) Highest counter ID seen: c4 Function name: if::branch_not diff --git a/tests/coverage/branch/lazy-boolean.cov-map b/tests/coverage/branch/lazy-boolean.cov-map index c2b6a5b8df24..decb847f60e3 100644 --- a/tests/coverage/branch/lazy-boolean.cov-map +++ b/tests/coverage/branch/lazy-boolean.cov-map @@ -34,39 +34,49 @@ Number of file 0 mappings: 6 Highest counter ID seen: c2 Function name: lazy_boolean::chain -Raw bytes (149): 0x[01, 01, 13, 11, 07, 0b, 16, 15, 1a, 09, 0d, 05, 09, 05, 09, 09, 0d, 47, 25, 4b, 21, 19, 1d, 03, 19, 03, 19, 3e, 1d, 03, 19, 3e, 1d, 03, 19, 47, 25, 4b, 21, 19, 1d, 13, 01, 24, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 12, 20, 09, 16, 00, 0d, 00, 12, 09, 00, 16, 00, 1b, 20, 0d, 1a, 00, 16, 00, 1b, 0d, 00, 1f, 00, 24, 20, 11, 15, 00, 1f, 00, 24, 11, 00, 28, 00, 2d, 03, 01, 05, 00, 11, 43, 03, 09, 00, 0a, 03, 00, 0d, 00, 12, 20, 19, 3e, 00, 0d, 00, 12, 3e, 00, 16, 00, 1b, 20, 1d, 3a, 00, 16, 00, 1b, 3a, 00, 1f, 00, 24, 20, 21, 25, 00, 1f, 00, 24, 25, 00, 28, 00, 2d, 43, 01, 05, 01, 02] +Raw bytes (169): 0x[01, 01, 1d, 5b, 0d, 5f, 15, 05, 11, 05, 09, 09, 0d, 6f, 25, 73, 21, 19, 1d, 5b, 67, 5f, 15, 05, 11, 0d, 19, 5b, 67, 5f, 15, 05, 11, 0d, 19, 5b, 63, 5f, 15, 05, 11, 67, 1d, 0d, 19, 5b, 63, 5f, 15, 05, 11, 67, 1d, 0d, 19, 6f, 25, 73, 21, 19, 1d, 13, 01, 24, 01, 01, 10, 02, 04, 09, 00, 0a, 05, 00, 0d, 00, 12, 20, 09, 0e, 00, 0d, 00, 12, 09, 00, 16, 00, 1b, 20, 0d, 12, 00, 16, 00, 1b, 0d, 00, 1f, 00, 24, 20, 11, 15, 00, 1f, 00, 24, 11, 00, 28, 00, 2d, 02, 01, 05, 00, 11, 6b, 03, 09, 00, 0a, 02, 00, 0d, 00, 12, 20, 19, 32, 00, 0d, 00, 12, 32, 00, 16, 00, 1b, 20, 1d, 56, 00, 16, 00, 1b, 56, 00, 1f, 00, 24, 20, 21, 25, 00, 1f, 00, 24, 25, 00, 28, 00, 2d, 6b, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 19 -- expression 0 operands: lhs = Counter(4), rhs = Expression(1, Add) -- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(5, Sub) -- expression 2 operands: lhs = Counter(5), rhs = Expression(6, Sub) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) -- expression 4 operands: lhs = Counter(1), rhs = Counter(2) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Counter(2), rhs = Counter(3) -- expression 7 operands: lhs = Expression(17, Add), rhs = Counter(9) -- expression 8 operands: lhs = Expression(18, Add), rhs = Counter(8) -- expression 9 operands: lhs = Counter(6), rhs = Counter(7) -- expression 10 operands: lhs = Expression(0, Add), rhs = Counter(6) -- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(6) -- expression 12 operands: lhs = Expression(15, Sub), rhs = Counter(7) -- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(6) -- expression 14 operands: lhs = Expression(15, Sub), rhs = Counter(7) -- expression 15 operands: lhs = Expression(0, Add), rhs = Counter(6) -- expression 16 operands: lhs = Expression(17, Add), rhs = Counter(9) -- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(8) -- expression 18 operands: lhs = Counter(6), rhs = Counter(7) +Number of expressions: 29 +- expression 0 operands: lhs = Expression(22, Add), rhs = Counter(3) +- expression 1 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 2 operands: lhs = Counter(1), rhs = Counter(4) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +- expression 5 operands: lhs = Expression(27, Add), rhs = Counter(9) +- expression 6 operands: lhs = Expression(28, Add), rhs = Counter(8) +- expression 7 operands: lhs = Counter(6), rhs = Counter(7) +- expression 8 operands: lhs = Expression(22, Add), rhs = Expression(25, Add) +- expression 9 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 10 operands: lhs = Counter(1), rhs = Counter(4) +- expression 11 operands: lhs = Counter(3), rhs = Counter(6) +- expression 12 operands: lhs = Expression(22, Add), rhs = Expression(25, Add) +- expression 13 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 14 operands: lhs = Counter(1), rhs = Counter(4) +- expression 15 operands: lhs = Counter(3), rhs = Counter(6) +- expression 16 operands: lhs = Expression(22, Add), rhs = Expression(24, Add) +- expression 17 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 18 operands: lhs = Counter(1), rhs = Counter(4) +- expression 19 operands: lhs = Expression(25, Add), rhs = Counter(7) +- expression 20 operands: lhs = Counter(3), rhs = Counter(6) +- expression 21 operands: lhs = Expression(22, Add), rhs = Expression(24, Add) +- expression 22 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 23 operands: lhs = Counter(1), rhs = Counter(4) +- expression 24 operands: lhs = Expression(25, Add), rhs = Counter(7) +- expression 25 operands: lhs = Counter(3), rhs = Counter(6) +- expression 26 operands: lhs = Expression(27, Add), rhs = Counter(9) +- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(8) +- expression 28 operands: lhs = Counter(6), rhs = Counter(7) Number of file 0 mappings: 19 - Code(Counter(0)) at (prev + 36, 1) to (start + 1, 16) -- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10) - = (c4 + ((c5 + (c2 - c3)) + (c1 - c2))) +- Code(Expression(0, Sub)) at (prev + 4, 9) to (start + 0, 10) + = (((c1 + c4) + c5) - c3) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 18) -- Branch { true: Counter(2), false: Expression(5, Sub) } at (prev + 0, 13) to (start + 0, 18) +- Branch { true: Counter(2), false: Expression(3, Sub) } at (prev + 0, 13) to (start + 0, 18) true = c2 false = (c1 - c2) - Code(Counter(2)) at (prev + 0, 22) to (start + 0, 27) -- Branch { true: Counter(3), false: Expression(6, Sub) } at (prev + 0, 22) to (start + 0, 27) +- Branch { true: Counter(3), false: Expression(4, Sub) } at (prev + 0, 22) to (start + 0, 27) true = c3 false = (c2 - c3) - Code(Counter(3)) at (prev + 0, 31) to (start + 0, 36) @@ -74,97 +84,87 @@ Number of file 0 mappings: 19 true = c4 false = c5 - Code(Counter(4)) at (prev + 0, 40) to (start + 0, 45) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 17) - = (c4 + ((c5 + (c2 - c3)) + (c1 - c2))) -- Code(Expression(16, Add)) at (prev + 3, 9) to (start + 0, 10) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 17) + = (((c1 + c4) + c5) - c3) +- Code(Expression(26, Add)) at (prev + 3, 9) to (start + 0, 10) = (((c6 + c7) + c8) + c9) -- Code(Expression(0, Add)) at (prev + 0, 13) to (start + 0, 18) - = (c4 + ((c5 + (c2 - c3)) + (c1 - c2))) -- Branch { true: Counter(6), false: Expression(15, Sub) } at (prev + 0, 13) to (start + 0, 18) +- Code(Expression(0, Sub)) at (prev + 0, 13) to (start + 0, 18) + = (((c1 + c4) + c5) - c3) +- Branch { true: Counter(6), false: Expression(12, Sub) } at (prev + 0, 13) to (start + 0, 18) true = c6 - false = ((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) -- Code(Expression(15, Sub)) at (prev + 0, 22) to (start + 0, 27) - = ((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) -- Branch { true: Counter(7), false: Expression(14, Sub) } at (prev + 0, 22) to (start + 0, 27) + false = (((c1 + c4) + c5) - (c3 + c6)) +- Code(Expression(12, Sub)) at (prev + 0, 22) to (start + 0, 27) + = (((c1 + c4) + c5) - (c3 + c6)) +- Branch { true: Counter(7), false: Expression(21, Sub) } at (prev + 0, 22) to (start + 0, 27) true = c7 - false = (((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) - c7) -- Code(Expression(14, Sub)) at (prev + 0, 31) to (start + 0, 36) - = (((c4 + ((c5 + (c2 - c3)) + (c1 - c2))) - c6) - c7) + false = (((c1 + c4) + c5) - ((c3 + c6) + c7)) +- Code(Expression(21, Sub)) at (prev + 0, 31) to (start + 0, 36) + = (((c1 + c4) + c5) - ((c3 + c6) + c7)) - Branch { true: Counter(8), false: Counter(9) } at (prev + 0, 31) to (start + 0, 36) true = c8 false = c9 - Code(Counter(9)) at (prev + 0, 40) to (start + 0, 45) -- Code(Expression(16, Add)) at (prev + 1, 5) to (start + 1, 2) +- Code(Expression(26, Add)) at (prev + 1, 5) to (start + 1, 2) = (((c6 + c7) + c8) + c9) Highest counter ID seen: c9 Function name: lazy_boolean::nested_mixed -Raw bytes (155): 0x[01, 01, 16, 33, 1a, 09, 0d, 1e, 0d, 05, 09, 05, 09, 05, 09, 1e, 0d, 05, 09, 09, 0d, 33, 11, 09, 0d, 33, 11, 09, 0d, 19, 57, 1d, 21, 03, 15, 15, 19, 4a, 4e, 15, 19, 03, 15, 19, 57, 1d, 21, 13, 01, 31, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0e, 00, 13, 20, 09, 1e, 00, 0e, 00, 13, 1e, 00, 17, 00, 1d, 20, 0d, 1a, 00, 17, 00, 1d, 33, 00, 23, 00, 28, 20, 11, 2e, 00, 23, 00, 28, 2e, 00, 2c, 00, 33, 03, 01, 05, 00, 11, 53, 03, 09, 00, 0a, 03, 00, 0e, 00, 13, 20, 15, 4e, 00, 0e, 00, 13, 15, 00, 17, 00, 1c, 20, 19, 4a, 00, 17, 00, 1c, 47, 00, 22, 00, 28, 20, 1d, 21, 00, 22, 00, 28, 1d, 00, 2c, 00, 33, 53, 01, 05, 01, 02] +Raw bytes (141): 0x[01, 01, 0f, 05, 09, 05, 1f, 09, 0d, 09, 0d, 1f, 11, 09, 0d, 1f, 11, 09, 0d, 3b, 21, 19, 1d, 05, 15, 15, 19, 05, 19, 3b, 21, 19, 1d, 13, 01, 31, 01, 01, 10, 05, 04, 09, 00, 0a, 05, 00, 0e, 00, 13, 20, 09, 02, 00, 0e, 00, 13, 02, 00, 17, 00, 1d, 20, 0d, 06, 00, 17, 00, 1d, 1f, 00, 23, 00, 28, 20, 11, 1a, 00, 23, 00, 28, 1a, 00, 2c, 00, 33, 05, 01, 05, 00, 11, 37, 03, 09, 00, 0a, 05, 00, 0e, 00, 13, 20, 15, 2a, 00, 0e, 00, 13, 15, 00, 17, 00, 1c, 20, 19, 2e, 00, 17, 00, 1c, 32, 00, 22, 00, 28, 20, 1d, 21, 00, 22, 00, 28, 1d, 00, 2c, 00, 33, 37, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 22 -- expression 0 operands: lhs = Expression(12, Add), rhs = Expression(6, Sub) -- expression 1 operands: lhs = Counter(2), rhs = Counter(3) -- expression 2 operands: lhs = Expression(7, Sub), rhs = Counter(3) -- expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Counter(1), rhs = Counter(2) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(3) -- expression 7 operands: lhs = Counter(1), rhs = Counter(2) -- expression 8 operands: lhs = Counter(2), rhs = Counter(3) -- expression 9 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 10 operands: lhs = Counter(2), rhs = Counter(3) -- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 12 operands: lhs = Counter(2), rhs = Counter(3) -- expression 13 operands: lhs = Counter(6), rhs = Expression(21, Add) -- expression 14 operands: lhs = Counter(7), rhs = Counter(8) -- expression 15 operands: lhs = Expression(0, Add), rhs = Counter(5) -- expression 16 operands: lhs = Counter(5), rhs = Counter(6) -- expression 17 operands: lhs = Expression(18, Sub), rhs = Expression(19, Sub) -- expression 18 operands: lhs = Counter(5), rhs = Counter(6) -- expression 19 operands: lhs = Expression(0, Add), rhs = Counter(5) -- expression 20 operands: lhs = Counter(6), rhs = Expression(21, Add) -- expression 21 operands: lhs = Counter(7), rhs = Counter(8) +Number of expressions: 15 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(7, Add), rhs = Counter(4) +- expression 5 operands: lhs = Counter(2), rhs = Counter(3) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(4) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 8 operands: lhs = Expression(14, Add), rhs = Counter(8) +- expression 9 operands: lhs = Counter(6), rhs = Counter(7) +- expression 10 operands: lhs = Counter(1), rhs = Counter(5) +- expression 11 operands: lhs = Counter(5), rhs = Counter(6) +- expression 12 operands: lhs = Counter(1), rhs = Counter(6) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(8) +- expression 14 operands: lhs = Counter(6), rhs = Counter(7) Number of file 0 mappings: 19 - Code(Counter(0)) at (prev + 49, 1) to (start + 1, 16) -- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10) - = ((c2 + c3) + ((c1 - c2) - c3)) +- Code(Counter(1)) at (prev + 4, 9) to (start + 0, 10) - Code(Counter(1)) at (prev + 0, 14) to (start + 0, 19) -- Branch { true: Counter(2), false: Expression(7, Sub) } at (prev + 0, 14) to (start + 0, 19) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 14) to (start + 0, 19) true = c2 false = (c1 - c2) -- Code(Expression(7, Sub)) at (prev + 0, 23) to (start + 0, 29) +- Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 0, 29) = (c1 - c2) -- Branch { true: Counter(3), false: Expression(6, Sub) } at (prev + 0, 23) to (start + 0, 29) +- Branch { true: Counter(3), false: Expression(1, Sub) } at (prev + 0, 23) to (start + 0, 29) true = c3 - false = ((c1 - c2) - c3) -- Code(Expression(12, Add)) at (prev + 0, 35) to (start + 0, 40) + false = (c1 - (c2 + c3)) +- Code(Expression(7, Add)) at (prev + 0, 35) to (start + 0, 40) = (c2 + c3) -- Branch { true: Counter(4), false: Expression(11, Sub) } at (prev + 0, 35) to (start + 0, 40) +- Branch { true: Counter(4), false: Expression(6, Sub) } at (prev + 0, 35) to (start + 0, 40) true = c4 false = ((c2 + c3) - c4) -- Code(Expression(11, Sub)) at (prev + 0, 44) to (start + 0, 51) +- Code(Expression(6, Sub)) at (prev + 0, 44) to (start + 0, 51) = ((c2 + c3) - c4) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 17) - = ((c2 + c3) + ((c1 - c2) - c3)) -- Code(Expression(20, Add)) at (prev + 3, 9) to (start + 0, 10) - = (c6 + (c7 + c8)) -- Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 19) - = ((c2 + c3) + ((c1 - c2) - c3)) -- Branch { true: Counter(5), false: Expression(19, Sub) } at (prev + 0, 14) to (start + 0, 19) +- Code(Counter(1)) at (prev + 1, 5) to (start + 0, 17) +- Code(Expression(13, Add)) at (prev + 3, 9) to (start + 0, 10) + = ((c6 + c7) + c8) +- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 19) +- Branch { true: Counter(5), false: Expression(10, Sub) } at (prev + 0, 14) to (start + 0, 19) true = c5 - false = (((c2 + c3) + ((c1 - c2) - c3)) - c5) + false = (c1 - c5) - Code(Counter(5)) at (prev + 0, 23) to (start + 0, 28) -- Branch { true: Counter(6), false: Expression(18, Sub) } at (prev + 0, 23) to (start + 0, 28) +- Branch { true: Counter(6), false: Expression(11, Sub) } at (prev + 0, 23) to (start + 0, 28) true = c6 false = (c5 - c6) -- Code(Expression(17, Add)) at (prev + 0, 34) to (start + 0, 40) - = ((c5 - c6) + (((c2 + c3) + ((c1 - c2) - c3)) - c5)) +- Code(Expression(12, Sub)) at (prev + 0, 34) to (start + 0, 40) + = (c1 - c6) - Branch { true: Counter(7), false: Counter(8) } at (prev + 0, 34) to (start + 0, 40) true = c7 false = c8 - Code(Counter(7)) at (prev + 0, 44) to (start + 0, 51) -- Code(Expression(20, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c6 + (c7 + c8)) +- Code(Expression(13, Add)) at (prev + 1, 5) to (start + 1, 2) + = ((c6 + c7) + c8) Highest counter ID seen: c8 diff --git a/tests/coverage/branch/match-arms.cov-map b/tests/coverage/branch/match-arms.cov-map index fd0366ee8183..a93df9814ee7 100644 --- a/tests/coverage/branch/match-arms.cov-map +++ b/tests/coverage/branch/match-arms.cov-map @@ -1,12 +1,12 @@ Function name: match_arms::guards -Raw bytes (88): 0x[01, 01, 08, 07, 15, 0b, 11, 0f, 0d, 00, 09, 17, 25, 1b, 21, 1f, 1d, 03, 19, 0c, 01, 30, 01, 01, 10, 29, 03, 0b, 00, 10, 19, 01, 11, 00, 29, 20, 19, 09, 00, 17, 00, 1b, 1d, 01, 11, 00, 29, 20, 1d, 0d, 00, 17, 00, 1b, 21, 01, 11, 00, 29, 20, 21, 11, 00, 17, 00, 1b, 25, 01, 11, 00, 29, 20, 25, 15, 00, 17, 00, 1b, 03, 01, 0e, 00, 18, 13, 03, 05, 01, 02] +Raw bytes (88): 0x[01, 01, 08, 07, 00, 0b, 11, 0f, 0d, 05, 09, 17, 25, 1b, 21, 1f, 1d, 03, 19, 0c, 01, 30, 01, 01, 10, 29, 03, 0b, 00, 10, 19, 01, 11, 00, 29, 20, 19, 05, 00, 17, 00, 1b, 1d, 01, 11, 00, 29, 20, 1d, 09, 00, 17, 00, 1b, 21, 01, 11, 00, 29, 20, 21, 0d, 00, 17, 00, 1b, 25, 01, 11, 00, 29, 20, 25, 11, 00, 17, 00, 1b, 03, 01, 0e, 00, 18, 13, 03, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 -- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(5) +- expression 0 operands: lhs = Expression(1, Add), rhs = Zero - expression 1 operands: lhs = Expression(2, Add), rhs = Counter(4) - expression 2 operands: lhs = Expression(3, Add), rhs = Counter(3) -- expression 3 operands: lhs = Zero, rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) - expression 4 operands: lhs = Expression(5, Add), rhs = Counter(9) - expression 5 operands: lhs = Expression(6, Add), rhs = Counter(8) - expression 6 operands: lhs = Expression(7, Add), rhs = Counter(7) @@ -15,81 +15,67 @@ Number of file 0 mappings: 12 - Code(Counter(0)) at (prev + 48, 1) to (start + 1, 16) - Code(Counter(10)) at (prev + 3, 11) to (start + 0, 16) - Code(Counter(6)) at (prev + 1, 17) to (start + 0, 41) -- Branch { true: Counter(6), false: Counter(2) } at (prev + 0, 23) to (start + 0, 27) +- Branch { true: Counter(6), false: Counter(1) } at (prev + 0, 23) to (start + 0, 27) true = c6 - false = c2 + false = c1 - Code(Counter(7)) at (prev + 1, 17) to (start + 0, 41) -- Branch { true: Counter(7), false: Counter(3) } at (prev + 0, 23) to (start + 0, 27) +- Branch { true: Counter(7), false: Counter(2) } at (prev + 0, 23) to (start + 0, 27) true = c7 - false = c3 + false = c2 - Code(Counter(8)) at (prev + 1, 17) to (start + 0, 41) -- Branch { true: Counter(8), false: Counter(4) } at (prev + 0, 23) to (start + 0, 27) +- Branch { true: Counter(8), false: Counter(3) } at (prev + 0, 23) to (start + 0, 27) true = c8 - false = c4 + false = c3 - Code(Counter(9)) at (prev + 1, 17) to (start + 0, 41) -- Branch { true: Counter(9), false: Counter(5) } at (prev + 0, 23) to (start + 0, 27) +- Branch { true: Counter(9), false: Counter(4) } at (prev + 0, 23) to (start + 0, 27) true = c9 - false = c5 + false = c4 - Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 24) - = ((((Zero + c2) + c3) + c4) + c5) + = ((((c1 + c2) + c3) + c4) + Zero) - Code(Expression(4, Add)) at (prev + 3, 5) to (start + 1, 2) - = ((((((((Zero + c2) + c3) + c4) + c5) + c6) + c7) + c8) + c9) + = ((((((((c1 + c2) + c3) + c4) + Zero) + c6) + c7) + c8) + c9) Highest counter ID seen: c10 Function name: match_arms::match_arms -Raw bytes (51): 0x[01, 01, 06, 05, 07, 0b, 11, 09, 0d, 13, 02, 17, 09, 11, 0d, 07, 01, 18, 01, 01, 10, 05, 03, 0b, 00, 10, 11, 01, 11, 00, 21, 0d, 01, 11, 00, 21, 09, 01, 11, 00, 21, 02, 01, 11, 00, 21, 0f, 03, 05, 01, 02] +Raw bytes (45): 0x[01, 01, 03, 05, 07, 0b, 11, 09, 0d, 07, 01, 18, 01, 01, 10, 05, 03, 0b, 00, 10, 09, 01, 11, 00, 21, 0d, 01, 11, 00, 21, 11, 01, 11, 00, 21, 02, 01, 11, 00, 21, 05, 03, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 6 +Number of expressions: 3 - expression 0 operands: lhs = Counter(1), rhs = Expression(1, Add) - expression 1 operands: lhs = Expression(2, Add), rhs = Counter(4) - expression 2 operands: lhs = Counter(2), rhs = Counter(3) -- expression 3 operands: lhs = Expression(4, Add), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(2) -- expression 5 operands: lhs = Counter(4), rhs = Counter(3) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 24, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 11) to (start + 0, 16) -- Code(Counter(4)) at (prev + 1, 17) to (start + 0, 33) -- Code(Counter(3)) at (prev + 1, 17) to (start + 0, 33) - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 33) +- Code(Counter(3)) at (prev + 1, 17) to (start + 0, 33) +- Code(Counter(4)) at (prev + 1, 17) to (start + 0, 33) - Code(Expression(0, Sub)) at (prev + 1, 17) to (start + 0, 33) = (c1 - ((c2 + c3) + c4)) -- Code(Expression(3, Add)) at (prev + 3, 5) to (start + 1, 2) - = (((c4 + c3) + c2) + (c1 - ((c2 + c3) + c4))) +- Code(Counter(1)) at (prev + 3, 5) to (start + 1, 2) Highest counter ID seen: c4 Function name: match_arms::or_patterns -Raw bytes (75): 0x[01, 01, 0d, 11, 0d, 05, 2f, 33, 11, 09, 0d, 09, 2a, 05, 2f, 33, 11, 09, 0d, 03, 27, 09, 2a, 05, 2f, 33, 11, 09, 0d, 09, 01, 25, 01, 01, 10, 05, 03, 0b, 00, 10, 11, 01, 11, 00, 12, 0d, 00, 1e, 00, 1f, 03, 00, 24, 00, 2e, 09, 01, 11, 00, 12, 2a, 00, 1e, 00, 1f, 27, 00, 24, 00, 2e, 23, 03, 05, 01, 02] +Raw bytes (57): 0x[01, 01, 04, 09, 0d, 05, 0b, 03, 11, 05, 03, 09, 01, 25, 01, 01, 10, 05, 03, 0b, 00, 10, 09, 01, 11, 00, 12, 0d, 00, 1e, 00, 1f, 03, 00, 24, 00, 2e, 11, 01, 11, 00, 12, 06, 00, 1e, 00, 1f, 0e, 00, 24, 00, 2e, 05, 03, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 13 -- expression 0 operands: lhs = Counter(4), rhs = Counter(3) -- expression 1 operands: lhs = Counter(1), rhs = Expression(11, Add) -- expression 2 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) -- expression 4 operands: lhs = Counter(2), rhs = Expression(10, Sub) -- expression 5 operands: lhs = Counter(1), rhs = Expression(11, Add) -- expression 6 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) -- expression 8 operands: lhs = Expression(0, Add), rhs = Expression(9, Add) -- expression 9 operands: lhs = Counter(2), rhs = Expression(10, Sub) -- expression 10 operands: lhs = Counter(1), rhs = Expression(11, Add) -- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(4) -- expression 12 operands: lhs = Counter(2), rhs = Counter(3) +Number of expressions: 4 +- expression 0 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add) +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Add) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 37, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 11) to (start + 0, 16) -- Code(Counter(4)) at (prev + 1, 17) to (start + 0, 18) +- Code(Counter(2)) at (prev + 1, 17) to (start + 0, 18) - Code(Counter(3)) at (prev + 0, 30) to (start + 0, 31) - Code(Expression(0, Add)) at (prev + 0, 36) to (start + 0, 46) - = (c4 + c3) -- Code(Counter(2)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(10, Sub)) at (prev + 0, 30) to (start + 0, 31) + = (c2 + c3) +- Code(Counter(4)) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(1, Sub)) at (prev + 0, 30) to (start + 0, 31) = (c1 - ((c2 + c3) + c4)) -- Code(Expression(9, Add)) at (prev + 0, 36) to (start + 0, 46) - = (c2 + (c1 - ((c2 + c3) + c4))) -- Code(Expression(8, Add)) at (prev + 3, 5) to (start + 1, 2) - = ((c4 + c3) + (c2 + (c1 - ((c2 + c3) + c4)))) +- Code(Expression(3, Sub)) at (prev + 0, 36) to (start + 0, 46) + = (c1 - (c2 + c3)) +- Code(Counter(1)) at (prev + 3, 5) to (start + 1, 2) Highest counter ID seen: c4 diff --git a/tests/coverage/branch/no-mir-spans.cov-map b/tests/coverage/branch/no-mir-spans.cov-map index ab12732b1ed3..6003efc36ca2 100644 --- a/tests/coverage/branch/no-mir-spans.cov-map +++ b/tests/coverage/branch/no-mir-spans.cov-map @@ -23,19 +23,19 @@ Number of file 0 mappings: 2 Highest counter ID seen: c2 Function name: no_mir_spans::while_op_and -Raw bytes (25): 0x[01, 01, 01, 09, 0d, 03, 01, 22, 01, 00, 13, 20, 09, 05, 05, 0b, 00, 10, 20, 02, 0d, 00, 14, 00, 19] +Raw bytes (25): 0x[01, 01, 01, 05, 09, 03, 01, 22, 01, 00, 13, 20, 05, 0d, 05, 0b, 00, 10, 20, 02, 09, 00, 14, 00, 19] Number of files: 1 - file 0 => global file 1 Number of expressions: 1 -- expression 0 operands: lhs = Counter(2), rhs = Counter(3) +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 34, 1) to (start + 0, 19) -- Branch { true: Counter(2), false: Counter(1) } at (prev + 5, 11) to (start + 0, 16) - true = c2 - false = c1 -- Branch { true: Expression(0, Sub), false: Counter(3) } at (prev + 0, 20) to (start + 0, 25) - true = (c2 - c3) +- Branch { true: Counter(1), false: Counter(3) } at (prev + 5, 11) to (start + 0, 16) + true = c1 false = c3 +- Branch { true: Expression(0, Sub), false: Counter(2) } at (prev + 0, 20) to (start + 0, 25) + true = (c1 - c2) + false = c2 Highest counter ID seen: c3 Function name: no_mir_spans::while_op_or diff --git a/tests/coverage/branch/while.cov-map b/tests/coverage/branch/while.cov-map index d5840a2c320b..305f6bc74d83 100644 --- a/tests/coverage/branch/while.cov-map +++ b/tests/coverage/branch/while.cov-map @@ -35,14 +35,14 @@ Number of file 0 mappings: 6 Highest counter ID seen: c2 Function name: while::while_op_and -Raw bytes (56): 0x[01, 01, 04, 05, 09, 03, 0d, 03, 0d, 11, 0d, 08, 01, 1e, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 0a, 0d, 00, 0b, 00, 10, 0a, 00, 14, 00, 19, 20, 09, 11, 00, 14, 00, 19, 09, 00, 1a, 03, 06, 0f, 04, 01, 00, 02] +Raw bytes (56): 0x[01, 01, 04, 05, 09, 03, 0d, 03, 0d, 0d, 11, 08, 01, 1e, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 0a, 0d, 00, 0b, 00, 10, 0a, 00, 14, 00, 19, 20, 09, 11, 00, 14, 00, 19, 09, 00, 1a, 03, 06, 0f, 04, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) - expression 1 operands: lhs = Expression(0, Add), rhs = Counter(3) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(4), rhs = Counter(3) +- expression 3 operands: lhs = Counter(3), rhs = Counter(4) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 30, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 9) to (start + 1, 18) @@ -58,39 +58,34 @@ Number of file 0 mappings: 8 false = c4 - Code(Counter(2)) at (prev + 0, 26) to (start + 3, 6) - Code(Expression(3, Add)) at (prev + 4, 1) to (start + 0, 2) - = (c4 + c3) + = (c3 + c4) Highest counter ID seen: c4 Function name: while::while_op_or -Raw bytes (66): 0x[01, 01, 09, 05, 1b, 09, 0d, 03, 09, 03, 09, 22, 0d, 03, 09, 09, 0d, 22, 0d, 03, 09, 08, 01, 29, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 09, 22, 00, 0b, 00, 10, 22, 00, 14, 00, 19, 20, 0d, 1e, 00, 14, 00, 19, 1b, 00, 1a, 03, 06, 1e, 04, 01, 00, 02] +Raw bytes (58): 0x[01, 01, 05, 07, 0d, 05, 09, 05, 0d, 05, 0d, 09, 0d, 08, 01, 29, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 09, 0f, 00, 0b, 00, 10, 0f, 00, 14, 00, 19, 20, 0d, 05, 00, 14, 00, 19, 13, 00, 1a, 03, 06, 05, 04, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 9 -- expression 0 operands: lhs = Counter(1), rhs = Expression(6, Add) -- expression 1 operands: lhs = Counter(2), rhs = Counter(3) -- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 4 operands: lhs = Expression(8, Sub), rhs = Counter(3) -- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(2), rhs = Counter(3) -- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(3) -- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of expressions: 5 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(3) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 41, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 9) to (start + 1, 18) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 16) - = (c1 + (c2 + c3)) -- Branch { true: Counter(2), false: Expression(8, Sub) } at (prev + 0, 11) to (start + 0, 16) + = ((c1 + c2) + c3) +- Branch { true: Counter(2), false: Expression(3, Add) } at (prev + 0, 11) to (start + 0, 16) true = c2 - false = ((c1 + (c2 + c3)) - c2) -- Code(Expression(8, Sub)) at (prev + 0, 20) to (start + 0, 25) - = ((c1 + (c2 + c3)) - c2) -- Branch { true: Counter(3), false: Expression(7, Sub) } at (prev + 0, 20) to (start + 0, 25) + false = (c1 + c3) +- Code(Expression(3, Add)) at (prev + 0, 20) to (start + 0, 25) + = (c1 + c3) +- Branch { true: Counter(3), false: Counter(1) } at (prev + 0, 20) to (start + 0, 25) true = c3 - false = (((c1 + (c2 + c3)) - c2) - c3) -- Code(Expression(6, Add)) at (prev + 0, 26) to (start + 3, 6) + false = c1 +- Code(Expression(4, Add)) at (prev + 0, 26) to (start + 3, 6) = (c2 + c3) -- Code(Expression(7, Sub)) at (prev + 4, 1) to (start + 0, 2) - = (((c1 + (c2 + c3)) - c2) - c3) +- Code(Counter(1)) at (prev + 4, 1) to (start + 0, 2) Highest counter ID seen: c3 diff --git a/tests/coverage/closure_macro.cov-map b/tests/coverage/closure_macro.cov-map index 7c9d3292f988..aedb924eca86 100644 --- a/tests/coverage/closure_macro.cov-map +++ b/tests/coverage/closure_macro.cov-map @@ -25,13 +25,13 @@ Number of file 0 mappings: 6 Highest counter ID seen: c1 Function name: closure_macro::main::{closure#0} -Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 05, 01, 10, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] +Raw bytes (35): 0x[01, 01, 03, 01, 05, 0b, 0d, 05, 09, 05, 01, 10, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 Number of expressions: 3 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 16, 28) to (start + 3, 33) - Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39) @@ -39,6 +39,6 @@ Number of file 0 mappings: 5 = (c0 - c1) - Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30) - Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c1 + (c2 + c3)) + = ((c1 + c2) + c3) Highest counter ID seen: c3 diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index e2a52e57015c..5b99889514ce 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -34,13 +34,13 @@ Number of file 0 mappings: 6 Highest counter ID seen: c1 Function name: closure_macro_async::test::{closure#0}::{closure#0} -Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 0d, 05, 01, 15, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] +Raw bytes (35): 0x[01, 01, 03, 01, 05, 0b, 0d, 05, 09, 05, 01, 15, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 0d, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 Number of expressions: 3 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 21, 28) to (start + 3, 33) - Code(Counter(1)) at (prev + 4, 17) to (start + 1, 39) @@ -48,6 +48,6 @@ Number of file 0 mappings: 5 = (c0 - c1) - Code(Counter(3)) at (prev + 0, 23) to (start + 0, 30) - Code(Expression(1, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c1 + (c2 + c3)) + = ((c1 + c2) + c3) Highest counter ID seen: c3 diff --git a/tests/coverage/condition/conditions.cov-map b/tests/coverage/condition/conditions.cov-map index 208d671919cf..72f39b88c6a9 100644 --- a/tests/coverage/condition/conditions.cov-map +++ b/tests/coverage/condition/conditions.cov-map @@ -1,29 +1,27 @@ Function name: conditions::assign_3_and_or -Raw bytes (69): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 09, 01, 1c, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 1a, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 20, 09, 16, 00, 12, 00, 13, 13, 00, 17, 00, 18, 20, 0d, 11, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (65): 0x[01, 01, 05, 07, 11, 09, 0d, 01, 05, 05, 09, 01, 09, 09, 01, 1c, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 0a, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 20, 09, 0e, 00, 12, 00, 13, 12, 00, 17, 00, 18, 20, 0d, 11, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 7 +Number of expressions: 5 - expression 0 operands: lhs = Expression(1, Add), rhs = Counter(4) - expression 1 operands: lhs = Counter(2), rhs = Counter(3) - expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Expression(6, Sub) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Counter(0), rhs = Counter(1) +- expression 4 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 28, 1) to (start + 0, 47) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = ((c2 + c3) + c4) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- Branch { true: Counter(1), false: Expression(6, Sub) } at (prev + 0, 13) to (start + 0, 14) +- Branch { true: Counter(1), false: Expression(2, Sub) } at (prev + 0, 13) to (start + 0, 14) true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) -- Branch { true: Counter(2), false: Expression(5, Sub) } at (prev + 0, 18) to (start + 0, 19) +- Branch { true: Counter(2), false: Expression(3, Sub) } at (prev + 0, 18) to (start + 0, 19) true = c2 false = (c1 - c2) -- Code(Expression(4, Add)) at (prev + 0, 23) to (start + 0, 24) - = ((c1 - c2) + (c0 - c1)) +- Code(Expression(4, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c0 - c2) - Branch { true: Counter(3), false: Counter(4) } at (prev + 0, 23) to (start + 0, 24) true = c3 false = c4 @@ -32,54 +30,54 @@ Number of file 0 mappings: 9 Highest counter ID seen: c4 Function name: conditions::assign_3_or_and -Raw bytes (73): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 09, 01, 17, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 22, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 20, 1e, 11, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 20, 09, 0d, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (73): 0x[01, 01, 09, 07, 11, 0b, 0d, 05, 09, 01, 05, 01, 05, 01, 23, 05, 11, 01, 23, 05, 11, 09, 01, 17, 01, 00, 2f, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 12, 00, 0d, 00, 0e, 12, 00, 12, 00, 13, 20, 1e, 11, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 20, 09, 0d, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 9 -- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Add) -- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(4) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(4) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) - expression 4 operands: lhs = Counter(0), rhs = Counter(1) -- expression 5 operands: lhs = Expression(8, Sub), rhs = Counter(4) -- expression 6 operands: lhs = Counter(0), rhs = Counter(1) -- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(4) -- expression 8 operands: lhs = Counter(0), rhs = Counter(1) +- expression 5 operands: lhs = Counter(0), rhs = Expression(8, Add) +- expression 6 operands: lhs = Counter(1), rhs = Counter(4) +- expression 7 operands: lhs = Counter(0), rhs = Expression(8, Add) +- expression 8 operands: lhs = Counter(1), rhs = Counter(4) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 23, 1) to (start + 0, 47) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) - = (c1 + ((c2 + c3) + c4)) + = (((c1 + c2) + c3) + c4) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) -- Branch { true: Counter(1), false: Expression(8, Sub) } at (prev + 0, 13) to (start + 0, 14) +- Branch { true: Counter(1), false: Expression(4, Sub) } at (prev + 0, 13) to (start + 0, 14) true = c1 false = (c0 - c1) -- Code(Expression(8, Sub)) at (prev + 0, 18) to (start + 0, 19) +- Code(Expression(4, Sub)) at (prev + 0, 18) to (start + 0, 19) = (c0 - c1) - Branch { true: Expression(7, Sub), false: Counter(4) } at (prev + 0, 18) to (start + 0, 19) - true = ((c0 - c1) - c4) + true = (c0 - (c1 + c4)) false = c4 - Code(Expression(7, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c0 - c1) - c4) + = (c0 - (c1 + c4)) - Branch { true: Counter(2), false: Counter(3) } at (prev + 0, 23) to (start + 0, 24) true = c2 false = c3 - Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c1 + ((c2 + c3) + c4)) + = (((c1 + c2) + c3) + c4) Highest counter ID seen: c4 Function name: conditions::assign_and -Raw bytes (51): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 07, 01, 0d, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 0e, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 20, 09, 0d, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (51): 0x[01, 01, 04, 07, 05, 0b, 0d, 01, 09, 01, 05, 07, 01, 0d, 01, 00, 21, 02, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 20, 05, 0e, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 20, 09, 0d, 00, 12, 00, 13, 02, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 -- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(3, Sub) -- expression 1 operands: lhs = Counter(2), rhs = Counter(3) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(1) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(0), rhs = Counter(2) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 13, 1) to (start + 0, 33) -- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 10) + = (((c0 + c2) + c3) - c1) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) - Branch { true: Counter(1), false: Expression(3, Sub) } at (prev + 0, 13) to (start + 0, 14) true = c1 @@ -88,8 +86,8 @@ Number of file 0 mappings: 7 - Branch { true: Counter(2), false: Counter(3) } at (prev + 0, 18) to (start + 0, 19) true = c2 false = c3 -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 1, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: conditions::assign_or @@ -128,13 +126,14 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: conditions::func_call -Raw bytes (39): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 05, 01, 25, 01, 01, 0a, 20, 05, 02, 01, 09, 00, 0a, 05, 00, 0e, 00, 0f, 20, 09, 0d, 00, 0e, 00, 0f, 07, 01, 01, 00, 02] +Raw bytes (41): 0x[01, 01, 04, 01, 05, 0b, 05, 0f, 0d, 01, 09, 05, 01, 25, 01, 01, 0a, 20, 05, 02, 01, 09, 00, 0a, 05, 00, 0e, 00, 0f, 20, 09, 0d, 00, 0e, 00, 0f, 06, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 4 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 37, 1) to (start + 1, 10) - Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 9) to (start + 0, 10) @@ -144,8 +143,8 @@ Number of file 0 mappings: 5 - Branch { true: Counter(2), false: Counter(3) } at (prev + 0, 14) to (start + 0, 15) true = c2 false = c3 -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(1, Sub)) at (prev + 1, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: conditions::simple_assign diff --git a/tests/coverage/conditions.cov-map b/tests/coverage/conditions.cov-map index 938e44040139..21b2ec9a19e0 100644 --- a/tests/coverage/conditions.cov-map +++ b/tests/coverage/conditions.cov-map @@ -1,264 +1,294 @@ Function name: conditions::main -Raw bytes (799): 0x[01, 01, 94, 01, 09, 2b, 2f, 41, 33, 3d, 35, 39, 01, 09, 0d, 35, 1e, 39, 0d, 35, 33, 3d, 35, 39, 2f, 41, 33, 3d, 35, 39, ce, 04, 0d, 01, 09, 03, 49, 62, 31, 03, 49, 5e, 4d, 62, 31, 03, 49, 5a, 51, 5e, 4d, 62, 31, 03, 49, 87, 01, 55, 4d, 51, 83, 01, 59, 87, 01, 55, 4d, 51, 49, 7f, 83, 01, 59, 87, 01, 55, 4d, 51, 5d, 65, ae, 01, 2d, 5d, 65, aa, 01, 69, ae, 01, 2d, 5d, 65, a6, 01, 6d, aa, 01, 69, ae, 01, 2d, 5d, 65, f3, 02, 71, 69, 6d, ef, 02, 75, f3, 02, 71, 69, 6d, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, e3, 02, 7d, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, de, 02, 29, e3, 02, 7d, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, da, 02, 81, 01, de, 02, 29, e3, 02, 7d, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, d6, 02, 85, 01, da, 02, 81, 01, de, 02, 29, e3, 02, 7d, e7, 02, 00, 65, eb, 02, ef, 02, 75, f3, 02, 71, 69, 6d, 8f, 04, 89, 01, 81, 01, 85, 01, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, 11, af, 04, b3, 04, 21, b7, 04, 1d, 15, 19, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, 83, 04, 11, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, fe, 03, 25, 83, 04, 11, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, fa, 03, 15, fe, 03, 25, 83, 04, 11, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, f6, 03, 19, fa, 03, 15, fe, 03, 25, 83, 04, 11, 7d, 87, 04, 8b, 04, 8d, 01, 8f, 04, 89, 01, 81, 01, 85, 01, b7, 04, 1d, 15, 19, b3, 04, 21, b7, 04, 1d, 15, 19, ab, 04, bb, 04, 11, af, 04, b3, 04, 21, b7, 04, 1d, 15, 19, bf, 04, ca, 04, c3, 04, 31, c7, 04, 2d, 25, 29, ce, 04, 0d, 01, 09, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, ce, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 1e, 00, 1d, 00, 2a, 1a, 00, 2e, 00, 3c, 2f, 00, 3d, 02, 0a, 41, 02, 09, 00, 0a, 2b, 01, 09, 01, 12, ca, 04, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 49, 00, 16, 02, 06, 62, 02, 0f, 00, 1c, 5e, 01, 0c, 00, 19, 5a, 00, 1d, 00, 2a, 56, 00, 2e, 00, 3c, 83, 01, 00, 3d, 02, 0a, 59, 02, 09, 00, 0a, 7f, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 7b, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 09, 00, 0a, 5d, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, ae, 01, 04, 11, 00, 1e, aa, 01, 01, 10, 00, 1d, a6, 01, 00, 21, 00, 2e, a2, 01, 00, 32, 00, 40, ef, 02, 00, 41, 02, 0e, 75, 02, 0d, 00, 0e, eb, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 05, 00, 06, e3, 02, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 83, 04, 02, 09, 00, 0a, e3, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, de, 02, 02, 0f, 00, 1c, da, 02, 01, 0c, 00, 19, d6, 02, 00, 1d, 00, 2a, d2, 02, 00, 2e, 00, 3c, 8b, 04, 00, 3d, 02, 0a, 8d, 01, 02, 09, 00, 0a, 87, 04, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, ab, 04, 05, 09, 00, 0a, 83, 04, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, fe, 03, 02, 0f, 00, 1c, fa, 03, 01, 0c, 00, 19, f6, 03, 00, 1d, 00, 2a, f2, 03, 00, 2e, 00, 3c, b3, 04, 00, 3d, 02, 0a, 21, 02, 09, 00, 0a, af, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, a7, 04, 02, 01, 00, 02] +Raw bytes (873): 0x[01, 01, b2, 01, 07, 19, 0b, 15, 0f, 11, 09, 0d, 01, 09, 8d, 01, 0d, 8d, 01, 33, 0d, 11, 33, 15, 0d, 11, 2f, 19, 33, 15, 0d, 11, 01, c7, 05, 09, 8d, 01, 03, 21, 03, 47, 21, 89, 01, 03, 4f, db, 03, 89, 01, 21, 25, 03, 5b, d7, 03, 89, 01, db, 03, 29, 21, 25, 77, 2d, 25, 29, 73, 31, 77, 2d, 25, 29, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, 35, 3d, 35, 93, 01, 3d, 85, 01, 35, 9b, 01, af, 01, 85, 01, 3d, 41, 35, a7, 01, ab, 01, 85, 01, af, 01, 45, 3d, 41, c3, 01, 49, 41, 45, bf, 01, 4d, c3, 01, 49, 41, 45, bb, 03, 35, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, bb, 03, 35, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, bb, 03, eb, 03, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, 35, 55, bb, 03, fb, 02, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, eb, 03, 81, 01, 35, 55, bb, 03, ab, 03, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, e7, 03, 81, 01, eb, 03, 59, 35, 55, bb, 03, df, 03, bf, 03, 4d, c3, 03, 49, c7, 03, 45, cb, 03, 41, cf, 03, 3d, d3, 03, 31, d7, 03, 2d, db, 03, 29, 21, 25, e3, 03, 81, 01, e7, 03, 5d, eb, 03, 59, 35, 55, ff, 03, 61, 59, 5d, fb, 03, 65, ff, 03, 61, 59, 5d, 87, 04, 79, 83, 05, 75, 87, 05, 71, 69, 6d, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, ef, 04, 69, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, ef, 04, cb, 04, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, 69, 7d, ef, 04, e3, 04, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, 87, 05, 7d, 69, 6d, ef, 04, ff, 04, f3, 04, 65, f7, 04, 61, fb, 04, 5d, 55, 59, 83, 05, 7d, 87, 05, 71, 69, 6d, 9b, 05, 75, 6d, 71, 97, 05, 79, 9b, 05, 75, 6d, 71, a3, 05, c7, 05, a7, 05, 89, 01, ab, 05, 85, 01, af, 05, 81, 01, b3, 05, 7d, b7, 05, 79, bb, 05, 75, bf, 05, 71, c3, 05, 6d, 01, 69, 09, 8d, 01, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, 12, 02, 0f, 00, 1c, 8d, 01, 01, 0c, 00, 19, 16, 00, 1d, 00, 2a, 1a, 00, 2e, 00, 3c, 2f, 00, 3d, 02, 0a, 19, 02, 09, 00, 0a, 2b, 01, 09, 01, 12, 36, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 1d, 01, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 21, 00, 16, 02, 06, 3e, 02, 0f, 00, 1c, 42, 01, 0c, 00, 19, 4a, 00, 1d, 00, 2a, 56, 00, 2e, 00, 3c, 73, 00, 3d, 02, 0a, 31, 02, 09, 00, 0a, 6f, 01, 09, 00, 17, 89, 01, 02, 09, 00, 0f, cf, 03, 03, 08, 00, 0c, 35, 01, 0d, 01, 10, 39, 01, 11, 02, 0a, 00, 02, 09, 00, 0a, 35, 02, 0c, 00, 19, 3d, 00, 1a, 02, 0a, 8a, 01, 04, 11, 00, 1e, 8e, 01, 01, 10, 00, 1d, 96, 01, 00, 21, 00, 2e, a2, 01, 00, 32, 00, 40, bf, 01, 00, 41, 02, 0e, 4d, 02, 0d, 00, 0e, bb, 01, 01, 0d, 00, 1b, 85, 01, 02, 0d, 00, 13, 00, 02, 05, 00, 06, fe, 01, 02, 09, 01, 0c, 51, 01, 0d, 02, 06, 00, 02, 05, 00, 06, ef, 04, 02, 09, 00, 0a, fe, 01, 00, 10, 00, 1d, 55, 00, 1e, 02, 06, a6, 02, 02, 0f, 00, 1c, d2, 02, 01, 0c, 00, 19, 82, 03, 00, 1d, 00, 2a, b6, 03, 00, 2e, 00, 3c, fb, 03, 00, 3d, 02, 0a, 65, 02, 09, 00, 0a, f7, 03, 01, 09, 00, 17, 81, 01, 02, 0d, 02, 0f, 83, 04, 05, 09, 00, 0a, ef, 04, 00, 10, 00, 1d, 69, 00, 1e, 02, 06, a2, 04, 02, 0f, 00, 1c, b6, 04, 01, 0c, 00, 19, ce, 04, 00, 1d, 00, 2a, ea, 04, 00, 2e, 00, 3c, 97, 05, 00, 3d, 02, 0a, 79, 02, 09, 00, 0a, 93, 05, 01, 09, 00, 17, 7d, 02, 09, 00, 0f, 9e, 05, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 148 -- expression 0 operands: lhs = Counter(2), rhs = Expression(10, Add) -- expression 1 operands: lhs = Expression(11, Add), rhs = Counter(16) -- expression 2 operands: lhs = Expression(12, Add), rhs = Counter(15) -- expression 3 operands: lhs = Counter(13), rhs = Counter(14) +Number of expressions: 178 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(6) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(5) +- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(4) +- expression 3 operands: lhs = Counter(2), rhs = Counter(3) - expression 4 operands: lhs = Counter(0), rhs = Counter(2) -- expression 5 operands: lhs = Counter(3), rhs = Counter(13) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(14) -- expression 7 operands: lhs = Counter(3), rhs = Counter(13) -- expression 8 operands: lhs = Expression(12, Add), rhs = Counter(15) -- expression 9 operands: lhs = Counter(13), rhs = Counter(14) -- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(16) -- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(15) -- expression 12 operands: lhs = Counter(13), rhs = Counter(14) -- expression 13 operands: lhs = Expression(147, Sub), rhs = Counter(3) -- expression 14 operands: lhs = Counter(0), rhs = Counter(2) -- expression 15 operands: lhs = Expression(0, Add), rhs = Counter(18) -- expression 16 operands: lhs = Expression(24, Sub), rhs = Counter(12) -- expression 17 operands: lhs = Expression(0, Add), rhs = Counter(18) -- expression 18 operands: lhs = Expression(23, Sub), rhs = Counter(19) -- expression 19 operands: lhs = Expression(24, Sub), rhs = Counter(12) -- expression 20 operands: lhs = Expression(0, Add), rhs = Counter(18) -- expression 21 operands: lhs = Expression(22, Sub), rhs = Counter(20) -- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(19) -- expression 23 operands: lhs = Expression(24, Sub), rhs = Counter(12) -- expression 24 operands: lhs = Expression(0, Add), rhs = Counter(18) -- expression 25 operands: lhs = Expression(33, Add), rhs = Counter(21) -- expression 26 operands: lhs = Counter(19), rhs = Counter(20) -- expression 27 operands: lhs = Expression(32, Add), rhs = Counter(22) -- expression 28 operands: lhs = Expression(33, Add), rhs = Counter(21) -- expression 29 operands: lhs = Counter(19), rhs = Counter(20) -- expression 30 operands: lhs = Counter(18), rhs = Expression(31, Add) -- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(22) -- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(21) -- expression 33 operands: lhs = Counter(19), rhs = Counter(20) -- expression 34 operands: lhs = Counter(23), rhs = Counter(25) -- expression 35 operands: lhs = Expression(43, Sub), rhs = Counter(11) -- expression 36 operands: lhs = Counter(23), rhs = Counter(25) -- expression 37 operands: lhs = Expression(42, Sub), rhs = Counter(26) -- expression 38 operands: lhs = Expression(43, Sub), rhs = Counter(11) -- expression 39 operands: lhs = Counter(23), rhs = Counter(25) -- expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(27) -- expression 41 operands: lhs = Expression(42, Sub), rhs = Counter(26) -- expression 42 operands: lhs = Expression(43, Sub), rhs = Counter(11) -- expression 43 operands: lhs = Counter(23), rhs = Counter(25) -- expression 44 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 45 operands: lhs = Counter(26), rhs = Counter(27) -- expression 46 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 47 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 48 operands: lhs = Counter(26), rhs = Counter(27) -- expression 49 operands: lhs = Expression(89, Add), rhs = Zero -- expression 50 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 51 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 52 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 53 operands: lhs = Counter(26), rhs = Counter(27) -- expression 54 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 55 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 56 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 57 operands: lhs = Counter(32), rhs = Counter(33) -- expression 58 operands: lhs = Expression(89, Add), rhs = Zero -- expression 59 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 60 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 61 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 62 operands: lhs = Counter(26), rhs = Counter(27) -- expression 63 operands: lhs = Expression(88, Add), rhs = Counter(31) -- expression 64 operands: lhs = Expression(89, Add), rhs = Zero -- expression 65 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 66 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 67 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 68 operands: lhs = Counter(26), rhs = Counter(27) -- expression 69 operands: lhs = Expression(87, Sub), rhs = Counter(10) -- expression 70 operands: lhs = Expression(88, Add), rhs = Counter(31) -- expression 71 operands: lhs = Expression(89, Add), rhs = Zero -- expression 72 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 73 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 74 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 75 operands: lhs = Counter(26), rhs = Counter(27) -- expression 76 operands: lhs = Expression(86, Sub), rhs = Counter(32) -- expression 77 operands: lhs = Expression(87, Sub), rhs = Counter(10) -- expression 78 operands: lhs = Expression(88, Add), rhs = Counter(31) -- expression 79 operands: lhs = Expression(89, Add), rhs = Zero -- expression 80 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 81 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 82 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 83 operands: lhs = Counter(26), rhs = Counter(27) -- expression 84 operands: lhs = Expression(85, Sub), rhs = Counter(33) -- expression 85 operands: lhs = Expression(86, Sub), rhs = Counter(32) -- expression 86 operands: lhs = Expression(87, Sub), rhs = Counter(10) -- expression 87 operands: lhs = Expression(88, Add), rhs = Counter(31) -- expression 88 operands: lhs = Expression(89, Add), rhs = Zero -- expression 89 operands: lhs = Counter(25), rhs = Expression(90, Add) -- expression 90 operands: lhs = Expression(91, Add), rhs = Counter(29) -- expression 91 operands: lhs = Expression(92, Add), rhs = Counter(28) -- expression 92 operands: lhs = Counter(26), rhs = Counter(27) -- expression 93 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 94 operands: lhs = Counter(32), rhs = Counter(33) -- expression 95 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 96 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 97 operands: lhs = Counter(32), rhs = Counter(33) -- expression 98 operands: lhs = Counter(4), rhs = Expression(139, Add) -- expression 99 operands: lhs = Expression(140, Add), rhs = Counter(8) -- expression 100 operands: lhs = Expression(141, Add), rhs = Counter(7) -- expression 101 operands: lhs = Counter(5), rhs = Counter(6) -- expression 102 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 103 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 104 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 105 operands: lhs = Counter(32), rhs = Counter(33) -- expression 106 operands: lhs = Expression(128, Add), rhs = Counter(4) -- expression 107 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 108 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 109 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 110 operands: lhs = Counter(32), rhs = Counter(33) -- expression 111 operands: lhs = Expression(127, Sub), rhs = Counter(9) -- expression 112 operands: lhs = Expression(128, Add), rhs = Counter(4) -- expression 113 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 114 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 115 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 116 operands: lhs = Counter(32), rhs = Counter(33) -- expression 117 operands: lhs = Expression(126, Sub), rhs = Counter(5) -- expression 118 operands: lhs = Expression(127, Sub), rhs = Counter(9) -- expression 119 operands: lhs = Expression(128, Add), rhs = Counter(4) -- expression 120 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 121 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 122 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 123 operands: lhs = Counter(32), rhs = Counter(33) -- expression 124 operands: lhs = Expression(125, Sub), rhs = Counter(6) -- expression 125 operands: lhs = Expression(126, Sub), rhs = Counter(5) -- expression 126 operands: lhs = Expression(127, Sub), rhs = Counter(9) -- expression 127 operands: lhs = Expression(128, Add), rhs = Counter(4) -- expression 128 operands: lhs = Counter(31), rhs = Expression(129, Add) -- expression 129 operands: lhs = Expression(130, Add), rhs = Counter(35) -- expression 130 operands: lhs = Expression(131, Add), rhs = Counter(34) -- expression 131 operands: lhs = Counter(32), rhs = Counter(33) -- expression 132 operands: lhs = Expression(141, Add), rhs = Counter(7) -- expression 133 operands: lhs = Counter(5), rhs = Counter(6) -- expression 134 operands: lhs = Expression(140, Add), rhs = Counter(8) -- expression 135 operands: lhs = Expression(141, Add), rhs = Counter(7) -- expression 136 operands: lhs = Counter(5), rhs = Counter(6) -- expression 137 operands: lhs = Expression(138, Add), rhs = Expression(142, Add) -- expression 138 operands: lhs = Counter(4), rhs = Expression(139, Add) -- expression 139 operands: lhs = Expression(140, Add), rhs = Counter(8) -- expression 140 operands: lhs = Expression(141, Add), rhs = Counter(7) -- expression 141 operands: lhs = Counter(5), rhs = Counter(6) -- expression 142 operands: lhs = Expression(143, Add), rhs = Expression(146, Sub) -- expression 143 operands: lhs = Expression(144, Add), rhs = Counter(12) -- expression 144 operands: lhs = Expression(145, Add), rhs = Counter(11) -- expression 145 operands: lhs = Counter(9), rhs = Counter(10) -- expression 146 operands: lhs = Expression(147, Sub), rhs = Counter(3) -- expression 147 operands: lhs = Counter(0), rhs = Counter(2) +- expression 5 operands: lhs = Counter(35), rhs = Counter(3) +- expression 6 operands: lhs = Counter(35), rhs = Expression(12, Add) +- expression 7 operands: lhs = Counter(3), rhs = Counter(4) +- expression 8 operands: lhs = Expression(12, Add), rhs = Counter(5) +- expression 9 operands: lhs = Counter(3), rhs = Counter(4) +- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(6) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(5) +- expression 12 operands: lhs = Counter(3), rhs = Counter(4) +- expression 13 operands: lhs = Counter(0), rhs = Expression(177, Add) +- expression 14 operands: lhs = Counter(2), rhs = Counter(35) +- expression 15 operands: lhs = Expression(0, Add), rhs = Counter(8) +- expression 16 operands: lhs = Expression(0, Add), rhs = Expression(17, Add) +- expression 17 operands: lhs = Counter(8), rhs = Counter(34) +- expression 18 operands: lhs = Expression(0, Add), rhs = Expression(19, Add) +- expression 19 operands: lhs = Expression(118, Add), rhs = Counter(34) +- expression 20 operands: lhs = Counter(8), rhs = Counter(9) +- expression 21 operands: lhs = Expression(0, Add), rhs = Expression(22, Add) +- expression 22 operands: lhs = Expression(117, Add), rhs = Counter(34) +- expression 23 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 24 operands: lhs = Counter(8), rhs = Counter(9) +- expression 25 operands: lhs = Expression(29, Add), rhs = Counter(11) +- expression 26 operands: lhs = Counter(9), rhs = Counter(10) +- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(12) +- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(11) +- expression 29 operands: lhs = Counter(9), rhs = Counter(10) +- expression 30 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 31 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 32 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 33 operands: lhs = Counter(8), rhs = Counter(9) +- expression 34 operands: lhs = Counter(13), rhs = Counter(15) +- expression 35 operands: lhs = Counter(13), rhs = Expression(36, Add) +- expression 36 operands: lhs = Counter(15), rhs = Counter(33) +- expression 37 operands: lhs = Counter(13), rhs = Expression(38, Add) +- expression 38 operands: lhs = Expression(43, Add), rhs = Counter(33) +- expression 39 operands: lhs = Counter(15), rhs = Counter(16) +- expression 40 operands: lhs = Counter(13), rhs = Expression(41, Add) +- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(33) +- expression 42 operands: lhs = Expression(43, Add), rhs = Counter(17) +- expression 43 operands: lhs = Counter(15), rhs = Counter(16) +- expression 44 operands: lhs = Expression(48, Add), rhs = Counter(18) +- expression 45 operands: lhs = Counter(16), rhs = Counter(17) +- expression 46 operands: lhs = Expression(47, Add), rhs = Counter(19) +- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(18) +- expression 48 operands: lhs = Counter(16), rhs = Counter(17) +- expression 49 operands: lhs = Expression(110, Add), rhs = Counter(13) +- expression 50 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 51 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 52 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 53 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 54 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 55 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 56 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 57 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 58 operands: lhs = Counter(8), rhs = Counter(9) +- expression 59 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 60 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 61 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 62 operands: lhs = Counter(21), rhs = Counter(22) +- expression 63 operands: lhs = Expression(110, Add), rhs = Counter(13) +- expression 64 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 65 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 66 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 67 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 68 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 69 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 70 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 71 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 72 operands: lhs = Counter(8), rhs = Counter(9) +- expression 73 operands: lhs = Expression(110, Add), rhs = Expression(122, Add) +- expression 74 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 75 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 76 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 77 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 78 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 79 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 80 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 81 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 82 operands: lhs = Counter(8), rhs = Counter(9) +- expression 83 operands: lhs = Counter(13), rhs = Counter(21) +- expression 84 operands: lhs = Expression(110, Add), rhs = Expression(94, Add) +- expression 85 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 86 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 87 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 88 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 89 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 90 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 91 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 92 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 93 operands: lhs = Counter(8), rhs = Counter(9) +- expression 94 operands: lhs = Expression(122, Add), rhs = Counter(32) +- expression 95 operands: lhs = Counter(13), rhs = Counter(21) +- expression 96 operands: lhs = Expression(110, Add), rhs = Expression(106, Add) +- expression 97 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 98 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 99 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 100 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 101 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 102 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 103 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 104 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 105 operands: lhs = Counter(8), rhs = Counter(9) +- expression 106 operands: lhs = Expression(121, Add), rhs = Counter(32) +- expression 107 operands: lhs = Expression(122, Add), rhs = Counter(22) +- expression 108 operands: lhs = Counter(13), rhs = Counter(21) +- expression 109 operands: lhs = Expression(110, Add), rhs = Expression(119, Add) +- expression 110 operands: lhs = Expression(111, Add), rhs = Counter(19) +- expression 111 operands: lhs = Expression(112, Add), rhs = Counter(18) +- expression 112 operands: lhs = Expression(113, Add), rhs = Counter(17) +- expression 113 operands: lhs = Expression(114, Add), rhs = Counter(16) +- expression 114 operands: lhs = Expression(115, Add), rhs = Counter(15) +- expression 115 operands: lhs = Expression(116, Add), rhs = Counter(12) +- expression 116 operands: lhs = Expression(117, Add), rhs = Counter(11) +- expression 117 operands: lhs = Expression(118, Add), rhs = Counter(10) +- expression 118 operands: lhs = Counter(8), rhs = Counter(9) +- expression 119 operands: lhs = Expression(120, Add), rhs = Counter(32) +- expression 120 operands: lhs = Expression(121, Add), rhs = Counter(23) +- expression 121 operands: lhs = Expression(122, Add), rhs = Counter(22) +- expression 122 operands: lhs = Counter(13), rhs = Counter(21) +- expression 123 operands: lhs = Expression(127, Add), rhs = Counter(24) +- expression 124 operands: lhs = Counter(22), rhs = Counter(23) +- expression 125 operands: lhs = Expression(126, Add), rhs = Counter(25) +- expression 126 operands: lhs = Expression(127, Add), rhs = Counter(24) +- expression 127 operands: lhs = Counter(22), rhs = Counter(23) +- expression 128 operands: lhs = Expression(129, Add), rhs = Counter(30) +- expression 129 operands: lhs = Expression(160, Add), rhs = Counter(29) +- expression 130 operands: lhs = Expression(161, Add), rhs = Counter(28) +- expression 131 operands: lhs = Counter(26), rhs = Counter(27) +- expression 132 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 133 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 134 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 135 operands: lhs = Counter(21), rhs = Counter(22) +- expression 136 operands: lhs = Expression(155, Add), rhs = Counter(26) +- expression 137 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 138 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 139 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 140 operands: lhs = Counter(21), rhs = Counter(22) +- expression 141 operands: lhs = Expression(155, Add), rhs = Expression(146, Add) +- expression 142 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 143 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 144 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 145 operands: lhs = Counter(21), rhs = Counter(22) +- expression 146 operands: lhs = Counter(26), rhs = Counter(31) +- expression 147 operands: lhs = Expression(155, Add), rhs = Expression(152, Add) +- expression 148 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 149 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 150 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 151 operands: lhs = Counter(21), rhs = Counter(22) +- expression 152 operands: lhs = Expression(161, Add), rhs = Counter(31) +- expression 153 operands: lhs = Counter(26), rhs = Counter(27) +- expression 154 operands: lhs = Expression(155, Add), rhs = Expression(159, Add) +- expression 155 operands: lhs = Expression(156, Add), rhs = Counter(25) +- expression 156 operands: lhs = Expression(157, Add), rhs = Counter(24) +- expression 157 operands: lhs = Expression(158, Add), rhs = Counter(23) +- expression 158 operands: lhs = Counter(21), rhs = Counter(22) +- expression 159 operands: lhs = Expression(160, Add), rhs = Counter(31) +- expression 160 operands: lhs = Expression(161, Add), rhs = Counter(28) +- expression 161 operands: lhs = Counter(26), rhs = Counter(27) +- expression 162 operands: lhs = Expression(166, Add), rhs = Counter(29) +- expression 163 operands: lhs = Counter(27), rhs = Counter(28) +- expression 164 operands: lhs = Expression(165, Add), rhs = Counter(30) +- expression 165 operands: lhs = Expression(166, Add), rhs = Counter(29) +- expression 166 operands: lhs = Counter(27), rhs = Counter(28) +- expression 167 operands: lhs = Expression(168, Add), rhs = Expression(177, Add) +- expression 168 operands: lhs = Expression(169, Add), rhs = Counter(34) +- expression 169 operands: lhs = Expression(170, Add), rhs = Counter(33) +- expression 170 operands: lhs = Expression(171, Add), rhs = Counter(32) +- expression 171 operands: lhs = Expression(172, Add), rhs = Counter(31) +- expression 172 operands: lhs = Expression(173, Add), rhs = Counter(30) +- expression 173 operands: lhs = Expression(174, Add), rhs = Counter(29) +- expression 174 operands: lhs = Expression(175, Add), rhs = Counter(28) +- expression 175 operands: lhs = Expression(176, Add), rhs = Counter(27) +- expression 176 operands: lhs = Counter(0), rhs = Counter(26) +- expression 177 operands: lhs = Counter(2), rhs = Counter(35) Number of file 0 mappings: 68 - Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12) - Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 0, 10) - = (c2 + (((c13 + c14) + c15) + c16)) + = ((((c2 + c3) + c4) + c5) + c6) - Code(Counter(0)) at (prev + 0, 16) to (start + 0, 29) - Code(Counter(2)) at (prev + 1, 9) to (start + 1, 10) -- Code(Expression(147, Sub)) at (prev + 2, 15) to (start + 0, 28) +- Code(Expression(4, Sub)) at (prev + 2, 15) to (start + 0, 28) = (c0 - c2) -- Code(Counter(3)) at (prev + 1, 12) to (start + 0, 25) -- Code(Expression(7, Sub)) at (prev + 0, 29) to (start + 0, 42) - = (c3 - c13) +- Code(Counter(35)) at (prev + 1, 12) to (start + 0, 25) +- Code(Expression(5, Sub)) at (prev + 0, 29) to (start + 0, 42) + = (c35 - c3) - Code(Expression(6, Sub)) at (prev + 0, 46) to (start + 0, 60) - = ((c3 - c13) - c14) + = (c35 - (c3 + c4)) - Code(Expression(11, Add)) at (prev + 0, 61) to (start + 2, 10) - = ((c13 + c14) + c15) -- Code(Counter(16)) at (prev + 2, 9) to (start + 0, 10) + = ((c3 + c4) + c5) +- Code(Counter(6)) at (prev + 2, 9) to (start + 0, 10) - Code(Expression(10, Add)) at (prev + 1, 9) to (start + 1, 18) - = (((c13 + c14) + c15) + c16) -- Code(Expression(146, Sub)) at (prev + 3, 9) to (start + 0, 15) - = ((c0 - c2) - c3) + = (((c3 + c4) + c5) + c6) +- Code(Expression(13, Sub)) at (prev + 3, 9) to (start + 0, 15) + = (c0 - (c2 + c35)) - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 1, 12) - = (c2 + (((c13 + c14) + c15) + c16)) -- Code(Counter(17)) at (prev + 1, 13) to (start + 2, 6) + = ((((c2 + c3) + c4) + c5) + c6) +- Code(Counter(7)) at (prev + 1, 13) to (start + 2, 6) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) - Code(Expression(0, Add)) at (prev + 2, 8) to (start + 0, 21) - = (c2 + (((c13 + c14) + c15) + c16)) -- Code(Counter(18)) at (prev + 0, 22) to (start + 2, 6) -- Code(Expression(24, Sub)) at (prev + 2, 15) to (start + 0, 28) - = ((c2 + (((c13 + c14) + c15) + c16)) - c18) -- Code(Expression(23, Sub)) at (prev + 1, 12) to (start + 0, 25) - = (((c2 + (((c13 + c14) + c15) + c16)) - c18) - c12) -- Code(Expression(22, Sub)) at (prev + 0, 29) to (start + 0, 42) - = ((((c2 + (((c13 + c14) + c15) + c16)) - c18) - c12) - c19) + = ((((c2 + c3) + c4) + c5) + c6) +- Code(Counter(8)) at (prev + 0, 22) to (start + 2, 6) +- Code(Expression(15, Sub)) at (prev + 2, 15) to (start + 0, 28) + = (((((c2 + c3) + c4) + c5) + c6) - c8) +- Code(Expression(16, Sub)) at (prev + 1, 12) to (start + 0, 25) + = (((((c2 + c3) + c4) + c5) + c6) - (c8 + c34)) +- Code(Expression(18, Sub)) at (prev + 0, 29) to (start + 0, 42) + = (((((c2 + c3) + c4) + c5) + c6) - ((c8 + c9) + c34)) - Code(Expression(21, Sub)) at (prev + 0, 46) to (start + 0, 60) - = (((((c2 + (((c13 + c14) + c15) + c16)) - c18) - c12) - c19) - c20) -- Code(Expression(32, Add)) at (prev + 0, 61) to (start + 2, 10) - = ((c19 + c20) + c21) -- Code(Counter(22)) at (prev + 2, 9) to (start + 0, 10) -- Code(Expression(31, Add)) at (prev + 1, 9) to (start + 0, 23) - = (((c19 + c20) + c21) + c22) -- Code(Counter(12)) at (prev + 2, 9) to (start + 0, 15) -- Code(Expression(30, Add)) at (prev + 3, 8) to (start + 0, 12) - = (c18 + (((c19 + c20) + c21) + c22)) -- Code(Counter(23)) at (prev + 1, 13) to (start + 1, 16) -- Code(Counter(24)) at (prev + 1, 17) to (start + 2, 10) + = (((((c2 + c3) + c4) + c5) + c6) - (((c8 + c9) + c10) + c34)) +- Code(Expression(28, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c9 + c10) + c11) +- Code(Counter(12)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(27, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c9 + c10) + c11) + c12) +- Code(Counter(34)) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(115, Add)) at (prev + 3, 8) to (start + 0, 12) + = ((((c8 + c9) + c10) + c11) + c12) +- Code(Counter(13)) at (prev + 1, 13) to (start + 1, 16) +- Code(Counter(14)) at (prev + 1, 17) to (start + 2, 10) - Code(Zero) at (prev + 2, 9) to (start + 0, 10) -- Code(Counter(23)) at (prev + 2, 12) to (start + 0, 25) -- Code(Counter(25)) at (prev + 0, 26) to (start + 2, 10) -- Code(Expression(43, Sub)) at (prev + 4, 17) to (start + 0, 30) - = (c23 - c25) -- Code(Expression(42, Sub)) at (prev + 1, 16) to (start + 0, 29) - = ((c23 - c25) - c11) -- Code(Expression(41, Sub)) at (prev + 0, 33) to (start + 0, 46) - = (((c23 - c25) - c11) - c26) +- Code(Counter(13)) at (prev + 2, 12) to (start + 0, 25) +- Code(Counter(15)) at (prev + 0, 26) to (start + 2, 10) +- Code(Expression(34, Sub)) at (prev + 4, 17) to (start + 0, 30) + = (c13 - c15) +- Code(Expression(35, Sub)) at (prev + 1, 16) to (start + 0, 29) + = (c13 - (c15 + c33)) +- Code(Expression(37, Sub)) at (prev + 0, 33) to (start + 0, 46) + = (c13 - ((c15 + c16) + c33)) - Code(Expression(40, Sub)) at (prev + 0, 50) to (start + 0, 64) - = ((((c23 - c25) - c11) - c26) - c27) -- Code(Expression(91, Add)) at (prev + 0, 65) to (start + 2, 14) - = ((c26 + c27) + c28) -- Code(Counter(29)) at (prev + 2, 13) to (start + 0, 14) -- Code(Expression(90, Add)) at (prev + 1, 13) to (start + 0, 27) - = (((c26 + c27) + c28) + c29) -- Code(Counter(11)) at (prev + 2, 13) to (start + 0, 19) + = (c13 - (((c15 + c16) + c17) + c33)) +- Code(Expression(47, Add)) at (prev + 0, 65) to (start + 2, 14) + = ((c16 + c17) + c18) +- Code(Counter(19)) at (prev + 2, 13) to (start + 0, 14) +- Code(Expression(46, Add)) at (prev + 1, 13) to (start + 0, 27) + = (((c16 + c17) + c18) + c19) +- Code(Counter(33)) at (prev + 2, 13) to (start + 0, 19) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) -- Code(Expression(88, Add)) at (prev + 2, 9) to (start + 1, 12) - = ((c25 + (((c26 + c27) + c28) + c29)) + Zero) -- Code(Counter(30)) at (prev + 1, 13) to (start + 2, 6) +- Code(Expression(63, Sub)) at (prev + 2, 9) to (start + 1, 12) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - c13) +- Code(Counter(20)) at (prev + 1, 13) to (start + 2, 6) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) -- Code(Expression(128, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c31 + (((c32 + c33) + c34) + c35)) -- Code(Expression(88, Add)) at (prev + 0, 16) to (start + 0, 29) - = ((c25 + (((c26 + c27) + c28) + c29)) + Zero) -- Code(Counter(31)) at (prev + 0, 30) to (start + 2, 6) -- Code(Expression(87, Sub)) at (prev + 2, 15) to (start + 0, 28) - = (((c25 + (((c26 + c27) + c28) + c29)) + Zero) - c31) -- Code(Expression(86, Sub)) at (prev + 1, 12) to (start + 0, 25) - = ((((c25 + (((c26 + c27) + c28) + c29)) + Zero) - c31) - c10) -- Code(Expression(85, Sub)) at (prev + 0, 29) to (start + 0, 42) - = (((((c25 + (((c26 + c27) + c28) + c29)) + Zero) - c31) - c10) - c32) -- Code(Expression(84, Sub)) at (prev + 0, 46) to (start + 0, 60) - = ((((((c25 + (((c26 + c27) + c28) + c29)) + Zero) - c31) - c10) - c32) - c33) -- Code(Expression(130, Add)) at (prev + 0, 61) to (start + 2, 10) - = ((c32 + c33) + c34) -- Code(Counter(35)) at (prev + 2, 9) to (start + 0, 10) -- Code(Expression(129, Add)) at (prev + 1, 9) to (start + 0, 23) - = (((c32 + c33) + c34) + c35) -- Code(Counter(10)) at (prev + 2, 13) to (start + 2, 15) -- Code(Expression(138, Add)) at (prev + 5, 9) to (start + 0, 10) - = (c4 + (((c5 + c6) + c7) + c8)) -- Code(Expression(128, Add)) at (prev + 0, 16) to (start + 0, 29) - = (c31 + (((c32 + c33) + c34) + c35)) -- Code(Counter(4)) at (prev + 0, 30) to (start + 2, 6) -- Code(Expression(127, Sub)) at (prev + 2, 15) to (start + 0, 28) - = ((c31 + (((c32 + c33) + c34) + c35)) - c4) -- Code(Expression(126, Sub)) at (prev + 1, 12) to (start + 0, 25) - = (((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) -- Code(Expression(125, Sub)) at (prev + 0, 29) to (start + 0, 42) - = ((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) -- Code(Expression(124, Sub)) at (prev + 0, 46) to (start + 0, 60) - = (((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) - c6) -- Code(Expression(140, Add)) at (prev + 0, 61) to (start + 2, 10) - = ((c5 + c6) + c7) -- Code(Counter(8)) at (prev + 2, 9) to (start + 0, 10) -- Code(Expression(139, Add)) at (prev + 1, 9) to (start + 0, 23) - = (((c5 + c6) + c7) + c8) -- Code(Counter(9)) at (prev + 2, 9) to (start + 0, 15) -- Code(Expression(137, Add)) at (prev + 2, 1) to (start + 0, 2) - = ((c4 + (((c5 + c6) + c7) + c8)) + ((((c9 + c10) + c11) + c12) + ((c0 - c2) - c3))) +- Code(Expression(155, Add)) at (prev + 2, 9) to (start + 0, 10) + = ((((c21 + c22) + c23) + c24) + c25) +- Code(Expression(63, Sub)) at (prev + 0, 16) to (start + 0, 29) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - c13) +- Code(Counter(21)) at (prev + 0, 30) to (start + 2, 6) +- Code(Expression(73, Sub)) at (prev + 2, 15) to (start + 0, 28) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - (c13 + c21)) +- Code(Expression(84, Sub)) at (prev + 1, 12) to (start + 0, 25) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - ((c13 + c21) + c32)) +- Code(Expression(96, Sub)) at (prev + 0, 29) to (start + 0, 42) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - (((c13 + c21) + c22) + c32)) +- Code(Expression(109, Sub)) at (prev + 0, 46) to (start + 0, 60) + = ((((((((((c8 + c9) + c10) + c11) + c12) + c15) + c16) + c17) + c18) + c19) - ((((c13 + c21) + c22) + c23) + c32)) +- Code(Expression(126, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c22 + c23) + c24) +- Code(Counter(25)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(125, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c22 + c23) + c24) + c25) +- Code(Counter(32)) at (prev + 2, 13) to (start + 2, 15) +- Code(Expression(128, Add)) at (prev + 5, 9) to (start + 0, 10) + = ((((c26 + c27) + c28) + c29) + c30) +- Code(Expression(155, Add)) at (prev + 0, 16) to (start + 0, 29) + = ((((c21 + c22) + c23) + c24) + c25) +- Code(Counter(26)) at (prev + 0, 30) to (start + 2, 6) +- Code(Expression(136, Sub)) at (prev + 2, 15) to (start + 0, 28) + = (((((c21 + c22) + c23) + c24) + c25) - c26) +- Code(Expression(141, Sub)) at (prev + 1, 12) to (start + 0, 25) + = (((((c21 + c22) + c23) + c24) + c25) - (c26 + c31)) +- Code(Expression(147, Sub)) at (prev + 0, 29) to (start + 0, 42) + = (((((c21 + c22) + c23) + c24) + c25) - ((c26 + c27) + c31)) +- Code(Expression(154, Sub)) at (prev + 0, 46) to (start + 0, 60) + = (((((c21 + c22) + c23) + c24) + c25) - (((c26 + c27) + c28) + c31)) +- Code(Expression(165, Add)) at (prev + 0, 61) to (start + 2, 10) + = ((c27 + c28) + c29) +- Code(Counter(30)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(164, Add)) at (prev + 1, 9) to (start + 0, 23) + = (((c27 + c28) + c29) + c30) +- Code(Counter(31)) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(167, Sub)) at (prev + 2, 1) to (start + 0, 2) + = ((((((((((c0 + c26) + c27) + c28) + c29) + c30) + c31) + c32) + c33) + c34) - (c2 + c35)) Highest counter ID seen: c35 diff --git a/tests/coverage/continue.cov-map b/tests/coverage/continue.cov-map index 7781d2d2544c..55313d7db49e 100644 --- a/tests/coverage/continue.cov-map +++ b/tests/coverage/continue.cov-map @@ -1,5 +1,5 @@ Function name: continue::main -Raw bytes (210): 0x[01, 01, 1c, 07, 09, 01, 05, 03, 0d, 1f, 15, 0d, 11, 1b, 19, 1f, 15, 0d, 11, 33, 21, 19, 1d, 2f, 25, 33, 21, 19, 1d, 47, 2d, 25, 29, 43, 31, 47, 2d, 25, 29, 31, 5f, 35, 39, 57, 3d, 31, 5f, 35, 39, 35, 39, 3d, 41, 6b, 45, 3d, 41, 49, 45, 1e, 01, 03, 01, 03, 12, 03, 04, 0e, 00, 13, 0a, 01, 0f, 00, 16, 05, 02, 11, 00, 19, 09, 02, 12, 04, 0e, 1b, 06, 0e, 00, 13, 16, 01, 0f, 00, 16, 15, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 15, 03, 09, 00, 0e, 2f, 02, 0e, 00, 13, 2a, 01, 0f, 00, 16, 1d, 01, 15, 02, 0e, 21, 04, 11, 00, 19, 1d, 03, 09, 00, 0e, 43, 02, 0e, 00, 13, 3e, 01, 0c, 00, 13, 29, 01, 0d, 00, 15, 2d, 01, 0a, 01, 0e, 57, 03, 0e, 00, 13, 52, 01, 0f, 00, 16, 39, 01, 16, 02, 0e, 35, 03, 12, 02, 0e, 5f, 04, 09, 00, 0e, 6b, 02, 0e, 00, 13, 66, 01, 0f, 00, 16, 41, 01, 16, 02, 0e, 49, 04, 11, 00, 16, 41, 03, 09, 00, 0e, 6f, 02, 0d, 01, 02] +Raw bytes (210): 0x[01, 01, 1c, 07, 09, 01, 05, 03, 0d, 1f, 15, 0d, 11, 1b, 19, 1f, 15, 0d, 11, 33, 21, 19, 1d, 2f, 25, 33, 21, 19, 1d, 47, 2d, 25, 29, 43, 31, 47, 2d, 25, 29, 5b, 39, 31, 35, 57, 3d, 5b, 39, 31, 35, 35, 39, 3d, 41, 6b, 45, 3d, 41, 45, 49, 1e, 01, 03, 01, 03, 12, 03, 04, 0e, 00, 13, 0a, 01, 0f, 00, 16, 05, 02, 11, 00, 19, 09, 02, 12, 04, 0e, 1b, 06, 0e, 00, 13, 16, 01, 0f, 00, 16, 15, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 15, 03, 09, 00, 0e, 2f, 02, 0e, 00, 13, 2a, 01, 0f, 00, 16, 1d, 01, 15, 02, 0e, 21, 04, 11, 00, 19, 1d, 03, 09, 00, 0e, 43, 02, 0e, 00, 13, 3e, 01, 0c, 00, 13, 29, 01, 0d, 00, 15, 2d, 01, 0a, 01, 0e, 57, 03, 0e, 00, 13, 52, 01, 0f, 00, 16, 39, 01, 16, 02, 0e, 35, 03, 12, 02, 0e, 5f, 04, 09, 00, 0e, 6b, 02, 0e, 00, 13, 66, 01, 0f, 00, 16, 41, 01, 16, 02, 0e, 49, 04, 11, 00, 16, 41, 03, 09, 00, 0e, 6f, 02, 0d, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 28 @@ -21,16 +21,16 @@ Number of expressions: 28 - expression 15 operands: lhs = Expression(16, Add), rhs = Counter(12) - expression 16 operands: lhs = Expression(17, Add), rhs = Counter(11) - expression 17 operands: lhs = Counter(9), rhs = Counter(10) -- expression 18 operands: lhs = Counter(12), rhs = Expression(23, Add) -- expression 19 operands: lhs = Counter(13), rhs = Counter(14) +- expression 18 operands: lhs = Expression(22, Add), rhs = Counter(14) +- expression 19 operands: lhs = Counter(12), rhs = Counter(13) - expression 20 operands: lhs = Expression(21, Add), rhs = Counter(15) -- expression 21 operands: lhs = Counter(12), rhs = Expression(23, Add) -- expression 22 operands: lhs = Counter(13), rhs = Counter(14) +- expression 21 operands: lhs = Expression(22, Add), rhs = Counter(14) +- expression 22 operands: lhs = Counter(12), rhs = Counter(13) - expression 23 operands: lhs = Counter(13), rhs = Counter(14) - expression 24 operands: lhs = Counter(15), rhs = Counter(16) - expression 25 operands: lhs = Expression(26, Add), rhs = Counter(17) - expression 26 operands: lhs = Counter(15), rhs = Counter(16) -- expression 27 operands: lhs = Counter(18), rhs = Counter(17) +- expression 27 operands: lhs = Counter(17), rhs = Counter(18) Number of file 0 mappings: 30 - Code(Counter(0)) at (prev + 3, 1) to (start + 3, 18) - Code(Expression(0, Add)) at (prev + 4, 14) to (start + 0, 19) @@ -60,9 +60,9 @@ Number of file 0 mappings: 30 - Code(Counter(10)) at (prev + 1, 13) to (start + 0, 21) - Code(Counter(11)) at (prev + 1, 10) to (start + 1, 14) - Code(Expression(21, Add)) at (prev + 3, 14) to (start + 0, 19) - = (c12 + (c13 + c14)) + = ((c12 + c13) + c14) - Code(Expression(20, Sub)) at (prev + 1, 15) to (start + 0, 22) - = ((c12 + (c13 + c14)) - c15) + = (((c12 + c13) + c14) - c15) - Code(Counter(14)) at (prev + 1, 22) to (start + 2, 14) - Code(Counter(13)) at (prev + 3, 18) to (start + 2, 14) - Code(Expression(23, Add)) at (prev + 4, 9) to (start + 0, 14) @@ -75,6 +75,6 @@ Number of file 0 mappings: 30 - Code(Counter(18)) at (prev + 4, 17) to (start + 0, 22) - Code(Counter(16)) at (prev + 3, 9) to (start + 0, 14) - Code(Expression(27, Add)) at (prev + 2, 13) to (start + 1, 2) - = (c18 + c17) + = (c17 + c18) Highest counter ID seen: c18 diff --git a/tests/coverage/coroutine.cov-map b/tests/coverage/coroutine.cov-map index 2fdc3220c196..21f6787e9f2d 100644 --- a/tests/coverage/coroutine.cov-map +++ b/tests/coverage/coroutine.cov-map @@ -13,18 +13,18 @@ Number of file 0 mappings: 4 Highest counter ID seen: c1 Function name: coroutine::main -Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 1e, 19, 11, 15, 15, 19, 1e, 19, 11, 15, 09, 01, 13, 01, 02, 16, 01, 08, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 1e, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 17, 01, 0e, 00, 35, 1a, 02, 01, 00, 02] +Raw bytes (65): 0x[01, 01, 08, 07, 0d, 05, 09, 11, 15, 11, 1f, 15, 19, 15, 19, 11, 1f, 15, 19, 09, 01, 13, 01, 02, 16, 01, 08, 0b, 00, 2e, 11, 01, 2b, 00, 2d, 03, 01, 0e, 00, 35, 11, 02, 0b, 00, 2e, 0a, 01, 22, 00, 27, 1a, 00, 2c, 00, 2e, 1f, 01, 0e, 00, 35, 1a, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 - expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) - expression 1 operands: lhs = Counter(1), rhs = Counter(2) - expression 2 operands: lhs = Counter(4), rhs = Counter(5) -- expression 3 operands: lhs = Expression(7, Sub), rhs = Counter(6) -- expression 4 operands: lhs = Counter(4), rhs = Counter(5) +- expression 3 operands: lhs = Counter(4), rhs = Expression(7, Add) +- expression 4 operands: lhs = Counter(5), rhs = Counter(6) - expression 5 operands: lhs = Counter(5), rhs = Counter(6) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(6) -- expression 7 operands: lhs = Counter(4), rhs = Counter(5) +- expression 6 operands: lhs = Counter(4), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(5), rhs = Counter(6) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 19, 1) to (start + 2, 22) - Code(Counter(0)) at (prev + 8, 11) to (start + 0, 46) @@ -32,14 +32,14 @@ Number of file 0 mappings: 9 - Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 53) = ((c1 + c2) + c3) - Code(Counter(4)) at (prev + 2, 11) to (start + 0, 46) -- Code(Expression(7, Sub)) at (prev + 1, 34) to (start + 0, 39) +- Code(Expression(2, Sub)) at (prev + 1, 34) to (start + 0, 39) = (c4 - c5) - Code(Expression(6, Sub)) at (prev + 0, 44) to (start + 0, 46) - = ((c4 - c5) - c6) -- Code(Expression(5, Add)) at (prev + 1, 14) to (start + 0, 53) + = (c4 - (c5 + c6)) +- Code(Expression(7, Add)) at (prev + 1, 14) to (start + 0, 53) = (c5 + c6) - Code(Expression(6, Sub)) at (prev + 2, 1) to (start + 0, 2) - = ((c4 - c5) - c6) + = (c4 - (c5 + c6)) Highest counter ID seen: c4 Function name: coroutine::main::{closure#0} diff --git a/tests/coverage/inline-dead.cov-map b/tests/coverage/inline-dead.cov-map index 5a20de3d4d44..3e2ca2bc992e 100644 --- a/tests/coverage/inline-dead.cov-map +++ b/tests/coverage/inline-dead.cov-map @@ -32,16 +32,16 @@ Number of file 0 mappings: 2 Highest counter ID seen: c0 Function name: inline_dead::main::{closure#0} -Raw bytes (23): 0x[01, 01, 02, 00, 06, 01, 00, 03, 01, 07, 17, 01, 16, 00, 01, 17, 00, 18, 03, 01, 05, 00, 06] +Raw bytes (23): 0x[01, 01, 02, 07, 00, 01, 00, 03, 01, 07, 17, 01, 16, 00, 01, 17, 00, 18, 02, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 -- expression 0 operands: lhs = Zero, rhs = Expression(1, Sub) +- expression 0 operands: lhs = Expression(1, Add), rhs = Zero - expression 1 operands: lhs = Counter(0), rhs = Zero Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 7, 23) to (start + 1, 22) - Code(Zero) at (prev + 1, 23) to (start + 0, 24) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 6) - = (Zero + (c0 - Zero)) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) + = ((c0 + Zero) - Zero) Highest counter ID seen: c0 diff --git a/tests/coverage/inline.cov-map b/tests/coverage/inline.cov-map index ab3a505e9250..1b5b45695dc9 100644 --- a/tests/coverage/inline.cov-map +++ b/tests/coverage/inline.cov-map @@ -41,14 +41,15 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: inline::permutate:: -Raw bytes (52): 0x[01, 01, 04, 01, 05, 02, 0d, 05, 0f, 09, 0d, 08, 01, 0f, 01, 02, 0e, 05, 02, 0f, 02, 06, 02, 02, 0f, 00, 14, 11, 01, 0d, 00, 0e, 06, 00, 12, 00, 16, 11, 00, 17, 04, 0a, 0d, 05, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (54): 0x[01, 01, 05, 01, 05, 01, 0b, 05, 0d, 13, 0d, 05, 09, 08, 01, 0f, 01, 02, 0e, 05, 02, 0f, 02, 06, 02, 02, 0f, 00, 14, 11, 01, 0d, 00, 0e, 06, 00, 12, 00, 16, 11, 00, 17, 04, 0a, 0d, 05, 0c, 02, 06, 0f, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 5 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(3) -- expression 2 operands: lhs = Counter(1), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Counter(0), rhs = Expression(2, Add) +- expression 2 operands: lhs = Counter(1), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(3) +- expression 4 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 15, 1) to (start + 2, 14) - Code(Counter(1)) at (prev + 2, 15) to (start + 2, 6) @@ -56,11 +57,11 @@ Number of file 0 mappings: 8 = (c0 - c1) - Code(Counter(4)) at (prev + 1, 13) to (start + 0, 14) - Code(Expression(1, Sub)) at (prev + 0, 18) to (start + 0, 22) - = ((c0 - c1) - c3) + = (c0 - (c1 + c3)) - Code(Counter(4)) at (prev + 0, 23) to (start + 4, 10) - Code(Counter(3)) at (prev + 5, 12) to (start + 2, 6) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c2 + c3)) +- Code(Expression(3, Add)) at (prev + 3, 1) to (start + 0, 2) + = ((c1 + c2) + c3) Highest counter ID seen: c4 Function name: inline::permutations:: diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index 64870c434b33..a2ab558f9608 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -59,69 +59,69 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: issue_84561::test3 -Raw bytes (414): 0x[01, 01, 3b, 05, 09, 0d, 11, 15, 19, 1e, 1d, 15, 19, 1a, 21, 1e, 1d, 15, 19, 25, 2d, 21, 25, 29, 35, 32, 29, 21, 25, 31, 39, 3d, 41, 42, 45, 3d, 41, 66, 49, 45, 4d, 63, 51, 66, 49, 45, 4d, 5e, 55, 63, 51, 66, 49, 45, 4d, 9e, 01, 55, 51, 59, 9e, 01, 55, 51, 59, 9b, 01, 5d, 9e, 01, 55, 51, 59, 9b, 01, 61, 9e, 01, 55, 51, 59, 96, 01, 65, 9b, 01, 61, 9e, 01, 55, 51, 59, 75, e2, 01, e6, 01, 79, 69, 6d, 69, 6d, 69, 6d, e6, 01, 00, 69, 6d, e6, 01, 79, 69, 6d, df, 01, 7d, 75, e2, 01, e6, 01, 79, 69, 6d, da, 01, 81, 01, df, 01, 7d, 75, e2, 01, e6, 01, 79, 69, 6d, 81, 01, 85, 01, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 1e, 02, 05, 00, 1f, 1a, 01, 05, 00, 0f, 16, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 2d, 00, 33, 00, 41, 22, 00, 4b, 00, 5a, 32, 01, 05, 00, 0f, 29, 05, 09, 03, 10, 35, 05, 0d, 00, 1b, 2a, 02, 0d, 00, 1c, 2e, 04, 09, 05, 06, 31, 06, 05, 03, 06, 36, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 42, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 3e, 05, 09, 03, 0a, 63, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 59, 03, 0d, 00, 1d, 5e, 03, 09, 00, 13, 5a, 03, 0d, 00, 1d, 9b, 01, 03, 05, 00, 0f, 9b, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 7a, 02, 0d, 00, 13, 96, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 92, 01, 02, 0d, 00, 13, df, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, e6, 01, 02, 0d, 00, 17, e6, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, b6, 01, 02, 15, 00, 1b, e2, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, da, 01, 02, 05, 00, 0f, d6, 01, 03, 09, 00, 22, 81, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 2c, 85, 01, 02, 01, 00, 02] +Raw bytes (409): 0x[01, 01, 3b, 05, 09, 0d, 11, 15, 19, 15, 1f, 19, 1d, 15, 1b, 1f, 21, 19, 1d, 25, 29, 21, 25, 2d, 31, 21, 33, 25, 2d, 35, 39, 3d, 41, 3d, 43, 41, 45, 5f, 4d, 45, 49, 5f, 67, 45, 49, 4d, 51, 5f, 63, 45, 49, 67, 59, 4d, 51, 97, 01, 55, 51, 59, 97, 01, 55, 51, 59, 97, 01, 83, 01, 51, 59, 55, 5d, 97, 01, 9f, 01, 51, 59, 55, 61, 97, 01, 9b, 01, 51, 59, 9f, 01, 65, 55, 61, db, 01, e7, 01, 69, 71, 6d, 75, 69, 6d, 69, 6d, 69, bb, 01, 6d, 00, 69, e7, 01, 6d, 75, db, 01, e3, 01, 69, 71, e7, 01, 79, 6d, 75, db, 01, df, 01, 69, 71, e3, 01, 7d, e7, 01, 79, 6d, 75, 7d, 81, 01, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 0a, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 16, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 29, 00, 33, 00, 41, 22, 00, 4b, 00, 5a, 26, 01, 05, 00, 0f, 2d, 05, 09, 03, 10, 31, 05, 0d, 00, 1b, 2a, 02, 0d, 00, 1c, 2e, 04, 09, 05, 06, 35, 06, 05, 03, 06, 36, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 3a, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 3e, 05, 09, 03, 0a, 46, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 55, 03, 0d, 00, 1d, 4e, 03, 09, 00, 13, 5a, 03, 0d, 00, 1d, 72, 03, 05, 00, 0f, 72, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 7a, 02, 0d, 00, 13, 86, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 92, 01, 02, 0d, 00, 13, a2, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 71, 04, 0d, 00, 13, b2, 01, 02, 0d, 00, 17, b2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, b6, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 79, 03, 09, 00, 19, c6, 01, 02, 05, 00, 0f, d6, 01, 03, 09, 00, 22, 7d, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 2c, 81, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 59 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) - expression 1 operands: lhs = Counter(3), rhs = Counter(4) - expression 2 operands: lhs = Counter(5), rhs = Counter(6) -- expression 3 operands: lhs = Expression(7, Sub), rhs = Counter(7) -- expression 4 operands: lhs = Counter(5), rhs = Counter(6) -- expression 5 operands: lhs = Expression(6, Sub), rhs = Counter(8) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(7) -- expression 7 operands: lhs = Counter(5), rhs = Counter(6) -- expression 8 operands: lhs = Counter(9), rhs = Counter(11) +- expression 3 operands: lhs = Counter(5), rhs = Expression(7, Add) +- expression 4 operands: lhs = Counter(6), rhs = Counter(7) +- expression 5 operands: lhs = Counter(5), rhs = Expression(6, Add) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(8) +- expression 7 operands: lhs = Counter(6), rhs = Counter(7) +- expression 8 operands: lhs = Counter(9), rhs = Counter(10) - expression 9 operands: lhs = Counter(8), rhs = Counter(9) -- expression 10 operands: lhs = Counter(10), rhs = Counter(13) -- expression 11 operands: lhs = Expression(12, Sub), rhs = Counter(10) -- expression 12 operands: lhs = Counter(8), rhs = Counter(9) -- expression 13 operands: lhs = Counter(12), rhs = Counter(14) +- expression 10 operands: lhs = Counter(11), rhs = Counter(12) +- expression 11 operands: lhs = Counter(8), rhs = Expression(12, Add) +- expression 12 operands: lhs = Counter(9), rhs = Counter(11) +- expression 13 operands: lhs = Counter(13), rhs = Counter(14) - expression 14 operands: lhs = Counter(15), rhs = Counter(16) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(17) -- expression 16 operands: lhs = Counter(15), rhs = Counter(16) -- expression 17 operands: lhs = Expression(25, Sub), rhs = Counter(18) -- expression 18 operands: lhs = Counter(17), rhs = Counter(19) -- expression 19 operands: lhs = Expression(24, Add), rhs = Counter(20) -- expression 20 operands: lhs = Expression(25, Sub), rhs = Counter(18) -- expression 21 operands: lhs = Counter(17), rhs = Counter(19) -- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(21) -- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(20) -- expression 24 operands: lhs = Expression(25, Sub), rhs = Counter(18) -- expression 25 operands: lhs = Counter(17), rhs = Counter(19) -- expression 26 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 15 operands: lhs = Counter(15), rhs = Expression(16, Add) +- expression 16 operands: lhs = Counter(16), rhs = Counter(17) +- expression 17 operands: lhs = Expression(23, Add), rhs = Counter(19) +- expression 18 operands: lhs = Counter(17), rhs = Counter(18) +- expression 19 operands: lhs = Expression(23, Add), rhs = Expression(25, Add) +- expression 20 operands: lhs = Counter(17), rhs = Counter(18) +- expression 21 operands: lhs = Counter(19), rhs = Counter(20) +- expression 22 operands: lhs = Expression(23, Add), rhs = Expression(24, Add) +- expression 23 operands: lhs = Counter(17), rhs = Counter(18) +- expression 24 operands: lhs = Expression(25, Add), rhs = Counter(22) +- expression 25 operands: lhs = Counter(19), rhs = Counter(20) +- expression 26 operands: lhs = Expression(37, Add), rhs = Counter(21) - expression 27 operands: lhs = Counter(20), rhs = Counter(22) -- expression 28 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 28 operands: lhs = Expression(37, Add), rhs = Counter(21) - expression 29 operands: lhs = Counter(20), rhs = Counter(22) -- expression 30 operands: lhs = Expression(38, Add), rhs = Counter(23) -- expression 31 operands: lhs = Expression(39, Sub), rhs = Counter(21) -- expression 32 operands: lhs = Counter(20), rhs = Counter(22) -- expression 33 operands: lhs = Expression(38, Add), rhs = Counter(24) -- expression 34 operands: lhs = Expression(39, Sub), rhs = Counter(21) -- expression 35 operands: lhs = Counter(20), rhs = Counter(22) -- expression 36 operands: lhs = Expression(37, Sub), rhs = Counter(25) -- expression 37 operands: lhs = Expression(38, Add), rhs = Counter(24) -- expression 38 operands: lhs = Expression(39, Sub), rhs = Counter(21) -- expression 39 operands: lhs = Counter(20), rhs = Counter(22) -- expression 40 operands: lhs = Counter(29), rhs = Expression(56, Sub) -- expression 41 operands: lhs = Expression(57, Sub), rhs = Counter(30) -- expression 42 operands: lhs = Counter(26), rhs = Counter(27) +- expression 30 operands: lhs = Expression(37, Add), rhs = Expression(32, Add) +- expression 31 operands: lhs = Counter(20), rhs = Counter(22) +- expression 32 operands: lhs = Counter(21), rhs = Counter(23) +- expression 33 operands: lhs = Expression(37, Add), rhs = Expression(39, Add) +- expression 34 operands: lhs = Counter(20), rhs = Counter(22) +- expression 35 operands: lhs = Counter(21), rhs = Counter(24) +- expression 36 operands: lhs = Expression(37, Add), rhs = Expression(38, Add) +- expression 37 operands: lhs = Counter(20), rhs = Counter(22) +- expression 38 operands: lhs = Expression(39, Add), rhs = Counter(25) +- expression 39 operands: lhs = Counter(21), rhs = Counter(24) +- expression 40 operands: lhs = Expression(54, Add), rhs = Expression(57, Add) +- expression 41 operands: lhs = Counter(26), rhs = Counter(28) +- expression 42 operands: lhs = Counter(27), rhs = Counter(29) - expression 43 operands: lhs = Counter(26), rhs = Counter(27) - expression 44 operands: lhs = Counter(26), rhs = Counter(27) -- expression 45 operands: lhs = Expression(57, Sub), rhs = Zero -- expression 46 operands: lhs = Counter(26), rhs = Counter(27) -- expression 47 operands: lhs = Expression(57, Sub), rhs = Counter(30) -- expression 48 operands: lhs = Counter(26), rhs = Counter(27) -- expression 49 operands: lhs = Expression(55, Add), rhs = Counter(31) -- expression 50 operands: lhs = Counter(29), rhs = Expression(56, Sub) -- expression 51 operands: lhs = Expression(57, Sub), rhs = Counter(30) -- expression 52 operands: lhs = Counter(26), rhs = Counter(27) -- expression 53 operands: lhs = Expression(54, Sub), rhs = Counter(32) -- expression 54 operands: lhs = Expression(55, Add), rhs = Counter(31) -- expression 55 operands: lhs = Counter(29), rhs = Expression(56, Sub) -- expression 56 operands: lhs = Expression(57, Sub), rhs = Counter(30) -- expression 57 operands: lhs = Counter(26), rhs = Counter(27) -- expression 58 operands: lhs = Counter(32), rhs = Counter(33) +- expression 45 operands: lhs = Counter(26), rhs = Expression(46, Add) +- expression 46 operands: lhs = Counter(27), rhs = Zero +- expression 47 operands: lhs = Counter(26), rhs = Expression(57, Add) +- expression 48 operands: lhs = Counter(27), rhs = Counter(29) +- expression 49 operands: lhs = Expression(54, Add), rhs = Expression(56, Add) +- expression 50 operands: lhs = Counter(26), rhs = Counter(28) +- expression 51 operands: lhs = Expression(57, Add), rhs = Counter(30) +- expression 52 operands: lhs = Counter(27), rhs = Counter(29) +- expression 53 operands: lhs = Expression(54, Add), rhs = Expression(55, Add) +- expression 54 operands: lhs = Counter(26), rhs = Counter(28) +- expression 55 operands: lhs = Expression(56, Add), rhs = Counter(31) +- expression 56 operands: lhs = Expression(57, Add), rhs = Counter(30) +- expression 57 operands: lhs = Counter(27), rhs = Counter(29) +- expression 58 operands: lhs = Counter(31), rhs = Counter(32) Number of file 0 mappings: 51 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) - Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28) @@ -131,76 +131,76 @@ Number of file 0 mappings: 51 - Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31) = (c3 - c4) - Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28) -- Code(Expression(7, Sub)) at (prev + 2, 5) to (start + 0, 31) +- Code(Expression(2, Sub)) at (prev + 2, 5) to (start + 0, 31) = (c5 - c6) -- Code(Expression(6, Sub)) at (prev + 1, 5) to (start + 0, 15) - = ((c5 - c6) - c7) +- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15) + = (c5 - (c6 + c7)) - Code(Expression(5, Sub)) at (prev + 0, 32) to (start + 0, 48) - = (((c5 - c6) - c7) - c8) + = (c5 - ((c6 + c7) + c8)) - Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15) - Code(Counter(9)) at (prev + 3, 32) to (start + 0, 48) -- Code(Counter(11)) at (prev + 0, 51) to (start + 0, 65) +- Code(Counter(10)) at (prev + 0, 51) to (start + 0, 65) - Code(Expression(8, Sub)) at (prev + 0, 75) to (start + 0, 90) - = (c9 - c11) -- Code(Expression(12, Sub)) at (prev + 1, 5) to (start + 0, 15) + = (c9 - c10) +- Code(Expression(9, Sub)) at (prev + 1, 5) to (start + 0, 15) = (c8 - c9) -- Code(Counter(10)) at (prev + 5, 9) to (start + 3, 16) -- Code(Counter(13)) at (prev + 5, 13) to (start + 0, 27) +- Code(Counter(11)) at (prev + 5, 9) to (start + 3, 16) +- Code(Counter(12)) at (prev + 5, 13) to (start + 0, 27) - Code(Expression(10, Sub)) at (prev + 2, 13) to (start + 0, 28) - = (c10 - c13) + = (c11 - c12) - Code(Expression(11, Sub)) at (prev + 4, 9) to (start + 5, 6) - = ((c8 - c9) - c10) -- Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6) + = (c8 - (c9 + c11)) +- Code(Counter(13)) at (prev + 6, 5) to (start + 3, 6) - Code(Expression(13, Sub)) at (prev + 4, 5) to (start + 3, 6) - = (c12 - c14) + = (c13 - c14) - Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6) -- Code(Expression(16, Sub)) at (prev + 5, 8) to (start + 0, 15) +- Code(Expression(14, Sub)) at (prev + 5, 8) to (start + 0, 15) = (c15 - c16) - Code(Counter(17)) at (prev + 1, 9) to (start + 3, 10) - Code(Expression(15, Sub)) at (prev + 5, 9) to (start + 3, 10) - = ((c15 - c16) - c17) -- Code(Expression(24, Add)) at (prev + 5, 8) to (start + 0, 15) - = ((c17 - c19) + c18) + = (c15 - (c16 + c17)) +- Code(Expression(17, Sub)) at (prev + 5, 8) to (start + 0, 15) + = ((c17 + c18) - c19) - Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19) -- Code(Counter(22)) at (prev + 3, 13) to (start + 0, 29) -- Code(Expression(23, Sub)) at (prev + 3, 9) to (start + 0, 19) - = (((c17 - c19) + c18) - c20) +- Code(Counter(21)) at (prev + 3, 13) to (start + 0, 29) +- Code(Expression(19, Sub)) at (prev + 3, 9) to (start + 0, 19) + = ((c17 + c18) - (c19 + c20)) - Code(Expression(22, Sub)) at (prev + 3, 13) to (start + 0, 29) - = ((((c17 - c19) + c18) - c20) - c21) -- Code(Expression(38, Add)) at (prev + 3, 5) to (start + 0, 15) - = ((c20 - c22) + c21) -- Code(Expression(38, Add)) at (prev + 1, 12) to (start + 0, 19) - = ((c20 - c22) + c21) + = ((c17 + c18) - ((c19 + c20) + c22)) +- Code(Expression(28, Sub)) at (prev + 3, 5) to (start + 0, 15) + = ((c20 + c22) - c21) +- Code(Expression(28, Sub)) at (prev + 1, 12) to (start + 0, 19) + = ((c20 + c22) - c21) - Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19) - Code(Expression(30, Sub)) at (prev + 2, 13) to (start + 0, 19) - = (((c20 - c22) + c21) - c23) -- Code(Expression(37, Sub)) at (prev + 4, 5) to (start + 2, 19) - = (((c20 - c22) + c21) - c24) + = ((c20 + c22) - (c21 + c23)) +- Code(Expression(33, Sub)) at (prev + 4, 5) to (start + 2, 19) + = ((c20 + c22) - (c21 + c24)) - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) - Code(Expression(36, Sub)) at (prev + 2, 13) to (start + 0, 19) - = ((((c20 - c22) + c21) - c24) - c25) -- Code(Expression(55, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c29 + ((c26 - c27) - c30)) + = ((c20 + c22) - ((c21 + c24) + c25)) +- Code(Expression(40, Sub)) at (prev + 3, 5) to (start + 0, 15) + = ((c26 + c28) - (c27 + c29)) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) -- Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) -- Code(Expression(57, Sub)) at (prev + 2, 13) to (start + 0, 23) +- Code(Counter(28)) at (prev + 4, 13) to (start + 0, 19) +- Code(Expression(44, Sub)) at (prev + 2, 13) to (start + 0, 23) = (c26 - c27) -- Code(Expression(57, Sub)) at (prev + 1, 20) to (start + 0, 27) +- Code(Expression(44, Sub)) at (prev + 1, 20) to (start + 0, 27) = (c26 - c27) - Code(Zero) at (prev + 1, 21) to (start + 0, 27) - Code(Expression(45, Sub)) at (prev + 2, 21) to (start + 0, 27) - = ((c26 - c27) - Zero) -- Code(Expression(56, Sub)) at (prev + 4, 13) to (start + 0, 19) - = ((c26 - c27) - c30) -- Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25) -- Code(Expression(54, Sub)) at (prev + 2, 5) to (start + 0, 15) - = ((c29 + ((c26 - c27) - c30)) - c31) + = (c26 - (c27 + Zero)) +- Code(Expression(47, Sub)) at (prev + 4, 13) to (start + 0, 19) + = (c26 - (c27 + c29)) +- Code(Counter(30)) at (prev + 3, 9) to (start + 0, 25) +- Code(Expression(49, Sub)) at (prev + 2, 5) to (start + 0, 15) + = ((c26 + c28) - ((c27 + c29) + c30)) - Code(Expression(53, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((c26 - c27) - c30)) - c31) - c32) -- Code(Counter(32)) at (prev + 2, 5) to (start + 0, 15) + = ((c26 + c28) - (((c27 + c29) + c30) + c31)) +- Code(Counter(31)) at (prev + 2, 5) to (start + 0, 15) - Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 44) - = (c32 - c33) -- Code(Counter(33)) at (prev + 2, 1) to (start + 0, 2) -Highest counter ID seen: c33 + = (c31 - c32) +- Code(Counter(32)) at (prev + 2, 1) to (start + 0, 2) +Highest counter ID seen: c32 diff --git a/tests/coverage/lazy_boolean.cov-map b/tests/coverage/lazy_boolean.cov-map index b0c2d736573a..3f7788da1ebc 100644 --- a/tests/coverage/lazy_boolean.cov-map +++ b/tests/coverage/lazy_boolean.cov-map @@ -1,15 +1,15 @@ Function name: lazy_boolean::main -Raw bytes (158): 0x[01, 01, 07, 01, 05, 01, 09, 01, 0d, 01, 19, 01, 1d, 01, 21, 01, 25, 1c, 01, 04, 01, 07, 0f, 05, 07, 10, 04, 06, 02, 04, 05, 00, 06, 01, 02, 09, 00, 11, 01, 02, 0d, 00, 12, 06, 02, 0d, 00, 12, 01, 03, 09, 00, 11, 01, 02, 0d, 00, 12, 0a, 02, 0d, 00, 12, 01, 02, 09, 00, 11, 01, 00, 14, 00, 19, 11, 00, 1d, 00, 22, 01, 01, 09, 00, 11, 01, 00, 14, 00, 19, 15, 00, 1d, 00, 22, 01, 03, 09, 01, 10, 0e, 02, 05, 03, 06, 19, 03, 05, 00, 06, 01, 03, 09, 00, 10, 1d, 01, 05, 03, 06, 12, 05, 05, 03, 06, 01, 05, 08, 00, 10, 16, 00, 11, 02, 06, 21, 02, 05, 00, 06, 01, 02, 08, 00, 0f, 25, 00, 10, 02, 06, 1a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] +Raw bytes (158): 0x[01, 01, 07, 01, 05, 01, 25, 01, 21, 01, 11, 01, 15, 01, 19, 01, 1d, 1c, 01, 04, 01, 07, 0f, 05, 07, 10, 04, 06, 02, 04, 05, 00, 06, 01, 02, 09, 00, 11, 01, 02, 0d, 00, 12, 06, 02, 0d, 00, 12, 01, 03, 09, 00, 11, 01, 02, 0d, 00, 12, 0a, 02, 0d, 00, 12, 01, 02, 09, 00, 11, 01, 00, 14, 00, 19, 09, 00, 1d, 00, 22, 01, 01, 09, 00, 11, 01, 00, 14, 00, 19, 0d, 00, 1d, 00, 22, 01, 03, 09, 01, 10, 0e, 02, 05, 03, 06, 11, 03, 05, 00, 06, 01, 03, 09, 00, 10, 15, 01, 05, 03, 06, 12, 05, 05, 03, 06, 01, 05, 08, 00, 10, 16, 00, 11, 02, 06, 19, 02, 05, 00, 06, 01, 02, 08, 00, 0f, 1d, 00, 10, 02, 06, 1a, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 7 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Counter(2) -- expression 2 operands: lhs = Counter(0), rhs = Counter(3) -- expression 3 operands: lhs = Counter(0), rhs = Counter(6) -- expression 4 operands: lhs = Counter(0), rhs = Counter(7) -- expression 5 operands: lhs = Counter(0), rhs = Counter(8) -- expression 6 operands: lhs = Counter(0), rhs = Counter(9) +- expression 1 operands: lhs = Counter(0), rhs = Counter(9) +- expression 2 operands: lhs = Counter(0), rhs = Counter(8) +- expression 3 operands: lhs = Counter(0), rhs = Counter(4) +- expression 4 operands: lhs = Counter(0), rhs = Counter(5) +- expression 5 operands: lhs = Counter(0), rhs = Counter(6) +- expression 6 operands: lhs = Counter(0), rhs = Counter(7) Number of file 0 mappings: 28 - Code(Counter(0)) at (prev + 4, 1) to (start + 7, 15) - Code(Counter(1)) at (prev + 7, 16) to (start + 4, 6) @@ -18,33 +18,33 @@ Number of file 0 mappings: 28 - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 17) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 18) - Code(Expression(1, Sub)) at (prev + 2, 13) to (start + 0, 18) - = (c0 - c2) + = (c0 - c9) - Code(Counter(0)) at (prev + 3, 9) to (start + 0, 17) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 18) - Code(Expression(2, Sub)) at (prev + 2, 13) to (start + 0, 18) - = (c0 - c3) + = (c0 - c8) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 17) - Code(Counter(0)) at (prev + 0, 20) to (start + 0, 25) -- Code(Counter(4)) at (prev + 0, 29) to (start + 0, 34) +- Code(Counter(2)) at (prev + 0, 29) to (start + 0, 34) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) - Code(Counter(0)) at (prev + 0, 20) to (start + 0, 25) -- Code(Counter(5)) at (prev + 0, 29) to (start + 0, 34) +- Code(Counter(3)) at (prev + 0, 29) to (start + 0, 34) - Code(Counter(0)) at (prev + 3, 9) to (start + 1, 16) - Code(Expression(3, Sub)) at (prev + 2, 5) to (start + 3, 6) - = (c0 - c6) -- Code(Counter(6)) at (prev + 3, 5) to (start + 0, 6) + = (c0 - c4) +- Code(Counter(4)) at (prev + 3, 5) to (start + 0, 6) - Code(Counter(0)) at (prev + 3, 9) to (start + 0, 16) -- Code(Counter(7)) at (prev + 1, 5) to (start + 3, 6) +- Code(Counter(5)) at (prev + 1, 5) to (start + 3, 6) - Code(Expression(4, Sub)) at (prev + 5, 5) to (start + 3, 6) - = (c0 - c7) + = (c0 - c5) - Code(Counter(0)) at (prev + 5, 8) to (start + 0, 16) - Code(Expression(5, Sub)) at (prev + 0, 17) to (start + 2, 6) - = (c0 - c8) -- Code(Counter(8)) at (prev + 2, 5) to (start + 0, 6) + = (c0 - c6) +- Code(Counter(6)) at (prev + 2, 5) to (start + 0, 6) - Code(Counter(0)) at (prev + 2, 8) to (start + 0, 15) -- Code(Counter(9)) at (prev + 0, 16) to (start + 2, 6) +- Code(Counter(7)) at (prev + 0, 16) to (start + 2, 6) - Code(Expression(6, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c9) + = (c0 - c7) - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c9 +Highest counter ID seen: c7 diff --git a/tests/coverage/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map index 61a6bda676a9..14707701d8a8 100644 --- a/tests/coverage/loops_branches.cov-map +++ b/tests/coverage/loops_branches.cov-map @@ -1,50 +1,42 @@ Function name: ::fmt -Raw bytes (228): 0x[01, 01, 2a, 05, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, a3, 01, a7, 01, 0d, 00, 11, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 9a, 01, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 96, 01, 00, 9a, 01, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 9a, 01, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 96, 01, 11, 9a, 01, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 8f, 01, 19, 25, 92, 01, 96, 01, 11, 9a, 01, 00, 9f, 01, 19, a3, 01, a7, 01, 0d, 00, 11, 00, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0d, 00, 0e, 05, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 9a, 01, 03, 0d, 00, 0e, 9f, 01, 00, 12, 00, 17, 9a, 01, 01, 10, 00, 14, 96, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 46, 01, 11, 00, 12, 96, 01, 01, 11, 00, 22, 92, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 8b, 01, 01, 05, 00, 06] +Raw bytes (174): 0x[01, 01, 22, 05, 00, 2f, 7b, 67, 00, 77, 19, 01, 15, 05, 21, 2f, 05, 67, 00, 77, 19, 01, 15, 2f, 7b, 67, 00, 77, 19, 01, 15, 05, 21, 67, 7b, 77, 19, 01, 15, 05, 21, 67, 5b, 77, 19, 01, 15, 7b, 00, 05, 21, 67, 7b, 77, 19, 01, 15, 05, 21, 77, 7b, 01, 15, 05, 21, 83, 01, 05, 87, 01, 15, 01, 11, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0d, 00, 0e, 05, 01, 0d, 00, 1e, 11, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 2a, 03, 0d, 00, 0e, 1a, 00, 12, 00, 17, 2a, 01, 10, 00, 14, 62, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 4e, 01, 11, 00, 12, 62, 01, 11, 00, 22, 72, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 21, 03, 09, 00, 0f, 7e, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 42 +Number of expressions: 34 - expression 0 operands: lhs = Counter(1), rhs = Zero -- expression 1 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 2 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 3 operands: lhs = Counter(3), rhs = Zero -- expression 4 operands: lhs = Counter(4), rhs = Zero -- expression 5 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 6 operands: lhs = Counter(3), rhs = Zero -- expression 7 operands: lhs = Counter(4), rhs = Zero -- expression 8 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 9 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 10 operands: lhs = Counter(3), rhs = Zero -- expression 11 operands: lhs = Counter(4), rhs = Zero -- expression 12 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 13 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 14 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 15 operands: lhs = Counter(3), rhs = Zero -- expression 16 operands: lhs = Counter(4), rhs = Zero -- expression 17 operands: lhs = Expression(37, Sub), rhs = Zero -- expression 18 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 19 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 20 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 21 operands: lhs = Counter(3), rhs = Zero -- expression 22 operands: lhs = Counter(4), rhs = Zero -- expression 23 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 24 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 25 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 26 operands: lhs = Counter(3), rhs = Zero -- expression 27 operands: lhs = Counter(4), rhs = Zero -- expression 28 operands: lhs = Expression(37, Sub), rhs = Counter(4) -- expression 29 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 30 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 31 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 32 operands: lhs = Counter(3), rhs = Zero -- expression 33 operands: lhs = Counter(4), rhs = Zero -- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(6) -- expression 35 operands: lhs = Counter(9), rhs = Expression(36, Sub) -- expression 36 operands: lhs = Expression(37, Sub), rhs = Counter(4) -- expression 37 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 38 operands: lhs = Expression(39, Add), rhs = Counter(6) -- expression 39 operands: lhs = Expression(40, Add), rhs = Expression(41, Add) -- expression 40 operands: lhs = Counter(3), rhs = Zero -- expression 41 operands: lhs = Counter(4), rhs = Zero +- expression 1 operands: lhs = Expression(11, Add), rhs = Expression(30, Add) +- expression 2 operands: lhs = Expression(25, Add), rhs = Zero +- expression 3 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 4 operands: lhs = Counter(0), rhs = Counter(5) +- expression 5 operands: lhs = Counter(1), rhs = Counter(8) +- expression 6 operands: lhs = Expression(11, Add), rhs = Counter(1) +- expression 7 operands: lhs = Expression(25, Add), rhs = Zero +- expression 8 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 9 operands: lhs = Counter(0), rhs = Counter(5) +- expression 10 operands: lhs = Expression(11, Add), rhs = Expression(30, Add) +- expression 11 operands: lhs = Expression(25, Add), rhs = Zero +- expression 12 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 13 operands: lhs = Counter(0), rhs = Counter(5) +- expression 14 operands: lhs = Counter(1), rhs = Counter(8) +- expression 15 operands: lhs = Expression(25, Add), rhs = Expression(30, Add) +- expression 16 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 17 operands: lhs = Counter(0), rhs = Counter(5) +- expression 18 operands: lhs = Counter(1), rhs = Counter(8) +- expression 19 operands: lhs = Expression(25, Add), rhs = Expression(22, Add) +- expression 20 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 21 operands: lhs = Counter(0), rhs = Counter(5) +- expression 22 operands: lhs = Expression(30, Add), rhs = Zero +- expression 23 operands: lhs = Counter(1), rhs = Counter(8) +- expression 24 operands: lhs = Expression(25, Add), rhs = Expression(30, Add) +- expression 25 operands: lhs = Expression(29, Add), rhs = Counter(6) +- expression 26 operands: lhs = Counter(0), rhs = Counter(5) +- expression 27 operands: lhs = Counter(1), rhs = Counter(8) +- expression 28 operands: lhs = Expression(29, Add), rhs = Expression(30, Add) +- expression 29 operands: lhs = Counter(0), rhs = Counter(5) +- expression 30 operands: lhs = Counter(1), rhs = Counter(8) +- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(1) +- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(5) +- expression 33 operands: lhs = Counter(0), rhs = Counter(4) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16) - Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21) @@ -53,78 +45,59 @@ Number of file 0 mappings: 20 - Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 14) = (c1 - Zero) - Code(Counter(1)) at (prev + 1, 13) to (start + 0, 30) -- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) +- Code(Counter(4)) at (prev + 0, 30) to (start + 0, 31) - Code(Zero) at (prev + 1, 16) to (start + 1, 10) -- Code(Expression(38, Sub)) at (prev + 3, 13) to (start + 0, 14) - = (((c3 + Zero) + (c4 + Zero)) - c6) -- Code(Expression(39, Add)) at (prev + 0, 18) to (start + 0, 23) - = ((c3 + Zero) + (c4 + Zero)) -- Code(Expression(38, Sub)) at (prev + 1, 16) to (start + 0, 20) - = (((c3 + Zero) + (c4 + Zero)) - c6) -- Code(Expression(37, Sub)) at (prev + 1, 20) to (start + 0, 25) - = ((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) +- Code(Expression(10, Sub)) at (prev + 3, 13) to (start + 0, 14) + = ((((c0 + c5) + c6) + Zero) - (c1 + c8)) +- Code(Expression(6, Sub)) at (prev + 0, 18) to (start + 0, 23) + = ((((c0 + c5) + c6) + Zero) - c1) +- Code(Expression(10, Sub)) at (prev + 1, 16) to (start + 0, 20) + = ((((c0 + c5) + c6) + Zero) - (c1 + c8)) +- Code(Expression(24, Sub)) at (prev + 1, 20) to (start + 0, 25) + = (((c0 + c5) + c6) - (c1 + c8)) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(17, Sub)) at (prev + 1, 17) to (start + 0, 18) - = (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero) -- Code(Expression(37, Sub)) at (prev + 1, 17) to (start + 0, 34) - = ((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) -- Code(Expression(36, Sub)) at (prev + 0, 34) to (start + 0, 35) - = (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - c4) +- Code(Expression(19, Sub)) at (prev + 1, 17) to (start + 0, 18) + = (((c0 + c5) + c6) - ((c1 + c8) + Zero)) +- Code(Expression(24, Sub)) at (prev + 1, 17) to (start + 0, 34) + = (((c0 + c5) + c6) - (c1 + c8)) +- Code(Expression(28, Sub)) at (prev + 0, 34) to (start + 0, 35) + = ((c0 + c5) - (c1 + c8)) - Code(Zero) at (prev + 1, 20) to (start + 1, 14) -- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) -- Code(Expression(34, Add)) at (prev + 1, 5) to (start + 0, 6) - = ((c9 + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - c4)) + c6) -Highest counter ID seen: c9 +- Code(Counter(8)) at (prev + 3, 9) to (start + 0, 15) +- Code(Expression(31, Sub)) at (prev + 1, 5) to (start + 0, 6) + = (((c0 + c4) + c5) - c1) +Highest counter ID seen: c8 Function name: ::fmt -Raw bytes (230): 0x[01, 01, 2b, 01, 00, 02, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, a7, 01, ab, 01, 00, 0d, 00, 15, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 9e, 01, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 9a, 01, 00, 9e, 01, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 9e, 01, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 9a, 01, 15, 9e, 01, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 93, 01, 25, 96, 01, 19, 9a, 01, 15, 9e, 01, 00, a3, 01, 19, a7, 01, ab, 01, 00, 0d, 00, 15, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 06, 01, 0d, 00, 0e, 02, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 9e, 01, 02, 0d, 00, 0e, a3, 01, 00, 12, 00, 17, 9e, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 9a, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 4a, 01, 11, 00, 12, 9a, 01, 01, 11, 00, 22, 96, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, 8f, 01, 01, 05, 00, 06] +Raw bytes (152): 0x[01, 01, 18, 01, 00, 01, 00, 23, 15, 27, 11, 00, 0d, 27, 11, 00, 0d, 23, 15, 27, 11, 00, 0d, 4b, 15, 4f, 11, 00, 0d, 4b, 43, 4f, 11, 00, 0d, 15, 00, 4b, 15, 4f, 11, 00, 0d, 5f, 15, 00, 11, 5f, 21, 00, 11, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 06, 01, 0d, 00, 0e, 02, 01, 0d, 00, 1e, 21, 00, 1e, 00, 1f, 1e, 02, 0d, 00, 0e, 23, 00, 12, 00, 17, 1e, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 46, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 36, 01, 11, 00, 12, 46, 01, 11, 00, 22, 52, 00, 22, 00, 23, 15, 03, 09, 00, 0f, 5b, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 43 +Number of expressions: 24 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero -- expression 2 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 3 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) +- expression 1 operands: lhs = Counter(0), rhs = Zero +- expression 2 operands: lhs = Expression(8, Add), rhs = Counter(5) +- expression 3 operands: lhs = Expression(9, Add), rhs = Counter(4) - expression 4 operands: lhs = Zero, rhs = Counter(3) -- expression 5 operands: lhs = Zero, rhs = Counter(5) -- expression 6 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 7 operands: lhs = Zero, rhs = Counter(3) -- expression 8 operands: lhs = Zero, rhs = Counter(5) -- expression 9 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 10 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 11 operands: lhs = Zero, rhs = Counter(3) -- expression 12 operands: lhs = Zero, rhs = Counter(5) -- expression 13 operands: lhs = Expression(39, Sub), rhs = Zero -- expression 14 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 15 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 16 operands: lhs = Zero, rhs = Counter(3) -- expression 17 operands: lhs = Zero, rhs = Counter(5) -- expression 18 operands: lhs = Expression(38, Sub), rhs = Zero -- expression 19 operands: lhs = Expression(39, Sub), rhs = Zero -- expression 20 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 21 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 22 operands: lhs = Zero, rhs = Counter(3) -- expression 23 operands: lhs = Zero, rhs = Counter(5) -- expression 24 operands: lhs = Expression(39, Sub), rhs = Zero -- expression 25 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 26 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 27 operands: lhs = Zero, rhs = Counter(3) -- expression 28 operands: lhs = Zero, rhs = Counter(5) -- expression 29 operands: lhs = Expression(38, Sub), rhs = Counter(5) -- expression 30 operands: lhs = Expression(39, Sub), rhs = Zero -- expression 31 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 32 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 33 operands: lhs = Zero, rhs = Counter(3) -- expression 34 operands: lhs = Zero, rhs = Counter(5) -- expression 35 operands: lhs = Expression(36, Add), rhs = Counter(9) -- expression 36 operands: lhs = Expression(37, Sub), rhs = Counter(6) -- expression 37 operands: lhs = Expression(38, Sub), rhs = Counter(5) -- expression 38 operands: lhs = Expression(39, Sub), rhs = Zero -- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 40 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) -- expression 41 operands: lhs = Zero, rhs = Counter(3) -- expression 42 operands: lhs = Zero, rhs = Counter(5) +- expression 5 operands: lhs = Expression(9, Add), rhs = Counter(4) +- expression 6 operands: lhs = Zero, rhs = Counter(3) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(5) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(4) +- expression 9 operands: lhs = Zero, rhs = Counter(3) +- expression 10 operands: lhs = Expression(18, Add), rhs = Counter(5) +- expression 11 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 12 operands: lhs = Zero, rhs = Counter(3) +- expression 13 operands: lhs = Expression(18, Add), rhs = Expression(16, Add) +- expression 14 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 15 operands: lhs = Zero, rhs = Counter(3) +- expression 16 operands: lhs = Counter(5), rhs = Zero +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(5) +- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 19 operands: lhs = Zero, rhs = Counter(3) +- expression 20 operands: lhs = Expression(23, Add), rhs = Counter(5) +- expression 21 operands: lhs = Zero, rhs = Counter(4) +- expression 22 operands: lhs = Expression(23, Add), rhs = Counter(8) +- expression 23 operands: lhs = Zero, rhs = Counter(4) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17) - Code(Zero) at (prev + 1, 18) to (start + 1, 10) @@ -133,31 +106,31 @@ Number of file 0 mappings: 20 - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) - Code(Expression(1, Sub)) at (prev + 1, 13) to (start + 0, 14) - = ((c0 - Zero) - Zero) + = (c0 - Zero) - Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 30) = (c0 - Zero) -- Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) -- Code(Expression(39, Sub)) at (prev + 2, 13) to (start + 0, 14) - = (((Zero + c3) + (Zero + c5)) - c6) -- Code(Expression(40, Add)) at (prev + 0, 18) to (start + 0, 23) - = ((Zero + c3) + (Zero + c5)) -- Code(Expression(39, Sub)) at (prev + 1, 16) to (start + 0, 21) - = (((Zero + c3) + (Zero + c5)) - c6) +- Code(Counter(8)) at (prev + 0, 30) to (start + 0, 31) +- Code(Expression(7, Sub)) at (prev + 2, 13) to (start + 0, 14) + = (((Zero + c3) + c4) - c5) +- Code(Expression(8, Add)) at (prev + 0, 18) to (start + 0, 23) + = ((Zero + c3) + c4) +- Code(Expression(7, Sub)) at (prev + 1, 16) to (start + 0, 21) + = (((Zero + c3) + c4) - c5) - Code(Zero) at (prev + 0, 22) to (start + 1, 14) -- Code(Expression(38, Sub)) at (prev + 2, 20) to (start + 0, 25) - = ((((Zero + c3) + (Zero + c5)) - c6) - Zero) +- Code(Expression(17, Sub)) at (prev + 2, 20) to (start + 0, 25) + = (((Zero + c3) + c4) - c5) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(18, Sub)) at (prev + 1, 17) to (start + 0, 18) - = (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero) -- Code(Expression(38, Sub)) at (prev + 1, 17) to (start + 0, 34) - = ((((Zero + c3) + (Zero + c5)) - c6) - Zero) -- Code(Expression(37, Sub)) at (prev + 0, 34) to (start + 0, 35) - = (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - c5) -- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) -- Code(Expression(35, Add)) at (prev + 1, 5) to (start + 0, 6) - = (((((((Zero + c3) + (Zero + c5)) - c6) - Zero) - c5) + c6) + c9) -Highest counter ID seen: c9 +- Code(Expression(13, Sub)) at (prev + 1, 17) to (start + 0, 18) + = (((Zero + c3) + c4) - (c5 + Zero)) +- Code(Expression(17, Sub)) at (prev + 1, 17) to (start + 0, 34) + = (((Zero + c3) + c4) - c5) +- Code(Expression(20, Sub)) at (prev + 0, 34) to (start + 0, 35) + = ((Zero + c4) - c5) +- Code(Counter(5)) at (prev + 3, 9) to (start + 0, 15) +- Code(Expression(22, Add)) at (prev + 1, 5) to (start + 0, 6) + = ((Zero + c4) + c8) +Highest counter ID seen: c8 Function name: loops_branches::main Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02] diff --git a/tests/coverage/mcdc/condition-limit.cov-map b/tests/coverage/mcdc/condition-limit.cov-map index e3f5b49d3636..19716878600d 100644 --- a/tests/coverage/mcdc/condition-limit.cov-map +++ b/tests/coverage/mcdc/condition-limit.cov-map @@ -1,52 +1,54 @@ Function name: condition_limit::accept_7_conditions -Raw bytes (232): 0x[01, 01, 2c, 01, 05, 05, 1d, 05, 1d, 7a, 19, 05, 1d, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 6e, 0d, 72, 11, 76, 15, 7a, 19, 05, 1d, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 21, 9b, 01, 9f, 01, 02, a3, 01, 1d, a7, 01, 19, ab, 01, 15, af, 01, 11, 09, 0d, 12, 01, 07, 01, 02, 09, 28, 08, 07, 02, 08, 00, 27, 30, 05, 02, 01, 07, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 7a, 1d, 07, 06, 00, 00, 0d, 00, 0e, 7a, 00, 12, 00, 13, 30, 76, 19, 06, 05, 00, 00, 12, 00, 13, 76, 00, 17, 00, 18, 30, 72, 15, 05, 04, 00, 00, 17, 00, 18, 72, 00, 1c, 00, 1d, 30, 6e, 11, 04, 03, 00, 00, 1c, 00, 1d, 6e, 00, 21, 00, 22, 30, 6a, 0d, 03, 02, 00, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 30, 21, 09, 02, 00, 00, 00, 26, 00, 27, 21, 00, 28, 02, 06, 9b, 01, 02, 05, 00, 06, 97, 01, 01, 01, 00, 02] +Raw bytes (237): 0x[01, 01, 2e, 01, 05, 05, 09, 05, 09, 05, 7b, 09, 0d, 05, 7b, 09, 0d, 05, 77, 7b, 11, 09, 0d, 05, 77, 7b, 11, 09, 0d, 05, 73, 77, 15, 7b, 11, 09, 0d, 05, 73, 77, 15, 7b, 11, 09, 0d, 05, 6f, 73, 19, 77, 15, 7b, 11, 09, 0d, 05, 6f, 73, 19, 77, 15, 7b, 11, 09, 0d, 83, 01, 05, a7, 01, 21, ab, 01, 19, af, 01, 15, b3, 01, 11, b7, 01, 0d, 01, 09, 9f, 01, 05, a3, 01, 21, a7, 01, 1d, ab, 01, 19, af, 01, 15, b3, 01, 11, b7, 01, 0d, 01, 09, 12, 01, 07, 01, 02, 09, 28, 08, 07, 02, 08, 00, 27, 30, 05, 02, 01, 07, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0a, 09, 07, 06, 00, 00, 0d, 00, 0e, 0a, 00, 12, 00, 13, 30, 16, 0d, 06, 05, 00, 00, 12, 00, 13, 16, 00, 17, 00, 18, 30, 2a, 11, 05, 04, 00, 00, 17, 00, 18, 2a, 00, 1c, 00, 1d, 30, 46, 15, 04, 03, 00, 00, 1c, 00, 1d, 46, 00, 21, 00, 22, 30, 6a, 19, 03, 02, 00, 00, 21, 00, 22, 6a, 00, 26, 00, 27, 30, 1d, 21, 02, 00, 00, 00, 26, 00, 27, 1d, 00, 28, 02, 06, 7e, 02, 05, 00, 06, 9a, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 44 +Number of expressions: 46 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(7) -- expression 2 operands: lhs = Counter(1), rhs = Counter(7) -- expression 3 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 4 operands: lhs = Counter(1), rhs = Counter(7) -- expression 5 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 6 operands: lhs = Counter(1), rhs = Counter(7) -- expression 7 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 8 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 9 operands: lhs = Counter(1), rhs = Counter(7) -- expression 10 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 11 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 12 operands: lhs = Counter(1), rhs = Counter(7) -- expression 13 operands: lhs = Expression(28, Sub), rhs = Counter(4) -- expression 14 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 15 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 16 operands: lhs = Counter(1), rhs = Counter(7) -- expression 17 operands: lhs = Expression(28, Sub), rhs = Counter(4) -- expression 18 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 19 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 20 operands: lhs = Counter(1), rhs = Counter(7) -- expression 21 operands: lhs = Expression(27, Sub), rhs = Counter(3) -- expression 22 operands: lhs = Expression(28, Sub), rhs = Counter(4) -- expression 23 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 24 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 25 operands: lhs = Counter(1), rhs = Counter(7) -- expression 26 operands: lhs = Expression(27, Sub), rhs = Counter(3) -- expression 27 operands: lhs = Expression(28, Sub), rhs = Counter(4) -- expression 28 operands: lhs = Expression(29, Sub), rhs = Counter(5) -- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(6) -- expression 30 operands: lhs = Counter(1), rhs = Counter(7) -- expression 31 operands: lhs = Expression(39, Add), rhs = Expression(0, Sub) -- expression 32 operands: lhs = Expression(40, Add), rhs = Counter(7) -- expression 33 operands: lhs = Expression(41, Add), rhs = Counter(6) -- expression 34 operands: lhs = Expression(42, Add), rhs = Counter(5) -- expression 35 operands: lhs = Expression(43, Add), rhs = Counter(4) -- expression 36 operands: lhs = Counter(2), rhs = Counter(3) -- expression 37 operands: lhs = Counter(8), rhs = Expression(38, Add) -- expression 38 operands: lhs = Expression(39, Add), rhs = Expression(0, Sub) -- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(7) -- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(6) -- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(5) -- expression 42 operands: lhs = Expression(43, Add), rhs = Counter(4) -- expression 43 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(30, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +- expression 5 operands: lhs = Counter(1), rhs = Expression(30, Add) +- expression 6 operands: lhs = Counter(2), rhs = Counter(3) +- expression 7 operands: lhs = Counter(1), rhs = Expression(29, Add) +- expression 8 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 9 operands: lhs = Counter(2), rhs = Counter(3) +- expression 10 operands: lhs = Counter(1), rhs = Expression(29, Add) +- expression 11 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 12 operands: lhs = Counter(2), rhs = Counter(3) +- expression 13 operands: lhs = Counter(1), rhs = Expression(28, Add) +- expression 14 operands: lhs = Expression(29, Add), rhs = Counter(5) +- expression 15 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 16 operands: lhs = Counter(2), rhs = Counter(3) +- expression 17 operands: lhs = Counter(1), rhs = Expression(28, Add) +- expression 18 operands: lhs = Expression(29, Add), rhs = Counter(5) +- expression 19 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 20 operands: lhs = Counter(2), rhs = Counter(3) +- expression 21 operands: lhs = Counter(1), rhs = Expression(27, Add) +- expression 22 operands: lhs = Expression(28, Add), rhs = Counter(6) +- expression 23 operands: lhs = Expression(29, Add), rhs = Counter(5) +- expression 24 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 25 operands: lhs = Counter(2), rhs = Counter(3) +- expression 26 operands: lhs = Counter(1), rhs = Expression(27, Add) +- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(6) +- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(5) +- expression 29 operands: lhs = Expression(30, Add), rhs = Counter(4) +- expression 30 operands: lhs = Counter(2), rhs = Counter(3) +- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(1) +- expression 32 operands: lhs = Expression(41, Add), rhs = Counter(8) +- expression 33 operands: lhs = Expression(42, Add), rhs = Counter(6) +- expression 34 operands: lhs = Expression(43, Add), rhs = Counter(5) +- expression 35 operands: lhs = Expression(44, Add), rhs = Counter(4) +- expression 36 operands: lhs = Expression(45, Add), rhs = Counter(3) +- expression 37 operands: lhs = Counter(0), rhs = Counter(2) +- expression 38 operands: lhs = Expression(39, Add), rhs = Counter(1) +- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(8) +- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(7) +- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(6) +- expression 42 operands: lhs = Expression(43, Add), rhs = Counter(5) +- expression 43 operands: lhs = Expression(44, Add), rhs = Counter(4) +- expression 44 operands: lhs = Expression(45, Add), rhs = Counter(3) +- expression 45 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 18 - Code(Counter(0)) at (prev + 7, 1) to (start + 2, 9) - MCDCDecision { bitmap_idx: 8, conditions_num: 7 } at (prev + 2, 8) to (start + 0, 39) @@ -54,38 +56,38 @@ Number of file 0 mappings: 18 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Expression(30, Sub), false: Counter(7), condition_id: 7, true_next_id: 6, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = (c1 - c7) - false = c7 -- Code(Expression(30, Sub)) at (prev + 0, 18) to (start + 0, 19) - = (c1 - c7) -- MCDCBranch { true: Expression(29, Sub), false: Counter(6), condition_id: 6, true_next_id: 5, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = ((c1 - c7) - c6) - false = c6 -- Code(Expression(29, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c1 - c7) - c6) -- MCDCBranch { true: Expression(28, Sub), false: Counter(5), condition_id: 5, true_next_id: 4, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) - true = (((c1 - c7) - c6) - c5) - false = c5 -- Code(Expression(28, Sub)) at (prev + 0, 28) to (start + 0, 29) - = (((c1 - c7) - c6) - c5) -- MCDCBranch { true: Expression(27, Sub), false: Counter(4), condition_id: 4, true_next_id: 3, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) - true = ((((c1 - c7) - c6) - c5) - c4) - false = c4 -- Code(Expression(27, Sub)) at (prev + 0, 33) to (start + 0, 34) - = ((((c1 - c7) - c6) - c5) - c4) -- MCDCBranch { true: Expression(26, Sub), false: Counter(3), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) - true = (((((c1 - c7) - c6) - c5) - c4) - c3) - false = c3 -- Code(Expression(26, Sub)) at (prev + 0, 38) to (start + 0, 39) - = (((((c1 - c7) - c6) - c5) - c4) - c3) -- MCDCBranch { true: Counter(8), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 38) to (start + 0, 39) - true = c8 +- MCDCBranch { true: Expression(2, Sub), false: Counter(2), condition_id: 7, true_next_id: 6, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) + true = (c1 - c2) false = c2 -- Code(Counter(8)) at (prev + 0, 40) to (start + 2, 6) -- Code(Expression(38, Add)) at (prev + 2, 5) to (start + 0, 6) - = ((((((c2 + c3) + c4) + c5) + c6) + c7) + (c0 - c1)) -- Code(Expression(37, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c8 + ((((((c2 + c3) + c4) + c5) + c6) + c7) + (c0 - c1))) +- Code(Expression(2, Sub)) at (prev + 0, 18) to (start + 0, 19) + = (c1 - c2) +- MCDCBranch { true: Expression(5, Sub), false: Counter(3), condition_id: 6, true_next_id: 5, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) + true = (c1 - (c2 + c3)) + false = c3 +- Code(Expression(5, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c1 - (c2 + c3)) +- MCDCBranch { true: Expression(10, Sub), false: Counter(4), condition_id: 5, true_next_id: 4, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) + true = (c1 - ((c2 + c3) + c4)) + false = c4 +- Code(Expression(10, Sub)) at (prev + 0, 28) to (start + 0, 29) + = (c1 - ((c2 + c3) + c4)) +- MCDCBranch { true: Expression(17, Sub), false: Counter(5), condition_id: 4, true_next_id: 3, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) + true = (c1 - (((c2 + c3) + c4) + c5)) + false = c5 +- Code(Expression(17, Sub)) at (prev + 0, 33) to (start + 0, 34) + = (c1 - (((c2 + c3) + c4) + c5)) +- MCDCBranch { true: Expression(26, Sub), false: Counter(6), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) + true = (c1 - ((((c2 + c3) + c4) + c5) + c6)) + false = c6 +- Code(Expression(26, Sub)) at (prev + 0, 38) to (start + 0, 39) + = (c1 - ((((c2 + c3) + c4) + c5) + c6)) +- MCDCBranch { true: Counter(7), false: Counter(8), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 38) to (start + 0, 39) + true = c7 + false = c8 +- Code(Counter(7)) at (prev + 0, 40) to (start + 2, 6) +- Code(Expression(31, Sub)) at (prev + 2, 5) to (start + 0, 6) + = (((((((c0 + c2) + c3) + c4) + c5) + c6) + c8) - c1) +- Code(Expression(38, Sub)) at (prev + 1, 1) to (start + 0, 2) + = ((((((((c0 + c2) + c3) + c4) + c5) + c6) + c7) + c8) - c1) Highest counter ID seen: c8 diff --git a/tests/coverage/mcdc/if.cov-map b/tests/coverage/mcdc/if.cov-map index c0e7d08bb028..acb8aac63de5 100644 --- a/tests/coverage/mcdc/if.cov-map +++ b/tests/coverage/mcdc/if.cov-map @@ -1,12 +1,14 @@ Function name: if::mcdc_check_a -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 0f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (68): 0x[01, 01, 06, 01, 05, 0b, 05, 01, 0d, 13, 05, 17, 0d, 01, 09, 08, 01, 0f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 0d, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 06, 02, 0c, 02, 06, 0e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(1) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) @@ -14,25 +16,27 @@ Number of file 0 mappings: 8 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c3 - false = c2 -- Code(Counter(3)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(3, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) + true = c2 + false = c3 +- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c3) - c1) +- Code(Expression(3, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: if::mcdc_check_b -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 17, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (68): 0x[01, 01, 06, 01, 05, 0b, 05, 01, 0d, 13, 05, 17, 0d, 01, 09, 08, 01, 17, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 0d, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 06, 02, 0c, 02, 06, 0e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(1) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 23, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) @@ -40,25 +44,27 @@ Number of file 0 mappings: 8 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c3 - false = c2 -- Code(Counter(3)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(3, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) + true = c2 + false = c3 +- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c3) - c1) +- Code(Expression(3, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: if::mcdc_check_both -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 1f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (68): 0x[01, 01, 06, 01, 05, 0b, 05, 01, 0d, 13, 05, 17, 0d, 01, 09, 08, 01, 1f, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 0d, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 06, 02, 0c, 02, 06, 0e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(1) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 31, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) @@ -66,25 +72,27 @@ Number of file 0 mappings: 8 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c3 - false = c2 -- Code(Counter(3)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(3, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) + true = c2 + false = c3 +- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c3) - c1) +- Code(Expression(3, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: if::mcdc_check_neither -Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 07, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] +Raw bytes (68): 0x[01, 01, 06, 01, 05, 0b, 05, 01, 0d, 13, 05, 17, 0d, 01, 09, 08, 01, 07, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 09, 0d, 02, 00, 00, 00, 0d, 00, 0e, 09, 00, 0f, 02, 06, 06, 02, 0c, 02, 06, 0e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 +Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(3), rhs = Expression(3, Add) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Counter(0), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(1) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) @@ -92,29 +100,32 @@ Number of file 0 mappings: 8 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) - true = c3 - false = c2 -- Code(Counter(3)) at (prev + 0, 15) to (start + 2, 6) -- Code(Expression(3, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) + true = c2 + false = c3 +- Code(Counter(2)) at (prev + 0, 15) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c3) - c1) +- Code(Expression(3, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: if::mcdc_check_not_tree_decision -Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 31, 01, 03, 0a, 28, 05, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02] +Raw bytes (93): 0x[01, 01, 0b, 01, 05, 01, 2b, 05, 09, 05, 09, 17, 2b, 01, 11, 05, 09, 23, 2b, 27, 11, 01, 0d, 05, 09, 0a, 01, 31, 01, 03, 0a, 28, 05, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 06, 03, 02, 00, 00, 0e, 00, 0f, 2b, 00, 14, 00, 15, 30, 0d, 11, 02, 00, 00, 00, 14, 00, 15, 0d, 00, 16, 02, 06, 12, 02, 0c, 02, 06, 1e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 8 +Number of expressions: 11 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Expression(10, Add) - expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Counter(3), rhs = Expression(7, Sub) -- expression 4 operands: lhs = Expression(0, Sub), rhs = Counter(2) -- expression 5 operands: lhs = Counter(4), rhs = Expression(6, Add) -- expression 6 operands: lhs = Counter(3), rhs = Expression(7, Sub) -- expression 7 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) +- expression 4 operands: lhs = Expression(5, Add), rhs = Expression(10, Add) +- expression 5 operands: lhs = Counter(0), rhs = Counter(4) +- expression 6 operands: lhs = Counter(1), rhs = Counter(2) +- expression 7 operands: lhs = Expression(8, Add), rhs = Expression(10, Add) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(4) +- expression 9 operands: lhs = Counter(0), rhs = Counter(3) +- expression 10 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 49, 1) to (start + 3, 10) - MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21) @@ -123,34 +134,36 @@ Number of file 0 mappings: 10 false = (c0 - c1) - Code(Expression(0, Sub)) at (prev + 0, 14) to (start + 0, 15) = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(7, Sub), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 14) to (start + 0, 15) +- MCDCBranch { true: Counter(2), false: Expression(1, Sub), condition_id: 3, true_next_id: 2, false_next_id: 0 } at (prev + 0, 14) to (start + 0, 15) true = c2 - false = ((c0 - c1) - c2) -- Code(Expression(2, Add)) at (prev + 0, 20) to (start + 0, 21) + false = (c0 - (c1 + c2)) +- Code(Expression(10, Add)) at (prev + 0, 20) to (start + 0, 21) = (c1 + c2) -- MCDCBranch { true: Counter(4), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 20) to (start + 0, 21) - true = c4 - false = c3 -- Code(Counter(4)) at (prev + 0, 22) to (start + 2, 6) -- Code(Expression(6, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c3 + ((c0 - c1) - c2)) -- Code(Expression(5, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c4 + (c3 + ((c0 - c1) - c2))) +- MCDCBranch { true: Counter(3), false: Counter(4), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 20) to (start + 0, 21) + true = c3 + false = c4 +- Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6) +- Code(Expression(4, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c4) - (c1 + c2)) +- Code(Expression(7, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c3) + c4) - (c1 + c2)) Highest counter ID seen: c4 Function name: if::mcdc_check_tree_decision -Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 27, 01, 03, 09, 28, 04, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02] +Raw bytes (91): 0x[01, 01, 0a, 01, 05, 05, 09, 05, 09, 09, 0d, 17, 05, 01, 11, 1f, 05, 23, 11, 27, 0d, 01, 09, 0a, 01, 27, 01, 03, 09, 28, 04, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 09, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 0d, 11, 03, 00, 00, 00, 13, 00, 14, 0f, 00, 16, 02, 06, 12, 02, 0c, 02, 06, 1a, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 8 +Number of expressions: 10 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(3) -- expression 2 operands: lhs = Counter(1), rhs = Counter(3) -- expression 3 operands: lhs = Counter(3), rhs = Counter(4) -- expression 4 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 5 operands: lhs = Expression(6, Add), rhs = Expression(7, Add) -- expression 6 operands: lhs = Counter(3), rhs = Counter(4) -- expression 7 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(1) +- expression 5 operands: lhs = Counter(0), rhs = Counter(4) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(1) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(4) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(3) +- expression 9 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 39, 1) to (start + 3, 9) - MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 3, 8) to (start + 0, 21) @@ -158,40 +171,43 @@ Number of file 0 mappings: 10 true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 14) to (start + 0, 15) -- MCDCBranch { true: Counter(3), false: Expression(2, Sub), condition_id: 2, true_next_id: 0, false_next_id: 3 } at (prev + 0, 14) to (start + 0, 15) - true = c3 - false = (c1 - c3) +- MCDCBranch { true: Counter(2), false: Expression(2, Sub), condition_id: 2, true_next_id: 0, false_next_id: 3 } at (prev + 0, 14) to (start + 0, 15) + true = c2 + false = (c1 - c2) - Code(Expression(2, Sub)) at (prev + 0, 19) to (start + 0, 20) - = (c1 - c3) -- MCDCBranch { true: Counter(4), false: Counter(2), condition_id: 3, true_next_id: 0, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) - true = c4 - false = c2 -- Code(Expression(6, Add)) at (prev + 0, 22) to (start + 2, 6) - = (c3 + c4) -- Code(Expression(7, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(5, Add)) at (prev + 3, 1) to (start + 0, 2) - = ((c3 + c4) + (c2 + (c0 - c1))) + = (c1 - c2) +- MCDCBranch { true: Counter(3), false: Counter(4), condition_id: 3, true_next_id: 0, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) + true = c3 + false = c4 +- Code(Expression(3, Add)) at (prev + 0, 22) to (start + 2, 6) + = (c2 + c3) +- Code(Expression(4, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c4) - c1) +- Code(Expression(6, Sub)) at (prev + 3, 1) to (start + 0, 2) + = ((((c0 + c2) + c3) + c4) - c1) Highest counter ID seen: c4 Function name: if::mcdc_nested_if -Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3b, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 06, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 09, 00, 0a, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02] +Raw bytes (130): 0x[01, 01, 10, 01, 05, 01, 3f, 05, 09, 05, 09, 3f, 0d, 05, 09, 3f, 0d, 05, 09, 0d, 15, 01, 3f, 05, 09, 33, 3f, 37, 15, 3b, 11, 01, 0d, 05, 09, 0e, 01, 3b, 01, 01, 09, 28, 03, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 26, 02, 00, 00, 00, 0d, 00, 0e, 3f, 01, 09, 01, 0d, 28, 06, 02, 01, 0c, 00, 12, 30, 1a, 0d, 01, 02, 00, 00, 0c, 00, 0d, 1a, 00, 11, 00, 12, 30, 11, 15, 02, 00, 00, 00, 11, 00, 12, 11, 00, 13, 02, 0a, 23, 02, 09, 00, 0a, 26, 01, 0c, 02, 06, 2e, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 13 +Number of expressions: 16 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Expression(15, Add) - expression 2 operands: lhs = Counter(1), rhs = Counter(2) -- expression 3 operands: lhs = Expression(6, Add), rhs = Counter(5) -- expression 4 operands: lhs = Counter(1), rhs = Counter(2) -- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(5) -- expression 6 operands: lhs = Counter(1), rhs = Counter(2) -- expression 7 operands: lhs = Counter(4), rhs = Counter(5) -- expression 8 operands: lhs = Expression(0, Sub), rhs = Counter(2) -- expression 9 operands: lhs = Expression(10, Add), rhs = Expression(12, Sub) -- expression 10 operands: lhs = Counter(3), rhs = Expression(11, Add) -- expression 11 operands: lhs = Counter(4), rhs = Counter(5) -- expression 12 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) +- expression 4 operands: lhs = Expression(15, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(1), rhs = Counter(2) +- expression 6 operands: lhs = Expression(15, Add), rhs = Counter(3) +- expression 7 operands: lhs = Counter(1), rhs = Counter(2) +- expression 8 operands: lhs = Counter(3), rhs = Counter(5) +- expression 9 operands: lhs = Counter(0), rhs = Expression(15, Add) +- expression 10 operands: lhs = Counter(1), rhs = Counter(2) +- expression 11 operands: lhs = Expression(12, Add), rhs = Expression(15, Add) +- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(5) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(4) +- expression 14 operands: lhs = Counter(0), rhs = Counter(3) +- expression 15 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 59, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 14) @@ -200,26 +216,26 @@ Number of file 0 mappings: 14 false = (c0 - c1) - Code(Expression(0, Sub)) at (prev + 0, 13) to (start + 0, 14) = (c0 - c1) -- MCDCBranch { true: Counter(2), false: Expression(12, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) +- MCDCBranch { true: Counter(2), false: Expression(9, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) true = c2 - false = ((c0 - c1) - c2) -- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 1, 13) + false = (c0 - (c1 + c2)) +- Code(Expression(15, Add)) at (prev + 1, 9) to (start + 1, 13) = (c1 + c2) - MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 1, 12) to (start + 0, 18) -- MCDCBranch { true: Expression(5, Sub), false: Counter(5), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 12) to (start + 0, 13) - true = ((c1 + c2) - c5) +- MCDCBranch { true: Expression(6, Sub), false: Counter(3), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 12) to (start + 0, 13) + true = ((c1 + c2) - c3) + false = c3 +- Code(Expression(6, Sub)) at (prev + 0, 17) to (start + 0, 18) + = ((c1 + c2) - c3) +- MCDCBranch { true: Counter(4), false: Counter(5), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 17) to (start + 0, 18) + true = c4 false = c5 -- Code(Expression(5, Sub)) at (prev + 0, 17) to (start + 0, 18) - = ((c1 + c2) - c5) -- MCDCBranch { true: Counter(3), false: Counter(4), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 17) to (start + 0, 18) - true = c3 - false = c4 -- Code(Counter(3)) at (prev + 0, 19) to (start + 2, 10) -- Code(Expression(11, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c4 + c5) -- Code(Expression(12, Sub)) at (prev + 1, 12) to (start + 2, 6) - = ((c0 - c1) - c2) -- Code(Expression(9, Add)) at (prev + 3, 1) to (start + 0, 2) - = ((c3 + (c4 + c5)) + ((c0 - c1) - c2)) +- Code(Counter(4)) at (prev + 0, 19) to (start + 2, 10) +- Code(Expression(8, Add)) at (prev + 2, 9) to (start + 0, 10) + = (c3 + c5) +- Code(Expression(9, Sub)) at (prev + 1, 12) to (start + 2, 6) + = (c0 - (c1 + c2)) +- Code(Expression(11, Sub)) at (prev + 3, 1) to (start + 0, 2) + = ((((c0 + c3) + c4) + c5) - (c1 + c2)) Highest counter ID seen: c5 diff --git a/tests/coverage/mcdc/inlined_expressions.cov-map b/tests/coverage/mcdc/inlined_expressions.cov-map index 4f44e0f2b855..92ec60dc23cb 100644 --- a/tests/coverage/mcdc/inlined_expressions.cov-map +++ b/tests/coverage/mcdc/inlined_expressions.cov-map @@ -1,11 +1,12 @@ Function name: inlined_expressions::inlined_instance -Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 03, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02] +Raw bytes (54): 0x[01, 01, 04, 01, 05, 0b, 05, 0f, 0d, 01, 09, 06, 01, 08, 01, 01, 06, 28, 03, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 06, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 4 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 8, 1) to (start + 1, 6) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11) @@ -16,7 +17,7 @@ Number of file 0 mappings: 6 - MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 10) to (start + 0, 11) true = c2 false = c3 -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(1, Sub)) at (prev + 1, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 diff --git a/tests/coverage/mcdc/nested_if.cov-map b/tests/coverage/mcdc/nested_if.cov-map index 3bed49e7a12d..72daecabc77a 100644 --- a/tests/coverage/mcdc/nested_if.cov-map +++ b/tests/coverage/mcdc/nested_if.cov-map @@ -1,205 +1,213 @@ Function name: nested_if::doubly_nested_if_in_condition -Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 0f, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 06, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 03, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02] +Raw bytes (172): 0x[01, 01, 10, 01, 05, 05, 09, 05, 09, 05, 27, 09, 19, 19, 1d, 19, 1d, 23, 27, 05, 1d, 09, 19, 09, 0d, 33, 05, 01, 15, 3b, 05, 3f, 15, 01, 11, 14, 01, 0f, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 11, 15, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 06, 02, 00, 10, 00, 36, 30, 09, 0a, 01, 00, 02, 00, 10, 00, 11, 30, 0d, 21, 02, 00, 00, 00, 15, 00, 36, 0a, 00, 18, 00, 19, 28, 03, 02, 00, 18, 00, 1e, 30, 19, 0e, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1e, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 11, 00, 4f, 02, 06, 2e, 02, 0c, 02, 06, 36, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 14 +Number of expressions: 16 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(4) -- expression 3 operands: lhs = Expression(9, Sub), rhs = Counter(6) -- expression 4 operands: lhs = Counter(1), rhs = Counter(4) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(9, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(6) - expression 5 operands: lhs = Counter(6), rhs = Counter(7) - expression 6 operands: lhs = Counter(6), rhs = Counter(7) -- expression 7 operands: lhs = Counter(7), rhs = Expression(8, Sub) -- expression 8 operands: lhs = Expression(9, Sub), rhs = Counter(6) -- expression 9 operands: lhs = Counter(1), rhs = Counter(4) -- expression 10 operands: lhs = Counter(4), rhs = Counter(5) -- expression 11 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 12 operands: lhs = Counter(3), rhs = Expression(13, Add) -- expression 13 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 7 operands: lhs = Expression(8, Add), rhs = Expression(9, Add) +- expression 8 operands: lhs = Counter(1), rhs = Counter(7) +- expression 9 operands: lhs = Counter(2), rhs = Counter(6) +- expression 10 operands: lhs = Counter(2), rhs = Counter(3) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(1) +- expression 12 operands: lhs = Counter(0), rhs = Counter(5) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(1) +- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(5) +- expression 15 operands: lhs = Counter(0), rhs = Counter(4) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 15, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 78) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 false = (c0 - c1) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 78) - true = c3 - false = c2 +- MCDCBranch { true: Counter(4), false: Counter(5), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 78) + true = c4 + false = c5 - Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) - MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 54) -- MCDCBranch { true: Counter(4), false: Expression(9, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c4 - false = (c1 - c4) -- MCDCBranch { true: Counter(5), false: Counter(8), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 54) - true = c5 +- MCDCBranch { true: Counter(2), false: Expression(2, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) + true = c2 + false = (c1 - c2) +- MCDCBranch { true: Counter(3), false: Counter(8), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 54) + true = c3 false = c8 -- Code(Expression(9, Sub)) at (prev + 0, 24) to (start + 0, 25) - = (c1 - c4) +- Code(Expression(2, Sub)) at (prev + 0, 24) to (start + 0, 25) + = (c1 - c2) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 24) to (start + 0, 30) -- MCDCBranch { true: Counter(6), false: Expression(8, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 24) to (start + 0, 25) +- MCDCBranch { true: Counter(6), false: Expression(3, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 24) to (start + 0, 25) true = c6 - false = ((c1 - c4) - c6) + false = (c1 - (c2 + c6)) - Code(Counter(6)) at (prev + 0, 29) to (start + 0, 30) - MCDCBranch { true: Expression(6, Sub), false: Counter(7), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 29) to (start + 0, 30) true = (c6 - c7) false = c7 - Code(Expression(6, Sub)) at (prev + 0, 33) to (start + 0, 37) = (c6 - c7) -- Code(Expression(7, Add)) at (prev + 0, 47) to (start + 0, 52) - = (c7 + ((c1 - c4) - c6)) +- Code(Expression(7, Sub)) at (prev + 0, 47) to (start + 0, 52) + = ((c1 + c7) - (c2 + c6)) - Code(Expression(10, Add)) at (prev + 0, 57) to (start + 0, 62) - = (c4 + c5) + = (c2 + c3) - Code(Counter(8)) at (prev + 0, 72) to (start + 0, 76) -- Code(Counter(3)) at (prev + 0, 79) to (start + 2, 6) -- Code(Expression(13, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(12, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- Code(Counter(4)) at (prev + 0, 79) to (start + 2, 6) +- Code(Expression(11, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c5) - c1) +- Code(Expression(13, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c4) + c5) - c1) Highest counter ID seen: c8 Function name: nested_if::nested_if_in_condition -Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 07, 01, 01, 09, 28, 06, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02] +Raw bytes (124): 0x[01, 01, 0d, 01, 05, 05, 09, 05, 09, 05, 1f, 09, 0d, 09, 0d, 05, 1f, 09, 0d, 27, 05, 01, 15, 2f, 05, 33, 15, 01, 11, 0e, 01, 07, 01, 01, 09, 28, 06, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 11, 15, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 09, 0a, 01, 00, 02, 00, 10, 00, 11, 0a, 00, 15, 00, 16, 30, 0d, 1a, 02, 00, 00, 00, 15, 00, 16, 1f, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 11, 00, 2f, 02, 06, 22, 02, 0c, 02, 06, 2a, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 11 +Number of expressions: 13 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(4) -- expression 3 operands: lhs = Expression(7, Sub), rhs = Counter(5) -- expression 4 operands: lhs = Counter(1), rhs = Counter(4) -- expression 5 operands: lhs = Counter(4), rhs = Counter(5) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(5) -- expression 7 operands: lhs = Counter(1), rhs = Counter(4) -- expression 8 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 9 operands: lhs = Counter(3), rhs = Expression(10, Add) -- expression 10 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +- expression 5 operands: lhs = Counter(2), rhs = Counter(3) +- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(1) +- expression 9 operands: lhs = Counter(0), rhs = Counter(5) +- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(1) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(5) +- expression 12 operands: lhs = Counter(0), rhs = Counter(4) Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 7, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 46) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 false = (c0 - c1) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 46) - true = c3 - false = c2 +- MCDCBranch { true: Counter(4), false: Counter(5), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 46) + true = c4 + false = c5 - Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22) -- MCDCBranch { true: Counter(4), false: Expression(7, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c4 - false = (c1 - c4) -- Code(Expression(7, Sub)) at (prev + 0, 21) to (start + 0, 22) - = (c1 - c4) -- MCDCBranch { true: Counter(5), false: Expression(6, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) - true = c5 - false = ((c1 - c4) - c5) -- Code(Expression(5, Add)) at (prev + 0, 25) to (start + 0, 29) - = (c4 + c5) +- MCDCBranch { true: Counter(2), false: Expression(2, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) + true = c2 + false = (c1 - c2) +- Code(Expression(2, Sub)) at (prev + 0, 21) to (start + 0, 22) + = (c1 - c2) +- MCDCBranch { true: Counter(3), false: Expression(6, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) + true = c3 + false = (c1 - (c2 + c3)) +- Code(Expression(7, Add)) at (prev + 0, 25) to (start + 0, 29) + = (c2 + c3) - Code(Expression(6, Sub)) at (prev + 0, 39) to (start + 0, 44) - = ((c1 - c4) - c5) -- Code(Counter(3)) at (prev + 0, 47) to (start + 2, 6) -- Code(Expression(10, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(9, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) + = (c1 - (c2 + c3)) +- Code(Counter(4)) at (prev + 0, 47) to (start + 2, 6) +- Code(Expression(8, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c5) - c1) +- Code(Expression(10, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c4) + c5) - c1) Highest counter ID seen: c5 Function name: nested_if::nested_in_then_block_in_condition -Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 22, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 06, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02] +Raw bytes (180): 0x[01, 01, 14, 01, 05, 05, 09, 05, 09, 05, 3b, 09, 0d, 09, 0d, 3b, 11, 09, 0d, 11, 15, 11, 15, 2f, 11, 3b, 15, 09, 0d, 05, 3b, 09, 0d, 43, 05, 01, 1d, 4b, 05, 4f, 1d, 01, 19, 14, 01, 22, 01, 01, 09, 28, 09, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 19, 1d, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 03, 02, 00, 10, 00, 16, 30, 09, 0a, 01, 00, 02, 00, 10, 00, 11, 0a, 00, 15, 00, 16, 30, 0d, 36, 02, 00, 00, 00, 15, 00, 16, 3b, 00, 1c, 00, 1d, 28, 06, 02, 00, 1c, 00, 22, 30, 11, 1a, 01, 02, 00, 00, 1c, 00, 1d, 11, 00, 21, 00, 22, 30, 26, 15, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2a, 00, 33, 00, 38, 36, 00, 44, 00, 49, 19, 00, 4c, 02, 06, 3e, 02, 0c, 02, 06, 46, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 18 +Number of expressions: 20 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(4) -- expression 3 operands: lhs = Expression(14, Sub), rhs = Counter(5) -- expression 4 operands: lhs = Counter(1), rhs = Counter(4) -- expression 5 operands: lhs = Counter(4), rhs = Counter(5) -- expression 6 operands: lhs = Expression(12, Add), rhs = Counter(6) -- expression 7 operands: lhs = Counter(4), rhs = Counter(5) -- expression 8 operands: lhs = Counter(6), rhs = Counter(7) -- expression 9 operands: lhs = Counter(6), rhs = Counter(7) -- expression 10 operands: lhs = Counter(7), rhs = Expression(11, Sub) -- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(6) -- expression 12 operands: lhs = Counter(4), rhs = Counter(5) -- expression 13 operands: lhs = Expression(14, Sub), rhs = Counter(5) -- expression 14 operands: lhs = Counter(1), rhs = Counter(4) -- expression 15 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 16 operands: lhs = Counter(3), rhs = Expression(17, Add) -- expression 17 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Counter(1), rhs = Expression(14, Add) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) +- expression 5 operands: lhs = Counter(2), rhs = Counter(3) +- expression 6 operands: lhs = Expression(14, Add), rhs = Counter(4) +- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 8 operands: lhs = Counter(4), rhs = Counter(5) +- expression 9 operands: lhs = Counter(4), rhs = Counter(5) +- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(4) +- expression 11 operands: lhs = Expression(14, Add), rhs = Counter(5) +- expression 12 operands: lhs = Counter(2), rhs = Counter(3) +- expression 13 operands: lhs = Counter(1), rhs = Expression(14, Add) +- expression 14 operands: lhs = Counter(2), rhs = Counter(3) +- expression 15 operands: lhs = Expression(16, Add), rhs = Counter(1) +- expression 16 operands: lhs = Counter(0), rhs = Counter(7) +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(1) +- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(7) +- expression 19 operands: lhs = Counter(0), rhs = Counter(6) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 34, 1) to (start + 1, 9) - MCDCDecision { bitmap_idx: 9, conditions_num: 2 } at (prev + 1, 8) to (start + 0, 75) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 false = (c0 - c1) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 75) - true = c3 - false = c2 +- MCDCBranch { true: Counter(6), false: Counter(7), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 75) + true = c6 + false = c7 - Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 16) to (start + 0, 22) -- MCDCBranch { true: Counter(4), false: Expression(14, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) - true = c4 - false = (c1 - c4) -- Code(Expression(14, Sub)) at (prev + 0, 21) to (start + 0, 22) - = (c1 - c4) -- MCDCBranch { true: Counter(5), false: Expression(13, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) - true = c5 - false = ((c1 - c4) - c5) -- Code(Expression(12, Add)) at (prev + 0, 28) to (start + 0, 29) - = (c4 + c5) +- MCDCBranch { true: Counter(2), false: Expression(2, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 16) to (start + 0, 17) + true = c2 + false = (c1 - c2) +- Code(Expression(2, Sub)) at (prev + 0, 21) to (start + 0, 22) + = (c1 - c2) +- MCDCBranch { true: Counter(3), false: Expression(13, Sub), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 21) to (start + 0, 22) + true = c3 + false = (c1 - (c2 + c3)) +- Code(Expression(14, Add)) at (prev + 0, 28) to (start + 0, 29) + = (c2 + c3) - MCDCDecision { bitmap_idx: 6, conditions_num: 2 } at (prev + 0, 28) to (start + 0, 34) -- MCDCBranch { true: Counter(6), false: Expression(11, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) - true = c6 - false = ((c4 + c5) - c6) -- Code(Counter(6)) at (prev + 0, 33) to (start + 0, 34) -- MCDCBranch { true: Expression(9, Sub), false: Counter(7), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) - true = (c6 - c7) - false = c7 +- MCDCBranch { true: Counter(4), false: Expression(6, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 28) to (start + 0, 29) + true = c4 + false = ((c2 + c3) - c4) +- Code(Counter(4)) at (prev + 0, 33) to (start + 0, 34) +- MCDCBranch { true: Expression(9, Sub), false: Counter(5), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 33) to (start + 0, 34) + true = (c4 - c5) + false = c5 - Code(Expression(9, Sub)) at (prev + 0, 37) to (start + 0, 41) - = (c6 - c7) -- Code(Expression(10, Add)) at (prev + 0, 51) to (start + 0, 56) - = (c7 + ((c4 + c5) - c6)) + = (c4 - c5) +- Code(Expression(10, Sub)) at (prev + 0, 51) to (start + 0, 56) + = (((c2 + c3) + c5) - c4) - Code(Expression(13, Sub)) at (prev + 0, 68) to (start + 0, 73) - = ((c1 - c4) - c5) -- Code(Counter(3)) at (prev + 0, 76) to (start + 2, 6) -- Code(Expression(17, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(16, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) + = (c1 - (c2 + c3)) +- Code(Counter(6)) at (prev + 0, 76) to (start + 2, 6) +- Code(Expression(15, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c7) - c1) +- Code(Expression(17, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c6) + c7) - c1) Highest counter ID seen: c7 Function name: nested_if::nested_single_condition_decision -Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 17, 01, 04, 09, 28, 03, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02] +Raw bytes (89): 0x[01, 01, 08, 01, 05, 05, 09, 05, 09, 13, 05, 01, 11, 1b, 05, 1f, 11, 01, 0d, 0b, 01, 17, 01, 04, 09, 28, 03, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 11, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 09, 0a, 00, 10, 00, 11, 09, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 0e, 02, 0c, 02, 06, 16, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 6 +Number of expressions: 8 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Counter(4) -- expression 2 operands: lhs = Counter(1), rhs = Counter(4) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Counter(3), rhs = Expression(5, Add) -- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(1) +- expression 4 operands: lhs = Counter(0), rhs = Counter(4) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(1) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(4) +- expression 7 operands: lhs = Counter(0), rhs = Counter(3) Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 23, 1) to (start + 4, 9) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 4, 8) to (start + 0, 41) - MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 8) to (start + 0, 9) true = c1 false = (c0 - c1) -- MCDCBranch { true: Counter(3), false: Counter(2), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 41) +- MCDCBranch { true: Counter(3), false: Counter(4), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 41) true = c3 - false = c2 + false = c4 - Code(Counter(1)) at (prev + 0, 16) to (start + 0, 17) -- Branch { true: Counter(4), false: Expression(2, Sub) } at (prev + 0, 16) to (start + 0, 17) - true = c4 - false = (c1 - c4) -- Code(Counter(4)) at (prev + 0, 20) to (start + 0, 25) +- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 16) to (start + 0, 17) + true = c2 + false = (c1 - c2) +- Code(Counter(2)) at (prev + 0, 20) to (start + 0, 25) - Code(Expression(2, Sub)) at (prev + 0, 35) to (start + 0, 39) - = (c1 - c4) + = (c1 - c2) - Code(Counter(3)) at (prev + 0, 42) to (start + 2, 6) -- Code(Expression(5, Add)) at (prev + 2, 12) to (start + 2, 6) - = (c2 + (c0 - c1)) -- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + (c2 + (c0 - c1))) +- Code(Expression(3, Sub)) at (prev + 2, 12) to (start + 2, 6) + = ((c0 + c4) - c1) +- Code(Expression(5, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (((c0 + c3) + c4) - c1) Highest counter ID seen: c4 diff --git a/tests/coverage/mcdc/non_control_flow.cov-map b/tests/coverage/mcdc/non_control_flow.cov-map index 677e31e404e4..0edeff9a5867 100644 --- a/tests/coverage/mcdc/non_control_flow.cov-map +++ b/tests/coverage/mcdc/non_control_flow.cov-map @@ -1,67 +1,65 @@ Function name: non_control_flow::assign_3 -Raw bytes (89): 0x[01, 01, 09, 05, 07, 0b, 11, 09, 0d, 01, 05, 01, 05, 22, 11, 01, 05, 22, 11, 01, 05, 0a, 01, 16, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 04, 03, 00, 0d, 00, 18, 30, 05, 22, 01, 00, 02, 00, 0d, 00, 0e, 22, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (89): 0x[01, 01, 09, 07, 11, 0b, 0d, 05, 09, 01, 05, 01, 05, 01, 23, 05, 11, 01, 23, 05, 11, 0a, 01, 16, 01, 00, 28, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 04, 03, 00, 0d, 00, 18, 30, 05, 12, 01, 00, 02, 00, 0d, 00, 0e, 12, 00, 12, 00, 13, 30, 1e, 11, 02, 03, 00, 00, 12, 00, 13, 1e, 00, 17, 00, 18, 30, 09, 0d, 03, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 9 -- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Add) -- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(4) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(4) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(2) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) - expression 4 operands: lhs = Counter(0), rhs = Counter(1) -- expression 5 operands: lhs = Expression(8, Sub), rhs = Counter(4) -- expression 6 operands: lhs = Counter(0), rhs = Counter(1) -- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(4) -- expression 8 operands: lhs = Counter(0), rhs = Counter(1) +- expression 5 operands: lhs = Counter(0), rhs = Expression(8, Add) +- expression 6 operands: lhs = Counter(1), rhs = Counter(4) +- expression 7 operands: lhs = Counter(0), rhs = Expression(8, Add) +- expression 8 operands: lhs = Counter(1), rhs = Counter(4) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 22, 1) to (start + 0, 40) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) - = (c1 + ((c2 + c3) + c4)) + = (((c1 + c2) + c3) + c4) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) - MCDCDecision { bitmap_idx: 4, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24) -- MCDCBranch { true: Counter(1), false: Expression(8, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) +- MCDCBranch { true: Counter(1), false: Expression(4, Sub), condition_id: 1, true_next_id: 0, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) true = c1 false = (c0 - c1) -- Code(Expression(8, Sub)) at (prev + 0, 18) to (start + 0, 19) +- Code(Expression(4, Sub)) at (prev + 0, 18) to (start + 0, 19) = (c0 - c1) - MCDCBranch { true: Expression(7, Sub), false: Counter(4), condition_id: 2, true_next_id: 3, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) - true = ((c0 - c1) - c4) + true = (c0 - (c1 + c4)) false = c4 - Code(Expression(7, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c0 - c1) - c4) + = (c0 - (c1 + c4)) - MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 3, true_next_id: 0, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) true = c2 false = c3 - Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c1 + ((c2 + c3) + c4)) + = (((c1 + c2) + c3) + c4) Highest counter ID seen: c4 Function name: non_control_flow::assign_3_bis -Raw bytes (85): 0x[01, 01, 07, 07, 11, 09, 0d, 01, 05, 05, 09, 16, 1a, 05, 09, 01, 05, 0a, 01, 1b, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 05, 03, 00, 0d, 00, 18, 30, 05, 1a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 16, 03, 00, 02, 00, 12, 00, 13, 13, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] +Raw bytes (81): 0x[01, 01, 05, 07, 11, 09, 0d, 01, 05, 05, 09, 01, 09, 0a, 01, 1b, 01, 00, 2c, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 05, 03, 00, 0d, 00, 18, 30, 05, 0a, 01, 03, 02, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0e, 03, 00, 02, 00, 12, 00, 13, 12, 00, 17, 00, 18, 30, 0d, 11, 02, 00, 00, 00, 17, 00, 18, 03, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 7 +Number of expressions: 5 - expression 0 operands: lhs = Expression(1, Add), rhs = Counter(4) - expression 1 operands: lhs = Counter(2), rhs = Counter(3) - expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Counter(1), rhs = Counter(2) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Expression(6, Sub) -- expression 5 operands: lhs = Counter(1), rhs = Counter(2) -- expression 6 operands: lhs = Counter(0), rhs = Counter(1) +- expression 4 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 27, 1) to (start + 0, 44) - Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) = ((c2 + c3) + c4) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) - MCDCDecision { bitmap_idx: 5, conditions_num: 3 } at (prev + 0, 13) to (start + 0, 24) -- MCDCBranch { true: Counter(1), false: Expression(6, Sub), condition_id: 1, true_next_id: 3, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) +- MCDCBranch { true: Counter(1), false: Expression(2, Sub), condition_id: 1, true_next_id: 3, false_next_id: 2 } at (prev + 0, 13) to (start + 0, 14) true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 18) to (start + 0, 19) -- MCDCBranch { true: Counter(2), false: Expression(5, Sub), condition_id: 3, true_next_id: 0, false_next_id: 2 } at (prev + 0, 18) to (start + 0, 19) +- MCDCBranch { true: Counter(2), false: Expression(3, Sub), condition_id: 3, true_next_id: 0, false_next_id: 2 } at (prev + 0, 18) to (start + 0, 19) true = c2 false = (c1 - c2) -- Code(Expression(4, Add)) at (prev + 0, 23) to (start + 0, 24) - = ((c1 - c2) + (c0 - c1)) +- Code(Expression(4, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c0 - c2) - MCDCBranch { true: Counter(3), false: Counter(4), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 23) to (start + 0, 24) true = c3 false = c4 @@ -70,18 +68,18 @@ Number of file 0 mappings: 10 Highest counter ID seen: c4 Function name: non_control_flow::assign_and -Raw bytes (64): 0x[01, 01, 04, 07, 0e, 09, 0d, 01, 05, 01, 05, 08, 01, 0c, 01, 00, 21, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (64): 0x[01, 01, 04, 07, 05, 0b, 0d, 01, 09, 01, 05, 08, 01, 0c, 01, 00, 21, 02, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 03, 02, 00, 0d, 00, 13, 30, 05, 0e, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 12, 00, 13, 30, 09, 0d, 02, 00, 00, 00, 12, 00, 13, 02, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 -- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(3, Sub) -- expression 1 operands: lhs = Counter(2), rhs = Counter(3) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(1) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(0), rhs = Counter(2) - expression 3 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 12, 1) to (start + 0, 33) -- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 10) + = (((c0 + c2) + c3) - c1) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 0, 13) to (start + 0, 19) - MCDCBranch { true: Counter(1), false: Expression(3, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) @@ -91,8 +89,8 @@ Number of file 0 mappings: 8 - MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 18) to (start + 0, 19) true = c2 false = c3 -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 1, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: non_control_flow::assign_or @@ -132,13 +130,14 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: non_control_flow::func_call -Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 29, 01, 01, 0a, 28, 03, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 07, 01, 01, 00, 02] +Raw bytes (54): 0x[01, 01, 04, 01, 05, 0b, 05, 0f, 0d, 01, 09, 06, 01, 29, 01, 01, 0a, 28, 03, 02, 01, 09, 00, 0f, 30, 05, 02, 01, 02, 00, 00, 09, 00, 0a, 05, 00, 0e, 00, 0f, 30, 09, 0d, 02, 00, 00, 00, 0e, 00, 0f, 06, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 4 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(1) +- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 41, 1) to (start + 1, 10) - MCDCDecision { bitmap_idx: 3, conditions_num: 2 } at (prev + 1, 9) to (start + 0, 15) @@ -149,63 +148,63 @@ Number of file 0 mappings: 6 - MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 14) to (start + 0, 15) true = c2 false = c3 -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((c2 + c3) + (c0 - c1)) +- Code(Expression(1, Sub)) at (prev + 1, 1) to (start + 0, 2) + = (((c0 + c2) + c3) - c1) Highest counter ID seen: c3 Function name: non_control_flow::right_comb_tree -Raw bytes (139): 0x[01, 01, 13, 07, 1a, 0b, 19, 0f, 15, 13, 11, 09, 0d, 01, 05, 01, 05, 05, 19, 05, 19, 4a, 15, 05, 19, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 46, 11, 4a, 15, 05, 19, 0e, 01, 20, 01, 00, 41, 03, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 06, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 4a, 19, 02, 03, 00, 00, 13, 00, 14, 4a, 00, 19, 00, 1a, 30, 46, 15, 03, 04, 00, 00, 19, 00, 1a, 46, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 09, 0d, 05, 00, 00, 00, 24, 00, 27, 03, 01, 05, 01, 02] +Raw bytes (139): 0x[01, 01, 13, 07, 05, 0b, 19, 0f, 15, 13, 11, 17, 0d, 01, 09, 01, 05, 05, 09, 05, 09, 05, 4b, 09, 0d, 05, 4b, 09, 0d, 05, 47, 4b, 11, 09, 0d, 05, 47, 4b, 11, 09, 0d, 0e, 01, 20, 01, 00, 41, 02, 01, 09, 00, 0a, 01, 00, 0d, 00, 0e, 28, 06, 05, 00, 0d, 00, 2a, 30, 05, 1a, 01, 02, 00, 00, 0d, 00, 0e, 05, 00, 13, 00, 14, 30, 22, 09, 02, 03, 00, 00, 13, 00, 14, 22, 00, 19, 00, 1a, 30, 2e, 0d, 03, 04, 00, 00, 19, 00, 1a, 2e, 00, 1f, 00, 20, 30, 42, 11, 04, 05, 00, 00, 1f, 00, 20, 42, 00, 24, 00, 27, 30, 15, 19, 05, 00, 00, 00, 24, 00, 27, 02, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 19 -- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(6, Sub) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(1) - expression 1 operands: lhs = Expression(2, Add), rhs = Counter(6) - expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5) - expression 3 operands: lhs = Expression(4, Add), rhs = Counter(4) -- expression 4 operands: lhs = Counter(2), rhs = Counter(3) -- expression 5 operands: lhs = Counter(0), rhs = Counter(1) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) - expression 6 operands: lhs = Counter(0), rhs = Counter(1) -- expression 7 operands: lhs = Counter(1), rhs = Counter(6) -- expression 8 operands: lhs = Counter(1), rhs = Counter(6) -- expression 9 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 10 operands: lhs = Counter(1), rhs = Counter(6) -- expression 11 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 12 operands: lhs = Counter(1), rhs = Counter(6) -- expression 13 operands: lhs = Expression(17, Sub), rhs = Counter(4) -- expression 14 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 15 operands: lhs = Counter(1), rhs = Counter(6) -- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(4) -- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 18 operands: lhs = Counter(1), rhs = Counter(6) +- expression 7 operands: lhs = Counter(1), rhs = Counter(2) +- expression 8 operands: lhs = Counter(1), rhs = Counter(2) +- expression 9 operands: lhs = Counter(1), rhs = Expression(18, Add) +- expression 10 operands: lhs = Counter(2), rhs = Counter(3) +- expression 11 operands: lhs = Counter(1), rhs = Expression(18, Add) +- expression 12 operands: lhs = Counter(2), rhs = Counter(3) +- expression 13 operands: lhs = Counter(1), rhs = Expression(17, Add) +- expression 14 operands: lhs = Expression(18, Add), rhs = Counter(4) +- expression 15 operands: lhs = Counter(2), rhs = Counter(3) +- expression 16 operands: lhs = Counter(1), rhs = Expression(17, Add) +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(4) +- expression 18 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 32, 1) to (start + 0, 65) -- Code(Expression(0, Add)) at (prev + 1, 9) to (start + 0, 10) - = (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1)) +- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 10) + = ((((((c0 + c2) + c3) + c4) + c5) + c6) - c1) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 14) - MCDCDecision { bitmap_idx: 6, conditions_num: 5 } at (prev + 0, 13) to (start + 0, 42) - MCDCBranch { true: Counter(1), false: Expression(6, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 13) to (start + 0, 14) true = c1 false = (c0 - c1) - Code(Counter(1)) at (prev + 0, 19) to (start + 0, 20) -- MCDCBranch { true: Expression(18, Sub), false: Counter(6), condition_id: 2, true_next_id: 3, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) - true = (c1 - c6) - false = c6 -- Code(Expression(18, Sub)) at (prev + 0, 25) to (start + 0, 26) - = (c1 - c6) -- MCDCBranch { true: Expression(17, Sub), false: Counter(5), condition_id: 3, true_next_id: 4, false_next_id: 0 } at (prev + 0, 25) to (start + 0, 26) - true = ((c1 - c6) - c5) - false = c5 -- Code(Expression(17, Sub)) at (prev + 0, 31) to (start + 0, 32) - = ((c1 - c6) - c5) +- MCDCBranch { true: Expression(8, Sub), false: Counter(2), condition_id: 2, true_next_id: 3, false_next_id: 0 } at (prev + 0, 19) to (start + 0, 20) + true = (c1 - c2) + false = c2 +- Code(Expression(8, Sub)) at (prev + 0, 25) to (start + 0, 26) + = (c1 - c2) +- MCDCBranch { true: Expression(11, Sub), false: Counter(3), condition_id: 3, true_next_id: 4, false_next_id: 0 } at (prev + 0, 25) to (start + 0, 26) + true = (c1 - (c2 + c3)) + false = c3 +- Code(Expression(11, Sub)) at (prev + 0, 31) to (start + 0, 32) + = (c1 - (c2 + c3)) - MCDCBranch { true: Expression(16, Sub), false: Counter(4), condition_id: 4, true_next_id: 5, false_next_id: 0 } at (prev + 0, 31) to (start + 0, 32) - true = (((c1 - c6) - c5) - c4) + true = (c1 - ((c2 + c3) + c4)) false = c4 - Code(Expression(16, Sub)) at (prev + 0, 36) to (start + 0, 39) - = (((c1 - c6) - c5) - c4) -- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 5, true_next_id: 0, false_next_id: 0 } at (prev + 0, 36) to (start + 0, 39) - true = c2 - false = c3 -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = (((((c2 + c3) + c4) + c5) + c6) + (c0 - c1)) + = (c1 - ((c2 + c3) + c4)) +- MCDCBranch { true: Counter(5), false: Counter(6), condition_id: 5, true_next_id: 0, false_next_id: 0 } at (prev + 0, 36) to (start + 0, 39) + true = c5 + false = c6 +- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 1, 2) + = ((((((c0 + c2) + c3) + c4) + c5) + c6) - c1) Highest counter ID seen: c6 diff --git a/tests/coverage/nested_loops.cov-map b/tests/coverage/nested_loops.cov-map index 21871ef32064..6ba5887d243b 100644 --- a/tests/coverage/nested_loops.cov-map +++ b/tests/coverage/nested_loops.cov-map @@ -1,52 +1,46 @@ Function name: nested_loops::main -Raw bytes (115): 0x[01, 01, 17, 01, 57, 05, 09, 03, 0d, 4e, 53, 03, 0d, 15, 19, 4b, 09, 4e, 53, 03, 0d, 15, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 42, 19, 46, 05, 4b, 09, 4e, 53, 03, 0d, 15, 19, 05, 09, 11, 0d, 0d, 01, 01, 01, 02, 1b, 03, 04, 13, 00, 20, 4e, 01, 0d, 01, 18, 4b, 02, 12, 00, 17, 46, 01, 10, 00, 16, 05, 01, 11, 00, 16, 42, 01, 0e, 03, 16, 3e, 04, 11, 01, 1b, 11, 02, 15, 00, 21, 15, 01, 18, 02, 12, 19, 03, 0d, 00, 0e, 57, 02, 09, 00, 17, 5b, 02, 01, 00, 02] +Raw bytes (103): 0x[01, 01, 11, 27, 09, 01, 05, 03, 0d, 13, 0d, 17, 15, 03, 11, 1f, 0d, 23, 15, 27, 11, 01, 05, 2f, 0d, 3b, 15, 01, 11, 3b, 0d, 01, 11, 05, 09, 0d, 19, 0d, 01, 01, 01, 02, 1b, 03, 04, 13, 00, 20, 0a, 01, 0d, 01, 18, 0e, 02, 12, 00, 17, 1a, 01, 10, 00, 16, 05, 01, 11, 00, 16, 2a, 01, 0e, 03, 16, 36, 04, 11, 01, 1b, 19, 02, 15, 00, 21, 11, 01, 18, 02, 12, 15, 03, 0d, 00, 0e, 3f, 02, 09, 00, 17, 43, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 23 -- expression 0 operands: lhs = Counter(0), rhs = Expression(21, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +Number of expressions: 17 +- expression 0 operands: lhs = Expression(9, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) -- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 5 operands: lhs = Counter(5), rhs = Counter(6) -- expression 6 operands: lhs = Expression(18, Add), rhs = Counter(2) -- expression 7 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) -- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 9 operands: lhs = Counter(5), rhs = Counter(6) -- expression 10 operands: lhs = Expression(17, Sub), rhs = Counter(1) -- expression 11 operands: lhs = Expression(18, Add), rhs = Counter(2) -- expression 12 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) -- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 14 operands: lhs = Counter(5), rhs = Counter(6) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(6) -- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(1) -- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(2) -- expression 18 operands: lhs = Expression(19, Sub), rhs = Expression(20, Add) -- expression 19 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 20 operands: lhs = Counter(5), rhs = Counter(6) -- expression 21 operands: lhs = Counter(1), rhs = Counter(2) -- expression 22 operands: lhs = Counter(4), rhs = Counter(3) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(3) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(5) +- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) +- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(3) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(5) +- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(4) +- expression 9 operands: lhs = Counter(0), rhs = Counter(1) +- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(3) +- expression 11 operands: lhs = Expression(14, Add), rhs = Counter(5) +- expression 12 operands: lhs = Counter(0), rhs = Counter(4) +- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(3) +- expression 14 operands: lhs = Counter(0), rhs = Counter(4) +- expression 15 operands: lhs = Counter(1), rhs = Counter(2) +- expression 16 operands: lhs = Counter(3), rhs = Counter(6) Number of file 0 mappings: 13 - Code(Counter(0)) at (prev + 1, 1) to (start + 2, 27) - Code(Expression(0, Add)) at (prev + 4, 19) to (start + 0, 32) - = (c0 + (c1 + c2)) -- Code(Expression(19, Sub)) at (prev + 1, 13) to (start + 1, 24) - = ((c0 + (c1 + c2)) - c3) -- Code(Expression(18, Add)) at (prev + 2, 18) to (start + 0, 23) - = (((c0 + (c1 + c2)) - c3) + (c5 + c6)) -- Code(Expression(17, Sub)) at (prev + 1, 16) to (start + 0, 22) - = ((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) + = ((c0 + c1) + c2) +- Code(Expression(2, Sub)) at (prev + 1, 13) to (start + 1, 24) + = (((c0 + c1) + c2) - c3) +- Code(Expression(3, Sub)) at (prev + 2, 18) to (start + 0, 23) + = (((((c0 + c1) + c2) + c4) + c5) - c3) +- Code(Expression(6, Sub)) at (prev + 1, 16) to (start + 0, 22) + = ((((c0 + c1) + c4) + c5) - c3) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 22) -- Code(Expression(16, Sub)) at (prev + 1, 14) to (start + 3, 22) - = (((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1) -- Code(Expression(15, Sub)) at (prev + 4, 17) to (start + 1, 27) - = ((((((c0 + (c1 + c2)) - c3) + (c5 + c6)) - c2) - c1) - c6) -- Code(Counter(4)) at (prev + 2, 21) to (start + 0, 33) -- Code(Counter(5)) at (prev + 1, 24) to (start + 2, 18) -- Code(Counter(6)) at (prev + 3, 13) to (start + 0, 14) -- Code(Expression(21, Add)) at (prev + 2, 9) to (start + 0, 23) +- Code(Expression(10, Sub)) at (prev + 1, 14) to (start + 3, 22) + = (((c0 + c4) + c5) - c3) +- Code(Expression(13, Sub)) at (prev + 4, 17) to (start + 1, 27) + = ((c0 + c4) - c3) +- Code(Counter(6)) at (prev + 2, 21) to (start + 0, 33) +- Code(Counter(4)) at (prev + 1, 24) to (start + 2, 18) +- Code(Counter(5)) at (prev + 3, 13) to (start + 0, 14) +- Code(Expression(15, Add)) at (prev + 2, 9) to (start + 0, 23) = (c1 + c2) -- Code(Expression(22, Add)) at (prev + 2, 1) to (start + 0, 2) - = (c4 + c3) +- Code(Expression(16, Add)) at (prev + 2, 1) to (start + 0, 2) + = (c3 + c6) Highest counter ID seen: c6 diff --git a/tests/coverage/overflow.cov-map b/tests/coverage/overflow.cov-map index f6bfb465bf9a..01abcc15003e 100644 --- a/tests/coverage/overflow.cov-map +++ b/tests/coverage/overflow.cov-map @@ -1,29 +1,30 @@ Function name: overflow::main -Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 10, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 09, 00, 0a, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Raw bytes (67): 0x[01, 01, 09, 07, 0d, 0b, 09, 01, 05, 03, 11, 17, 11, 1b, 0d, 01, 09, 23, 0d, 05, 09, 09, 01, 10, 01, 01, 1b, 03, 02, 0b, 00, 18, 0e, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 09, 00, 0a, 1f, 01, 09, 00, 17, 11, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) -- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +Number of expressions: 9 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) -- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(4) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3) +- expression 6 operands: lhs = Counter(0), rhs = Counter(2) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 16, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) - = (c0 + (c1 + (c2 + c3))) -- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) - = ((c0 + (c1 + (c2 + c3))) - c4) + = (((c0 + c1) + c2) + c3) +- Code(Expression(3, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((((c0 + c1) + c2) + c3) - c4) - Code(Counter(1)) at (prev + 0, 27) to (start + 3, 10) - Code(Expression(4, Sub)) at (prev + 3, 19) to (start + 0, 32) - = (((c0 + (c1 + (c2 + c3))) - c4) - c1) + = (((c0 + c2) + c3) - c4) - Code(Counter(2)) at (prev + 0, 33) to (start + 3, 10) - Code(Counter(3)) at (prev + 3, 9) to (start + 0, 10) -- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) - = (c1 + (c2 + c3)) +- Code(Expression(7, Add)) at (prev + 1, 9) to (start + 0, 23) + = ((c1 + c2) + c3) - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) Highest counter ID seen: c4 diff --git a/tests/coverage/panic_unwind.cov-map b/tests/coverage/panic_unwind.cov-map index 58a796ff3a2c..005c4babbea8 100644 --- a/tests/coverage/panic_unwind.cov-map +++ b/tests/coverage/panic_unwind.cov-map @@ -1,29 +1,30 @@ Function name: panic_unwind::main -Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 09, 00, 0a, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Raw bytes (67): 0x[01, 01, 09, 07, 0d, 0b, 09, 01, 05, 03, 11, 17, 11, 1b, 0d, 01, 09, 23, 0d, 05, 09, 09, 01, 0d, 01, 01, 1b, 03, 02, 0b, 00, 18, 0e, 01, 0c, 00, 1a, 05, 00, 1b, 02, 0a, 12, 02, 13, 00, 20, 09, 00, 21, 02, 0a, 0d, 02, 09, 00, 0a, 1f, 01, 09, 00, 17, 11, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Expression(6, Add) -- expression 1 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +Number of expressions: 9 +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(3) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(0), rhs = Counter(1) - expression 3 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(1) -- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(4) -- expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(4) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3) +- expression 6 operands: lhs = Counter(0), rhs = Counter(2) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 13, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) - = (c0 + (c1 + (c2 + c3))) -- Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) - = ((c0 + (c1 + (c2 + c3))) - c4) + = (((c0 + c1) + c2) + c3) +- Code(Expression(3, Sub)) at (prev + 1, 12) to (start + 0, 26) + = ((((c0 + c1) + c2) + c3) - c4) - Code(Counter(1)) at (prev + 0, 27) to (start + 2, 10) - Code(Expression(4, Sub)) at (prev + 2, 19) to (start + 0, 32) - = (((c0 + (c1 + (c2 + c3))) - c4) - c1) + = (((c0 + c2) + c3) - c4) - Code(Counter(2)) at (prev + 0, 33) to (start + 2, 10) - Code(Counter(3)) at (prev + 2, 9) to (start + 0, 10) -- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23) - = (c1 + (c2 + c3)) +- Code(Expression(7, Add)) at (prev + 1, 9) to (start + 0, 23) + = ((c1 + c2) + c3) - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) Highest counter ID seen: c4 diff --git a/tests/coverage/simple_match.cov-map b/tests/coverage/simple_match.cov-map index d8bf9eae4bc6..8f973742959e 100644 --- a/tests/coverage/simple_match.cov-map +++ b/tests/coverage/simple_match.cov-map @@ -1,29 +1,29 @@ Function name: simple_match::main -Raw bytes (72): 0x[01, 01, 09, 01, 05, 01, 23, 09, 0d, 1f, 11, 01, 23, 09, 0d, 1f, 11, 01, 23, 09, 0d, 0a, 01, 04, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 05, 00, 06, 1f, 05, 09, 00, 0d, 1a, 05, 0d, 00, 16, 09, 02, 0d, 00, 0e, 1a, 02, 11, 02, 12, 09, 04, 0d, 07, 0e, 0d, 0a, 0d, 00, 0f, 11, 03, 01, 00, 02] +Raw bytes (72): 0x[01, 01, 09, 01, 05, 23, 0d, 01, 09, 1f, 11, 23, 0d, 01, 09, 1f, 11, 23, 0d, 01, 09, 0a, 01, 04, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 05, 00, 06, 1f, 05, 09, 00, 0d, 1a, 05, 0d, 00, 16, 09, 02, 0d, 00, 0e, 1a, 02, 11, 02, 12, 09, 04, 0d, 07, 0e, 0d, 0a, 0d, 00, 0f, 11, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 9 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(8, Add) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 2 operands: lhs = Counter(0), rhs = Counter(2) - expression 3 operands: lhs = Expression(7, Add), rhs = Counter(4) -- expression 4 operands: lhs = Counter(0), rhs = Expression(8, Add) -- expression 5 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(0), rhs = Counter(2) - expression 6 operands: lhs = Expression(7, Add), rhs = Counter(4) -- expression 7 operands: lhs = Counter(0), rhs = Expression(8, Add) -- expression 8 operands: lhs = Counter(2), rhs = Counter(3) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 4, 1) to (start + 7, 15) - Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) = (c0 - c1) - Code(Expression(7, Add)) at (prev + 5, 9) to (start + 0, 13) - = (c0 + (c2 + c3)) + = ((c0 + c2) + c3) - Code(Expression(6, Sub)) at (prev + 5, 13) to (start + 0, 22) - = ((c0 + (c2 + c3)) - c4) + = (((c0 + c2) + c3) - c4) - Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(6, Sub)) at (prev + 2, 17) to (start + 2, 18) - = ((c0 + (c2 + c3)) - c4) + = (((c0 + c2) + c3) - c4) - Code(Counter(2)) at (prev + 4, 13) to (start + 7, 14) - Code(Counter(3)) at (prev + 10, 13) to (start + 0, 15) - Code(Counter(4)) at (prev + 3, 1) to (start + 0, 2) diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map index 246a1ba738b2..7fbd2cc642e6 100644 --- a/tests/coverage/try_error_result.cov-map +++ b/tests/coverage/try_error_result.cov-map @@ -55,162 +55,162 @@ Number of file 0 mappings: 4 Highest counter ID seen: c1 Function name: try_error_result::test1 -Raw bytes (75): 0x[01, 01, 08, 01, 07, 00, 09, 03, 0d, 12, 1d, 03, 0d, 1b, 0d, 1f, 00, 11, 00, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 12, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0e, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 17, 01, 01, 00, 02] +Raw bytes (75): 0x[01, 01, 08, 07, 09, 01, 00, 03, 0d, 03, 13, 0d, 11, 1b, 00, 1f, 00, 0d, 15, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 0a, 02, 09, 04, 1a, 11, 06, 0d, 00, 29, 15, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0e, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 17, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 -- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) -- expression 1 operands: lhs = Zero, rhs = Counter(2) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Zero - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7) -- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3) +- expression 3 operands: lhs = Expression(0, Add), rhs = Expression(4, Add) +- expression 4 operands: lhs = Counter(3), rhs = Counter(4) +- expression 5 operands: lhs = Expression(6, Add), rhs = Zero - expression 6 operands: lhs = Expression(7, Add), rhs = Zero -- expression 7 operands: lhs = Counter(4), rhs = Zero +- expression 7 operands: lhs = Counter(3), rhs = Counter(5) Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 13, 1) to (start + 2, 23) - Code(Expression(0, Add)) at (prev + 7, 9) to (start + 0, 14) - = (c0 + (Zero + c2)) -- Code(Expression(4, Sub)) at (prev + 2, 9) to (start + 4, 26) - = ((c0 + (Zero + c2)) - c3) -- Code(Counter(7)) at (prev + 6, 13) to (start + 0, 41) -- Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42) + = ((c0 + Zero) + c2) +- Code(Expression(2, Sub)) at (prev + 2, 9) to (start + 4, 26) + = (((c0 + Zero) + c2) - c3) +- Code(Counter(4)) at (prev + 6, 13) to (start + 0, 41) +- Code(Counter(5)) at (prev + 0, 41) to (start + 0, 42) - Code(Zero) at (prev + 1, 13) to (start + 0, 42) - Code(Zero) at (prev + 0, 42) to (start + 0, 43) - Code(Expression(3, Sub)) at (prev + 4, 13) to (start + 0, 42) - = (((c0 + (Zero + c2)) - c3) - c7) + = (((c0 + Zero) + c2) - (c3 + c4)) - Code(Zero) at (prev + 0, 42) to (start + 0, 43) - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) - Code(Expression(5, Add)) at (prev + 1, 1) to (start + 0, 2) - = (((c4 + Zero) + Zero) + c3) -Highest counter ID seen: c7 + = (((c3 + c5) + Zero) + Zero) +Highest counter ID seen: c5 Function name: try_error_result::test2 -Raw bytes (358): 0x[01, 01, 3b, 01, 07, 05, 09, 03, 0d, 41, 11, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 4a, 15, 41, 11, 46, 19, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 5e, 25, 49, 21, 49, 21, 5e, 25, 49, 21, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, 92, 01, 41, 03, 0d, 8e, 01, 29, 92, 01, 41, 03, 0d, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, a6, 01, 35, 45, 31, 45, 31, a6, 01, 35, 45, 31, ba, 01, 3d, 4d, 39, 4d, 39, ba, 01, 3d, 4d, 39, c3, 01, 0d, c7, 01, db, 01, cb, 01, cf, 01, 11, 15, d3, 01, d7, 01, 19, 1d, 21, 25, df, 01, e3, 01, 29, 2d, e7, 01, eb, 01, 31, 35, 39, 3d, 28, 01, 3d, 01, 03, 17, 03, 08, 09, 00, 0e, 92, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 4a, 00, 31, 03, 35, 15, 04, 11, 00, 12, 46, 02, 11, 04, 12, 3e, 05, 11, 00, 14, 46, 00, 17, 00, 41, 19, 00, 41, 00, 42, 42, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 3e, 01, 0d, 00, 20, 5a, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 5e, 00, 43, 00, 60, 25, 00, 60, 00, 61, 5a, 01, 0d, 00, 20, 86, 01, 04, 11, 00, 14, 8e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 8a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 86, 01, 01, 0d, 00, 20, a2, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, a6, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, ba, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, bf, 01, 01, 01, 00, 02] +Raw bytes (355): 0x[01, 01, 3b, 07, 09, 01, 05, 03, 0d, 11, 15, 11, 4b, 15, 19, 11, 43, 47, 21, 4b, 1d, 15, 19, 11, 4b, 15, 19, 11, 47, 4b, 1d, 15, 19, 11, 43, 47, 21, 4b, 1d, 15, 19, 45, 5f, 25, 29, 45, 25, 45, 5f, 25, 29, 03, 8b, 01, 8f, 01, 31, 93, 01, 2d, 0d, 11, 03, 93, 01, 0d, 11, 03, 8f, 01, 93, 01, 2d, 0d, 11, 03, 8b, 01, 8f, 01, 31, 93, 01, 2d, 0d, 11, 49, a7, 01, 35, 39, 49, 35, 49, a7, 01, 35, 39, 4d, bb, 01, 3d, 41, 4d, 3d, 4d, bb, 01, 3d, 41, c3, 01, 41, c7, 01, 3d, cb, 01, 39, cf, 01, 35, d3, 01, 31, d7, 01, 2d, db, 01, 29, df, 01, 25, e3, 01, 21, e7, 01, 1d, eb, 01, 19, 0d, 15, 28, 01, 3d, 01, 03, 17, 03, 08, 09, 00, 0e, 0a, 02, 09, 04, 1a, 11, 06, 0d, 00, 2f, 15, 00, 2f, 00, 30, 0e, 00, 31, 03, 35, 19, 04, 11, 00, 12, 2a, 02, 11, 04, 12, 3e, 05, 11, 00, 14, 2a, 00, 17, 00, 41, 1d, 00, 41, 00, 42, 32, 00, 43, 00, 5f, 21, 00, 5f, 00, 60, 3e, 01, 0d, 00, 20, 5a, 01, 11, 00, 14, 45, 00, 17, 00, 41, 25, 00, 41, 00, 42, 56, 00, 43, 00, 60, 29, 00, 60, 00, 61, 5a, 01, 0d, 00, 20, 86, 01, 04, 11, 00, 14, 72, 00, 17, 00, 42, 2d, 00, 42, 00, 43, 7a, 00, 44, 00, 61, 31, 00, 61, 00, 62, 86, 01, 01, 0d, 00, 20, a2, 01, 01, 11, 00, 14, 49, 00, 17, 01, 36, 35, 01, 36, 00, 37, 9e, 01, 01, 12, 00, 2f, 39, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 3d, 02, 11, 00, 12, b2, 01, 01, 12, 00, 2f, 41, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, bf, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 59 -- expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(16), rhs = Counter(4) -- expression 4 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 5 operands: lhs = Counter(16), rhs = Counter(4) -- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 7 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 8 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 9 operands: lhs = Counter(16), rhs = Counter(4) -- expression 10 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 11 operands: lhs = Counter(16), rhs = Counter(4) -- expression 12 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 13 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 14 operands: lhs = Counter(16), rhs = Counter(4) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 18 operands: lhs = Counter(16), rhs = Counter(4) -- expression 19 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 20 operands: lhs = Counter(18), rhs = Counter(8) -- expression 21 operands: lhs = Counter(18), rhs = Counter(8) -- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 23 operands: lhs = Counter(18), rhs = Counter(8) -- expression 24 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 25 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 26 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 27 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 28 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 29 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 30 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 31 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 33 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 34 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 36 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 37 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 38 operands: lhs = Counter(17), rhs = Counter(12) -- expression 39 operands: lhs = Counter(17), rhs = Counter(12) -- expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 41 operands: lhs = Counter(17), rhs = Counter(12) -- expression 42 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 43 operands: lhs = Counter(19), rhs = Counter(14) -- expression 44 operands: lhs = Counter(19), rhs = Counter(14) -- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 46 operands: lhs = Counter(19), rhs = Counter(14) -- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(3) -- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(54, Add) -- expression 49 operands: lhs = Expression(50, Add), rhs = Expression(51, Add) -- expression 50 operands: lhs = Counter(4), rhs = Counter(5) -- expression 51 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) -- expression 52 operands: lhs = Counter(6), rhs = Counter(7) -- expression 53 operands: lhs = Counter(8), rhs = Counter(9) -- expression 54 operands: lhs = Expression(55, Add), rhs = Expression(56, Add) -- expression 55 operands: lhs = Counter(10), rhs = Counter(11) -- expression 56 operands: lhs = Expression(57, Add), rhs = Expression(58, Add) -- expression 57 operands: lhs = Counter(12), rhs = Counter(13) -- expression 58 operands: lhs = Counter(14), rhs = Counter(15) +- expression 3 operands: lhs = Counter(4), rhs = Counter(5) +- expression 4 operands: lhs = Counter(4), rhs = Expression(18, Add) +- expression 5 operands: lhs = Counter(5), rhs = Counter(6) +- expression 6 operands: lhs = Counter(4), rhs = Expression(16, Add) +- expression 7 operands: lhs = Expression(17, Add), rhs = Counter(8) +- expression 8 operands: lhs = Expression(18, Add), rhs = Counter(7) +- expression 9 operands: lhs = Counter(5), rhs = Counter(6) +- expression 10 operands: lhs = Counter(4), rhs = Expression(18, Add) +- expression 11 operands: lhs = Counter(5), rhs = Counter(6) +- expression 12 operands: lhs = Counter(4), rhs = Expression(17, Add) +- expression 13 operands: lhs = Expression(18, Add), rhs = Counter(7) +- expression 14 operands: lhs = Counter(5), rhs = Counter(6) +- expression 15 operands: lhs = Counter(4), rhs = Expression(16, Add) +- expression 16 operands: lhs = Expression(17, Add), rhs = Counter(8) +- expression 17 operands: lhs = Expression(18, Add), rhs = Counter(7) +- expression 18 operands: lhs = Counter(5), rhs = Counter(6) +- expression 19 operands: lhs = Counter(17), rhs = Expression(23, Add) +- expression 20 operands: lhs = Counter(9), rhs = Counter(10) +- expression 21 operands: lhs = Counter(17), rhs = Counter(9) +- expression 22 operands: lhs = Counter(17), rhs = Expression(23, Add) +- expression 23 operands: lhs = Counter(9), rhs = Counter(10) +- expression 24 operands: lhs = Expression(0, Add), rhs = Expression(34, Add) +- expression 25 operands: lhs = Expression(35, Add), rhs = Counter(12) +- expression 26 operands: lhs = Expression(36, Add), rhs = Counter(11) +- expression 27 operands: lhs = Counter(3), rhs = Counter(4) +- expression 28 operands: lhs = Expression(0, Add), rhs = Expression(36, Add) +- expression 29 operands: lhs = Counter(3), rhs = Counter(4) +- expression 30 operands: lhs = Expression(0, Add), rhs = Expression(35, Add) +- expression 31 operands: lhs = Expression(36, Add), rhs = Counter(11) +- expression 32 operands: lhs = Counter(3), rhs = Counter(4) +- expression 33 operands: lhs = Expression(0, Add), rhs = Expression(34, Add) +- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(12) +- expression 35 operands: lhs = Expression(36, Add), rhs = Counter(11) +- expression 36 operands: lhs = Counter(3), rhs = Counter(4) +- expression 37 operands: lhs = Counter(18), rhs = Expression(41, Add) +- expression 38 operands: lhs = Counter(13), rhs = Counter(14) +- expression 39 operands: lhs = Counter(18), rhs = Counter(13) +- expression 40 operands: lhs = Counter(18), rhs = Expression(41, Add) +- expression 41 operands: lhs = Counter(13), rhs = Counter(14) +- expression 42 operands: lhs = Counter(19), rhs = Expression(46, Add) +- expression 43 operands: lhs = Counter(15), rhs = Counter(16) +- expression 44 operands: lhs = Counter(19), rhs = Counter(15) +- expression 45 operands: lhs = Counter(19), rhs = Expression(46, Add) +- expression 46 operands: lhs = Counter(15), rhs = Counter(16) +- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(16) +- expression 48 operands: lhs = Expression(49, Add), rhs = Counter(15) +- expression 49 operands: lhs = Expression(50, Add), rhs = Counter(14) +- expression 50 operands: lhs = Expression(51, Add), rhs = Counter(13) +- expression 51 operands: lhs = Expression(52, Add), rhs = Counter(12) +- expression 52 operands: lhs = Expression(53, Add), rhs = Counter(11) +- expression 53 operands: lhs = Expression(54, Add), rhs = Counter(10) +- expression 54 operands: lhs = Expression(55, Add), rhs = Counter(9) +- expression 55 operands: lhs = Expression(56, Add), rhs = Counter(8) +- expression 56 operands: lhs = Expression(57, Add), rhs = Counter(7) +- expression 57 operands: lhs = Expression(58, Add), rhs = Counter(6) +- expression 58 operands: lhs = Counter(3), rhs = Counter(5) Number of file 0 mappings: 40 - Code(Counter(0)) at (prev + 61, 1) to (start + 3, 23) - Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14) - = (c0 + (c1 + c2)) -- Code(Expression(36, Sub)) at (prev + 2, 9) to (start + 4, 26) - = ((c0 + (c1 + c2)) - c3) -- Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47) -- Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(18, Sub)) at (prev + 0, 49) to (start + 3, 53) - = (c16 - c4) -- Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18) -- Code(Expression(17, Sub)) at (prev + 2, 17) to (start + 4, 18) - = ((c16 - c4) - c5) + = ((c0 + c1) + c2) +- Code(Expression(2, Sub)) at (prev + 2, 9) to (start + 4, 26) + = (((c0 + c1) + c2) - c3) +- Code(Counter(4)) at (prev + 6, 13) to (start + 0, 47) +- Code(Counter(5)) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(3, Sub)) at (prev + 0, 49) to (start + 3, 53) + = (c4 - c5) +- Code(Counter(6)) at (prev + 4, 17) to (start + 0, 18) +- Code(Expression(10, Sub)) at (prev + 2, 17) to (start + 4, 18) + = (c4 - (c5 + c6)) - Code(Expression(15, Sub)) at (prev + 5, 17) to (start + 0, 20) - = ((((c16 - c4) - c5) - c6) - c7) -- Code(Expression(17, Sub)) at (prev + 0, 23) to (start + 0, 65) - = ((c16 - c4) - c5) -- Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(16, Sub)) at (prev + 0, 67) to (start + 0, 95) - = (((c16 - c4) - c5) - c6) -- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96) + = (c4 - (((c5 + c6) + c7) + c8)) +- Code(Expression(10, Sub)) at (prev + 0, 23) to (start + 0, 65) + = (c4 - (c5 + c6)) +- Code(Counter(7)) at (prev + 0, 65) to (start + 0, 66) +- Code(Expression(12, Sub)) at (prev + 0, 67) to (start + 0, 95) + = (c4 - ((c5 + c6) + c7)) +- Code(Counter(8)) at (prev + 0, 95) to (start + 0, 96) - Code(Expression(15, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((((c16 - c4) - c5) - c6) - c7) + = (c4 - (((c5 + c6) + c7) + c8)) - Code(Expression(22, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c18 - c8) - c9) -- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65) -- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(23, Sub)) at (prev + 0, 67) to (start + 0, 96) - = (c18 - c8) -- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97) + = (c17 - (c9 + c10)) +- Code(Counter(17)) at (prev + 0, 23) to (start + 0, 65) +- Code(Counter(9)) at (prev + 0, 65) to (start + 0, 66) +- Code(Expression(21, Sub)) at (prev + 0, 67) to (start + 0, 96) + = (c17 - c9) +- Code(Counter(10)) at (prev + 0, 96) to (start + 0, 97) - Code(Expression(22, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((c18 - c8) - c9) + = (c17 - (c9 + c10)) - Code(Expression(33, Sub)) at (prev + 4, 17) to (start + 0, 20) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) -- Code(Expression(35, Sub)) at (prev + 0, 23) to (start + 0, 66) - = (((c0 + (c1 + c2)) - c3) - c16) -- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67) -- Code(Expression(34, Sub)) at (prev + 0, 68) to (start + 0, 97) - = ((((c0 + (c1 + c2)) - c3) - c16) - c10) -- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98) + = (((c0 + c1) + c2) - (((c3 + c4) + c11) + c12)) +- Code(Expression(28, Sub)) at (prev + 0, 23) to (start + 0, 66) + = (((c0 + c1) + c2) - (c3 + c4)) +- Code(Counter(11)) at (prev + 0, 66) to (start + 0, 67) +- Code(Expression(30, Sub)) at (prev + 0, 68) to (start + 0, 97) + = (((c0 + c1) + c2) - ((c3 + c4) + c11)) +- Code(Counter(12)) at (prev + 0, 97) to (start + 0, 98) - Code(Expression(33, Sub)) at (prev + 1, 13) to (start + 0, 32) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) + = (((c0 + c1) + c2) - (((c3 + c4) + c11) + c12)) - Code(Expression(40, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c17 - c12) - c13) -- Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54) -- Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55) -- Code(Expression(41, Sub)) at (prev + 1, 18) to (start + 0, 47) - = (c17 - c12) -- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48) + = (c18 - (c13 + c14)) +- Code(Counter(18)) at (prev + 0, 23) to (start + 1, 54) +- Code(Counter(13)) at (prev + 1, 54) to (start + 0, 55) +- Code(Expression(39, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c18 - c13) +- Code(Counter(14)) at (prev + 0, 47) to (start + 0, 48) - Code(Expression(40, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((c17 - c12) - c13) + = (c18 - (c13 + c14)) - Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c19 - c14) - c15) + = (c19 - (c15 + c16)) - Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54) -- Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18) -- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47) - = (c19 - c14) -- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18) +- Code(Counter(15)) at (prev + 2, 17) to (start + 0, 18) +- Code(Expression(44, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c19 - c15) +- Code(Counter(16)) at (prev + 1, 17) to (start + 0, 18) - Code(Expression(45, Sub)) at (prev + 2, 13) to (start + 0, 32) - = ((c19 - c14) - c15) + = (c19 - (c15 + c16)) - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) - Code(Expression(47, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((((c4 + c5) + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15)))) + c3) + = ((((((((((((c3 + c5) + c6) + c7) + c8) + c9) + c10) + c11) + c12) + c13) + c14) + c15) + c16) Highest counter ID seen: c19 diff --git a/tests/coverage/unicode.cov-map b/tests/coverage/unicode.cov-map index 769930110d67..630ab4ce47e1 100644 --- a/tests/coverage/unicode.cov-map +++ b/tests/coverage/unicode.cov-map @@ -1,14 +1,14 @@ Function name: unicode::main -Raw bytes (61): 0x[01, 01, 06, 01, 05, 16, 0d, 01, 09, 11, 13, 16, 0d, 01, 09, 09, 01, 0e, 01, 00, 0b, 05, 01, 09, 00, 0c, 03, 00, 10, 00, 1b, 05, 00, 1c, 00, 28, 01, 02, 08, 00, 25, 09, 00, 29, 00, 46, 11, 00, 47, 02, 06, 13, 02, 05, 00, 06, 0f, 02, 05, 01, 02] +Raw bytes (61): 0x[01, 01, 06, 01, 05, 0b, 09, 01, 11, 13, 09, 17, 11, 01, 0d, 09, 01, 0e, 01, 00, 0b, 05, 01, 09, 00, 0c, 03, 00, 10, 00, 1b, 05, 00, 1c, 00, 28, 01, 02, 08, 00, 25, 09, 00, 29, 00, 46, 0d, 00, 47, 02, 06, 06, 02, 05, 00, 06, 0e, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(5, Sub), rhs = Counter(3) -- expression 2 operands: lhs = Counter(0), rhs = Counter(2) -- expression 3 operands: lhs = Counter(4), rhs = Expression(4, Add) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(3) -- expression 5 operands: lhs = Counter(0), rhs = Counter(2) +- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(2) +- expression 2 operands: lhs = Counter(0), rhs = Counter(4) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(2) +- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(4) +- expression 5 operands: lhs = Counter(0), rhs = Counter(3) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 14, 1) to (start + 0, 11) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 12) @@ -17,12 +17,12 @@ Number of file 0 mappings: 9 - Code(Counter(1)) at (prev + 0, 28) to (start + 0, 40) - Code(Counter(0)) at (prev + 2, 8) to (start + 0, 37) - Code(Counter(2)) at (prev + 0, 41) to (start + 0, 70) -- Code(Counter(4)) at (prev + 0, 71) to (start + 2, 6) -- Code(Expression(4, Add)) at (prev + 2, 5) to (start + 0, 6) - = ((c0 - c2) + c3) -- Code(Expression(3, Add)) at (prev + 2, 5) to (start + 1, 2) - = (c4 + ((c0 - c2) + c3)) -Highest counter ID seen: c4 +- Code(Counter(3)) at (prev + 0, 71) to (start + 2, 6) +- Code(Expression(1, Sub)) at (prev + 2, 5) to (start + 0, 6) + = ((c0 + c4) - c2) +- Code(Expression(3, Sub)) at (prev + 2, 5) to (start + 1, 2) + = (((c0 + c3) + c4) - c2) +Highest counter ID seen: c3 Function name: unicode::他 (unused) Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 19, 00, 25] diff --git a/tests/coverage/unused.cov-map b/tests/coverage/unused.cov-map index e865ac3ee622..4eae63f380ca 100644 --- a/tests/coverage/unused.cov-map +++ b/tests/coverage/unused.cov-map @@ -1,18 +1,18 @@ Function name: unused::foo:: -Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] +Raw bytes (42): 0x[01, 01, 04, 07, 09, 01, 05, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 -- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) - expression 3 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17) - = (c0 + (c1 + c2)) + = ((c0 + c1) + c2) - Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15) - = ((c0 + (c1 + c2)) - c3) + = (((c0 + c1) + c2) - c3) - Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25) - Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15) = (c1 + c2) @@ -20,20 +20,20 @@ Number of file 0 mappings: 6 Highest counter ID seen: c3 Function name: unused::foo:: -Raw bytes (42): 0x[01, 01, 04, 01, 0f, 05, 09, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] +Raw bytes (42): 0x[01, 01, 04, 07, 09, 01, 05, 03, 0d, 05, 09, 06, 01, 03, 01, 01, 12, 03, 02, 0b, 00, 11, 0a, 01, 09, 00, 0f, 09, 00, 13, 00, 19, 0f, 01, 09, 00, 0f, 0d, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 4 -- expression 0 operands: lhs = Counter(0), rhs = Expression(3, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Expression(1, Add), rhs = Counter(2) +- expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) - expression 3 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 3, 1) to (start + 1, 18) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 17) - = (c0 + (c1 + c2)) + = ((c0 + c1) + c2) - Code(Expression(2, Sub)) at (prev + 1, 9) to (start + 0, 15) - = ((c0 + (c1 + c2)) - c3) + = (((c0 + c1) + c2) - c3) - Code(Counter(2)) at (prev + 0, 19) to (start + 0, 25) - Code(Expression(3, Add)) at (prev + 1, 9) to (start + 0, 15) = (c1 + c2) diff --git a/tests/coverage/while_early_ret.cov-map b/tests/coverage/while_early_ret.cov-map index 6254dfbcf010..ade770597e2f 100644 --- a/tests/coverage/while_early_ret.cov-map +++ b/tests/coverage/while_early_ret.cov-map @@ -1,27 +1,26 @@ Function name: while_early_ret::main -Raw bytes (61): 0x[01, 01, 06, 01, 05, 03, 09, 0e, 05, 03, 09, 17, 09, 0d, 11, 09, 01, 05, 01, 01, 1b, 03, 03, 09, 02, 0a, 0e, 05, 0d, 02, 0e, 0a, 06, 15, 02, 16, 0d, 04, 15, 00, 1b, 11, 04, 15, 00, 1b, 05, 03, 0a, 03, 0a, 09, 06, 05, 00, 0b, 13, 01, 01, 00, 02] +Raw bytes (59): 0x[01, 01, 05, 01, 05, 03, 09, 01, 09, 13, 11, 09, 0d, 09, 01, 05, 01, 01, 1b, 03, 03, 09, 02, 0a, 06, 05, 0d, 02, 0e, 0a, 06, 15, 02, 16, 0d, 04, 15, 00, 1b, 11, 04, 15, 00, 1b, 05, 03, 0a, 03, 0a, 09, 06, 05, 00, 0b, 0f, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 6 +Number of expressions: 5 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 2 operands: lhs = Expression(3, Sub), rhs = Counter(1) -- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(2) -- expression 5 operands: lhs = Counter(3), rhs = Counter(4) +- expression 2 operands: lhs = Counter(0), rhs = Counter(2) +- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(4) +- expression 4 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 5, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 2, 10) = (c0 + c1) -- Code(Expression(3, Sub)) at (prev + 5, 13) to (start + 2, 14) +- Code(Expression(1, Sub)) at (prev + 5, 13) to (start + 2, 14) = ((c0 + c1) - c2) - Code(Expression(2, Sub)) at (prev + 6, 21) to (start + 2, 22) - = (((c0 + c1) - c2) - c1) + = (c0 - c2) - Code(Counter(3)) at (prev + 4, 21) to (start + 0, 27) - Code(Counter(4)) at (prev + 4, 21) to (start + 0, 27) - Code(Counter(1)) at (prev + 3, 10) to (start + 3, 10) - Code(Counter(2)) at (prev + 6, 5) to (start + 0, 11) -- Code(Expression(4, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((c3 + c4) + c2) +- Code(Expression(3, Add)) at (prev + 1, 1) to (start + 0, 2) + = ((c2 + c3) + c4) Highest counter ID seen: c4 diff --git a/tests/coverage/yield.cov-map b/tests/coverage/yield.cov-map index 578994a45305..e01ec8f9edbe 100644 --- a/tests/coverage/yield.cov-map +++ b/tests/coverage/yield.cov-map @@ -1,17 +1,17 @@ Function name: yield::main -Raw bytes (106): 0x[01, 01, 0b, 05, 00, 0d, 11, 22, 15, 0d, 11, 11, 15, 22, 15, 0d, 11, 22, 15, 0d, 11, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 07, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 22, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 13, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 08, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02] +Raw bytes (106): 0x[01, 01, 0b, 05, 00, 0d, 11, 0d, 23, 11, 15, 11, 15, 0d, 23, 11, 15, 0d, 23, 11, 15, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 07, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 06, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 23, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 08, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 11 - expression 0 operands: lhs = Counter(1), rhs = Zero - expression 1 operands: lhs = Counter(3), rhs = Counter(4) -- expression 2 operands: lhs = Expression(8, Sub), rhs = Counter(5) -- expression 3 operands: lhs = Counter(3), rhs = Counter(4) +- expression 2 operands: lhs = Counter(3), rhs = Expression(8, Add) +- expression 3 operands: lhs = Counter(4), rhs = Counter(5) - expression 4 operands: lhs = Counter(4), rhs = Counter(5) -- expression 5 operands: lhs = Expression(8, Sub), rhs = Counter(5) -- expression 6 operands: lhs = Counter(3), rhs = Counter(4) -- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(5) -- expression 8 operands: lhs = Counter(3), rhs = Counter(4) +- expression 5 operands: lhs = Counter(3), rhs = Expression(8, Add) +- expression 6 operands: lhs = Counter(4), rhs = Counter(5) +- expression 7 operands: lhs = Counter(3), rhs = Expression(8, Add) +- expression 8 operands: lhs = Counter(4), rhs = Counter(5) - expression 9 operands: lhs = Counter(6), rhs = Counter(7) - expression 10 operands: lhs = Counter(9), rhs = Counter(10) Number of file 0 mappings: 16 @@ -21,16 +21,16 @@ Number of file 0 mappings: 16 - Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 52) = (c1 + Zero) - Code(Counter(3)) at (prev + 2, 11) to (start + 0, 46) -- Code(Expression(8, Sub)) at (prev + 1, 34) to (start + 0, 39) +- Code(Expression(1, Sub)) at (prev + 1, 34) to (start + 0, 39) = (c3 - c4) - Code(Expression(7, Sub)) at (prev + 0, 44) to (start + 0, 46) - = ((c3 - c4) - c5) -- Code(Expression(4, Add)) at (prev + 1, 14) to (start + 0, 52) + = (c3 - (c4 + c5)) +- Code(Expression(8, Add)) at (prev + 1, 14) to (start + 0, 52) = (c4 + c5) - Code(Expression(7, Sub)) at (prev + 3, 9) to (start + 0, 22) - = ((c3 - c4) - c5) + = (c3 - (c4 + c5)) - Code(Expression(7, Sub)) at (prev + 8, 11) to (start + 0, 46) - = ((c3 - c4) - c5) + = (c3 - (c4 + c5)) - Code(Counter(8)) at (prev + 1, 39) to (start + 0, 41) - Code(Expression(9, Add)) at (prev + 1, 14) to (start + 0, 52) = (c6 + c7) diff --git a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff index cbb11d50f797..8dd23e4d6a3c 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -30,15 +30,12 @@ + coverage ExpressionId(0) => Expression { lhs: Counter(1), op: Add, rhs: Counter(2) }; + coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Add, rhs: Counter(3) }; + coverage ExpressionId(2) => Expression { lhs: Counter(0), op: Subtract, rhs: Expression(1) }; -+ coverage ExpressionId(3) => Expression { lhs: Counter(3), op: Add, rhs: Counter(2) }; -+ coverage ExpressionId(4) => Expression { lhs: Expression(3), op: Add, rhs: Counter(1) }; -+ coverage ExpressionId(5) => Expression { lhs: Expression(4), op: Add, rhs: Expression(2) }; + coverage Code(Counter(0)) => 14:1 - 15:21; -+ coverage Code(Counter(3)) => 16:17 - 16:33; ++ coverage Code(Counter(1)) => 16:17 - 16:33; + coverage Code(Counter(2)) => 17:17 - 17:33; -+ coverage Code(Counter(1)) => 18:17 - 18:33; ++ coverage Code(Counter(3)) => 18:17 - 18:33; + coverage Code(Expression(2)) => 19:17 - 19:33; -+ coverage Code(Expression(5)) => 21:1 - 21:2; ++ coverage Code(Counter(0)) => 21:1 - 21:2; + bb0: { + Coverage::CounterIncrement(0); @@ -55,7 +52,7 @@ } bb2: { -+ Coverage::CounterIncrement(3); ++ Coverage::CounterIncrement(1); falseEdge -> [real: bb8, imaginary: bb3]; } @@ -65,7 +62,7 @@ } bb4: { -+ Coverage::CounterIncrement(1); ++ Coverage::CounterIncrement(3); falseEdge -> [real: bb6, imaginary: bb5]; } @@ -127,7 +124,6 @@ } bb13: { -+ Coverage::ExpressionUsed(5); StorageDead(_1); return; } From d7090f335c8d6cee2d86f37a8ac55a2e20f7f72b Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 2 Dec 2024 23:39:42 +1100 Subject: [PATCH 28/59] coverage: Use a separate counter type during counter creation --- .../src/coverage/counters.rs | 167 ++++++++++-------- 1 file changed, 94 insertions(+), 73 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 4e543fc99189..be12ebd2a85f 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -63,12 +63,6 @@ pub(super) struct CoverageCounters { /// Coverage counters/expressions that are associated with individual BCBs. node_counters: IndexVec>, - /// Coverage counters/expressions that are associated with the control-flow - /// edge between two BCBs. - /// - /// We currently don't iterate over this map, but if we do in the future, - /// switch it back to `FxIndexMap` to avoid query stability hazards. - edge_counters: FxHashMap<(BasicCoverageBlock, BasicCoverageBlock), BcbCounter>, /// Table of expression data, associating each expression ID with its /// corresponding operator (+ or -) and its LHS/RHS operands. @@ -95,7 +89,6 @@ impl CoverageCounters { Self { counter_increment_sites: IndexVec::new(), node_counters: IndexVec::from_elem_n(None, num_bcbs), - edge_counters: FxHashMap::default(), expressions: IndexVec::new(), expressions_memo: FxHashMap::default(), } @@ -191,20 +184,6 @@ impl CoverageCounters { counter } - fn set_edge_counter( - &mut self, - from_bcb: BasicCoverageBlock, - to_bcb: BasicCoverageBlock, - counter: BcbCounter, - ) -> BcbCounter { - let existing = self.edge_counters.insert((from_bcb, to_bcb), counter); - assert!( - existing.is_none(), - "edge ({from_bcb:?} -> {to_bcb:?}) already has a counter: {existing:?} => {counter:?}" - ); - counter - } - pub(super) fn term_for_bcb(&self, bcb: BasicCoverageBlock) -> Option { self.node_counters[bcb].map(|counter| counter.as_term()) } @@ -250,22 +229,53 @@ impl CoverageCounters { } } +/// Symbolic representation of the coverage counter to be used for a particular +/// node or edge in the coverage graph. The same site counter can be used for +/// multiple sites, if they have been determined to have the same count. +#[derive(Clone, Copy, Debug)] +enum SiteCounter { + /// A physical counter at some node/edge. + Phys { site: Site }, + /// A counter expression for a node that takes the sum of all its in-edge + /// counters. + NodeSumExpr { bcb: BasicCoverageBlock }, + /// A counter expression for an edge that takes the counter of its source + /// node, and subtracts the counters of all its sibling out-edges. + EdgeDiffExpr { from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock }, +} + +/// Yields the graph successors of `from_bcb` that aren't `to_bcb`. This is +/// used when creating a counter expression for [`SiteCounter::EdgeDiffExpr`]. +/// +/// For example, in this diagram the sibling out-edge targets of edge `AC` are +/// the nodes `B` and `D`. +/// +/// ```text +/// A +/// / | \ +/// B C D +/// ``` +fn sibling_out_edge_targets( + graph: &CoverageGraph, + from_bcb: BasicCoverageBlock, + to_bcb: BasicCoverageBlock, +) -> impl Iterator + Captures<'_> { + graph.successors[from_bcb].iter().copied().filter(move |&t| t != to_bcb) +} + /// Helper struct that allows counter creation to inspect the BCB graph, and /// the set of nodes that need counters. struct CountersBuilder<'a> { - counters: CoverageCounters, graph: &'a CoverageGraph, bcb_needs_counter: &'a BitSet, + + site_counters: FxHashMap, } impl<'a> CountersBuilder<'a> { fn new(graph: &'a CoverageGraph, bcb_needs_counter: &'a BitSet) -> Self { assert_eq!(graph.num_nodes(), bcb_needs_counter.domain_size()); - Self { - counters: CoverageCounters::with_num_bcbs(graph.num_nodes()), - graph, - bcb_needs_counter, - } + Self { graph, bcb_needs_counter, site_counters: FxHashMap::default() } } fn make_bcb_counters(&mut self) { @@ -298,9 +308,7 @@ impl<'a> CountersBuilder<'a> { fn make_node_counter_and_out_edge_counters(&mut self, from_bcb: BasicCoverageBlock) { // First, ensure that this node has a counter of some kind. // We might also use that counter to compute one of the out-edge counters. - let node_counter = self.get_or_make_node_counter(from_bcb); - - let successors = self.graph.successors[from_bcb].as_slice(); + self.get_or_make_node_counter(from_bcb); // If this node's out-edges won't sum to the node's counter, // then there's no reason to create edge counters here. @@ -311,11 +319,11 @@ impl<'a> CountersBuilder<'a> { // When choosing which out-edge should be given a counter expression, ignore edges that // already have counters, or could use the existing counter of their target node. let out_edge_has_counter = |to_bcb| { - if self.counters.edge_counters.contains_key(&(from_bcb, to_bcb)) { + if self.site_counters.contains_key(&Site::Edge { from_bcb, to_bcb }) { return true; } self.graph.sole_predecessor(to_bcb) == Some(from_bcb) - && self.counters.node_counters[to_bcb].is_some() + && self.site_counters.contains_key(&Site::Node { bcb: to_bcb }) }; // Determine the set of out-edges that could benefit from being given an expression. @@ -328,45 +336,41 @@ impl<'a> CountersBuilder<'a> { // If there are out-edges without counters, choose one to be given an expression // (computed from this node and the other out-edges) instead of a physical counter. - let Some(target_bcb) = self.choose_out_edge_for_expression(from_bcb, &candidate_successors) + let Some(to_bcb) = self.choose_out_edge_for_expression(from_bcb, &candidate_successors) else { return; }; // For each out-edge other than the one that was chosen to get an expression, // ensure that it has a counter (existing counter/expression or a new counter). - let other_out_edge_counters = successors - .iter() - .copied() - // Skip the chosen edge, since we'll calculate its count from this sum. - .filter(|&edge_target_bcb| edge_target_bcb != target_bcb) - .map(|to_bcb| self.get_or_make_edge_counter(from_bcb, to_bcb)) - .collect::>(); + for target in sibling_out_edge_targets(self.graph, from_bcb, to_bcb) { + self.get_or_make_edge_counter(from_bcb, target); + } // Now create an expression for the chosen edge, by taking the counter // for its source node and subtracting the sum of its sibling out-edges. - let expression = self.counters.make_subtracted_sum(node_counter, &other_out_edge_counters); - - debug!("{target_bcb:?} gets an expression: {expression:?}"); - self.counters.set_edge_counter(from_bcb, target_bcb, expression); + let counter = SiteCounter::EdgeDiffExpr { from_bcb, to_bcb }; + self.site_counters.insert(Site::Edge { from_bcb, to_bcb }, counter); } #[instrument(level = "debug", skip(self))] - fn get_or_make_node_counter(&mut self, bcb: BasicCoverageBlock) -> BcbCounter { + fn get_or_make_node_counter(&mut self, bcb: BasicCoverageBlock) -> SiteCounter { // If the BCB already has a counter, return it. - if let Some(counter) = self.counters.node_counters[bcb] { + if let Some(&counter) = self.site_counters.get(&Site::Node { bcb }) { debug!("{bcb:?} already has a counter: {counter:?}"); return counter; } let counter = self.make_node_counter_inner(bcb); - self.counters.set_node_counter(bcb, counter) + self.site_counters.insert(Site::Node { bcb }, counter); + counter } - fn make_node_counter_inner(&mut self, bcb: BasicCoverageBlock) -> BcbCounter { + fn make_node_counter_inner(&mut self, bcb: BasicCoverageBlock) -> SiteCounter { // If the node's sole in-edge already has a counter, use that. if let Some(sole_pred) = self.graph.sole_predecessor(bcb) - && let Some(&edge_counter) = self.counters.edge_counters.get(&(sole_pred, bcb)) + && let Some(&edge_counter) = + self.site_counters.get(&Site::Edge { from_bcb: sole_pred, to_bcb: bcb }) { return edge_counter; } @@ -380,20 +384,17 @@ impl<'a> CountersBuilder<'a> { // leading to infinite recursion. if predecessors.len() <= 1 || predecessors.contains(&bcb) { debug!(?bcb, ?predecessors, "node has <=1 predecessors or is its own predecessor"); - let counter = self.counters.make_phys_counter(Site::Node { bcb }); + let counter = SiteCounter::Phys { site: Site::Node { bcb } }; debug!(?bcb, ?counter, "node gets a physical counter"); return counter; } // A BCB with multiple incoming edges can compute its count by ensuring that counters // exist for each of those edges, and then adding them up to get a total count. - let in_edge_counters = predecessors - .iter() - .copied() - .map(|from_bcb| self.get_or_make_edge_counter(from_bcb, bcb)) - .collect::>(); - let sum_of_in_edges: BcbCounter = - self.counters.make_sum(&in_edge_counters).expect("there must be at least one in-edge"); + for &from_bcb in predecessors { + self.get_or_make_edge_counter(from_bcb, bcb); + } + let sum_of_in_edges = SiteCounter::NodeSumExpr { bcb }; debug!("{bcb:?} gets a new counter (sum of predecessor counters): {sum_of_in_edges:?}"); sum_of_in_edges @@ -404,22 +405,23 @@ impl<'a> CountersBuilder<'a> { &mut self, from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock, - ) -> BcbCounter { + ) -> SiteCounter { // If the edge already has a counter, return it. - if let Some(&counter) = self.counters.edge_counters.get(&(from_bcb, to_bcb)) { + if let Some(&counter) = self.site_counters.get(&Site::Edge { from_bcb, to_bcb }) { debug!("Edge {from_bcb:?}->{to_bcb:?} already has a counter: {counter:?}"); return counter; } let counter = self.make_edge_counter_inner(from_bcb, to_bcb); - self.counters.set_edge_counter(from_bcb, to_bcb, counter) + self.site_counters.insert(Site::Edge { from_bcb, to_bcb }, counter); + counter } fn make_edge_counter_inner( &mut self, from_bcb: BasicCoverageBlock, to_bcb: BasicCoverageBlock, - ) -> BcbCounter { + ) -> SiteCounter { // If the target node has exactly one in-edge (i.e. this one), then just // use the node's counter, since it will have the same value. if let Some(sole_pred) = self.graph.sole_predecessor(to_bcb) { @@ -437,7 +439,7 @@ impl<'a> CountersBuilder<'a> { } // Make a new counter to count this edge. - let counter = self.counters.make_phys_counter(Site::Edge { from_bcb, to_bcb }); + let counter = SiteCounter::Phys { site: Site::Edge { from_bcb, to_bcb } }; debug!(?from_bcb, ?to_bcb, ?counter, "edge gets a physical counter"); counter } @@ -525,14 +527,14 @@ impl<'a> Transcriber<'a> { fn transcribe_counters(mut self) -> CoverageCounters { for bcb in self.old.bcb_needs_counter.iter() { let site = Site::Node { bcb }; - let Some(old_counter) = self.old.counters.node_counters[bcb] else { continue }; + let site_counter = self.site_counter(site); - // Resolve the old counter into flat lists of nodes/edges whose + // Resolve the site counter into flat lists of nodes/edges whose // physical counts contribute to the counter for this node. // Distinguish between counts that will be added vs subtracted. let mut pos = vec![]; let mut neg = vec![]; - self.push_resolved_sites(old_counter, &mut pos, &mut neg); + self.push_resolved_sites(site_counter, &mut pos, &mut neg); // Simplify by cancelling out sites that appear on both sides. let (mut pos, mut neg) = sort_and_cancel(pos, neg); @@ -566,22 +568,41 @@ impl<'a> Transcriber<'a> { self.new } + fn site_counter(&self, site: Site) -> SiteCounter { + self.old.site_counters.get(&site).copied().unwrap_or_else(|| { + // We should have already created all necessary site counters. + // But if we somehow didn't, avoid crashing in release builds, + // and just use an extra physical counter instead. + debug_assert!(false, "{site:?} should have a counter"); + SiteCounter::Phys { site } + }) + } + fn ensure_phys_counter(&mut self, site: Site) -> BcbCounter { *self.phys_counter_for_site.entry(site).or_insert_with(|| self.new.make_phys_counter(site)) } /// Resolves the given counter into flat lists of nodes/edges, whose counters /// will then be added and subtracted to form a counter expression. - fn push_resolved_sites(&self, counter: BcbCounter, pos: &mut Vec, neg: &mut Vec) { + fn push_resolved_sites(&self, counter: SiteCounter, pos: &mut Vec, neg: &mut Vec) { match counter { - BcbCounter::Counter { id } => pos.push(self.old.counters.counter_increment_sites[id]), - BcbCounter::Expression { id } => { - let BcbExpression { lhs, op, rhs } = self.old.counters.expressions[id]; - self.push_resolved_sites(lhs, pos, neg); - match op { - Op::Add => self.push_resolved_sites(rhs, pos, neg), + SiteCounter::Phys { site } => pos.push(site), + SiteCounter::NodeSumExpr { bcb } => { + for &from_bcb in &self.old.graph.predecessors[bcb] { + let edge_counter = self.site_counter(Site::Edge { from_bcb, to_bcb: bcb }); + self.push_resolved_sites(edge_counter, pos, neg); + } + } + SiteCounter::EdgeDiffExpr { from_bcb, to_bcb } => { + // First, add the count for `from_bcb`. + let node_counter = self.site_counter(Site::Node { bcb: from_bcb }); + self.push_resolved_sites(node_counter, pos, neg); + + // Then subtract the counts for the other out-edges. + for target in sibling_out_edge_targets(self.old.graph, from_bcb, to_bcb) { + let edge_counter = self.site_counter(Site::Edge { from_bcb, to_bcb: target }); // Swap `neg` and `pos` so that the counter is subtracted. - Op::Subtract => self.push_resolved_sites(rhs, neg, pos), + self.push_resolved_sites(edge_counter, neg, pos); } } } From ba08056d470bc9bfff6304aa436ae3219d2e3775 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 1 Dec 2024 15:50:57 +1100 Subject: [PATCH 29/59] coverage: Remove the expression simplifier from `CoverageCounters` These simplifications are now handled by the transcribe step. --- .../src/coverage/counters.rs | 55 ++----------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index be12ebd2a85f..46efdd16ee83 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -102,57 +102,10 @@ impl CoverageCounters { fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter { let new_expr = BcbExpression { lhs, op, rhs }; - *self - .expressions_memo - .entry(new_expr) - .or_insert_with(|| Self::make_expression_inner(&mut self.expressions, new_expr)) - } - - /// This is an associated function so that we can call it while borrowing - /// `&mut self.expressions_memo`. - fn make_expression_inner( - expressions: &mut IndexVec, - new_expr: BcbExpression, - ) -> BcbCounter { - // Simplify expressions using basic algebra. - // - // Some of these cases might not actually occur in practice, depending - // on the details of how the instrumentor builds expressions. - let BcbExpression { lhs, op, rhs } = new_expr; - - if let BcbCounter::Expression { id } = lhs { - let lhs_expr = &expressions[id]; - - // Simplify `(a - b) + b` to `a`. - if lhs_expr.op == Op::Subtract && op == Op::Add && lhs_expr.rhs == rhs { - return lhs_expr.lhs; - } - // Simplify `(a + b) - b` to `a`. - if lhs_expr.op == Op::Add && op == Op::Subtract && lhs_expr.rhs == rhs { - return lhs_expr.lhs; - } - // Simplify `(a + b) - a` to `b`. - if lhs_expr.op == Op::Add && op == Op::Subtract && lhs_expr.lhs == rhs { - return lhs_expr.rhs; - } - } - - if let BcbCounter::Expression { id } = rhs { - let rhs_expr = &expressions[id]; - - // Simplify `a + (b - a)` to `b`. - if op == Op::Add && rhs_expr.op == Op::Subtract && lhs == rhs_expr.rhs { - return rhs_expr.lhs; - } - // Simplify `a - (a - b)` to `b`. - if op == Op::Subtract && rhs_expr.op == Op::Subtract && lhs == rhs_expr.lhs { - return rhs_expr.rhs; - } - } - - // Simplification failed, so actually create the new expression. - let id = expressions.push(new_expr); - BcbCounter::Expression { id } + *self.expressions_memo.entry(new_expr).or_insert_with(|| { + let id = self.expressions.push(new_expr); + BcbCounter::Expression { id } + }) } /// Creates a counter that is the sum of the given counters. From e52f5bf16dea36f302ad33af92518dcc8083012f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 4 Dec 2024 19:20:01 +1100 Subject: [PATCH 30/59] Remove `-Zshow-span`. It's very old (added in #12087). It's strange, and it's not clear what its use cases are. It only works with the crate root file because it runs before expansion. I suspect it won't be missed. --- compiler/rustc_ast_passes/messages.ftl | 2 - compiler/rustc_ast_passes/src/errors.rs | 8 --- compiler/rustc_ast_passes/src/lib.rs | 3 - compiler/rustc_ast_passes/src/show_span.rs | 68 ---------------------- compiler/rustc_driver_impl/src/lib.rs | 4 +- compiler/rustc_interface/src/passes.rs | 4 -- compiler/rustc_interface/src/tests.rs | 1 - compiler/rustc_session/src/options.rs | 2 - 8 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 compiler/rustc_ast_passes/src/show_span.rs diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index d81fd53938b8..5a0ec865f9d4 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -207,8 +207,6 @@ ast_passes_precise_capturing_duplicated = duplicate `use<...>` precise capturing ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc} -ast_passes_show_span = {$msg} - ast_passes_stability_outside_std = stability attributes may not be used outside of the standard library ast_passes_static_without_body = diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index f65056a494ba..9b600e3ee92a 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -779,14 +779,6 @@ pub(crate) struct IncompatibleFeatures { pub f2: Symbol, } -#[derive(Diagnostic)] -#[diag(ast_passes_show_span)] -pub(crate) struct ShowSpan { - #[primary_span] - pub span: Span, - pub msg: &'static str, -} - #[derive(Diagnostic)] #[diag(ast_passes_negative_bound_not_supported)] pub(crate) struct NegativeBoundUnsupported { diff --git a/compiler/rustc_ast_passes/src/lib.rs b/compiler/rustc_ast_passes/src/lib.rs index 86752da79aeb..b4ed70d83e57 100644 --- a/compiler/rustc_ast_passes/src/lib.rs +++ b/compiler/rustc_ast_passes/src/lib.rs @@ -1,8 +1,6 @@ //! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax` //! parsed by `rustc_parse` and then lowered, after the passes in this crate, //! by `rustc_ast_lowering`. -//! -//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`. // tidy-alphabetical-start #![allow(internal_features)] @@ -18,6 +16,5 @@ pub mod ast_validation; mod errors; pub mod feature_gate; -pub mod show_span; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_ast_passes/src/show_span.rs b/compiler/rustc_ast_passes/src/show_span.rs deleted file mode 100644 index e7ba2e7fc30b..000000000000 --- a/compiler/rustc_ast_passes/src/show_span.rs +++ /dev/null @@ -1,68 +0,0 @@ -//! Span debugger -//! -//! This module shows spans for all expressions in the crate -//! to help with compiler debugging. - -use std::str::FromStr; - -use rustc_ast as ast; -use rustc_ast::visit; -use rustc_ast::visit::Visitor; -use rustc_errors::DiagCtxtHandle; - -use crate::errors; - -enum Mode { - Expression, - Pattern, - Type, -} - -impl FromStr for Mode { - type Err = (); - fn from_str(s: &str) -> Result { - let mode = match s { - "expr" => Mode::Expression, - "pat" => Mode::Pattern, - "ty" => Mode::Type, - _ => return Err(()), - }; - Ok(mode) - } -} - -struct ShowSpanVisitor<'a> { - dcx: DiagCtxtHandle<'a>, - mode: Mode, -} - -impl<'a> Visitor<'a> for ShowSpanVisitor<'a> { - fn visit_expr(&mut self, e: &'a ast::Expr) { - if let Mode::Expression = self.mode { - self.dcx.emit_warn(errors::ShowSpan { span: e.span, msg: "expression" }); - } - visit::walk_expr(self, e); - } - - fn visit_pat(&mut self, p: &'a ast::Pat) { - if let Mode::Pattern = self.mode { - self.dcx.emit_warn(errors::ShowSpan { span: p.span, msg: "pattern" }); - } - visit::walk_pat(self, p); - } - - fn visit_ty(&mut self, t: &'a ast::Ty) { - if let Mode::Type = self.mode { - self.dcx.emit_warn(errors::ShowSpan { span: t.span, msg: "type" }); - } - visit::walk_ty(self, t); - } -} - -pub fn run(dcx: DiagCtxtHandle<'_>, mode: &str, krate: &ast::Crate) { - let Ok(mode) = mode.parse() else { - return; - }; - let mut v = ShowSpanVisitor { dcx, mode }; - visit::walk_crate(&mut v, krate); -} diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 85eaae8a1046..550a97c2c79b 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -418,9 +418,7 @@ fn run_compiler( return early_exit(); } - if sess.opts.unstable_opts.parse_crate_root_only - || sess.opts.unstable_opts.show_span.is_some() - { + if sess.opts.unstable_opts.parse_crate_root_only { return early_exit(); } diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 2905fe688b50..d47b6f9aba0a 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -54,10 +54,6 @@ pub(crate) fn parse<'a>(sess: &'a Session) -> Result { }) .map_err(|parse_error| parse_error.emit())?; - if let Some(ref s) = sess.opts.unstable_opts.show_span { - rustc_ast_passes::show_span::run(sess.dcx(), s, &krate); - } - if sess.opts.unstable_opts.input_stats { input_stats::print_ast_stats(&krate, "PRE EXPANSION AST STATS", "ast-stats-1"); } diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index c1b2d8562522..4012956bddb0 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -843,7 +843,6 @@ fn test_unstable_options_tracking_hash() { tracked!(sanitizer_recover, SanitizerSet::ADDRESS); tracked!(saturating_float_casts, Some(true)); tracked!(share_generics, Some(true)); - tracked!(show_span, Some(String::from("abc"))); tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc"))); tracked!(small_data_threshold, Some(16)); tracked!(split_lto_unit, Some(true)); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 25f75ae12e8e..07b55c048df6 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2036,8 +2036,6 @@ written to standard error output)"), "make the current crate share its generic instantiations"), shell_argfiles: bool = (false, parse_bool, [UNTRACKED], "allow argument files to be specified with POSIX \"shell-style\" argument quoting"), - show_span: Option = (None, parse_opt_string, [TRACKED], - "show spans in the crate root file, for compiler debugging (expr|pat|ty)"), simulate_remapped_rust_src_base: Option = (None, parse_opt_pathbuf, [TRACKED], "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \ to rust's source base directory. only meant for testing purposes"), From ec3424a90515a26146e3e111171e43ed3db81194 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 4 Dec 2024 09:54:12 +0000 Subject: [PATCH 31/59] Remove some noisy tracing --- compiler/rustc_metadata/src/rmeta/table.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 9438350ca097..28f406fbc962 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -1,6 +1,5 @@ use rustc_hir::def::CtorOf; use rustc_index::Idx; -use tracing::trace; use crate::rmeta::*; @@ -530,8 +529,6 @@ where { /// Given the metadata, extract out the value at a particular index (if any). pub(super) fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>(&self, metadata: M, i: I) -> T::Value<'tcx> { - trace!("LazyTable::lookup: index={:?} len={:?}", i, self.len); - // Access past the end of the table returns a Default if i.index() >= self.len { return Default::default(); From a91c36139a5aeef66483de18117788d3c85b8b9d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 31 Jul 2024 12:58:32 +0000 Subject: [PATCH 32/59] Avoid `opaque type not constrained` errors in the presence of other errors --- .../src/collect/type_of/opaque.rs | 14 ++++++++++-- ...-method-resolution-opaque-type.next.stderr | 2 +- ...e-method-resolution-opaque-type.old.stderr | 14 +++--------- ...rm-before-method-resolution-opaque-type.rs | 1 - tests/ui/impl-trait/issues/issue-86800.rs | 1 - tests/ui/impl-trait/issues/issue-86800.stderr | 20 +++++------------ ...alias-impl-trait-declaration-too-subtle.rs | 1 - ...s-impl-trait-declaration-too-subtle.stderr | 20 +++++------------ ...o_tait_defining_each_other2.current.stderr | 10 +-------- .../two_tait_defining_each_other2.rs | 2 +- tests/ui/self/arbitrary-self-opaque.rs | 1 - tests/ui/self/arbitrary-self-opaque.stderr | 14 +++--------- .../bad-tait-no-substs.rs | 1 - .../bad-tait-no-substs.stderr | 22 ++++++------------- .../const_generic_type.infer.stderr | 2 +- .../const_generic_type.no_infer.stderr | 16 ++++---------- .../const_generic_type.rs | 1 - .../type-alias-impl-trait/hkl_forbidden4.rs | 1 - .../hkl_forbidden4.stderr | 22 ++++++------------- .../nested-tait-inference3.rs | 1 - .../nested-tait-inference3.stderr | 12 ++-------- .../no_inferrable_concrete_type.rs | 1 - .../no_inferrable_concrete_type.stderr | 12 ++-------- 23 files changed, 56 insertions(+), 135 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs index fcea0052546f..66255829dcff 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs @@ -226,13 +226,18 @@ impl TaitConstraintLocator<'_> { constrained = true; if !opaque_types_defined_by.contains(&self.def_id) { - self.tcx.dcx().emit_err(TaitForwardCompat { + let guar = self.tcx.dcx().emit_err(TaitForwardCompat { span: hidden_type.span, item_span: self .tcx .def_ident_span(item_def_id) .unwrap_or_else(|| self.tcx.def_span(item_def_id)), }); + // Avoid "opaque type not constrained" errors on the opaque itself. + self.found = Some(ty::OpaqueHiddenType { + span: DUMMY_SP, + ty: Ty::new_error(self.tcx, guar), + }); } let concrete_type = self.tcx.erase_regions(hidden_type.remap_generic_params_to_declaration_params( @@ -248,7 +253,7 @@ impl TaitConstraintLocator<'_> { if !constrained { debug!("no constraints in typeck results"); if opaque_types_defined_by.contains(&self.def_id) { - self.tcx.dcx().emit_err(TaitForwardCompat2 { + let guar = self.tcx.dcx().emit_err(TaitForwardCompat2 { span: self .tcx .def_ident_span(item_def_id) @@ -256,6 +261,11 @@ impl TaitConstraintLocator<'_> { opaque_type_span: self.tcx.def_span(self.def_id), opaque_type: self.tcx.def_path_str(self.def_id), }); + // Avoid "opaque type not constrained" errors on the opaque itself. + self.found = Some(ty::OpaqueHiddenType { + span: DUMMY_SP, + ty: Ty::new_error(self.tcx, guar), + }); } return; }; diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.next.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.next.stderr index 72646b7bc768..9e04e90a98ac 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.next.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.next.stderr @@ -1,5 +1,5 @@ error[E0284]: type annotations needed: cannot satisfy `Foo == _` - --> $DIR/norm-before-method-resolution-opaque-type.rs:16:19 + --> $DIR/norm-before-method-resolution-opaque-type.rs:15:19 | LL | fn weird_bound(x: &>::Out) -> X | ^ cannot satisfy `Foo == _` diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.old.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.old.stderr index dbd0d5dc7332..479f59843557 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.old.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.old.stderr @@ -1,5 +1,5 @@ error: item does not constrain `Foo::{opaque#0}`, but has it in its signature - --> $DIR/norm-before-method-resolution-opaque-type.rs:16:4 + --> $DIR/norm-before-method-resolution-opaque-type.rs:15:4 | LL | fn weird_bound(x: &>::Out) -> X | ^^^^^^^^^^^ @@ -11,16 +11,8 @@ note: this opaque type is in the signature LL | type Foo = impl Sized; | ^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/norm-before-method-resolution-opaque-type.rs:13:12 - | -LL | type Foo = impl Sized; - | ^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - error[E0507]: cannot move out of `*x` which is behind a shared reference - --> $DIR/norm-before-method-resolution-opaque-type.rs:23:13 + --> $DIR/norm-before-method-resolution-opaque-type.rs:22:13 | LL | let x = *x; | ^^ move occurs because `*x` has type `>::Out`, which does not implement the `Copy` trait @@ -31,6 +23,6 @@ LL - let x = *x; LL + let x = x; | -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs index cf752f814c90..ffbfc622bb01 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs @@ -11,7 +11,6 @@ impl<'a, T> Trait<'a> for T { } type Foo = impl Sized; -//[old]~^ ERROR: unconstrained opaque type fn weird_bound(x: &>::Out) -> X //[old]~^ ERROR: item does not constrain diff --git a/tests/ui/impl-trait/issues/issue-86800.rs b/tests/ui/impl-trait/issues/issue-86800.rs index 5a6959ad7e6f..ff1d273ae482 100644 --- a/tests/ui/impl-trait/issues/issue-86800.rs +++ b/tests/ui/impl-trait/issues/issue-86800.rs @@ -23,7 +23,6 @@ struct Context { type TransactionResult = Result; type TransactionFuture<'__, O> = impl '__ + Future>; -//~^ ERROR unconstrained opaque type fn execute_transaction_fut<'f, F, O>( //~^ ERROR: item does not constrain diff --git a/tests/ui/impl-trait/issues/issue-86800.stderr b/tests/ui/impl-trait/issues/issue-86800.stderr index 095f648143ca..fd9b8e7ac999 100644 --- a/tests/ui/impl-trait/issues/issue-86800.stderr +++ b/tests/ui/impl-trait/issues/issue-86800.stderr @@ -1,5 +1,5 @@ error: item does not constrain `TransactionFuture::{opaque#0}`, but has it in its signature - --> $DIR/issue-86800.rs:28:4 + --> $DIR/issue-86800.rs:27:4 | LL | fn execute_transaction_fut<'f, F, O>( | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future $DIR/issue-86800.rs:40:14 + --> $DIR/issue-86800.rs:39:14 | LL | async fn do_transaction( | ^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future $DIR/issue-86800.rs:44:5 + --> $DIR/issue-86800.rs:43:5 | LL | / { LL | | @@ -43,16 +43,8 @@ note: this opaque type is in the signature LL | type TransactionFuture<'__, O> = impl '__ + Future>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/issue-86800.rs:25:34 - | -LL | type TransactionFuture<'__, O> = impl '__ + Future>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `TransactionFuture` must be used in combination with a concrete type within the same module - error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/issue-86800.rs:35:5 + --> $DIR/issue-86800.rs:34:5 | LL | type TransactionFuture<'__, O> = impl '__ + Future>; | --- this generic parameter must be used with a generic lifetime parameter @@ -61,7 +53,7 @@ LL | f | ^ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/issue-86800.rs:44:5 + --> $DIR/issue-86800.rs:43:5 | LL | type TransactionFuture<'__, O> = impl '__ + Future>; | --- this generic parameter must be used with a generic lifetime parameter @@ -75,6 +67,6 @@ LL | | f(&mut transaction).await LL | | } | |_____^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs index dc9424c3ca7a..3f41c5984b41 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs @@ -2,7 +2,6 @@ mod a { type Foo = impl PartialEq<(Foo, i32)>; - //~^ ERROR: unconstrained opaque type struct Bar; diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index 6485aa207103..b127bf418003 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -1,5 +1,5 @@ error[E0053]: method `eq` has an incompatible type for trait - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:30 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:9:30 | LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the found opaque type @@ -15,7 +15,7 @@ LL | fn eq(&self, _other: &(a::Bar, i32)) -> bool { | ~~~~~~~~~~~~~~ error: item does not constrain `a::Foo::{opaque#0}`, but has it in its signature - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:10:12 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:9:12 | LL | fn eq(&self, _other: &(Foo, i32)) -> bool { | ^^ @@ -27,16 +27,8 @@ note: this opaque type is in the signature LL | type Foo = impl PartialEq<(Foo, i32)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - error[E0053]: method `eq` has an incompatible type for trait - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:30 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:30 | LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the expected opaque type @@ -47,7 +39,7 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool { = note: expected signature `fn(&b::Bar, &(b::Foo, _)) -> _` found signature `fn(&b::Bar, &(b::Bar, _)) -> _` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:25:12 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:12 | LL | fn eq(&self, _other: &(Bar, i32)) -> bool { | ^^ @@ -57,13 +49,13 @@ LL | fn eq(&self, _other: &(b::Foo, i32)) -> bool { | ~~~~~~~~~~~~~~ error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:19:16 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16 | LL | type Foo = impl PartialEq<(Foo, i32)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `Foo` must be used in combination with a concrete type within the same module -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr index b70676ece0e2..7d02a0606fc2 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr @@ -11,14 +11,6 @@ note: this opaque type is in the signature LL | type A = impl Foo; | ^^^^^^^^ -error: unconstrained opaque type - --> $DIR/two_tait_defining_each_other2.rs:6:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - | - = note: `A` must be used in combination with a concrete type within the same module - error: opaque type's hidden type cannot be another opaque type from the same scope --> $DIR/two_tait_defining_each_other2.rs:14:5 | @@ -36,5 +28,5 @@ note: opaque type being used as hidden type LL | type A = impl Foo; | ^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index 3311c5565681..1681b019418e 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -3,7 +3,7 @@ //@[next] compile-flags: -Znext-solver #![feature(type_alias_impl_trait)] -type A = impl Foo; //[current]~ ERROR unconstrained opaque type +type A = impl Foo; type B = impl Foo; trait Foo {} diff --git a/tests/ui/self/arbitrary-self-opaque.rs b/tests/ui/self/arbitrary-self-opaque.rs index 3c2e2d9db727..c26ef658b695 100644 --- a/tests/ui/self/arbitrary-self-opaque.rs +++ b/tests/ui/self/arbitrary-self-opaque.rs @@ -2,7 +2,6 @@ struct Foo; type Bar = impl Sized; -//~^ ERROR unconstrained opaque type impl Foo { fn foo(self: Bar) {} diff --git a/tests/ui/self/arbitrary-self-opaque.stderr b/tests/ui/self/arbitrary-self-opaque.stderr index 5634b3d6e64a..c75165d9f8e2 100644 --- a/tests/ui/self/arbitrary-self-opaque.stderr +++ b/tests/ui/self/arbitrary-self-opaque.stderr @@ -1,5 +1,5 @@ error[E0307]: invalid `self` parameter type: `Bar` - --> $DIR/arbitrary-self-opaque.rs:8:18 + --> $DIR/arbitrary-self-opaque.rs:7:18 | LL | fn foo(self: Bar) {} | ^^^ @@ -8,7 +8,7 @@ LL | fn foo(self: Bar) {} = help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one of the previous types except `Self`) error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/arbitrary-self-opaque.rs:8:8 + --> $DIR/arbitrary-self-opaque.rs:7:8 | LL | fn foo(self: Bar) {} | ^^^ @@ -20,14 +20,6 @@ note: this opaque type is in the signature LL | type Bar = impl Sized; | ^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/arbitrary-self-opaque.rs:4:12 - | -LL | type Bar = impl Sized; - | ^^^^^^^^^^ - | - = note: `Bar` must be used in combination with a concrete type within the same module - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0307`. diff --git a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.rs b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.rs index 18cfb1c1f93b..4b2ee344aa32 100644 --- a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.rs +++ b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.rs @@ -3,7 +3,6 @@ #![feature(type_alias_impl_trait)] trait Trait {} type Alias<'a, U> = impl Trait; -//~^ ERROR unconstrained opaque type pub enum UninhabitedVariants { Tuple(Alias), diff --git a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr index cf366c55ea81..55df117d0664 100644 --- a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr +++ b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/bad-tait-no-substs.rs:9:11 + --> $DIR/bad-tait-no-substs.rs:8:11 | LL | Tuple(Alias), | ^^^^^ expected named lifetime parameter @@ -11,7 +11,7 @@ LL ~ Tuple(Alias<'a>), | error[E0107]: missing generics for type alias `Alias` - --> $DIR/bad-tait-no-substs.rs:9:11 + --> $DIR/bad-tait-no-substs.rs:8:11 | LL | Tuple(Alias), | ^^^^^ expected 1 generic argument @@ -27,7 +27,7 @@ LL | Tuple(Alias), | +++ error[E0792]: non-defining opaque type use in defining scope - --> $DIR/bad-tait-no-substs.rs:9:11 + --> $DIR/bad-tait-no-substs.rs:8:11 | LL | Tuple(Alias), | ^^^^^ argument `'_` is not a generic parameter @@ -39,7 +39,7 @@ LL | type Alias<'a, U> = impl Trait; | ^^^^^^^^^^^^^ error: item does not constrain `Alias::{opaque#0}`, but has it in its signature - --> $DIR/bad-tait-no-substs.rs:15:4 + --> $DIR/bad-tait-no-substs.rs:14:4 | LL | fn uwu(x: UninhabitedVariants) { | ^^^ @@ -51,22 +51,14 @@ note: this opaque type is in the signature LL | type Alias<'a, U> = impl Trait; | ^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/bad-tait-no-substs.rs:5:21 - | -LL | type Alias<'a, U> = impl Trait; - | ^^^^^^^^^^^^^ - | - = note: `Alias` must be used in combination with a concrete type within the same module - error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` not covered - --> $DIR/bad-tait-no-substs.rs:17:11 + --> $DIR/bad-tait-no-substs.rs:16:11 | LL | match x {} | ^ pattern `UninhabitedVariants::Tuple(_)` not covered | note: `UninhabitedVariants` defined here - --> $DIR/bad-tait-no-substs.rs:8:10 + --> $DIR/bad-tait-no-substs.rs:7:10 | LL | pub enum UninhabitedVariants { | ^^^^^^^^^^^^^^^^^^^ @@ -80,7 +72,7 @@ LL + UninhabitedVariants::Tuple(_) => todo!(), LL + } | -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0004, E0106, E0107, E0792. For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr index b7999a695e7f..5b77bb6c2bc2 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr @@ -1,5 +1,5 @@ error: `Bar` is forbidden as the type of a const generic parameter - --> $DIR/const_generic_type.rs:8:24 + --> $DIR/const_generic_type.rs:7:24 | LL | async fn test() { | ^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index ec8a51b08188..8888f2d49df1 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -1,5 +1,5 @@ error: `Bar` is forbidden as the type of a const generic parameter - --> $DIR/const_generic_type.rs:8:24 + --> $DIR/const_generic_type.rs:7:24 | LL | async fn test() { | ^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | async fn test() { = note: the only supported types are integers, `bool`, and `char` error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/const_generic_type.rs:8:10 + --> $DIR/const_generic_type.rs:7:10 | LL | async fn test() { | ^^^^ @@ -20,7 +20,7 @@ LL | type Bar = impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^^^^^^ error: item does not constrain `Bar::{opaque#0}`, but has it in its signature - --> $DIR/const_generic_type.rs:8:38 + --> $DIR/const_generic_type.rs:7:38 | LL | async fn test() { | ______________________________________^ @@ -39,13 +39,5 @@ note: this opaque type is in the signature LL | type Bar = impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/const_generic_type.rs:5:12 - | -LL | type Bar = impl std::fmt::Display; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Bar` must be used in combination with a concrete type within the same module - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.rs b/tests/ui/type-alias-impl-trait/const_generic_type.rs index de493d04f811..7149370048b3 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.rs +++ b/tests/ui/type-alias-impl-trait/const_generic_type.rs @@ -3,7 +3,6 @@ #![feature(type_alias_impl_trait)] type Bar = impl std::fmt::Display; -//[no_infer]~^ ERROR: unconstrained opaque type async fn test() { //~^ ERROR: `Bar` is forbidden as the type of a const generic parameter diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden4.rs b/tests/ui/type-alias-impl-trait/hkl_forbidden4.rs index 96c905ef3a90..fd06ea677c33 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden4.rs +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden4.rs @@ -8,7 +8,6 @@ use std::future::Future; type FutNothing<'a> = impl 'a + Future; -//~^ ERROR: unconstrained opaque type async fn operation(_: &mut ()) -> () { //~^ ERROR: concrete type differs from previous diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr index 0c2772683a91..08ebc3208d7e 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr @@ -1,5 +1,5 @@ error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature - --> $DIR/hkl_forbidden4.rs:19:10 + --> $DIR/hkl_forbidden4.rs:18:10 | LL | async fn call(_f: F) | ^^^^ @@ -12,7 +12,7 @@ LL | type FutNothing<'a> = impl 'a + Future; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: item does not constrain `FutNothing::{opaque#0}`, but has it in its signature - --> $DIR/hkl_forbidden4.rs:23:1 + --> $DIR/hkl_forbidden4.rs:22:1 | LL | / { LL | | @@ -27,16 +27,8 @@ note: this opaque type is in the signature LL | type FutNothing<'a> = impl 'a + Future; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/hkl_forbidden4.rs:10:23 - | -LL | type FutNothing<'a> = impl 'a + Future; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `FutNothing` must be used in combination with a concrete type within the same module - error[E0792]: expected generic lifetime parameter, found `'any` - --> $DIR/hkl_forbidden4.rs:15:5 + --> $DIR/hkl_forbidden4.rs:14:5 | LL | async fn operation(_: &mut ()) -> () { | - this generic parameter must be used with a generic lifetime parameter @@ -45,19 +37,19 @@ LL | call(operation).await | ^^^^^^^^^^^^^^^ error: concrete type differs from previous defining opaque type use - --> $DIR/hkl_forbidden4.rs:13:1 + --> $DIR/hkl_forbidden4.rs:12:1 | LL | async fn operation(_: &mut ()) -> () { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `FutNothing<'_>`, got `{async fn body of operation()}` | note: previous use here - --> $DIR/hkl_forbidden4.rs:15:5 + --> $DIR/hkl_forbidden4.rs:14:5 | LL | call(operation).await | ^^^^^^^^^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'any` - --> $DIR/hkl_forbidden4.rs:23:1 + --> $DIR/hkl_forbidden4.rs:22:1 | LL | type FutNothing<'a> = impl 'a + Future; | -- this generic parameter must be used with a generic lifetime parameter @@ -68,6 +60,6 @@ LL | | LL | | } | |_^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference3.rs b/tests/ui/type-alias-impl-trait/nested-tait-inference3.rs index a7d824c5a6a0..aaf2812532d3 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference3.rs +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference3.rs @@ -4,7 +4,6 @@ use std::fmt::Debug; type FooX = impl Debug; -//~^ ERROR unconstrained opaque type trait Foo {} diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr index 9ccd95448963..969409ebc59e 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr @@ -1,5 +1,5 @@ error: item does not constrain `FooX::{opaque#0}`, but has it in its signature - --> $DIR/nested-tait-inference3.rs:13:4 + --> $DIR/nested-tait-inference3.rs:12:4 | LL | fn foo() -> impl Foo { | ^^^ @@ -11,13 +11,5 @@ note: this opaque type is in the signature LL | type FooX = impl Debug; | ^^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/nested-tait-inference3.rs:6:13 - | -LL | type FooX = impl Debug; - | ^^^^^^^^^^ - | - = note: `FooX` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs index 3954672500b4..41238c27351d 100644 --- a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs +++ b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs @@ -5,7 +5,6 @@ mod foo { pub type Foo = impl Copy; - //~^ ERROR unconstrained opaque type // make compiler happy about using 'Foo' pub fn bar(x: Foo) -> Foo { diff --git a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr index d95a4a8a727a..eed88c5df4f4 100644 --- a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr +++ b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr @@ -1,5 +1,5 @@ error: item does not constrain `Foo::{opaque#0}`, but has it in its signature - --> $DIR/no_inferrable_concrete_type.rs:11:12 + --> $DIR/no_inferrable_concrete_type.rs:10:12 | LL | pub fn bar(x: Foo) -> Foo { | ^^^ @@ -11,13 +11,5 @@ note: this opaque type is in the signature LL | pub type Foo = impl Copy; | ^^^^^^^^^ -error: unconstrained opaque type - --> $DIR/no_inferrable_concrete_type.rs:7:20 - | -LL | pub type Foo = impl Copy; - | ^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error From 4cbb599edf5b0762caa36ee4cbba00c5c86c1f5e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 4 Dec 2024 11:01:20 +0000 Subject: [PATCH 33/59] Stop git from merging generated files --- .gitattributes | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index d29c15fe712f..a02c95fbd481 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,8 +4,10 @@ *.cpp rust *.h rust *.rs rust diff=rust -*.fixed linguist-language=Rust -*.mir linguist-language=Rust +*.fixed linguist-language=Rust -merge +*.mir linguist-language=Rust -merge +*.stderr -merge +*.stdout -merge src/etc/installer/gfx/* binary src/vendor/** -text Cargo.lock linguist-generated=false From 836ab5cd89e72487b003d0034b6ca4c3399878e8 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Tue, 3 Dec 2024 06:46:17 +0800 Subject: [PATCH 34/59] make CoercePointee errors translatable --- compiler/rustc_builtin_macros/messages.ftl | 15 +++ .../src/deriving/coerce_pointee.rs | 97 +++++++++++-------- .../deriving/deriving-coerce-pointee-neg.rs | 6 +- .../deriving-coerce-pointee-neg.stderr | 8 +- 4 files changed, 78 insertions(+), 48 deletions(-) diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index 6ebc2fd870cc..c05d44cb4525 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -94,6 +94,21 @@ builtin_macros_cfg_accessible_indeterminate = cannot determine whether the path builtin_macros_cfg_accessible_literal_path = `cfg_accessible` path cannot be a literal builtin_macros_cfg_accessible_multiple_paths = multiple `cfg_accessible` paths are specified builtin_macros_cfg_accessible_unspecified_path = `cfg_accessible` path is not specified + +builtin_macros_coerce_pointee_requires_maybe_sized = `derive(CoercePointee)` requires `{$name}` to be marked `?Sized` + +builtin_macros_coerce_pointee_requires_one_field = `CoercePointee` can only be derived on `struct`s with at least one field + +builtin_macros_coerce_pointee_requires_one_generic = `CoercePointee` can only be derived on `struct`s that are generic over at least one type + +builtin_macros_coerce_pointee_requires_one_pointee = exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits + +builtin_macros_coerce_pointee_requires_transparent = `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]` + +builtin_macros_coerce_pointee_too_many_pointees = only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits + .label = here another type parameter is marked as `#[pointee]` + + builtin_macros_concat_bytes_array = cannot concatenate doubly nested array .note = byte strings are treated as arrays of bytes .help = try flattening the array diff --git a/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs b/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs index 8adb9a3f4b0e..3bd8f899a4af 100644 --- a/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs +++ b/compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs @@ -9,6 +9,7 @@ use rustc_ast::{ use rustc_attr as attr; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_expand::base::{Annotatable, ExtCtxt}; +use rustc_macros::Diagnostic; use rustc_span::symbol::{Ident, sym}; use rustc_span::{Span, Symbol}; use thin_vec::{ThinVec, thin_vec}; @@ -38,12 +39,7 @@ pub(crate) fn expand_deriving_coerce_pointee( .any(|r| matches!(r, attr::ReprTransparent)) }); if !is_transparent { - cx.dcx() - .struct_span_err( - span, - "`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`", - ) - .emit(); + cx.dcx().emit_err(RequireTransparent { span }); return; } if !matches!( @@ -51,22 +47,12 @@ pub(crate) fn expand_deriving_coerce_pointee( VariantData::Struct { fields, recovered: _ } | VariantData::Tuple(fields, _) if !fields.is_empty()) { - cx.dcx() - .struct_span_err( - span, - "`CoercePointee` can only be derived on `struct`s with at least one field", - ) - .emit(); + cx.dcx().emit_err(RequireOneField { span }); return; } (aitem.ident, g) } else { - cx.dcx() - .struct_span_err( - span, - "`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`", - ) - .emit(); + cx.dcx().emit_err(RequireTransparent { span }); return; }; @@ -95,10 +81,7 @@ pub(crate) fn expand_deriving_coerce_pointee( let pointee_param_idx = if type_params.is_empty() { // `#[derive(CoercePointee)]` requires at least one generic type on the target `struct` - cx.dcx().struct_span_err( - span, - "`CoercePointee` can only be derived on `struct`s that are generic over at least one type", - ).emit(); + cx.dcx().emit_err(RequireOneGeneric { span }); return; } else if type_params.len() == 1 { // Regardless of the only type param being designed as `#[pointee]` or not, we can just use it as such @@ -111,19 +94,11 @@ pub(crate) fn expand_deriving_coerce_pointee( match (pointees.next(), pointees.next()) { (Some((idx, _span)), None) => idx, (None, _) => { - cx.dcx().struct_span_err( - span, - "exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits", - ).emit(); + cx.dcx().emit_err(RequireOnePointee { span }); return; } (Some((_, one)), Some((_, another))) => { - cx.dcx() - .struct_span_err( - vec![one, another], - "only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits", - ) - .emit(); + cx.dcx().emit_err(TooManyPointees { one, another }); return; } } @@ -181,15 +156,10 @@ pub(crate) fn expand_deriving_coerce_pointee( pointee_ty_ident.name, ) { - cx.dcx() - .struct_span_err( - pointee_ty_ident.span, - format!( - "`derive(CoercePointee)` requires {} to be marked `?Sized`", - pointee_ty_ident.name - ), - ) - .emit(); + cx.dcx().emit_err(RequiresMaybeSized { + span: pointee_ty_ident.span, + name: pointee_ty_ident.name.to_ident_string(), + }); return; } let arg = GenericArg::Type(s_ty.clone()); @@ -459,3 +429,48 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b> } } } + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_requires_transparent)] +struct RequireTransparent { + #[primary_span] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_requires_one_field)] +struct RequireOneField { + #[primary_span] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_requires_one_generic)] +struct RequireOneGeneric { + #[primary_span] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_requires_one_pointee)] +struct RequireOnePointee { + #[primary_span] + span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_too_many_pointees)] +struct TooManyPointees { + #[primary_span] + one: Span, + #[label] + another: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_coerce_pointee_requires_maybe_sized)] +struct RequiresMaybeSized { + #[primary_span] + span: Span, + name: String, +} diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.rs b/tests/ui/deriving/deriving-coerce-pointee-neg.rs index deef35cdf701..da25c854c546 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-neg.rs +++ b/tests/ui/deriving/deriving-coerce-pointee-neg.rs @@ -29,7 +29,7 @@ struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); struct NoGeneric<'a>(&'a u8); #[derive(CoercePointee)] -//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits +//~^ ERROR: exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits #[repr(transparent)] struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> { a: (&'a T1, &'a T2), @@ -38,7 +38,7 @@ struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> { #[derive(CoercePointee)] #[repr(transparent)] struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B)); -//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits +//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits #[derive(CoercePointee)] //~^ ERROR: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]` @@ -49,7 +49,7 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> { #[derive(CoercePointee)] #[repr(transparent)] struct NoMaybeSized<'a, #[pointee] T> { - //~^ ERROR: `derive(CoercePointee)` requires T to be marked `?Sized` + //~^ ERROR: `derive(CoercePointee)` requires `T` to be marked `?Sized` ptr: &'a T, } diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.stderr b/tests/ui/deriving/deriving-coerce-pointee-neg.stderr index e590d636d0e3..c1e8be49d37d 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-neg.stderr +++ b/tests/ui/deriving/deriving-coerce-pointee-neg.stderr @@ -30,7 +30,7 @@ LL | #[derive(CoercePointee)] | = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) -error: exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits +error: exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits --> $DIR/deriving-coerce-pointee-neg.rs:31:10 | LL | #[derive(CoercePointee)] @@ -38,11 +38,11 @@ LL | #[derive(CoercePointee)] | = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) -error: only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits +error: only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits --> $DIR/deriving-coerce-pointee-neg.rs:40:39 | LL | struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B)); - | ^ ^ + | ^ - here another type parameter is marked as `#[pointee]` error: `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]` --> $DIR/deriving-coerce-pointee-neg.rs:43:10 @@ -52,7 +52,7 @@ LL | #[derive(CoercePointee)] | = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `derive(CoercePointee)` requires T to be marked `?Sized` +error: `derive(CoercePointee)` requires `T` to be marked `?Sized` --> $DIR/deriving-coerce-pointee-neg.rs:51:36 | LL | struct NoMaybeSized<'a, #[pointee] T> { From 52a6badb968aeeed1105492bb0d074fbd53e3637 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 4 Dec 2024 14:41:51 +0100 Subject: [PATCH 35/59] Update sysinfo version to 0.33.0 --- src/bootstrap/Cargo.lock | 8 ++++---- src/bootstrap/Cargo.toml | 2 +- src/bootstrap/src/utils/metrics.rs | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 86d23d9bd024..c9697e670b77 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -324,9 +324,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libredox" @@ -558,9 +558,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.31.4" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" +checksum = "948512566b1895f93b1592c7574baeb2de842f224f2aab158799ecadb8ebbb46" dependencies = [ "core-foundation-sys", "libc", diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index fcd97b7b5898..6da716b7a895 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -63,7 +63,7 @@ walkdir = "2.4" xz2 = "0.1" # Dependencies needed by the build-metrics feature -sysinfo = { version = "0.31.2", default-features = false, optional = true, features = ["system"] } +sysinfo = { version = "0.33.0", default-features = false, optional = true, features = ["system"] } [target.'cfg(windows)'.dependencies.junction] version = "1.0.0" diff --git a/src/bootstrap/src/utils/metrics.rs b/src/bootstrap/src/utils/metrics.rs index 3b31fa36e889..b51fd490535a 100644 --- a/src/bootstrap/src/utils/metrics.rs +++ b/src/bootstrap/src/utils/metrics.rs @@ -56,7 +56,7 @@ impl BuildMetrics { running_steps: Vec::new(), system_info: System::new_with_specifics( - RefreshKind::new().with_cpu(CpuRefreshKind::everything()), + RefreshKind::nothing().with_cpu(CpuRefreshKind::everything()), ), timer_start: None, invocation_timer_start: Instant::now(), @@ -161,8 +161,9 @@ impl BuildMetrics { let dest = build.out.join("metrics.json"); - let mut system = - System::new_with_specifics(RefreshKind::new().with_cpu(CpuRefreshKind::everything())); + let mut system = System::new_with_specifics( + RefreshKind::nothing().with_cpu(CpuRefreshKind::everything()), + ); system.refresh_cpu_usage(); system.refresh_memory(); From 3f089971ffd41af9bfe2b362c1952b8e0809de9e Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 3 Dec 2024 22:42:41 +0000 Subject: [PATCH 36/59] Add failing test --- tests/incremental/track-deps-in-new-solver.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/incremental/track-deps-in-new-solver.rs diff --git a/tests/incremental/track-deps-in-new-solver.rs b/tests/incremental/track-deps-in-new-solver.rs new file mode 100644 index 000000000000..fb013b2b24a7 --- /dev/null +++ b/tests/incremental/track-deps-in-new-solver.rs @@ -0,0 +1,25 @@ +//@ revisions: cfail1 cfail2 + +//@ compile-flags: -Znext-solver +//@ check-pass + +pub trait Future { + type Error; + fn poll() -> Self::Error; +} + +struct S; +impl Future for S { + type Error = Error; + fn poll() -> Self::Error { + todo!() + } +} + +#[cfg(cfail1)] +pub struct Error(()); + +#[cfg(cfail2)] +pub struct Error(); + +fn main() {} From 988f28d442d2e959897e43a239f67d42e0297990 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 3 Dec 2024 22:47:08 +0000 Subject: [PATCH 37/59] Make sure to record deps from cached task in new solver on first run --- .../rustc_query_system/src/dep_graph/graph.rs | 17 +++++++++++++++-- .../rustc_query_system/src/query/plumbing.rs | 8 +++++--- .../src/traits/select/mod.rs | 5 +---- compiler/rustc_type_ir/src/search_graph/mod.rs | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 9b26a5bbcc6c..4b47ce8389c3 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -302,7 +302,11 @@ impl DepGraph { OP: FnOnce() -> R, { match self.data() { - Some(data) => data.with_anon_task(cx, dep_kind, op), + Some(data) => { + let (result, index) = data.with_anon_task_inner(cx, dep_kind, op); + self.read_index(index); + (result, index) + } None => (op(), self.next_virtual_depnode_index()), } } @@ -397,7 +401,16 @@ impl DepGraphData { /// Executes something within an "anonymous" task, that is, a task the /// `DepNode` of which is determined by the list of inputs it read from. - pub(crate) fn with_anon_task, OP, R>( + /// + /// NOTE: this does not actually count as a read of the DepNode here. + /// Using the result of this task without reading the DepNode will result + /// in untracked dependencies which may lead to ICEs as nodes are + /// incorrectly marked green. + /// + /// FIXME: This could perhaps return a `WithDepNode` to ensure that the + /// user of this function actually performs the read; we'll have to see + /// how to make that work with `anon` in `execute_job_incr`, though. + pub(crate) fn with_anon_task_inner, OP, R>( &self, cx: Tcx, dep_kind: DepKind, diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index aac8ab87c64e..6fb5e37d2d06 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -520,9 +520,11 @@ where let (result, dep_node_index) = qcx.start_query(job_id, query.depth_limit(), Some(&diagnostics), || { if query.anon() { - return dep_graph_data.with_anon_task(*qcx.dep_context(), query.dep_kind(), || { - query.compute(qcx, key) - }); + return dep_graph_data.with_anon_task_inner( + *qcx.dep_context(), + query.dep_kind(), + || query.compute(qcx, key), + ); } // `to_dep_node` is expensive for some `DepKind`s. diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 41a35c31fe43..d362866cbc38 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1400,10 +1400,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { where OP: FnOnce(&mut Self) -> R, { - let (result, dep_node) = - self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, || op(self)); - self.tcx().dep_graph.read_index(dep_node); - (result, dep_node) + self.tcx().dep_graph.with_anon_task(self.tcx(), dep_kinds::TraitSelect, || op(self)) } /// filter_impls filters candidates that have a positive impl for a negative diff --git a/compiler/rustc_type_ir/src/search_graph/mod.rs b/compiler/rustc_type_ir/src/search_graph/mod.rs index 5010fc09adc3..3cc2dcbaca6d 100644 --- a/compiler/rustc_type_ir/src/search_graph/mod.rs +++ b/compiler/rustc_type_ir/src/search_graph/mod.rs @@ -511,7 +511,7 @@ impl, X: Cx> SearchGraph { // This is for global caching, so we properly track query dependencies. // Everything that affects the `result` should be performed within this - // `with_anon_task` closure. If computing this goal depends on something + // `with_cached_task` closure. If computing this goal depends on something // not tracked by the cache key and from outside of this anon task, it // must not be added to the global cache. Notably, this is the case for // trait solver cycles participants. From f613636ae87e7e973138c7cb3e850ec26f93c723 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 4 Dec 2024 16:01:31 +0000 Subject: [PATCH 38/59] Rename `core_pattern_type` and `core_pattern_types` lib feature gates to `pattern_type_macro` That's what the gates are actually gating, and the single char difference in naming was not helpful either --- library/core/src/lib.rs | 2 +- library/core/src/pat.rs | 2 +- library/std/src/lib.rs | 2 +- .../crates/ide-db/src/generated/lints.rs | 13 ++---------- tests/codegen/pattern_type_symbols.rs | 3 +-- .../bad_const_generics_args_on_const_param.rs | 2 +- tests/ui/type/pattern_types/bad_pat.rs | 3 +-- tests/ui/type/pattern_types/bad_pat.stderr | 6 +++--- tests/ui/type/pattern_types/const_generics.rs | 3 +-- tests/ui/type/pattern_types/derives.rs | 3 +-- tests/ui/type/pattern_types/derives.stderr | 2 +- .../feature-gate-pattern_types.rs | 10 +++++----- .../feature-gate-pattern_types.stderr | 20 +++++++++---------- .../feature-gate-pattern_types2.rs | 2 +- tests/ui/type/pattern_types/missing-is.rs | 2 +- tests/ui/type/pattern_types/range_patterns.rs | 3 +-- .../type/pattern_types/range_patterns.stderr | 10 +++++----- .../range_patterns_inherent_impls.rs | 3 +-- .../range_patterns_inherent_impls.stderr | 4 ++-- .../range_patterns_trait_impls.rs | 3 +-- .../range_patterns_trait_impls2.rs | 3 +-- .../range_patterns_trait_impls2.stderr | 2 +- .../pattern_types/range_patterns_unusable.rs | 3 +-- .../range_patterns_unusable.stderr | 2 +- .../range_patterns_unusable_math.rs | 3 +-- .../range_patterns_unusable_math.stderr | 2 +- .../pattern_types/range_patterns_usage.rs | 3 +-- .../type/pattern_types/unimplemented_pat.rs | 3 +-- .../pattern_types/unimplemented_pat.stderr | 4 ++-- tests/ui/unpretty/expanded-exhaustive.rs | 2 +- tests/ui/unpretty/expanded-exhaustive.stdout | 2 +- 31 files changed, 53 insertions(+), 74 deletions(-) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ab9c33ee7547..fde6887c5aba 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -345,7 +345,7 @@ pub mod net; pub mod option; pub mod panic; pub mod panicking; -#[unstable(feature = "core_pattern_types", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] pub mod pat; pub mod pin; #[unstable(feature = "random", issue = "130703")] diff --git a/library/core/src/pat.rs b/library/core/src/pat.rs index 1f89d960be67..752e79c2dace 100644 --- a/library/core/src/pat.rs +++ b/library/core/src/pat.rs @@ -6,7 +6,7 @@ /// ``` #[macro_export] #[rustc_builtin_macro(pattern_type)] -#[unstable(feature = "core_pattern_type", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] macro_rules! pattern_type { ($($arg:tt)*) => { /* compiler built-in */ diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 585946c1d50e..6be27b283b29 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -589,7 +589,7 @@ pub mod net; pub mod num; pub mod os; pub mod panic; -#[unstable(feature = "core_pattern_types", issue = "123646")] +#[unstable(feature = "pattern_type_macro", issue = "123646")] pub mod pat; pub mod path; #[unstable(feature = "anonymous_pipe", issue = "127154")] diff --git a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs index 266109765ab8..b97dfb3b8ef8 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs @@ -3936,17 +3936,8 @@ The tracking issue for this feature is: [#117693] "##, }, Lint { - label: "core_pattern_type", - description: r##"# `core_pattern_type` - -This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use. - ------------------------- -"##, - }, - Lint { - label: "core_pattern_types", - description: r##"# `core_pattern_types` + label: "pattern_type_macro", + description: r##"# `pattern_type_macro` This feature has no tracking issue, and is therefore likely internal to the compiler, not being intended for general use. diff --git a/tests/codegen/pattern_type_symbols.rs b/tests/codegen/pattern_type_symbols.rs index a99b3efca415..b504a3508f94 100644 --- a/tests/codegen/pattern_type_symbols.rs +++ b/tests/codegen/pattern_type_symbols.rs @@ -4,8 +4,7 @@ //@ compile-flags: -Csymbol-mangling-version=v0 -Copt-level=0 --crate-type=lib #![feature(pattern_types)] -#![feature(core_pattern_types)] -#![feature(core_pattern_type)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs index 3defe0cb44d3..55f45ade3880 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs @@ -1,4 +1,4 @@ -#![feature(pattern_types, core_pattern_type)] +#![feature(pattern_types, pattern_type_macro)] #![allow(internal_features)] type Pat = diff --git a/tests/ui/type/pattern_types/bad_pat.rs b/tests/ui/type/pattern_types/bad_pat.rs index 8ad042eeba65..6cb2a0f1f8e7 100644 --- a/tests/ui/type/pattern_types/bad_pat.rs +++ b/tests/ui/type/pattern_types/bad_pat.rs @@ -1,6 +1,5 @@ #![feature(pattern_types)] -#![feature(core_pattern_types)] -#![feature(core_pattern_type)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/bad_pat.stderr b/tests/ui/type/pattern_types/bad_pat.stderr index f5cf7930c832..c857cc3c3add 100644 --- a/tests/ui/type/pattern_types/bad_pat.stderr +++ b/tests/ui/type/pattern_types/bad_pat.stderr @@ -1,5 +1,5 @@ error[E0586]: inclusive range with no end - --> $DIR/bad_pat.rs:7:43 + --> $DIR/bad_pat.rs:6:43 | LL | type NonNullU32_2 = pattern_type!(u32 is 1..=); | ^^^ @@ -12,7 +12,7 @@ LL + type NonNullU32_2 = pattern_type!(u32 is 1..); | error[E0586]: inclusive range with no end - --> $DIR/bad_pat.rs:9:40 + --> $DIR/bad_pat.rs:8:40 | LL | type Positive2 = pattern_type!(i32 is 0..=); | ^^^ @@ -25,7 +25,7 @@ LL + type Positive2 = pattern_type!(i32 is 0..); | error: wildcard patterns are not permitted for pattern types - --> $DIR/bad_pat.rs:11:33 + --> $DIR/bad_pat.rs:10:33 | LL | type Wild = pattern_type!(() is _); | ^ diff --git a/tests/ui/type/pattern_types/const_generics.rs b/tests/ui/type/pattern_types/const_generics.rs index 5bc6fd54e0fc..5cef0dc03055 100644 --- a/tests/ui/type/pattern_types/const_generics.rs +++ b/tests/ui/type/pattern_types/const_generics.rs @@ -1,8 +1,7 @@ //@ check-pass #![feature(pattern_types)] -#![feature(core_pattern_types)] -#![feature(core_pattern_type)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/derives.rs b/tests/ui/type/pattern_types/derives.rs index b8b53e61102b..3878c47554d9 100644 --- a/tests/ui/type/pattern_types/derives.rs +++ b/tests/ui/type/pattern_types/derives.rs @@ -1,8 +1,7 @@ //! Check that pattern types don't implement traits of their base automatically #![feature(pattern_types)] -#![feature(core_pattern_types)] -#![feature(core_pattern_type)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/derives.stderr b/tests/ui/type/pattern_types/derives.stderr index 1d4d3fc55c3f..9d4baef621be 100644 --- a/tests/ui/type/pattern_types/derives.stderr +++ b/tests/ui/type/pattern_types/derives.stderr @@ -1,5 +1,5 @@ error[E0369]: binary operation `==` cannot be applied to type `(i32) is 0..=999999999` - --> $DIR/derives.rs:11:20 + --> $DIR/derives.rs:10:20 | LL | #[derive(Clone, Copy, PartialEq)] | --------- in this derive macro expansion diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types.rs b/tests/ui/type/pattern_types/feature-gate-pattern_types.rs index e638f3c6c40d..b90ba4784023 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types.rs +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types.rs @@ -3,12 +3,12 @@ use std::pat::pattern_type; type NonNullU32 = pattern_type!(u32 is 1..); -//~^ use of unstable library feature `core_pattern_type` +//~^ use of unstable library feature `pattern_type_macro` type Percent = pattern_type!(u32 is 0..=100); -//~^ use of unstable library feature `core_pattern_type` +//~^ use of unstable library feature `pattern_type_macro` type Negative = pattern_type!(i32 is ..=0); -//~^ use of unstable library feature `core_pattern_type` +//~^ use of unstable library feature `pattern_type_macro` type Positive = pattern_type!(i32 is 0..); -//~^ use of unstable library feature `core_pattern_type` +//~^ use of unstable library feature `pattern_type_macro` type Always = pattern_type!(Option is Some(_)); -//~^ use of unstable library feature `core_pattern_type` +//~^ use of unstable library feature `pattern_type_macro` diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr b/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr index 6cbadf370a7d..69239d68bdc7 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types.stderr @@ -1,51 +1,51 @@ -error[E0658]: use of unstable library feature `core_pattern_type` +error[E0658]: use of unstable library feature `pattern_type_macro` --> $DIR/feature-gate-pattern_types.rs:5:19 | LL | type NonNullU32 = pattern_type!(u32 is 1..); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable + = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `core_pattern_type` +error[E0658]: use of unstable library feature `pattern_type_macro` --> $DIR/feature-gate-pattern_types.rs:7:16 | LL | type Percent = pattern_type!(u32 is 0..=100); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable + = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `core_pattern_type` +error[E0658]: use of unstable library feature `pattern_type_macro` --> $DIR/feature-gate-pattern_types.rs:9:17 | LL | type Negative = pattern_type!(i32 is ..=0); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable + = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `core_pattern_type` +error[E0658]: use of unstable library feature `pattern_type_macro` --> $DIR/feature-gate-pattern_types.rs:11:17 | LL | type Positive = pattern_type!(i32 is 0..); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable + = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: use of unstable library feature `core_pattern_type` +error[E0658]: use of unstable library feature `pattern_type_macro` --> $DIR/feature-gate-pattern_types.rs:13:15 | LL | type Always = pattern_type!(Option is Some(_)); | ^^^^^^^^^^^^ | = note: see issue #123646 for more information - = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable + = help: add `#![feature(pattern_type_macro)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 5 previous errors diff --git a/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs b/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs index d7b3ea58e026..50c355c8de61 100644 --- a/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs +++ b/tests/ui/type/pattern_types/feature-gate-pattern_types2.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Zno-analysis //@ check-pass -#![feature(core_pattern_type)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/missing-is.rs b/tests/ui/type/pattern_types/missing-is.rs index 2fbcc1908efc..564b41649d89 100644 --- a/tests/ui/type/pattern_types/missing-is.rs +++ b/tests/ui/type/pattern_types/missing-is.rs @@ -1,4 +1,4 @@ -#![feature(core_pattern_type, core_pattern_types)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/range_patterns.rs b/tests/ui/type/pattern_types/range_patterns.rs index 9eddc8cab7fe..7c25edb1c3fd 100644 --- a/tests/ui/type/pattern_types/range_patterns.rs +++ b/tests/ui/type/pattern_types/range_patterns.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //@ normalize-stderr-test: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN" diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index 7bd0d826cab7..0eed7c2ce1ce 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -37,7 +37,7 @@ error: layout_of(NonZero) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:11:1 + --> $DIR/range_patterns.rs:10:1 | LL | type X = std::num::NonZeroU32; | ^^^^^^ @@ -74,7 +74,7 @@ error: layout_of((u32) is 1..=) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:13:1 + --> $DIR/range_patterns.rs:12:1 | LL | type Y = pattern_type!(u32 is 1..); | ^^^^^^ @@ -182,7 +182,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:15:1 + --> $DIR/range_patterns.rs:14:1 | LL | type Z = Option; | ^^^^^^ @@ -290,7 +290,7 @@ error: layout_of(Option>) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:17:1 + --> $DIR/range_patterns.rs:16:1 | LL | type A = Option; | ^^^^^^ @@ -334,7 +334,7 @@ error: layout_of(NonZeroU32New) = Layout { max_repr_align: None, unadjusted_abi_align: Align(4 bytes), } - --> $DIR/range_patterns.rs:19:1 + --> $DIR/range_patterns.rs:18:1 | LL | struct NonZeroU32New(pattern_type!(u32 is 1..)); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs b/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs index 9653a744c416..fe8feda0934e 100644 --- a/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs +++ b/tests/ui/type/pattern_types/range_patterns_inherent_impls.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //! check that pattern types can have traits implemented for them if diff --git a/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr b/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr index 784ebb0c9f01..ed2e4c0bd5f8 100644 --- a/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr +++ b/tests/ui/type/pattern_types/range_patterns_inherent_impls.stderr @@ -1,12 +1,12 @@ error[E0390]: cannot define inherent `impl` for primitive types outside of `core` - --> $DIR/range_patterns_inherent_impls.rs:13:1 + --> $DIR/range_patterns_inherent_impls.rs:12:1 | LL | impl Y { | ^^^^^^ | = help: consider moving this inherent impl into `core` if possible help: alternatively add `#[rustc_allow_incoherent_impl]` to the relevant impl items - --> $DIR/range_patterns_inherent_impls.rs:15:5 + --> $DIR/range_patterns_inherent_impls.rs:14:5 | LL | fn foo() {} | ^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls.rs b/tests/ui/type/pattern_types/range_patterns_trait_impls.rs index f8c9af862818..1731cd470fe2 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls.rs +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //! check that pattern types can have local traits diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs b/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs index acde4580c1b2..90f80a2f3464 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls2.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //! check that pattern types can have local traits diff --git a/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr b/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr index df56db031ed1..d5c539b6c52e 100644 --- a/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr +++ b/tests/ui/type/pattern_types/range_patterns_trait_impls2.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/range_patterns_trait_impls2.rs:13:1 + --> $DIR/range_patterns_trait_impls2.rs:12:1 | LL | impl Eq for Y {} | ^^^^^^^^^^^^- diff --git a/tests/ui/type/pattern_types/range_patterns_unusable.rs b/tests/ui/type/pattern_types/range_patterns_unusable.rs index 7cde44f41335..98f13ca0bc0b 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable.rs +++ b/tests/ui/type/pattern_types/range_patterns_unusable.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //! Some practical niche checks. diff --git a/tests/ui/type/pattern_types/range_patterns_unusable.stderr b/tests/ui/type/pattern_types/range_patterns_unusable.stderr index aa0e592684b6..8377d417452b 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable.stderr +++ b/tests/ui/type/pattern_types/range_patterns_unusable.stderr @@ -1,5 +1,5 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/range_patterns_unusable.rs:14:35 + --> $DIR/range_patterns_unusable.rs:13:35 | LL | let _: Option = unsafe { std::mem::transmute(z) }; | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/range_patterns_unusable_math.rs b/tests/ui/type/pattern_types/range_patterns_unusable_math.rs index bc1ab75429d6..ece4009e1e7d 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable_math.rs +++ b/tests/ui/type/pattern_types/range_patterns_unusable_math.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //! check that pattern types don't have an `Add` impl. diff --git a/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr b/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr index e52d899a703f..373615e3714e 100644 --- a/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr +++ b/tests/ui/type/pattern_types/range_patterns_unusable_math.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `u32` to `(u32) is 1..=` - --> $DIR/range_patterns_unusable_math.rs:15:15 + --> $DIR/range_patterns_unusable_math.rs:14:15 | LL | let x = x + 1_u32; | - ^ ----- u32 diff --git a/tests/ui/type/pattern_types/range_patterns_usage.rs b/tests/ui/type/pattern_types/range_patterns_usage.rs index 2a9f736ae61d..0ecbdcaa0f7a 100644 --- a/tests/ui/type/pattern_types/range_patterns_usage.rs +++ b/tests/ui/type/pattern_types/range_patterns_usage.rs @@ -1,6 +1,5 @@ #![feature(pattern_types, rustc_attrs)] -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] #![allow(incomplete_features)] //@ check-pass diff --git a/tests/ui/type/pattern_types/unimplemented_pat.rs b/tests/ui/type/pattern_types/unimplemented_pat.rs index c02160ff58a6..b2398cec7c9b 100644 --- a/tests/ui/type/pattern_types/unimplemented_pat.rs +++ b/tests/ui/type/pattern_types/unimplemented_pat.rs @@ -1,8 +1,7 @@ //! This test ensures we do not ICE for unimplemented //! patterns unless the feature gate is enabled. -#![feature(core_pattern_type)] -#![feature(core_pattern_types)] +#![feature(pattern_type_macro)] use std::pat::pattern_type; diff --git a/tests/ui/type/pattern_types/unimplemented_pat.stderr b/tests/ui/type/pattern_types/unimplemented_pat.stderr index 481c6017dccc..7b0f9cbaa6a9 100644 --- a/tests/ui/type/pattern_types/unimplemented_pat.stderr +++ b/tests/ui/type/pattern_types/unimplemented_pat.stderr @@ -1,5 +1,5 @@ error[E0658]: pattern types are unstable - --> $DIR/unimplemented_pat.rs:9:15 + --> $DIR/unimplemented_pat.rs:8:15 | LL | type Always = pattern_type!(Option is Some(_)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | type Always = pattern_type!(Option is Some(_)); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pattern types are unstable - --> $DIR/unimplemented_pat.rs:12:16 + --> $DIR/unimplemented_pat.rs:11:16 | LL | type Binding = pattern_type!(Option is x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs index 891021e87660..9af57fe4c3cd 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -8,7 +8,6 @@ #![feature(builtin_syntax)] #![feature(concat_idents)] #![feature(const_trait_impl)] -#![feature(core_pattern_type)] #![feature(decl_macro)] #![feature(deref_patterns)] #![feature(explicit_tail_calls)] @@ -18,6 +17,7 @@ #![feature(never_patterns)] #![feature(never_type)] #![feature(pattern_types)] +#![feature(pattern_type_macro)] #![feature(prelude_import)] #![feature(specialization)] #![feature(trace_macros)] diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout index 007626e2c440..14a274415ca7 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -9,7 +9,6 @@ #![feature(builtin_syntax)] #![feature(concat_idents)] #![feature(const_trait_impl)] -#![feature(core_pattern_type)] #![feature(decl_macro)] #![feature(deref_patterns)] #![feature(explicit_tail_calls)] @@ -19,6 +18,7 @@ #![feature(never_patterns)] #![feature(never_type)] #![feature(pattern_types)] +#![feature(pattern_type_macro)] #![feature(prelude_import)] #![feature(specialization)] #![feature(trace_macros)] From 1b449e123d8d935b3ac7d475e3fc075860af444e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Dec 2024 05:57:55 +0000 Subject: [PATCH 39/59] Do not emit empty suggestion The `println!();` statement's span doesn't include the `;`, and the modified suggestions where trying to get the `;` by getting the differenece between the statement's and the expression's spans, which was an empty suggestion. Fix #133833, fix #133834. --- .../src/fn_ctxt/suggestions.rs | 8 ++- .../src/error_reporting/traits/suggestions.rs | 6 +++ ...uggestion-when-stmt-and-expr-span-equal.rs | 26 ++++++++++ ...stion-when-stmt-and-expr-span-equal.stderr | 50 +++++++++++++++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.rs create mode 100644 tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 61260dbd16c5..ddcd90a2a9da 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -3394,7 +3394,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let Some(ty) = self.node_ty_opt(tail_expr.hir_id) else { return; }; - if self.can_eq(self.param_env, expected_ty, ty) { + if self.can_eq(self.param_env, expected_ty, ty) + // FIXME: this happens with macro calls. Need to figure out why the stmt + // `println!();` doesn't include the `;` in its `Span`. (#133845) + // We filter these out to avoid ICEs with debug assertions on caused by + // empty suggestions. + && stmt.span.hi() != tail_expr.span.hi() + { err.span_suggestion_short( stmt.span.with_lo(tail_expr.span.hi()), "remove this semicolon", diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 2bb503f17b4e..94682f501a8c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3838,6 +3838,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { && self.predicate_must_hold_modulo_regions(&Obligation::misc( tcx, expr.span, body_id, param_env, pred, )) + && expr.span.hi() != rcvr.span.hi() { err.span_suggestion_verbose( expr.span.with_lo(rcvr.span.hi()), @@ -4115,6 +4116,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // the expected is a projection that we need to resolve. // && let Some(tail_ty) = typeck_results.expr_ty_opt(expr) && expected_found.found.is_unit() + // FIXME: this happens with macro calls. Need to figure out why the stmt + // `println!();` doesn't include the `;` in its `Span`. (#133845) + // We filter these out to avoid ICEs with debug assertions on caused by + // empty suggestions. + && expr.span.hi() != stmt.span.hi() { err.span_suggestion_verbose( expr.span.shrink_to_hi().with_hi(stmt.span.hi()), diff --git a/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.rs b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.rs new file mode 100644 index 000000000000..35612093aff0 --- /dev/null +++ b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.rs @@ -0,0 +1,26 @@ +//! Regression test for suggestions that were fired on empty spans +//! involving macro-call statements. For some reason the semicolon +//! is not included in the overall span of the macro-call statement. +//! +//! Issue 1: . +//! Issue 2: . +//! See also: . + +fn foo() -> String { + let mut list = { + println!(); + }; + list //~ ERROR mismatched types +} + +fn bar() { + String::new() + .chars() + .filter(|x| !x.is_whitespace()) + .map(|x| { + println!("Child spawned with the size: {}", x); + }) + .collect::(); //~ ERROR E0277 +} + +fn main() {} diff --git a/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr new file mode 100644 index 000000000000..4b83bfff8633 --- /dev/null +++ b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr @@ -0,0 +1,50 @@ +error[E0308]: mismatched types + --> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:13:5 + | +LL | fn foo() -> String { + | ------ expected `String` because of return type +LL | let mut list = { + | ____________________- +LL | | println!(); +LL | | }; + | |_____- this block is missing a tail expression +LL | list + | ^^^^ expected `String`, found `()` + +error[E0277]: a value of type `String` cannot be built from an iterator over elements of type `()` + --> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:23:20 + | +LL | .collect::(); + | ------- ^^^^^^ value of type `String` cannot be built from `std::iter::Iterator` + | | + | required by a bound introduced by this call + | + = help: the trait `FromIterator<()>` is not implemented for `String` + = help: the following other types implement trait `FromIterator`: + `String` implements `FromIterator<&char>` + `String` implements `FromIterator<&str>` + `String` implements `FromIterator>` + `String` implements `FromIterator>` + `String` implements `FromIterator` + `String` implements `FromIterator` +note: the method call chain might not have had the expected associated types + --> $DIR/semi-suggestion-when-stmt-and-expr-span-equal.rs:20:10 + | +LL | String::new() + | ------------- this expression has type `String` +LL | .chars() + | ------- `Iterator::Item` is `char` here +LL | .filter(|x| !x.is_whitespace()) + | ------------------------------ `Iterator::Item` remains `char` here +LL | .map(|x| { + | __________^ +LL | | println!("Child spawned with the size: {}", x); +LL | | }) + | |__________^ `Iterator::Item` changed to `()` here +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. From 05c34cc5ed35dbf32f83e2eaa0ebbda4c4953294 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 8 Mar 2024 00:02:11 +0000 Subject: [PATCH 40/59] Fix suggestion when shorthand self has erroneous type --- compiler/rustc_ast/src/ast.rs | 12 ++++++ compiler/rustc_parse/messages.ftl | 3 ++ compiler/rustc_parse/src/errors.rs | 19 ++++++++++ compiler/rustc_parse/src/parser/item.rs | 30 ++++++++++++++- tests/ui/parser/typed-self-param.rs | 14 +++++++ tests/ui/parser/typed-self-param.stderr | 50 +++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 tests/ui/parser/typed-self-param.rs create mode 100644 tests/ui/parser/typed-self-param.stderr diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index ed2a3a507c8a..2f55a9eaedab 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2566,6 +2566,18 @@ pub enum SelfKind { Explicit(P, Mutability), } +impl SelfKind { + pub fn to_ref_suggestion(&self) -> String { + match self { + SelfKind::Region(None, mutbl) => mutbl.ref_prefix_str().to_string(), + SelfKind::Region(Some(lt), mutbl) => format!("&{lt} {}", mutbl.prefix_str()), + SelfKind::Value(_) | SelfKind::Explicit(_, _) => { + unreachable!("if we had an explicit self, we wouldn't be here") + } + } + } +} + pub type ExplicitSelf = Spanned; impl Param { diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index b9a325eddd80..e5cd4622dae9 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -343,6 +343,9 @@ parse_incorrect_semicolon = .suggestion = remove this semicolon .help = {$name} declarations are not followed by a semicolon +parse_incorrect_type_on_self = type not allowed for shorthand `self` parameter + .suggestion = move the modifiers on `self` to the type + parse_incorrect_use_of_await = incorrect use of `await` .parentheses_suggestion = `await` is not a method call, remove the parentheses diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 2579e4c1f259..14f2dd32e923 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3409,3 +3409,22 @@ pub(crate) struct PolarityAndModifiers { pub polarity: &'static str, pub modifiers_concatenated: String, } + +#[derive(Diagnostic)] +#[diag(parse_incorrect_type_on_self)] +pub(crate) struct IncorrectTypeOnSelf { + #[primary_span] + pub span: Span, + #[subdiagnostic] + pub move_self_modifier: MoveSelfModifier, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")] +pub(crate) struct MoveSelfModifier { + #[suggestion_part(code = "")] + pub removal_span: Span, + #[suggestion_part(code = "{modifier}")] + pub insertion_span: Span, + pub modifier: String, +} diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 26e81b7676bb..475cd09147f5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2941,6 +2941,32 @@ impl<'a> Parser<'a> { }; Ok((eself, eself_ident, eself_hi)) }; + let expect_self_ident_not_typed = + |this: &mut Self, modifier: &SelfKind, modifier_span: Span| { + let eself_ident = expect_self_ident(this); + + // Recover `: Type` after a qualified self + if this.may_recover() && this.eat_noexpect(&token::Colon) { + let snap = this.create_snapshot_for_diagnostic(); + match this.parse_ty() { + Ok(ty) => { + this.dcx().emit_err(errors::IncorrectTypeOnSelf { + span: ty.span, + move_self_modifier: errors::MoveSelfModifier { + removal_span: modifier_span, + insertion_span: ty.span.shrink_to_lo(), + modifier: modifier.to_ref_suggestion(), + }, + }); + } + Err(diag) => { + diag.cancel(); + this.restore_snapshot(snap); + } + } + } + eself_ident + }; // Recover for the grammar `*self`, `*const self`, and `*mut self`. let recover_self_ptr = |this: &mut Self| { this.dcx().emit_err(errors::SelfArgumentPointer { span: this.token.span }); @@ -2978,7 +3004,9 @@ impl<'a> Parser<'a> { // `¬_self` return Ok(None); }; - (eself, expect_self_ident(self), self.prev_token.span) + let hi = self.token.span; + let self_ident = expect_self_ident_not_typed(self, &eself, eself_lo.until(hi)); + (eself, self_ident, hi) } // `*self` token::BinOp(token::Star) if is_isolated_self(self, 1) => { diff --git a/tests/ui/parser/typed-self-param.rs b/tests/ui/parser/typed-self-param.rs new file mode 100644 index 000000000000..e3d85ab891b5 --- /dev/null +++ b/tests/ui/parser/typed-self-param.rs @@ -0,0 +1,14 @@ +struct S; + +impl S { + fn a(&self: Self) {} + //~^ ERROR type not allowed for shorthand `self` parameter + fn b(&mut self: Self) {} + //~^ ERROR type not allowed for shorthand `self` parameter + fn c<'c>(&'c mut self: Self) {} + //~^ ERROR type not allowed for shorthand `self` parameter + fn d<'d>(&'d self: Self) {} + //~^ ERROR type not allowed for shorthand `self` parameter +} + +fn main() {} diff --git a/tests/ui/parser/typed-self-param.stderr b/tests/ui/parser/typed-self-param.stderr new file mode 100644 index 000000000000..c1ecd3b7fef4 --- /dev/null +++ b/tests/ui/parser/typed-self-param.stderr @@ -0,0 +1,50 @@ +error: type not allowed for shorthand `self` parameter + --> $DIR/typed-self-param.rs:4:17 + | +LL | fn a(&self: Self) {} + | ^^^^ + | +help: move the modifiers on `self` to the type + | +LL - fn a(&self: Self) {} +LL + fn a(self: &Self) {} + | + +error: type not allowed for shorthand `self` parameter + --> $DIR/typed-self-param.rs:6:21 + | +LL | fn b(&mut self: Self) {} + | ^^^^ + | +help: move the modifiers on `self` to the type + | +LL - fn b(&mut self: Self) {} +LL + fn b(self: &mut Self) {} + | + +error: type not allowed for shorthand `self` parameter + --> $DIR/typed-self-param.rs:8:28 + | +LL | fn c<'c>(&'c mut self: Self) {} + | ^^^^ + | +help: move the modifiers on `self` to the type + | +LL - fn c<'c>(&'c mut self: Self) {} +LL + fn c<'c>(self: &'c mut Self) {} + | + +error: type not allowed for shorthand `self` parameter + --> $DIR/typed-self-param.rs:10:24 + | +LL | fn d<'d>(&'d self: Self) {} + | ^^^^ + | +help: move the modifiers on `self` to the type + | +LL - fn d<'d>(&'d self: Self) {} +LL + fn d<'d>(self: &'d Self) {} + | + +error: aborting due to 4 previous errors + From c6205055e085a1210c1503978225d34147a0d8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 02:15:21 +0000 Subject: [PATCH 41/59] On `const` pattern errors, point at the `const` item definition Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition: ``` error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { | ------------- LL | const X: EFoo; | ------------- constant defined here ... LL | A::X => println!("A::X"), | ^^^^ ``` --- compiler/rustc_mir_build/messages.ftl | 2 + .../src/thir/pattern/const_to_pat.rs | 103 ++++++++++++------ ...ciated-const-type-parameter-pattern.stderr | 20 ++++ ...e-type-mismatch-when-copying-112824.stderr | 5 + .../const-eval/const-eval-overflow-2.stderr | 3 + .../const-eval/ref_to_int_match.64bit.stderr | 3 + .../const_in_pattern/cross-crate-fail.stderr | 10 ++ ...ssue-34784-match-on-non-int-raw-ptr.stderr | 12 ++ .../const_in_pattern/issue-44333.stderr | 6 + .../const_in_pattern/issue-65466.stderr | 3 + .../const_in_pattern/no-eq-branch-fail.stderr | 3 + .../reject_non_partial_eq.stderr | 3 + .../const_in_pattern/reject_non_structural.rs | 20 ++-- .../reject_non_structural.stderr | 21 ++++ .../const_refs_to_static_fail_invalid.stderr | 9 ++ tests/ui/consts/issue-43105.stderr | 3 + .../ui/consts/issue-73976-polymorphic.stderr | 10 ++ tests/ui/consts/issue-78655.stderr | 3 + tests/ui/consts/issue-79137-toogeneric.stderr | 5 + tests/ui/consts/issue-87046.stderr | 3 + tests/ui/consts/issue-89088.stderr | 3 + tests/ui/consts/match_ice.stderr | 3 + .../const_refers_to_static_cross_crate.stderr | 12 ++ .../ui/consts/missing_assoc_const_type.stderr | 5 + ...ansmute-size-mismatch-before-typeck.stderr | 3 + tests/ui/match/issue-70972-dyn-trait.stderr | 3 + .../issue-72896-non-partial-eq-const.stderr | 3 + tests/ui/pattern/issue-115599.stderr | 3 + tests/ui/pattern/issue-72565.stderr | 3 + .../const-partial_eq-fallback-ice.stderr | 3 + .../pattern/usefulness/consts-opaque.stderr | 24 ++++ ...-hide-behind-direct-struct-embedded.stderr | 3 + ...ant-hide-behind-direct-struct-param.stderr | 3 + ...ide-behind-doubly-indirect-embedded.stderr | 3 + ...t-hide-behind-doubly-indirect-param.stderr | 3 + ...ide-behind-indirect-struct-embedded.stderr | 3 + ...t-hide-behind-indirect-struct-param.stderr | 3 + ...n-ptr-is-not-structurally-matchable.stderr | 30 +++++ ...88-match-slice-forbidden-without-eq.stderr | 3 + ...-match-ref-ref-forbidden-without-eq.stderr | 6 + .../issue-63479-match-fnptr.stderr | 6 + .../issue-6804-nan-match.stderr | 21 ++++ ...atch-requires-both-partialeq-and-eq.stderr | 3 + .../structural-match-no-leak.stderr | 3 + .../structural-match.stderr | 3 + tests/ui/union/union-const-pat.stderr | 3 + 46 files changed, 365 insertions(+), 43 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index f28cf84fa693..fdefc0bfd190 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -84,6 +84,8 @@ mir_build_call_to_unsafe_fn_requires_unsafe_unsafe_op_in_unsafe_fn_allowed = mir_build_confused = missing patterns are not covered because `{$variable}` is interpreted as a constant pattern, not a new variable +mir_build_const_defined_here = constant defined here + mir_build_const_param_in_pattern = const parameters cannot be referenced in patterns mir_build_const_pattern_depends_on_generic_parameter = diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 5db08f01fdbd..aa98874654ed 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -1,5 +1,6 @@ use rustc_abi::{FieldIdx, VariantIdx}; use rustc_apfloat::Float; +use rustc_errors::{Diag, PResult}; use rustc_hir as hir; use rustc_index::Idx; use rustc_infer::infer::TyCtxtInferExt; @@ -35,11 +36,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { id: hir::HirId, span: Span, ) -> Box> { - let mut convert = ConstToPat::new(self, id, span); + let mut convert = ConstToPat::new(self, id, span, c); match c.kind() { ty::ConstKind::Unevaluated(uv) => convert.unevaluated_to_pat(uv, ty), - ty::ConstKind::Value(_, val) => convert.valtree_to_pat(val, ty), + ty::ConstKind::Value(_, val) => match convert.valtree_to_pat(val, ty) { + Ok(pat) => pat, + Err(err) => convert.mk_err(err, ty), + }, _ => span_bug!(span, "Invalid `ConstKind` for `const_to_pat`: {:?}", c), } } @@ -51,10 +55,12 @@ struct ConstToPat<'tcx> { span: Span, treat_byte_string_as_slice: bool, + + c: ty::Const<'tcx>, } impl<'tcx> ConstToPat<'tcx> { - fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span) -> Self { + fn new(pat_ctxt: &PatCtxt<'_, 'tcx>, id: hir::HirId, span: Span, c: ty::Const<'tcx>) -> Self { trace!(?pat_ctxt.typeck_results.hir_owner); ConstToPat { tcx: pat_ctxt.tcx, @@ -64,6 +70,7 @@ impl<'tcx> ConstToPat<'tcx> { .typeck_results .treat_byte_string_as_slice .contains(&id.local_id), + c, } } @@ -71,13 +78,32 @@ impl<'tcx> ConstToPat<'tcx> { ty.is_structural_eq_shallow(self.tcx) } + /// We errored. Signal that in the pattern, so that follow up errors can be silenced. + fn mk_err(&self, mut err: Diag<'_>, ty: Ty<'tcx>) -> Box> { + if let ty::ConstKind::Unevaluated(uv) = self.c.kind() { + let def_kind = self.tcx.def_kind(uv.def); + if let hir::def::DefKind::AssocConst = def_kind + && let Some(def_id) = uv.def.as_local() + { + // Include the container item in the output. + err.span_label(self.tcx.def_span(self.tcx.local_parent(def_id)), ""); + } + if let hir::def::DefKind::Const | hir::def::DefKind::AssocConst = def_kind { + err.span_label( + self.tcx.def_span(uv.def), + crate::fluent_generated::mir_build_const_defined_here, + ); + } + } + Box::new(Pat { span: self.span, ty, kind: PatKind::Error(err.emit()) }) + } + fn unevaluated_to_pat( &mut self, uv: ty::UnevaluatedConst<'tcx>, ty: Ty<'tcx>, ) -> Box> { trace!(self.treat_byte_string_as_slice); - let pat_from_kind = |kind| Box::new(Pat { span: self.span, ty, kind }); // It's not *technically* correct to be revealing opaque types here as borrowcheck has // not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even @@ -96,44 +122,46 @@ impl<'tcx> ConstToPat<'tcx> { Ok(Ok(c)) => c, Err(ErrorHandled::Reported(_, _)) => { // Let's tell the use where this failing const occurs. - let e = self.tcx.dcx().emit_err(CouldNotEvalConstPattern { span: self.span }); - return pat_from_kind(PatKind::Error(e)); + let err = self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span }); + return self.mk_err(err, ty); } Err(ErrorHandled::TooGeneric(_)) => { let e = self .tcx .dcx() - .emit_err(ConstPatternDependsOnGenericParameter { span: self.span }); - return pat_from_kind(PatKind::Error(e)); + .create_err(ConstPatternDependsOnGenericParameter { span: self.span }); + return self.mk_err(e, ty); } Ok(Err(bad_ty)) => { // The pattern cannot be turned into a valtree. let e = match bad_ty.kind() { ty::Adt(def, ..) => { assert!(def.is_union()); - self.tcx.dcx().emit_err(UnionPattern { span: self.span }) + self.tcx.dcx().create_err(UnionPattern { span: self.span }) } ty::FnPtr(..) | ty::RawPtr(..) => { - self.tcx.dcx().emit_err(PointerPattern { span: self.span }) + self.tcx.dcx().create_err(PointerPattern { span: self.span }) } _ => self .tcx .dcx() - .emit_err(InvalidPattern { span: self.span, non_sm_ty: bad_ty }), + .create_err(InvalidPattern { span: self.span, non_sm_ty: bad_ty }), }; - return pat_from_kind(PatKind::Error(e)); + return self.mk_err(e, ty); } }; // Convert the valtree to a const. - let inlined_const_as_pat = self.valtree_to_pat(valtree, ty); + let inlined_const_as_pat = match self.valtree_to_pat(valtree, ty) { + Ok(pat) => pat, + Err(err) => self.mk_err(err, ty), + }; if !inlined_const_as_pat.references_error() { // Always check for `PartialEq` if we had no other errors yet. if !self.type_has_partial_eq_impl(ty) { let err = TypeNotPartialEq { span: self.span, non_peq_ty: ty }; - let e = self.tcx.dcx().emit_err(err); - return pat_from_kind(PatKind::Error(e)); + return self.mk_err(self.tcx.dcx().create_err(err), ty); } } @@ -175,14 +203,20 @@ impl<'tcx> ConstToPat<'tcx> { let field = FieldIdx::new(idx); // Patterns can only use monomorphic types. let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty); - FieldPat { field, pattern: self.valtree_to_pat(val, ty) } + FieldPat { + field, + pattern: match self.valtree_to_pat(val, ty) { + Ok(pat) => pat, + Err(err) => self.mk_err(err, ty), + }, + } }) .collect() } // Recursive helper for `to_pat`; invoke that (instead of calling this directly). #[instrument(skip(self), level = "debug")] - fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box> { + fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> PResult<'_, Box>> { let span = self.span; let tcx = self.tcx; let kind = match ty.kind() { @@ -191,9 +225,7 @@ impl<'tcx> ConstToPat<'tcx> { // patterns. debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty); let err = TypeNotStructural { span, non_sm_ty: ty }; - let e = tcx.dcx().emit_err(err); - // We errored. Signal that in the pattern, so that follow up errors can be silenced. - PatKind::Error(e) + return Err(tcx.dcx().create_err(err)); } ty::Adt(adt_def, args) if adt_def.is_enum() => { let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap(); @@ -227,7 +259,10 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| self.valtree_to_pat(*val, *elem_ty)) + .map(|val| match self.valtree_to_pat(*val, *elem_ty) { + Ok(pat) => pat, + Err(err) => self.mk_err(err, ty), + }) .collect(), slice: None, suffix: Box::new([]), @@ -236,7 +271,10 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| self.valtree_to_pat(*val, *elem_ty)) + .map(|val| match self.valtree_to_pat(*val, *elem_ty) { + Ok(pat) => pat, + Err(err) => self.mk_err(err, ty), + }) .collect(), slice: None, suffix: Box::new([]), @@ -252,10 +290,9 @@ impl<'tcx> ConstToPat<'tcx> { // deref pattern. _ => { if !pointee_ty.is_sized(tcx, self.typing_env) && !pointee_ty.is_slice() { - let err = UnsizedPattern { span, non_sm_ty: *pointee_ty }; - let e = tcx.dcx().emit_err(err); - // We errored. Signal that in the pattern, so that follow up errors can be silenced. - PatKind::Error(e) + return Err(tcx + .dcx() + .create_err(UnsizedPattern { span, non_sm_ty: *pointee_ty })); } else { // `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when // matching against references, you can only use byte string literals. @@ -270,7 +307,10 @@ impl<'tcx> ConstToPat<'tcx> { _ => *pointee_ty, }; // References have the same valtree representation as their pointee. - let subpattern = self.valtree_to_pat(cv, pointee_ty); + let subpattern = match self.valtree_to_pat(cv, pointee_ty) { + Ok(pat) => pat, + Err(err) => self.mk_err(err, ty), + }; PatKind::Deref { subpattern } } } @@ -286,8 +326,7 @@ impl<'tcx> ConstToPat<'tcx> { if is_nan { // NaNs are not ever equal to anything so they make no sense as patterns. // Also see . - let e = tcx.dcx().emit_err(NaNPattern { span }); - PatKind::Error(e) + return Err(tcx.dcx().create_err(NaNPattern { span })); } else { PatKind::Constant { value: mir::Const::Ty(ty, ty::Const::new_value(tcx, cv, ty)), @@ -306,12 +345,10 @@ impl<'tcx> ConstToPat<'tcx> { } _ => { let err = InvalidPattern { span, non_sm_ty: ty }; - let e = tcx.dcx().emit_err(err); - // We errored. Signal that in the pattern, so that follow up errors can be silenced. - PatKind::Error(e) + return Err(tcx.dcx().create_err(err)); } }; - Box::new(Pat { span, ty, kind }) + Ok(Box::new(Pat { span, ty, kind })) } } diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr index adc8f3992072..5aef0fa414bd 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr @@ -1,24 +1,44 @@ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | A::X => println!("A::X"), | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:22:9 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | B::X => println!("B::X"), | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:30:9 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | let A::X = arg; | ^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:28:48 | +LL | pub trait Foo { + | ------------- +LL | const X: EFoo; + | ------------- constant defined here +... LL | pub fn test_let_pat(arg: EFoo, A::X: EFoo) { | ^^^^ diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr index 9442eac0cf54..9cce6fee55ac 100644 --- a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr +++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr @@ -20,6 +20,11 @@ LL | pub struct Opcode2(&'a S); error: could not evaluate constant pattern --> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9 | +LL | impl Opcode2 { + | ------------ +LL | pub const OP2: Opcode2 = Opcode2(Opcode(0x1)); + | ---------------------- constant defined here +... LL | Opcode2::OP2 => unimplemented!(), | ^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index fc0baf11051b..66c54af4f83f 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -7,6 +7,9 @@ LL | const NEG_NEG_128: i8 = -NEG_128; error: could not evaluate constant pattern --> $DIR/const-eval-overflow-2.rs:15:9 | +LL | const NEG_NEG_128: i8 = -NEG_128; + | --------------------- constant defined here +... LL | NEG_NEG_128 => println!("A"), | ^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 8175fe6016ab..b1c6cfd3246e 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -12,6 +12,9 @@ error: could not evaluate constant pattern | LL | 10..=BAR => {}, | ^^^ +... +LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; + | -------------- constant defined here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr index e0f97a9abd21..81fc67e6aebb 100644 --- a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr +++ b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr @@ -4,6 +4,11 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann LL | consts::SOME => panic!(), | ^^^^^^^^^^^^ | + ::: $DIR/auxiliary/consts.rs:11:1 + | +LL | pub const SOME: Option = Some(CustomEq); + | -------------------------------- constant defined here + | = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details @@ -13,6 +18,11 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann LL | ::SOME => panic!(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + ::: $DIR/auxiliary/consts.rs:15:5 + | +LL | const SOME: Option = Some(CustomEq); + | ---------------------------- constant defined here + | = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details diff --git a/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr b/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr index aa208341c131..cc7ec771e6cd 100644 --- a/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr +++ b/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr @@ -1,24 +1,36 @@ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:9:9 | +LL | const C: *const u8 = &0; + | ------------------ constant defined here +... LL | C => {} | ^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:16:9 | +LL | const C_INNER: (*const u8, u8) = (C, 0); + | ------------------------------ constant defined here +... LL | C_INNER => {} | ^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:27:9 | +LL | const D: *const [u8; 4] = b"abcd"; + | ----------------------- constant defined here +... LL | D => {} | ^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:32:9 | +LL | const STR: *const str = "abcd"; + | --------------------- constant defined here +... LL | STR => {} | ^^^ diff --git a/tests/ui/consts/const_in_pattern/issue-44333.stderr b/tests/ui/consts/const_in_pattern/issue-44333.stderr index d377bfd95f9c..81393952f0fc 100644 --- a/tests/ui/consts/const_in_pattern/issue-44333.stderr +++ b/tests/ui/consts/const_in_pattern/issue-44333.stderr @@ -1,12 +1,18 @@ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-44333.rs:15:9 | +LL | const FOO: Func = foo; + | --------------- constant defined here +... LL | FOO => println!("foo"), | ^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-44333.rs:16:9 | +LL | const BAR: Func = bar; + | --------------- constant defined here +... LL | BAR => println!("bar"), | ^^^ diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index 7d5e5b5b0c64..070ce384f6aa 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `&[O]` in a pattern, the type must implement `PartialEq` --> $DIR/issue-65466.rs:14:9 | +LL | const C: &[O] = &[O::None]; + | ---------------- constant defined here +... LL | C => (), | ^ diff --git a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr index 7766c6ce683d..5e2fc6eca3c5 100644 --- a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr +++ b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]` --> $DIR/no-eq-branch-fail.rs:19:9 | +LL | const BAR_BAZ: Foo = if 42 == 42 { + | ------------------ constant defined here +... LL | BAR_BAZ => panic!(), | ^^^^^^^ | diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index ed531a1fead8..463b37e7caa7 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `Option` in a pattern, the type must implement `PartialEq` --> $DIR/reject_non_partial_eq.rs:28:9 | +LL | const NO_PARTIAL_EQ_NONE: Option = None; + | --------------------------------------------- constant defined here +... LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.rs b/tests/ui/consts/const_in_pattern/reject_non_structural.rs index e3dcecec960a..52cb974c1df1 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.rs +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.rs @@ -36,63 +36,63 @@ fn main() { #[derive(PartialEq, Eq, Debug)] enum Derive { Some(X), None, } - const ENUM: Derive = Derive::Some(NoDerive); + const ENUM: Derive = Derive::Some(NoDerive); //~ NOTE constant defined here match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const FIELD: OND = TrivialEq(Some(NoDerive)).0; + const FIELD: OND = TrivialEq(Some(NoDerive)).0; //~ NOTE constant defined here match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details const NO_DERIVE_SOME: OND = Some(NoDerive); - const INDIRECT: OND = NO_DERIVE_SOME; + const INDIRECT: OND = NO_DERIVE_SOME; //~ NOTE constant defined here match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const TUPLE: (OND, OND) = (None, Some(NoDerive)); + const TUPLE: (OND, OND) = (None, Some(NoDerive)); //~ NOTE constant defined here match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); + const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); //~ NOTE constant defined here match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const ARRAY: [OND; 2] = [None, Some(NoDerive)]; + const ARRAY: [OND; 2] = [None, Some(NoDerive)]; //~ NOTE constant defined here match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const REPEAT: [OND; 2] = [Some(NoDerive); 2]; + const REPEAT: [OND; 2] = [Some(NoDerive); 2]; //~ NOTE constant defined here match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - trait Trait: Sized { const ASSOC: Option; } + trait Trait: Sized { const ASSOC: Option; } //~ NOTE constant defined here impl Trait for NoDerive { const ASSOC: Option = Some(NoDerive); } match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const BLOCK: OND = { NoDerive; Some(NoDerive) }; + const BLOCK: OND = { NoDerive; Some(NoDerive) }; //~ NOTE constant defined here match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived //~| NOTE StructuralPartialEq.html for details - const ADDR_OF: &OND = &Some(NoDerive); + const ADDR_OF: &OND = &Some(NoDerive); //~ NOTE constant defined here match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq)]` //~| NOTE the traits must be derived diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr index c068db42e4d9..e8a69512e7ed 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr @@ -1,6 +1,8 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:40:36 | +LL | const ENUM: Derive = Derive::Some(NoDerive); + | ---------------------------- constant defined here LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; | ^^^^ | @@ -10,6 +12,8 @@ LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops" error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:46:28 | +LL | const FIELD: OND = TrivialEq(Some(NoDerive)).0; + | ---------------- constant defined here LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; | ^^^^^ | @@ -19,6 +23,8 @@ LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:53:27 | +LL | const INDIRECT: OND = NO_DERIVE_SOME; + | ------------------- constant defined here LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; | ^^^^^^^^ | @@ -28,6 +34,8 @@ LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops") error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:59:36 | +LL | const TUPLE: (OND, OND) = (None, Some(NoDerive)); + | ----------------------- constant defined here LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; | ^^^^^ | @@ -37,6 +45,8 @@ LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoop error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:65:28 | +LL | const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); + | -------------------------- constant defined here LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; | ^^^^^^^^^^^^^^^ | @@ -46,6 +56,8 @@ LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => p error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:71:36 | +LL | const ARRAY: [OND; 2] = [None, Some(NoDerive)]; + | --------------------- constant defined here LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; | ^^^^^ | @@ -55,6 +67,8 @@ LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoop error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:77:33 | +LL | const REPEAT: [OND; 2] = [Some(NoDerive); 2]; + | ---------------------- constant defined here LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; | ^^^^^^ | @@ -64,6 +78,9 @@ LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:84:28 | +LL | trait Trait: Sized { const ASSOC: Option; } + | ------------------ ------------------------- constant defined here +LL | impl Trait for NoDerive { const ASSOC: Option = Some(NoDerive); } LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; | ^^^^^^^^^^^^^^^ | @@ -73,6 +90,8 @@ LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => p error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:90:28 | +LL | const BLOCK: OND = { NoDerive; Some(NoDerive) }; + | ---------------- constant defined here LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; | ^^^^^ | @@ -82,6 +101,8 @@ LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/reject_non_structural.rs:96:29 | +LL | const ADDR_OF: &OND = &Some(NoDerive); + | ------------------- constant defined here LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; | ^^^^^^^ | diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index 0153f501174b..9f2633a64d59 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -34,18 +34,27 @@ LL | const C: &i32 = unsafe { &S_MUT }; error: could not evaluate constant pattern --> $DIR/const_refs_to_static_fail_invalid.rs:14:9 | +LL | const C: &bool = unsafe { std::mem::transmute(&S) }; + | -------------- constant defined here +... LL | C => {} | ^ error: could not evaluate constant pattern --> $DIR/const_refs_to_static_fail_invalid.rs:30:9 | +LL | const C: &i8 = unsafe { &S }; + | ------------ constant defined here +... LL | C => {} | ^ error: could not evaluate constant pattern --> $DIR/const_refs_to_static_fail_invalid.rs:45:9 | +LL | const C: &i32 = unsafe { &S_MUT }; + | ------------- constant defined here +... LL | C => {} | ^ diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index 856a8f0dab6c..4c59bdd4520e 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -9,6 +9,9 @@ LL | const NUM: u8 = xyz(); error: could not evaluate constant pattern --> $DIR/issue-43105.rs:8:9 | +LL | const NUM: u8 = xyz(); + | ------------- constant defined here +... LL | NUM => unimplemented!(), | ^^^ diff --git a/tests/ui/consts/issue-73976-polymorphic.stderr b/tests/ui/consts/issue-73976-polymorphic.stderr index 8a44eb9854fe..79a03d4ec32c 100644 --- a/tests/ui/consts/issue-73976-polymorphic.stderr +++ b/tests/ui/consts/issue-73976-polymorphic.stderr @@ -1,12 +1,22 @@ error[E0158]: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:20:37 | +LL | impl GetTypeId { + | ----------------------------- +LL | pub const VALUE: TypeId = TypeId::of::(); + | ----------------------- constant defined here +... LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ error[E0158]: constant pattern depends on a generic parameter --> $DIR/issue-73976-polymorphic.rs:31:42 | +LL | impl GetTypeNameLen { + | ---------------------------------- +LL | pub const VALUE: usize = any::type_name::().len(); + | ---------------------- constant defined here +... LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/issue-78655.stderr b/tests/ui/consts/issue-78655.stderr index ccaed03b4c1d..5d684227be8b 100644 --- a/tests/ui/consts/issue-78655.stderr +++ b/tests/ui/consts/issue-78655.stderr @@ -14,6 +14,9 @@ LL | let x = 42; error: could not evaluate constant pattern --> $DIR/issue-78655.rs:7:9 | +LL | const FOO: *const u32 = { + | --------------------- constant defined here +... LL | let FOO = FOO; | ^^^ diff --git a/tests/ui/consts/issue-79137-toogeneric.stderr b/tests/ui/consts/issue-79137-toogeneric.stderr index de81512ec6d2..9b53a2595479 100644 --- a/tests/ui/consts/issue-79137-toogeneric.stderr +++ b/tests/ui/consts/issue-79137-toogeneric.stderr @@ -1,6 +1,11 @@ error[E0158]: constant pattern depends on a generic parameter --> $DIR/issue-79137-toogeneric.rs:12:43 | +LL | impl GetVariantCount { + | -------------------------- +LL | pub const VALUE: usize = std::mem::variant_count::(); + | ---------------------- constant defined here +... LL | matches!(GetVariantCount::::VALUE, GetVariantCount::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/issue-87046.stderr b/tests/ui/consts/issue-87046.stderr index 0f965e1ac3f1..36e2564fae6b 100644 --- a/tests/ui/consts/issue-87046.stderr +++ b/tests/ui/consts/issue-87046.stderr @@ -1,6 +1,9 @@ error: cannot use unsized non-slice type `Username` in constant patterns --> $DIR/issue-87046.rs:28:13 | +LL | pub const ROOT_USER: &Username = Username::from_str("root"); + | ------------------------------ constant defined here +... LL | ROOT_USER => true, | ^^^^^^^^^ diff --git a/tests/ui/consts/issue-89088.stderr b/tests/ui/consts/issue-89088.stderr index 362c63a2a456..740cc25647e5 100644 --- a/tests/ui/consts/issue-89088.stderr +++ b/tests/ui/consts/issue-89088.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` --> $DIR/issue-89088.rs:16:9 | +LL | const FOO: &A = &A::Field(Cow::Borrowed("foo")); + | ------------- constant defined here +... LL | FOO => todo!(), | ^^^ | diff --git a/tests/ui/consts/match_ice.stderr b/tests/ui/consts/match_ice.stderr index 472c24a5cbe3..0841ed050251 100644 --- a/tests/ui/consts/match_ice.stderr +++ b/tests/ui/consts/match_ice.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq)]` --> $DIR/match_ice.rs:11:9 | +LL | const C: &S = &S; + | ----------- constant defined here +LL | match C { LL | C => {} | ^ | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 147d3f238f77..513f456bdf4e 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -40,24 +40,36 @@ LL | match static_cross_crate::OPT_ZERO { error: could not evaluate constant pattern --> $DIR/const_refers_to_static_cross_crate.rs:40:9 | +LL | const SLICE_MUT: &[u8; 1] = { + | ------------------------- constant defined here +... LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern --> $DIR/const_refers_to_static_cross_crate.rs:48:9 | +LL | const U8_MUT: &u8 = { + | ----------------- constant defined here +... LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern --> $DIR/const_refers_to_static_cross_crate.rs:58:9 | +LL | const U8_MUT2: &u8 = { + | ------------------ constant defined here +... LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern --> $DIR/const_refers_to_static_cross_crate.rs:65:9 | +LL | const U8_MUT3: &u8 = { + | ------------------ constant defined here +... LL | U8_MUT3 => true, | ^^^^^^^ diff --git a/tests/ui/consts/missing_assoc_const_type.stderr b/tests/ui/consts/missing_assoc_const_type.stderr index ef7ff962d2d1..8123a43ef74f 100644 --- a/tests/ui/consts/missing_assoc_const_type.stderr +++ b/tests/ui/consts/missing_assoc_const_type.stderr @@ -7,6 +7,11 @@ LL | const FIRST: = 10; error: could not evaluate constant pattern --> $DIR/missing_assoc_const_type.rs:19:9 | +LL | trait Range { + | ----------- +LL | const FIRST: u8; + | --------------- constant defined here +... LL | TwoDigits::FIRST..=TwoDigits::LAST => 0, | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr b/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr index e0d658db9976..79f59ba865d8 100644 --- a/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -12,6 +12,9 @@ error: could not evaluate constant pattern | LL | ZST => {} | ^^^ +... +LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; + | ---------------- constant defined here error: aborting due to 2 previous errors diff --git a/tests/ui/match/issue-70972-dyn-trait.stderr b/tests/ui/match/issue-70972-dyn-trait.stderr index b0af50f8599c..91f49c8a2ff1 100644 --- a/tests/ui/match/issue-70972-dyn-trait.stderr +++ b/tests/ui/match/issue-70972-dyn-trait.stderr @@ -1,6 +1,9 @@ error: `dyn Send` cannot be used in patterns --> $DIR/issue-70972-dyn-trait.rs:6:9 | +LL | const F: &'static dyn Send = &7u32; + | -------------------------- constant defined here +... LL | F => panic!(), | ^ diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index 4155586c1606..eeca541fc3cd 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `EnumSet` in a pattern, the type must implement `PartialEq` --> $DIR/issue-72896-non-partial-eq-const.rs:19:9 | +LL | const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; + | ------------------------------- constant defined here +... LL | CONST_SET => { /* ok */ } | ^^^^^^^^^ diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index adab4e4d241b..65e3b08ac485 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `Vec` in a pattern, `Vec` must be annotated with `#[derive(PartialEq)]` --> $DIR/issue-115599.rs:5:12 | +LL | const CONST_STRING: String = String::new(); + | -------------------------- constant defined here +... LL | if let CONST_STRING = empty_str {} | ^^^^^^^^^^^^ | diff --git a/tests/ui/pattern/issue-72565.stderr b/tests/ui/pattern/issue-72565.stderr index b503a17fe849..abfd4512e9b8 100644 --- a/tests/ui/pattern/issue-72565.stderr +++ b/tests/ui/pattern/issue-72565.stderr @@ -1,6 +1,9 @@ error: `dyn PartialEq` cannot be used in patterns --> $DIR/issue-72565.rs:6:9 | +LL | const F: &'static dyn PartialEq = &7u32; + | ------------------------------------ constant defined here +... LL | F => panic!(), | ^ diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr index 0b4d99727581..bcbcd0bc280d 100644 --- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr +++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]` --> $DIR/const-partial_eq-fallback-ice.rs:14:12 | +LL | const CONSTANT: &&MyType = &&MyType; + | ------------------------ constant defined here +... LL | if let CONSTANT = &&MyType { | ^^^^^^^^ | diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index 32d385eecb47..15aa1769662c 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -1,48 +1,72 @@ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:96:9 | +LL | const QUUX: Quux = quux; + | ---------------- constant defined here +... LL | QUUX => {} | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:97:9 | +LL | const QUUX: Quux = quux; + | ---------------- constant defined here +... LL | QUUX => {} | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:106:9 | +LL | const WRAPQUUX: Wrap = Wrap(quux); + | -------------------------- constant defined here +... LL | WRAPQUUX => {} | ^^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:107:9 | +LL | const WRAPQUUX: Wrap = Wrap(quux); + | -------------------------- constant defined here +... LL | WRAPQUUX => {} | ^^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:113:9 | +LL | const WRAPQUUX: Wrap = Wrap(quux); + | -------------------------- constant defined here +... LL | WRAPQUUX => {} | ^^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:121:9 | +LL | const WRAPQUUX: Wrap = Wrap(quux); + | -------------------------- constant defined here +... LL | WRAPQUUX => {} | ^^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:132:9 | +LL | const WHOKNOWSQUUX: WhoKnows = WhoKnows::Yay(quux); + | ---------------------------------- constant defined here +... LL | WHOKNOWSQUUX => {} | ^^^^^^^^^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/consts-opaque.rs:134:9 | +LL | const WHOKNOWSQUUX: WhoKnows = WhoKnows::Yay(quux); + | ---------------------------------- constant defined here +... LL | WHOKNOWSQUUX => {} | ^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr index cc5d4106331d..dffaafd88a08 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9 | +LL | const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0)); + | ------------------------------------ constant defined here +... LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } | ^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr index 3d00ef2dfbf6..8da9fa71c536 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-direct-struct-param.rs:21:9 | +LL | const WRAP_DIRECT_PARAM: WrapParam = WrapParam(NoDerive(0)); + | -------------------------------------------- constant defined here +... LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } | ^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr index 3636307e16c6..3cd6a184bbe2 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9 | +LL | const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)); + | ------------------------------------------------ constant defined here +... LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr index 40fd31762b2f..35693da99abf 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9 | +LL | const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam = & &WrapParam(& & NoDerive(0)); + | -------------------------------------------------------- constant defined here +... LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr index dbf1848326aa..5312d61c4469 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9 | +LL | const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0)); + | ----------------------------------------- constant defined here +... LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } | ^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr index 58acc11a7449..2066c53e73a6 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` --> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9 | +LL | const WRAP_INDIRECT_PARAM: & &WrapParam = & &WrapParam(NoDerive(0)); + | ------------------------------------------------- constant defined here +... LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } | ^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr index 0bc1e7fc89b5..ee6f44a364da 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr @@ -1,60 +1,90 @@ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:41:14 | +LL | const CFN1: Wrap = Wrap(trivial); + | ---------------------- constant defined here +... LL | Wrap(CFN1) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:49:14 | +LL | const CFN2: Wrap = Wrap(sm_to); + | ------------------------ constant defined here +... LL | Wrap(CFN2) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:57:14 | +LL | const CFN3: Wrap SM> = Wrap(to_sm); + | ---------------------------- constant defined here +... LL | Wrap(CFN3) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:65:14 | +LL | const CFN4: Wrap = Wrap(not_sm_to); + | --------------------------- constant defined here +... LL | Wrap(CFN4) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:73:14 | +LL | const CFN5: Wrap NotSM> = Wrap(to_not_sm); + | ------------------------------- constant defined here +... LL | Wrap(CFN5) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:81:14 | +LL | const CFN6: Wrap = Wrap(r_sm_to); + | ------------------------- constant defined here +... LL | Wrap(CFN6) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:89:14 | +LL | const CFN7: Wrap &SM> = Wrap(r_to_r_sm); + | -------------------------------- constant defined here +... LL | Wrap(CFN7) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:97:14 | +LL | const CFN8: Wrap = Wrap(r_not_sm_to); + | ---------------------------- constant defined here +... LL | Wrap(CFN8) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:105:14 | +LL | const CFN9: Wrap &NotSM> = Wrap(r_to_r_not_sm); + | ----------------------------------- constant defined here +... LL | Wrap(CFN9) => count += 1, | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/fn-ptr-is-not-structurally-matchable.rs:127:9 | +LL | const CFOO: Foo = Foo { + | --------------- constant defined here +... LL | CFOO => count += 1, | ^^^^ diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index 736e4c30c8ae..e105c6a1f98a 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `&[B]` in a pattern, the type must implement `PartialEq` --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | +LL | const A: &[B] = &[]; + | ------------- constant defined here +... LL | A => (), | ^ diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr index e79b05fdf9dc..5cfe6dabc895 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]` --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:29:9 | +LL | const RR_B1: & & B = & & B(1); + | ------------------ constant defined here +... LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } | ^^^^^ | @@ -10,6 +13,9 @@ LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]` --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9 | +LL | const RR_B1: & & B = & & B(1); + | ------------------ constant defined here +... LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } | ^^^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr index 7b1832ed0fa5..be735ccab0a5 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr @@ -1,12 +1,18 @@ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-63479-match-fnptr.rs:32:7 | +LL | const TEST: Fn = my_fn; + | -------------- constant defined here +... LL | B(TEST) => println!("matched"), | ^^^^ error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-63479-match-fnptr.rs:37:5 | +LL | const TEST2: (Fn, u8) = (TEST, 0); + | --------------------- constant defined here +... LL | TEST2 => println!("matched"), | ^^^^^ diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr index 44b05ea31e96..4e2dcb52da80 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr @@ -1,6 +1,9 @@ error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:14:9 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | NAN => {}, | ^^^ | @@ -10,6 +13,9 @@ LL | NAN => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:19:10 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | [NAN, _] => {}, | ^^^ | @@ -19,6 +25,9 @@ LL | [NAN, _] => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:24:9 | +LL | const C: MyType = MyType(f32::NAN); + | -------------------- constant defined here +... LL | C => {}, | ^ | @@ -28,6 +37,9 @@ LL | C => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:30:9 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | NAN..=1.0 => {}, | ^^^ | @@ -37,6 +49,9 @@ LL | NAN..=1.0 => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:31:16 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | -1.0..=NAN => {}, | ^^^ | @@ -46,6 +61,9 @@ LL | -1.0..=NAN => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:32:9 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | NAN.. => {}, | ^^^ | @@ -55,6 +73,9 @@ LL | NAN.. => {}, error: cannot use NaN in patterns --> $DIR/issue-6804-nan-match.rs:33:11 | +LL | const NAN: f64 = f64::NAN; + | -------------- constant defined here +... LL | ..NAN => {}, | ^^^ | diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr index efd9c8c45afa..c471fe572548 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr @@ -1,6 +1,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]` --> $DIR/match-requires-both-partialeq-and-eq.rs:17:9 | +LL | const FOO: Foo = Foo { x: 0 }; + | -------------- constant defined here +... LL | FOO => { } | ^^^ | diff --git a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr index 98d71aa9a17d..743ad75628e2 100644 --- a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr +++ b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr @@ -1,6 +1,9 @@ error: `Bar` cannot be used in patterns --> $DIR/structural-match-no-leak.rs:16:9 | +LL | const LEAK_FREE: bar::Bar = bar::leak_free(); + | ------------------------- constant defined here +... LL | LEAK_FREE => (), | ^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/structural-match.stderr b/tests/ui/type-alias-impl-trait/structural-match.stderr index c7478b0a135e..9c26aa9a9a64 100644 --- a/tests/ui/type-alias-impl-trait/structural-match.stderr +++ b/tests/ui/type-alias-impl-trait/structural-match.stderr @@ -1,6 +1,9 @@ error: `foo::Foo` cannot be used in patterns --> $DIR/structural-match.rs:18:9 | +LL | const VALUE: Foo = value(); + | ---------------- constant defined here +... LL | VALUE => (), | ^^^^^ diff --git a/tests/ui/union/union-const-pat.stderr b/tests/ui/union/union-const-pat.stderr index e9dbb275944a..baf32bf48495 100644 --- a/tests/ui/union/union-const-pat.stderr +++ b/tests/ui/union/union-const-pat.stderr @@ -1,6 +1,9 @@ error: cannot use unions in constant patterns --> $DIR/union-const-pat.rs:10:9 | +LL | const C: U = U { a: 10 }; + | ---------- constant defined here +... LL | C => {} | ^ From cc492edc9d65125a25a42446bbffefb8087dedf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 02:37:56 +0000 Subject: [PATCH 42/59] Tweak unevaluated constant in pattern error Silence errors that are implied by the errors in the `const` item definition. Add a primary span label. --- compiler/rustc_mir_build/messages.ftl | 1 + compiler/rustc_mir_build/src/errors.rs | 1 + .../src/thir/pattern/const_to_pat.rs | 11 +++++- .../ice-type-mismatch-when-copying-112824.rs | 3 +- ...e-type-mismatch-when-copying-112824.stderr | 13 +------ .../const-eval/const-eval-overflow-2.rs | 3 +- .../const-eval/const-eval-overflow-2.stderr | 11 +----- .../const-eval/ref_to_int_match.64bit.stderr | 11 +----- .../ui/consts/const-eval/ref_to_int_match.rs | 2 +- .../const_refs_to_static_fail_invalid.rs | 6 +-- .../const_refs_to_static_fail_invalid.stderr | 29 +------------- .../invalid-inline-const-in-match-arm.stderr | 2 +- tests/ui/consts/issue-43105.rs | 3 +- tests/ui/consts/issue-43105.stderr | 11 +----- tests/ui/consts/issue-78655.rs | 3 +- tests/ui/consts/issue-78655.stderr | 11 +----- .../const_refers_to_static_cross_crate.rs | 12 ++---- .../const_refers_to_static_cross_crate.stderr | 38 +------------------ tests/ui/consts/missing_assoc_const_type.rs | 5 +-- .../ui/consts/missing_assoc_const_type.stderr | 13 +------ .../transmute-size-mismatch-before-typeck.rs | 2 +- ...ansmute-size-mismatch-before-typeck.stderr | 11 +----- 22 files changed, 37 insertions(+), 165 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index fdefc0bfd190..ad2f13f6d21a 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -92,6 +92,7 @@ mir_build_const_pattern_depends_on_generic_parameter = constant pattern depends on a generic parameter mir_build_could_not_eval_const_pattern = could not evaluate constant pattern + .label = could not evaluate constant mir_build_deref_raw_pointer_requires_unsafe = dereference of raw pointer is unsafe and requires unsafe block diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 58487a48184a..226c469b7d78 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -702,6 +702,7 @@ pub(crate) struct ConstPatternDependsOnGenericParameter { #[diag(mir_build_could_not_eval_const_pattern)] pub(crate) struct CouldNotEvalConstPattern { #[primary_span] + #[label] pub(crate) span: Span, } diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index aa98874654ed..3690459bf515 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -122,7 +122,16 @@ impl<'tcx> ConstToPat<'tcx> { Ok(Ok(c)) => c, Err(ErrorHandled::Reported(_, _)) => { // Let's tell the use where this failing const occurs. - let err = self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span }); + let mut err = + self.tcx.dcx().create_err(CouldNotEvalConstPattern { span: self.span }); + // We've emitted an error on the original const, it would be redundant to complain + // on its use as well. + if let ty::ConstKind::Unevaluated(uv) = self.c.kind() + && let hir::def::DefKind::Const | hir::def::DefKind::AssocConst = + self.tcx.def_kind(uv.def) + { + err.downgrade_to_delayed_bug(); + } return self.mk_err(err, ty); } Err(ErrorHandled::TooGeneric(_)) => { diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs index 09f7e2ba5b1d..270496d45a6b 100644 --- a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs +++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs @@ -12,8 +12,7 @@ impl Opcode2 { pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) { move |i| match msg_type { - Opcode2::OP2 => unimplemented!(), - //~^ ERROR: could not evaluate constant pattern + Opcode2::OP2 => unimplemented!(), // ok, `const` already emitted an error } } diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr index 9cce6fee55ac..d95a8861230e 100644 --- a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr +++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr @@ -17,18 +17,7 @@ help: you might be missing a type parameter LL | pub struct Opcode2(&'a S); | +++ -error: could not evaluate constant pattern - --> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9 - | -LL | impl Opcode2 { - | ------------ -LL | pub const OP2: Opcode2 = Opcode2(Opcode(0x1)); - | ---------------------- constant defined here -... -LL | Opcode2::OP2 => unimplemented!(), - | ^^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0261, E0412. For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.rs b/tests/ui/consts/const-eval/const-eval-overflow-2.rs index c19a0c443ec5..bae8a7ce243e 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.rs @@ -12,8 +12,7 @@ const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant fn main() { match -128i8 { - NEG_NEG_128 => println!("A"), - //~^ ERROR could not evaluate constant pattern + NEG_NEG_128 => println!("A"), // ok, `const` error already emitted _ => println!("B"), } } diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index 66c54af4f83f..5599ff931e8e 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -4,15 +4,6 @@ error[E0080]: evaluation of constant value failed LL | const NEG_NEG_128: i8 = -NEG_128; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow -error: could not evaluate constant pattern - --> $DIR/const-eval-overflow-2.rs:15:9 - | -LL | const NEG_NEG_128: i8 = -NEG_128; - | --------------------- constant defined here -... -LL | NEG_NEG_128 => println!("A"), - | ^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index b1c6cfd3246e..18935626af1c 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -7,15 +7,6 @@ LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: could not evaluate constant pattern - --> $DIR/ref_to_int_match.rs:7:14 - | -LL | 10..=BAR => {}, - | ^^^ -... -LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; - | -------------- constant defined here - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ref_to_int_match.rs b/tests/ui/consts/const-eval/ref_to_int_match.rs index c627ad97bb05..be9420e0215d 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.rs +++ b/tests/ui/consts/const-eval/ref_to_int_match.rs @@ -4,7 +4,7 @@ fn main() { let n: Int = 40; match n { 0..=10 => {}, - 10..=BAR => {}, //~ ERROR could not evaluate constant pattern + 10..=BAR => {}, // ok, `const` error already emitted _ => {}, } } diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs index a160862a0fa6..aa101cf9d8a6 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -11,7 +11,7 @@ fn invalid() { // This must be rejected here (or earlier), since it's not a valid `&bool`. match &true { - C => {} //~ERROR: could not evaluate constant pattern + C => {} // ok, `const` already emitted an error _ => {} } } @@ -27,7 +27,7 @@ fn extern_() { // This must be rejected here (or earlier), since the pattern cannot be read. match &0 { - C => {} //~ERROR: could not evaluate constant pattern + C => {} // ok, `const` already emitted an error _ => {} } } @@ -42,7 +42,7 @@ fn mutable() { // This *must not build*, the constant we are matching against // could change its value! match &42 { - C => {} //~ERROR: could not evaluate constant pattern + C => {} // ok, `const` already emitted an error _ => {} } } diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index 9f2633a64d59..c9d5cb60bf77 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -31,33 +31,6 @@ LL | const C: &i32 = unsafe { &S_MUT }; HEX_DUMP } -error: could not evaluate constant pattern - --> $DIR/const_refs_to_static_fail_invalid.rs:14:9 - | -LL | const C: &bool = unsafe { std::mem::transmute(&S) }; - | -------------- constant defined here -... -LL | C => {} - | ^ - -error: could not evaluate constant pattern - --> $DIR/const_refs_to_static_fail_invalid.rs:30:9 - | -LL | const C: &i8 = unsafe { &S }; - | ------------ constant defined here -... -LL | C => {} - | ^ - -error: could not evaluate constant pattern - --> $DIR/const_refs_to_static_fail_invalid.rs:45:9 - | -LL | const C: &i32 = unsafe { &S_MUT }; - | ------------- constant defined here -... -LL | C => {} - | ^ - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr index 2e48837bdcdc..b22f99f40d35 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr @@ -11,7 +11,7 @@ error: could not evaluate constant pattern --> $DIR/invalid-inline-const-in-match-arm.rs:5:9 | LL | const { (|| {})() } => {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ could not evaluate constant error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-43105.rs b/tests/ui/consts/issue-43105.rs index 20b78d64209e..a4ee34c0532f 100644 --- a/tests/ui/consts/issue-43105.rs +++ b/tests/ui/consts/issue-43105.rs @@ -5,8 +5,7 @@ const NUM: u8 = xyz(); fn main() { match 1 { - NUM => unimplemented!(), - //~^ ERROR could not evaluate constant pattern + NUM => unimplemented!(), // ok, the `const` already emitted an error _ => unimplemented!(), } } diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index 4c59bdd4520e..0e08feb58de9 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -6,15 +6,6 @@ LL | const NUM: u8 = xyz(); | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: could not evaluate constant pattern - --> $DIR/issue-43105.rs:8:9 - | -LL | const NUM: u8 = xyz(); - | ------------- constant defined here -... -LL | NUM => unimplemented!(), - | ^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-78655.rs b/tests/ui/consts/issue-78655.rs index cd95ee32c60d..b0f862e84181 100644 --- a/tests/ui/consts/issue-78655.rs +++ b/tests/ui/consts/issue-78655.rs @@ -4,6 +4,5 @@ const FOO: *const u32 = { }; fn main() { - let FOO = FOO; - //~^ ERROR could not evaluate constant pattern + let FOO = FOO; // ok, the `const` already emitted an error } diff --git a/tests/ui/consts/issue-78655.stderr b/tests/ui/consts/issue-78655.stderr index 5d684227be8b..6a93c1a8cec9 100644 --- a/tests/ui/consts/issue-78655.stderr +++ b/tests/ui/consts/issue-78655.stderr @@ -11,15 +11,6 @@ help: consider assigning a value LL | let x = 42; | ++++ -error: could not evaluate constant pattern - --> $DIR/issue-78655.rs:7:9 - | -LL | const FOO: *const u32 = { - | --------------------- constant defined here -... -LL | let FOO = FOO; - | ^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0381`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index a6d75658c758..facb21a04ef0 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -37,16 +37,14 @@ const U8_MUT3: &u8 = { pub fn test(x: &[u8; 1]) -> bool { match x { - SLICE_MUT => true, - //~^ ERROR could not evaluate constant pattern + SLICE_MUT => true, // ok, `const` error already emitted &[1..] => false, } } pub fn test2(x: &u8) -> bool { match x { - U8_MUT => true, - //~^ ERROR could not evaluate constant pattern + U8_MUT => true, // ok, `const` error already emitted &(1..) => false, } } @@ -55,15 +53,13 @@ pub fn test2(x: &u8) -> bool { // the errors above otherwise stop compilation too early? pub fn test3(x: &u8) -> bool { match x { - U8_MUT2 => true, - //~^ ERROR could not evaluate constant pattern + U8_MUT2 => true, // ok, `const` error already emitted &(1..) => false, } } pub fn test4(x: &u8) -> bool { match x { - U8_MUT3 => true, - //~^ ERROR could not evaluate constant pattern + U8_MUT3 => true, // ok, `const` error already emitted &(1..) => false, } } diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 513f456bdf4e..8f8271cce38e 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -37,42 +37,6 @@ error[E0080]: evaluation of constant value failed LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 - | -LL | const SLICE_MUT: &[u8; 1] = { - | ------------------------- constant defined here -... -LL | SLICE_MUT => true, - | ^^^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:48:9 - | -LL | const U8_MUT: &u8 = { - | ----------------- constant defined here -... -LL | U8_MUT => true, - | ^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:58:9 - | -LL | const U8_MUT2: &u8 = { - | ------------------ constant defined here -... -LL | U8_MUT2 => true, - | ^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:65:9 - | -LL | const U8_MUT3: &u8 = { - | ------------------ constant defined here -... -LL | U8_MUT3 => true, - | ^^^^^^^ - -error: aborting due to 8 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/missing_assoc_const_type.rs b/tests/ui/consts/missing_assoc_const_type.rs index 633998e9bc15..61042bfa96d0 100644 --- a/tests/ui/consts/missing_assoc_const_type.rs +++ b/tests/ui/consts/missing_assoc_const_type.rs @@ -9,14 +9,13 @@ trait Range { struct TwoDigits; impl Range for TwoDigits { - const FIRST: = 10; - //~^ ERROR: missing type for `const` item + const FIRST: = 10; //~ ERROR missing type for `const` item const LAST: u8 = 99; } const fn digits(x: u8) -> usize { match x { - TwoDigits::FIRST..=TwoDigits::LAST => 0, //~ ERROR: could not evaluate constant pattern + TwoDigits::FIRST..=TwoDigits::LAST => 0, // ok, `const` error already emitted 0..=9 | 100..=255 => panic!(), } } diff --git a/tests/ui/consts/missing_assoc_const_type.stderr b/tests/ui/consts/missing_assoc_const_type.stderr index 8123a43ef74f..28af1f0f321e 100644 --- a/tests/ui/consts/missing_assoc_const_type.stderr +++ b/tests/ui/consts/missing_assoc_const_type.stderr @@ -4,16 +4,5 @@ error: missing type for `const` item LL | const FIRST: = 10; | ^ help: provide a type for the associated constant: `u8` -error: could not evaluate constant pattern - --> $DIR/missing_assoc_const_type.rs:19:9 - | -LL | trait Range { - | ----------- -LL | const FIRST: u8; - | --------------- constant defined here -... -LL | TwoDigits::FIRST..=TwoDigits::LAST => 0, - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/consts/transmute-size-mismatch-before-typeck.rs b/tests/ui/consts/transmute-size-mismatch-before-typeck.rs index 44eac5b16cc0..ffb143da2d48 100644 --- a/tests/ui/consts/transmute-size-mismatch-before-typeck.rs +++ b/tests/ui/consts/transmute-size-mismatch-before-typeck.rs @@ -5,7 +5,7 @@ fn main() { match &b""[..] { - ZST => {} //~ ERROR: could not evaluate constant pattern + ZST => {} // ok, `const` error already emitted } } diff --git a/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr b/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr index 79f59ba865d8..6bc7e7203aa7 100644 --- a/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/tests/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -7,15 +7,6 @@ LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; = note: source type: `usize` (word size) = note: target type: `&[u8]` (2 * word size) -error: could not evaluate constant pattern - --> $DIR/transmute-size-mismatch-before-typeck.rs:8:9 - | -LL | ZST => {} - | ^^^ -... -LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; - | ---------------- constant defined here - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0512`. From c0f00086f85ae1fff34dd2daf6a11850e5bfc2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 03:00:58 +0000 Subject: [PATCH 43/59] Tweak ptr in pattern error Conform to error style guide. --- compiler/rustc_mir_build/messages.ftl | 4 +- compiler/rustc_mir_build/src/errors.rs | 2 + src/tools/tidy/src/fluent_period.rs | 1 - ...ssue-34784-match-on-non-int-raw-ptr.stderr | 24 +++++--- .../const_in_pattern/issue-44333.stderr | 12 ++-- .../pattern/usefulness/consts-opaque.stderr | 48 ++++++++++----- ...n-ptr-is-not-structurally-matchable.stderr | 60 ++++++++++++------- .../issue-63479-match-fnptr.stderr | 12 ++-- 8 files changed, 109 insertions(+), 54 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index ad2f13f6d21a..2bf49137e8f8 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -274,7 +274,9 @@ mir_build_non_partial_eq_match = mir_build_pattern_not_covered = refutable pattern in {$origin} .pattern_ty = the matched value is of type `{$pattern_ty}` -mir_build_pointer_pattern = function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +mir_build_pointer_pattern = function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon + .label = can't be used in patterns + .note = see https://github.com/rust-lang/rust/issues/70861 for details mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 226c469b7d78..7f4bb139fad2 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -916,8 +916,10 @@ pub(crate) struct NaNPattern { #[derive(Diagnostic)] #[diag(mir_build_pointer_pattern)] +#[note] pub(crate) struct PointerPattern { #[primary_span] + #[label] pub(crate) span: Span, } diff --git a/src/tools/tidy/src/fluent_period.rs b/src/tools/tidy/src/fluent_period.rs index 8bc404dc8581..6a136e5aec69 100644 --- a/src/tools/tidy/src/fluent_period.rs +++ b/src/tools/tidy/src/fluent_period.rs @@ -18,7 +18,6 @@ const ALLOWLIST: &[&str] = &[ "const_eval_validation_failure_note", "driver_impl_ice", "incremental_corrupt_file", - "mir_build_pointer_pattern", ]; fn check_period(filename: &str, contents: &str, bad: &mut bool) { diff --git a/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr b/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr index cc7ec771e6cd..0453a88e43db 100644 --- a/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr +++ b/tests/ui/consts/const_in_pattern/issue-34784-match-on-non-int-raw-ptr.stderr @@ -1,38 +1,46 @@ -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:9:9 | LL | const C: *const u8 = &0; | ------------------ constant defined here ... LL | C => {} - | ^ + | ^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:16:9 | LL | const C_INNER: (*const u8, u8) = (C, 0); | ------------------------------ constant defined here ... LL | C_INNER => {} - | ^^^^^^^ + | ^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:27:9 | LL | const D: *const [u8; 4] = b"abcd"; | ----------------------- constant defined here ... LL | D => {} - | ^ + | ^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:32:9 | LL | const STR: *const str = "abcd"; | --------------------- constant defined here ... LL | STR => {} - | ^^^ + | ^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const_in_pattern/issue-44333.stderr b/tests/ui/consts/const_in_pattern/issue-44333.stderr index 81393952f0fc..61b45377c761 100644 --- a/tests/ui/consts/const_in_pattern/issue-44333.stderr +++ b/tests/ui/consts/const_in_pattern/issue-44333.stderr @@ -1,20 +1,24 @@ -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-44333.rs:15:9 | LL | const FOO: Func = foo; | --------------- constant defined here ... LL | FOO => println!("foo"), - | ^^^ + | ^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-44333.rs:16:9 | LL | const BAR: Func = bar; | --------------- constant defined here ... LL | BAR => println!("bar"), - | ^^^ + | ^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index 15aa1769662c..d52451d9438a 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -1,74 +1,90 @@ -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:96:9 | LL | const QUUX: Quux = quux; | ---------------- constant defined here ... LL | QUUX => {} - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:97:9 | LL | const QUUX: Quux = quux; | ---------------- constant defined here ... LL | QUUX => {} - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:106:9 | LL | const WRAPQUUX: Wrap = Wrap(quux); | -------------------------- constant defined here ... LL | WRAPQUUX => {} - | ^^^^^^^^ + | ^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:107:9 | LL | const WRAPQUUX: Wrap = Wrap(quux); | -------------------------- constant defined here ... LL | WRAPQUUX => {} - | ^^^^^^^^ + | ^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:113:9 | LL | const WRAPQUUX: Wrap = Wrap(quux); | -------------------------- constant defined here ... LL | WRAPQUUX => {} - | ^^^^^^^^ + | ^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:121:9 | LL | const WRAPQUUX: Wrap = Wrap(quux); | -------------------------- constant defined here ... LL | WRAPQUUX => {} - | ^^^^^^^^ + | ^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:132:9 | LL | const WHOKNOWSQUUX: WhoKnows = WhoKnows::Yay(quux); | ---------------------------------- constant defined here ... LL | WHOKNOWSQUUX => {} - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/consts-opaque.rs:134:9 | LL | const WHOKNOWSQUUX: WhoKnows = WhoKnows::Yay(quux); | ---------------------------------- constant defined here ... LL | WHOKNOWSQUUX => {} - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details error: unreachable pattern --> $DIR/consts-opaque.rs:48:9 diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr index ee6f44a364da..cdbe72ca48f8 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-not-structurally-matchable.stderr @@ -1,92 +1,112 @@ -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:41:14 | LL | const CFN1: Wrap = Wrap(trivial); | ---------------------- constant defined here ... LL | Wrap(CFN1) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:49:14 | LL | const CFN2: Wrap = Wrap(sm_to); | ------------------------ constant defined here ... LL | Wrap(CFN2) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:57:14 | LL | const CFN3: Wrap SM> = Wrap(to_sm); | ---------------------------- constant defined here ... LL | Wrap(CFN3) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:65:14 | LL | const CFN4: Wrap = Wrap(not_sm_to); | --------------------------- constant defined here ... LL | Wrap(CFN4) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:73:14 | LL | const CFN5: Wrap NotSM> = Wrap(to_not_sm); | ------------------------------- constant defined here ... LL | Wrap(CFN5) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:81:14 | LL | const CFN6: Wrap = Wrap(r_sm_to); | ------------------------- constant defined here ... LL | Wrap(CFN6) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:89:14 | LL | const CFN7: Wrap &SM> = Wrap(r_to_r_sm); | -------------------------------- constant defined here ... LL | Wrap(CFN7) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:97:14 | LL | const CFN8: Wrap = Wrap(r_not_sm_to); | ---------------------------- constant defined here ... LL | Wrap(CFN8) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:105:14 | LL | const CFN9: Wrap &NotSM> = Wrap(r_to_r_not_sm); | ----------------------------------- constant defined here ... LL | Wrap(CFN9) => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/fn-ptr-is-not-structurally-matchable.rs:127:9 | LL | const CFOO: Foo = Foo { | --------------- constant defined here ... LL | CFOO => count += 1, - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details error: aborting due to 10 previous errors diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr index be735ccab0a5..ea6121839be5 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr @@ -1,20 +1,24 @@ -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-63479-match-fnptr.rs:32:7 | LL | const TEST: Fn = my_fn; | -------------- constant defined here ... LL | B(TEST) => println!("matched"), - | ^^^^ + | ^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details -error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. +error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon --> $DIR/issue-63479-match-fnptr.rs:37:5 | LL | const TEST2: (Fn, u8) = (TEST, 0); | --------------------- constant defined here ... LL | TEST2 => println!("matched"), - | ^^^^^ + | ^^^^^ can't be used in patterns + | + = note: see https://github.com/rust-lang/rust/issues/70861 for details error: aborting due to 2 previous errors From 87ddc1ea33edbe1be119d73e57c2783940e797fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 03:08:52 +0000 Subject: [PATCH 44/59] Point at generic param through which a const is used in a pattern ``` error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { | ------------- LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test(arg: EFoo) { | - constant depends on this generic param LL | match arg { LL | A::X => println!("A::X"), | ^^^^ `const` depends on a generic parameter ``` --- compiler/rustc_mir_build/messages.ftl | 4 +-- compiler/rustc_mir_build/src/errors.rs | 1 + .../src/thir/pattern/const_to_pat.rs | 22 ++++++++++++++- ...ciated-const-type-parameter-pattern.stderr | 27 +++++++++++++------ .../ui/consts/issue-73976-polymorphic.stderr | 12 ++++++--- tests/ui/consts/issue-79137-toogeneric.stderr | 6 +++-- .../const-match-pat-generic.stderr | 8 +++--- 7 files changed, 59 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 2bf49137e8f8..4bc7dcf95646 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -88,8 +88,8 @@ mir_build_const_defined_here = constant defined here mir_build_const_param_in_pattern = const parameters cannot be referenced in patterns -mir_build_const_pattern_depends_on_generic_parameter = - constant pattern depends on a generic parameter +mir_build_const_pattern_depends_on_generic_parameter = constant pattern depends on a generic parameter, which is not allowed + .label = `const` depends on a generic parameter mir_build_could_not_eval_const_pattern = could not evaluate constant pattern .label = could not evaluate constant diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 7f4bb139fad2..1068c56eeca6 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -695,6 +695,7 @@ pub(crate) struct WantedConstant { #[diag(mir_build_const_pattern_depends_on_generic_parameter, code = E0158)] pub(crate) struct ConstPatternDependsOnGenericParameter { #[primary_span] + #[label] pub(crate) span: Span, } diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 3690459bf515..b625c655fac4 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -53,6 +53,7 @@ struct ConstToPat<'tcx> { tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, span: Span, + id: hir::HirId, treat_byte_string_as_slice: bool, @@ -66,6 +67,7 @@ impl<'tcx> ConstToPat<'tcx> { tcx: pat_ctxt.tcx, typing_env: pat_ctxt.typing_env, span, + id, treat_byte_string_as_slice: pat_ctxt .typeck_results .treat_byte_string_as_slice @@ -135,10 +137,28 @@ impl<'tcx> ConstToPat<'tcx> { return self.mk_err(err, ty); } Err(ErrorHandled::TooGeneric(_)) => { - let e = self + let mut e = self .tcx .dcx() .create_err(ConstPatternDependsOnGenericParameter { span: self.span }); + for arg in uv.args { + if let ty::GenericArgKind::Type(ty) = arg.unpack() + && let ty::Param(param_ty) = ty.kind() + { + let def_id = self.tcx.hir().enclosing_body_owner(self.id); + let generics = self.tcx.generics_of(def_id); + let param = generics.type_param(*param_ty, self.tcx); + let span = self.tcx.def_span(param.def_id); + e.span_label(span, "constant depends on this generic param"); + if let Some(ident) = self.tcx.def_ident_span(def_id) + && self.tcx.sess.source_map().is_multiline(ident.between(span)) + { + // Display the `fn` name as well in the diagnostic, as the generic isn't + // in the same line and it could be confusing otherwise. + e.span_label(ident, ""); + } + } + } return self.mk_err(e, ty); } Ok(Err(bad_ty)) => { diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr index 5aef0fa414bd..455831e8401c 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { @@ -6,10 +6,13 @@ LL | pub trait Foo { LL | const X: EFoo; | ------------- constant defined here ... +LL | pub fn test(arg: EFoo) { + | - constant depends on this generic param +LL | match arg { LL | A::X => println!("A::X"), - | ^^^^ + | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/associated-const-type-parameter-pattern.rs:22:9 | LL | pub trait Foo { @@ -17,10 +20,13 @@ LL | pub trait Foo { LL | const X: EFoo; | ------------- constant defined here ... +LL | pub fn test(arg: EFoo) { + | - constant depends on this generic param +... LL | B::X => println!("B::X"), - | ^^^^ + | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/associated-const-type-parameter-pattern.rs:30:9 | LL | pub trait Foo { @@ -28,10 +34,13 @@ LL | pub trait Foo { LL | const X: EFoo; | ------------- constant defined here ... +LL | pub fn test_let_pat(arg: EFoo, A::X: EFoo) { + | - constant depends on this generic param +LL | LL | let A::X = arg; - | ^^^^ + | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/associated-const-type-parameter-pattern.rs:28:48 | LL | pub trait Foo { @@ -40,7 +49,9 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test_let_pat(arg: EFoo, A::X: EFoo) { - | ^^^^ + | - ^^^^ `const` depends on a generic parameter + | | + | constant depends on this generic param error: aborting due to 4 previous errors diff --git a/tests/ui/consts/issue-73976-polymorphic.stderr b/tests/ui/consts/issue-73976-polymorphic.stderr index 79a03d4ec32c..2f50e6ac2fd4 100644 --- a/tests/ui/consts/issue-73976-polymorphic.stderr +++ b/tests/ui/consts/issue-73976-polymorphic.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/issue-73976-polymorphic.rs:20:37 | LL | impl GetTypeId { @@ -6,10 +6,12 @@ LL | impl GetTypeId { LL | pub const VALUE: TypeId = TypeId::of::(); | ----------------------- constant defined here ... +LL | const fn check_type_id() -> bool { + | - constant depends on this generic param LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | impl GetTypeNameLen { @@ -17,8 +19,10 @@ LL | impl GetTypeNameLen { LL | pub const VALUE: usize = any::type_name::().len(); | ---------------------- constant defined here ... +LL | const fn check_type_name_len() -> bool { + | - constant depends on this generic param LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-79137-toogeneric.stderr b/tests/ui/consts/issue-79137-toogeneric.stderr index 9b53a2595479..d36f3ecbb769 100644 --- a/tests/ui/consts/issue-79137-toogeneric.stderr +++ b/tests/ui/consts/issue-79137-toogeneric.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/issue-79137-toogeneric.rs:12:43 | LL | impl GetVariantCount { @@ -6,8 +6,10 @@ LL | impl GetVariantCount { LL | pub const VALUE: usize = std::mem::variant_count::(); | ---------------------- constant defined here ... +LL | const fn check_variant_count() -> bool { + | - constant depends on this generic param LL | matches!(GetVariantCount::::VALUE, GetVariantCount::::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter error: aborting due to 1 previous error diff --git a/tests/ui/inline-const/const-match-pat-generic.stderr b/tests/ui/inline-const/const-match-pat-generic.stderr index 26f72b34eca2..cf48161b5e3d 100644 --- a/tests/ui/inline-const/const-match-pat-generic.stderr +++ b/tests/ui/inline-const/const-match-pat-generic.stderr @@ -1,14 +1,14 @@ -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/const-match-pat-generic.rs:7:9 | LL | const { V } => {}, - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter +error[E0158]: constant pattern depends on a generic parameter, which is not allowed --> $DIR/const-match-pat-generic.rs:19:9 | LL | const { f(V) } => {}, - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ `const` depends on a generic parameter error: aborting due to 2 previous errors From 253eb95d4582e1abffc4a74dd8eaccd5b94b5d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 03:57:30 +0000 Subject: [PATCH 45/59] Tweak output of some const pattern errors - Add primary span labels. - Point at const generic parameter used as pattern. - Point at statics used as pattern. - Point at let bindings used in const pattern. --- compiler/rustc_mir_build/messages.ftl | 10 +++++++++- compiler/rustc_mir_build/src/errors.rs | 10 ++++++++++ compiler/rustc_mir_build/src/thir/pattern/mod.rs | 14 ++++++++++---- tests/ui/binding/const-param.rs | 2 +- tests/ui/binding/const-param.stderr | 7 +++++-- .../ui/consts/const_in_pattern/issue-65466.stderr | 2 +- .../const_in_pattern/reject_non_partial_eq.stderr | 2 +- .../match/issue-72896-non-partial-eq-const.stderr | 2 +- tests/ui/pattern/non-constant-in-const-path.stderr | 14 ++++++++++---- ...e-61188-match-slice-forbidden-without-eq.stderr | 2 +- .../issue-6804-nan-match.stderr | 14 +++++++------- tests/ui/union/union-const-pat.stderr | 2 +- 12 files changed, 57 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 4bc7dcf95646..28011833e586 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -86,7 +86,9 @@ mir_build_confused = missing patterns are not covered because `{$variable}` is i mir_build_const_defined_here = constant defined here -mir_build_const_param_in_pattern = const parameters cannot be referenced in patterns +mir_build_const_param_in_pattern = constant parameters cannot be referenced in patterns + .label = can't be used in patterns +mir_build_const_param_in_pattern_def = constant defined here mir_build_const_pattern_depends_on_generic_parameter = constant pattern depends on a generic parameter, which is not allowed .label = `const` depends on a generic parameter @@ -247,10 +249,12 @@ mir_build_mutation_of_layout_constrained_field_requires_unsafe_unsafe_op_in_unsa .label = mutation of layout constrained field mir_build_nan_pattern = cannot use NaN in patterns + .label = evaluates to `NaN`, which is not allowed in patterns .note = NaNs compare inequal to everything, even themselves, so this pattern would never match .help = try using the `is_nan` method instead mir_build_non_const_path = runtime values cannot be referenced in patterns + .label = references a runtime value mir_build_non_empty_never_pattern = mismatched types @@ -270,6 +274,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type mir_build_non_partial_eq_match = to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq` + .label = constant of non-structural type mir_build_pattern_not_covered = refutable pattern in {$origin} .pattern_ty = the matched value is of type `{$pattern_ty}` @@ -288,6 +293,8 @@ mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly .missing_box = `#[rustc_box]` requires the `owned_box` lang item mir_build_static_in_pattern = statics cannot be referenced in patterns + .label = can't be used in patterns +mir_build_static_in_pattern_def = `static` defined here mir_build_suggest_attempted_int_lit = alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits @@ -339,6 +346,7 @@ mir_build_union_field_requires_unsafe_unsafe_op_in_unsafe_fn_allowed = .label = access to union field mir_build_union_pattern = cannot use unions in constant patterns + .label = can't use a `union` here mir_build_unreachable_making_this_unreachable = collectively making this unreachable diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 1068c56eeca6..1c4de5c07a13 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -631,20 +631,27 @@ pub(crate) struct NonExhaustiveMatchAllArmsGuarded; #[diag(mir_build_static_in_pattern, code = E0158)] pub(crate) struct StaticInPattern { #[primary_span] + #[label] pub(crate) span: Span, + #[label(mir_build_static_in_pattern_def)] + pub(crate) static_span: Span, } #[derive(Diagnostic)] #[diag(mir_build_const_param_in_pattern, code = E0158)] pub(crate) struct ConstParamInPattern { #[primary_span] + #[label] pub(crate) span: Span, + #[label(mir_build_const_param_in_pattern_def)] + pub(crate) const_span: Span, } #[derive(Diagnostic)] #[diag(mir_build_non_const_path, code = E0080)] pub(crate) struct NonConstPath { #[primary_span] + #[label] pub(crate) span: Span, } @@ -869,6 +876,7 @@ pub(crate) enum Conflict { #[diag(mir_build_union_pattern)] pub(crate) struct UnionPattern { #[primary_span] + #[label] pub(crate) span: Span, } @@ -886,6 +894,7 @@ pub(crate) struct TypeNotStructural<'tcx> { #[diag(mir_build_non_partial_eq_match)] pub(crate) struct TypeNotPartialEq<'tcx> { #[primary_span] + #[label] pub(crate) span: Span, pub(crate) non_peq_ty: Ty<'tcx>, } @@ -912,6 +921,7 @@ pub(crate) struct UnsizedPattern<'tcx> { #[help] pub(crate) struct NaNPattern { #[primary_span] + #[label] pub(crate) span: Span, } diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 08c6b4abd3b9..3ac53fa6272b 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -528,11 +528,17 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { | Res::SelfCtor(..) => PatKind::Leaf { subpatterns }, _ => { let e = match res { - Res::Def(DefKind::ConstParam, _) => { - self.tcx.dcx().emit_err(ConstParamInPattern { span }) + Res::Def(DefKind::ConstParam, def_id) => { + self.tcx.dcx().emit_err(ConstParamInPattern { + span, + const_span: self.tcx().def_span(def_id), + }) } - Res::Def(DefKind::Static { .. }, _) => { - self.tcx.dcx().emit_err(StaticInPattern { span }) + Res::Def(DefKind::Static { .. }, def_id) => { + self.tcx.dcx().emit_err(StaticInPattern { + span, + static_span: self.tcx().def_span(def_id), + }) } _ => self.tcx.dcx().emit_err(NonConstPath { span }), }; diff --git a/tests/ui/binding/const-param.rs b/tests/ui/binding/const-param.rs index 2d051808fe0b..98bc90f508ab 100644 --- a/tests/ui/binding/const-param.rs +++ b/tests/ui/binding/const-param.rs @@ -2,7 +2,7 @@ fn check() { match 1 { - N => {} //~ ERROR const parameters cannot be referenced in patterns + N => {} //~ ERROR constant parameters cannot be referenced in patterns _ => {} } } diff --git a/tests/ui/binding/const-param.stderr b/tests/ui/binding/const-param.stderr index e68893a59e49..b0b8108945c9 100644 --- a/tests/ui/binding/const-param.stderr +++ b/tests/ui/binding/const-param.stderr @@ -1,8 +1,11 @@ -error[E0158]: const parameters cannot be referenced in patterns +error[E0158]: constant parameters cannot be referenced in patterns --> $DIR/const-param.rs:5:9 | +LL | fn check() { + | -------------- constant defined here +LL | match 1 { LL | N => {} - | ^ + | ^ can't be used in patterns error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index 070ce384f6aa..90bac6262cc9 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -5,7 +5,7 @@ LL | const C: &[O] = &[O::None]; | ---------------- constant defined here ... LL | C => (), - | ^ + | ^ constant of non-structural type error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index 463b37e7caa7..d4952a8bfb8c 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -5,7 +5,7 @@ LL | const NO_PARTIAL_EQ_NONE: Option = None; | --------------------------------------------- constant defined here ... LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ constant of non-structural type error: aborting due to 1 previous error diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index eeca541fc3cd..d6ae9e56377d 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -5,7 +5,7 @@ LL | const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; | ------------------------------- constant defined here ... LL | CONST_SET => { /* ok */ } - | ^^^^^^^^^ + | ^^^^^^^^^ constant of non-structural type error: aborting due to 1 previous error diff --git a/tests/ui/pattern/non-constant-in-const-path.stderr b/tests/ui/pattern/non-constant-in-const-path.stderr index 53c3974f780e..2ba4963e6dc2 100644 --- a/tests/ui/pattern/non-constant-in-const-path.stderr +++ b/tests/ui/pattern/non-constant-in-const-path.stderr @@ -2,25 +2,31 @@ error[E0080]: runtime values cannot be referenced in patterns --> $DIR/non-constant-in-const-path.rs:8:15 | LL | let 0u8..=x = 0; - | ^ + | ^ references a runtime value error[E0158]: statics cannot be referenced in patterns --> $DIR/non-constant-in-const-path.rs:10:15 | +LL | static FOO: u8 = 10; + | -------------- `static` defined here +... LL | let 0u8..=FOO = 0; - | ^^^ + | ^^^ can't be used in patterns error[E0080]: runtime values cannot be referenced in patterns --> $DIR/non-constant-in-const-path.rs:13:15 | LL | 0 ..= x => {} - | ^ + | ^ references a runtime value error[E0158]: statics cannot be referenced in patterns --> $DIR/non-constant-in-const-path.rs:15:15 | +LL | static FOO: u8 = 10; + | -------------- `static` defined here +... LL | 0 ..= FOO => {} - | ^^^ + | ^^^ can't be used in patterns error: aborting due to 4 previous errors diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index e105c6a1f98a..51bcfc07c9e0 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -5,7 +5,7 @@ LL | const A: &[B] = &[]; | ------------- constant defined here ... LL | A => (), - | ^ + | ^ constant of non-structural type error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr index 4e2dcb52da80..7c49870e5d03 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804-nan-match.stderr @@ -5,7 +5,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | NAN => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -17,7 +17,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | [NAN, _] => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -29,7 +29,7 @@ LL | const C: MyType = MyType(f32::NAN); | -------------------- constant defined here ... LL | C => {}, - | ^ + | ^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -41,7 +41,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | NAN..=1.0 => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -53,7 +53,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | -1.0..=NAN => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -65,7 +65,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | NAN.. => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead @@ -77,7 +77,7 @@ LL | const NAN: f64 = f64::NAN; | -------------- constant defined here ... LL | ..NAN => {}, - | ^^^ + | ^^^ evaluates to `NaN`, which is not allowed in patterns | = note: NaNs compare inequal to everything, even themselves, so this pattern would never match = help: try using the `is_nan` method instead diff --git a/tests/ui/union/union-const-pat.stderr b/tests/ui/union/union-const-pat.stderr index baf32bf48495..59dc89c77a47 100644 --- a/tests/ui/union/union-const-pat.stderr +++ b/tests/ui/union/union-const-pat.stderr @@ -5,7 +5,7 @@ LL | const C: U = U { a: 10 }; | ---------- constant defined here ... LL | C => {} - | ^ + | ^ can't use a `union` here error: aborting due to 1 previous error From a6040bc230bc7b26f413d7fbf60402e6e7940192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 04:06:39 +0000 Subject: [PATCH 46/59] Specify type kind of constant that can't be used in patterns ``` error: trait object `dyn Send` cannot be used in patterns --> $DIR/issue-70972-dyn-trait.rs:6:9 | LL | const F: &'static dyn Send = &7u32; | -------------------------- constant defined here ... LL | F => panic!(), | ^ trait object can't be used in patterns ``` --- compiler/rustc_mir_build/messages.ftl | 3 ++- compiler/rustc_mir_build/src/errors.rs | 2 ++ .../src/thir/pattern/const_to_pat.rs | 15 ++++++++++----- tests/ui/inline-const/pat-match-fndef.stderr | 4 ++-- tests/ui/match/issue-70972-dyn-trait.stderr | 4 ++-- tests/ui/pattern/issue-72565.stderr | 4 ++-- .../ui/pattern/non-structural-match-types.stderr | 8 ++++---- .../structural-match-no-leak.stderr | 4 ++-- .../type-alias-impl-trait/structural-match.stderr | 4 ++-- 9 files changed, 28 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 28011833e586..1e6b32bf6055 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -152,7 +152,8 @@ mir_build_inline_assembly_requires_unsafe_unsafe_op_in_unsafe_fn_allowed = mir_build_interpreted_as_const = introduce a variable instead -mir_build_invalid_pattern = `{$non_sm_ty}` cannot be used in patterns +mir_build_invalid_pattern = {$prefix} `{$non_sm_ty}` cannot be used in patterns + .label = {$prefix} can't be used in patterns mir_build_irrefutable_let_patterns_if_let = irrefutable `if let` {$count -> [one] pattern diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 1c4de5c07a13..2741830c62d0 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -903,8 +903,10 @@ pub(crate) struct TypeNotPartialEq<'tcx> { #[diag(mir_build_invalid_pattern)] pub(crate) struct InvalidPattern<'tcx> { #[primary_span] + #[label] pub(crate) span: Span, pub(crate) non_sm_ty: Ty<'tcx>, + pub(crate) prefix: String, } #[derive(Diagnostic)] diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index b625c655fac4..71cef18e3161 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -171,10 +171,11 @@ impl<'tcx> ConstToPat<'tcx> { ty::FnPtr(..) | ty::RawPtr(..) => { self.tcx.dcx().create_err(PointerPattern { span: self.span }) } - _ => self - .tcx - .dcx() - .create_err(InvalidPattern { span: self.span, non_sm_ty: bad_ty }), + _ => self.tcx.dcx().create_err(InvalidPattern { + span: self.span, + non_sm_ty: bad_ty, + prefix: bad_ty.prefix_string(self.tcx).to_string(), + }), }; return self.mk_err(e, ty); } @@ -373,7 +374,11 @@ impl<'tcx> ConstToPat<'tcx> { ) } _ => { - let err = InvalidPattern { span, non_sm_ty: ty }; + let err = InvalidPattern { + span, + non_sm_ty: ty, + prefix: ty.prefix_string(self.tcx).to_string(), + }; return Err(tcx.dcx().create_err(err)); } }; diff --git a/tests/ui/inline-const/pat-match-fndef.stderr b/tests/ui/inline-const/pat-match-fndef.stderr index b189ec51ade3..220437a0491a 100644 --- a/tests/ui/inline-const/pat-match-fndef.stderr +++ b/tests/ui/inline-const/pat-match-fndef.stderr @@ -1,8 +1,8 @@ -error: `fn() {uwu}` cannot be used in patterns +error: fn item `fn() {uwu}` cannot be used in patterns --> $DIR/pat-match-fndef.rs:8:9 | LL | const { uwu } => {} - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ fn item can't be used in patterns error: aborting due to 1 previous error diff --git a/tests/ui/match/issue-70972-dyn-trait.stderr b/tests/ui/match/issue-70972-dyn-trait.stderr index 91f49c8a2ff1..cec9c8539f41 100644 --- a/tests/ui/match/issue-70972-dyn-trait.stderr +++ b/tests/ui/match/issue-70972-dyn-trait.stderr @@ -1,11 +1,11 @@ -error: `dyn Send` cannot be used in patterns +error: trait object `dyn Send` cannot be used in patterns --> $DIR/issue-70972-dyn-trait.rs:6:9 | LL | const F: &'static dyn Send = &7u32; | -------------------------- constant defined here ... LL | F => panic!(), - | ^ + | ^ trait object can't be used in patterns error: aborting due to 1 previous error diff --git a/tests/ui/pattern/issue-72565.stderr b/tests/ui/pattern/issue-72565.stderr index abfd4512e9b8..e2927ada0f70 100644 --- a/tests/ui/pattern/issue-72565.stderr +++ b/tests/ui/pattern/issue-72565.stderr @@ -1,11 +1,11 @@ -error: `dyn PartialEq` cannot be used in patterns +error: trait object `dyn PartialEq` cannot be used in patterns --> $DIR/issue-72565.rs:6:9 | LL | const F: &'static dyn PartialEq = &7u32; | ------------------------------------ constant defined here ... LL | F => panic!(), - | ^ + | ^ trait object can't be used in patterns error: aborting due to 1 previous error diff --git a/tests/ui/pattern/non-structural-match-types.stderr b/tests/ui/pattern/non-structural-match-types.stderr index 9075cf40ddae..3588751bf668 100644 --- a/tests/ui/pattern/non-structural-match-types.stderr +++ b/tests/ui/pattern/non-structural-match-types.stderr @@ -1,14 +1,14 @@ -error: `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns +error: closure `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns --> $DIR/non-structural-match-types.rs:9:9 | LL | const { || {} } => {} - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ closure can't be used in patterns -error: `{async block@$DIR/non-structural-match-types.rs:12:17: 12:22}` cannot be used in patterns +error: `async` block `{async block@$DIR/non-structural-match-types.rs:12:17: 12:22}` cannot be used in patterns --> $DIR/non-structural-match-types.rs:12:9 | LL | const { async {} } => {} - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ `async` block can't be used in patterns error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr index 743ad75628e2..28f5d6728a9d 100644 --- a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr +++ b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr @@ -1,11 +1,11 @@ -error: `Bar` cannot be used in patterns +error: opaque type `Bar` cannot be used in patterns --> $DIR/structural-match-no-leak.rs:16:9 | LL | const LEAK_FREE: bar::Bar = bar::leak_free(); | ------------------------- constant defined here ... LL | LEAK_FREE => (), - | ^^^^^^^^^ + | ^^^^^^^^^ opaque type can't be used in patterns error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/structural-match.stderr b/tests/ui/type-alias-impl-trait/structural-match.stderr index 9c26aa9a9a64..b06b31a060fb 100644 --- a/tests/ui/type-alias-impl-trait/structural-match.stderr +++ b/tests/ui/type-alias-impl-trait/structural-match.stderr @@ -1,11 +1,11 @@ -error: `foo::Foo` cannot be used in patterns +error: opaque type `foo::Foo` cannot be used in patterns --> $DIR/structural-match.rs:18:9 | LL | const VALUE: Foo = value(); | ---------------- constant defined here ... LL | VALUE => (), - | ^^^^^ + | ^^^^^ opaque type can't be used in patterns error: aborting due to 1 previous error From fb2f6a44c05c017139ef0266683fdfe3c66c4220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 04:15:37 +0000 Subject: [PATCH 47/59] Reword message for non-structural type constant in pattern --- compiler/rustc_mir_build/messages.ftl | 3 +-- tests/ui/consts/const_in_pattern/issue-65466.rs | 2 +- tests/ui/consts/const_in_pattern/issue-65466.stderr | 2 +- tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs | 2 +- tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr | 2 +- tests/ui/match/issue-72896-non-partial-eq-const.rs | 2 +- tests/ui/match/issue-72896-non-partial-eq-const.stderr | 2 +- .../issue-61188-match-slice-forbidden-without-eq.rs | 3 +-- .../issue-61188-match-slice-forbidden-without-eq.stderr | 2 +- 9 files changed, 9 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 1e6b32bf6055..df51388c7728 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -273,8 +273,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type .suggestion = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown .help = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern -mir_build_non_partial_eq_match = - to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq` +mir_build_non_partial_eq_match = constant of non-structural type `{$non_peq_ty}` in a pattern .label = constant of non-structural type mir_build_pattern_not_covered = refutable pattern in {$origin} diff --git a/tests/ui/consts/const_in_pattern/issue-65466.rs b/tests/ui/consts/const_in_pattern/issue-65466.rs index 62efce648761..82838657b02f 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.rs +++ b/tests/ui/consts/const_in_pattern/issue-65466.rs @@ -11,7 +11,7 @@ const C: &[O] = &[O::None]; fn main() { let x = O::None; match &[x][..] { - C => (), //~ERROR: the type must implement `PartialEq` + C => (), //~ ERROR constant of non-structural type `&[O]` in a pattern _ => (), } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index 90bac6262cc9..c51d14d39f88 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -1,4 +1,4 @@ -error: to use a constant of type `&[O]` in a pattern, the type must implement `PartialEq` +error: constant of non-structural type `&[O]` in a pattern --> $DIR/issue-65466.rs:14:9 | LL | const C: &[O] = &[O::None]; diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs index 645e14189124..e555ecfeb8f1 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.rs @@ -26,7 +26,7 @@ fn main() { match None { NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), - //~^ ERROR must implement `PartialEq` + //~^ ERROR constant of non-structural type `Option` in a pattern _ => panic!("whoops"), } } diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index d4952a8bfb8c..2c9cda7d1853 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -1,4 +1,4 @@ -error: to use a constant of type `Option` in a pattern, the type must implement `PartialEq` +error: constant of non-structural type `Option` in a pattern --> $DIR/reject_non_partial_eq.rs:28:9 | LL | const NO_PARTIAL_EQ_NONE: Option = None; diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.rs b/tests/ui/match/issue-72896-non-partial-eq-const.rs index f15eae83896d..e4fc1ac057d3 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.rs +++ b/tests/ui/match/issue-72896-non-partial-eq-const.rs @@ -16,7 +16,7 @@ const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; fn main() { match CONST_SET { - CONST_SET => { /* ok */ } //~ERROR: must implement `PartialEq` + CONST_SET => { /* ok */ } //~ ERROR constant of non-structural type `EnumSet` in a pattern _ => panic!("match fell through?"), } } diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index d6ae9e56377d..47323b3cd22c 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -1,4 +1,4 @@ -error: to use a constant of type `EnumSet` in a pattern, the type must implement `PartialEq` +error: constant of non-structural type `EnumSet` in a pattern --> $DIR/issue-72896-non-partial-eq-const.rs:19:9 | LL | const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs index c01f8934c750..95a3be517a9a 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs @@ -12,8 +12,7 @@ const A: &[B] = &[]; pub fn main() { match &[][..] { - A => (), - //~^ ERROR must implement `PartialEq` + A => (), //~ ERROR constant of non-structural type `&[B]` in a pattern _ => (), } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index 51bcfc07c9e0..33244b2841fb 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -1,4 +1,4 @@ -error: to use a constant of type `&[B]` in a pattern, the type must implement `PartialEq` +error: constant of non-structural type `&[B]` in a pattern --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | LL | const A: &[B] = &[]; From 335d05aee555c19d375a46c34134312ac720aba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 04:30:35 +0000 Subject: [PATCH 48/59] Add additional context for non-sructural type constant used in pattern - Point at type that should derive `PartialEq` to be structural. - Point at manual `impl PartialEq`, explaining that it is not sufficient to be structural. ``` error: constant of non-structural type `MyType` in a pattern --> $DIR/const-partial_eq-fallback-ice.rs:14:12 | LL | struct MyType; | ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns ... LL | const CONSTANT: &&MyType = &&MyType; | ------------------------ constant defined here ... LL | if let CONSTANT = &&MyType { | ^^^^^^^^ constant of non-structural type | note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details --> $DIR/const-partial_eq-fallback-ice.rs:5:1 | LL | impl PartialEq for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` --- compiler/rustc_mir_build/messages.ftl | 10 +- compiler/rustc_mir_build/src/errors.rs | 9 +- .../src/thir/pattern/const_to_pat.rs | 23 ++- .../const_in_pattern/cross-crate-fail.rs | 6 +- .../const_in_pattern/cross-crate-fail.stderr | 22 ++- .../const_in_pattern/no-eq-branch-fail.rs | 3 +- .../const_in_pattern/no-eq-branch-fail.stderr | 8 +- .../const_in_pattern/reject_non_structural.rs | 70 ++++---- .../reject_non_structural.stderr | 160 ++++++++++++------ tests/ui/consts/issue-89088.rs | 2 +- tests/ui/consts/issue-89088.stderr | 8 +- tests/ui/consts/match_ice.rs | 3 +- tests/ui/consts/match_ice.stderr | 8 +- tests/ui/pattern/issue-115599.rs | 2 +- tests/ui/pattern/issue-115599.stderr | 8 +- .../const-partial_eq-fallback-ice.rs | 2 +- .../const-partial_eq-fallback-ice.stderr | 14 +- ...cant-hide-behind-direct-struct-embedded.rs | 2 +- ...-hide-behind-direct-struct-embedded.stderr | 14 +- .../cant-hide-behind-direct-struct-param.rs | 2 +- ...ant-hide-behind-direct-struct-param.stderr | 14 +- ...nt-hide-behind-doubly-indirect-embedded.rs | 2 +- ...ide-behind-doubly-indirect-embedded.stderr | 14 +- .../cant-hide-behind-doubly-indirect-param.rs | 2 +- ...t-hide-behind-doubly-indirect-param.stderr | 14 +- ...nt-hide-behind-indirect-struct-embedded.rs | 2 +- ...ide-behind-indirect-struct-embedded.stderr | 14 +- .../cant-hide-behind-indirect-struct-param.rs | 2 +- ...t-hide-behind-indirect-struct-param.stderr | 14 +- ...2307-match-ref-ref-forbidden-without-eq.rs | 12 +- ...-match-ref-ref-forbidden-without-eq.stderr | 32 ++-- .../match-requires-both-partialeq-and-eq.rs | 4 +- ...atch-requires-both-partialeq-and-eq.stderr | 16 +- 33 files changed, 343 insertions(+), 175 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index df51388c7728..6122307e5bb9 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -322,12 +322,12 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count -> *[other] them } into the body -mir_build_type_not_structural = - to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]` - +mir_build_type_not_structural = constant of non-structural type `{$non_sm_ty}` in a pattern + .label = constant of non-structural type +mir_build_type_not_structural_def = `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details - -mir_build_type_not_structural_tip = the traits must be derived, manual `impl`s are not sufficient +mir_build_type_not_structural_tip = + the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details mir_build_unconditional_recursion = function cannot return without recursing .label = cannot return without recursing diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 2741830c62d0..da4c78ddc4ec 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -882,12 +882,17 @@ pub(crate) struct UnionPattern { #[derive(Diagnostic)] #[diag(mir_build_type_not_structural)] -#[note(mir_build_type_not_structural_tip)] -#[note(mir_build_type_not_structural_more_info)] pub(crate) struct TypeNotStructural<'tcx> { #[primary_span] + #[label] pub(crate) span: Span, + #[label(mir_build_type_not_structural_def)] + pub(crate) ty_def_span: Span, pub(crate) non_sm_ty: Ty<'tcx>, + #[note(mir_build_type_not_structural_tip)] + pub(crate) manual_partialeq_impl_span: Option, + #[note(mir_build_type_not_structural_more_info)] + pub(crate) manual_partialeq_impl_note: bool, } #[derive(Diagnostic)] diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 71cef18e3161..36c84f68f735 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -254,7 +254,22 @@ impl<'tcx> ConstToPat<'tcx> { // Extremely important check for all ADTs! Make sure they opted-in to be used in // patterns. debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty); - let err = TypeNotStructural { span, non_sm_ty: ty }; + let ty_def_span = tcx.def_span(adt_def.did()); + let mut manual_partialeq_impl_span = None; + let partial_eq_trait_id = + tcx.require_lang_item(hir::LangItem::PartialEq, Some(self.span)); + tcx.for_each_relevant_impl(partial_eq_trait_id, ty, |def_id| { + if def_id.is_local() { + manual_partialeq_impl_span = Some(tcx.def_span(def_id)); + } + }); + let err = TypeNotStructural { + span, + non_sm_ty: ty, + ty_def_span, + manual_partialeq_impl_span, + manual_partialeq_impl_note: manual_partialeq_impl_span.is_none(), + }; return Err(tcx.dcx().create_err(err)); } ty::Adt(adt_def, args) if adt_def.is_enum() => { @@ -269,7 +284,7 @@ impl<'tcx> ConstToPat<'tcx> { adt_def.variants()[variant_index] .fields .iter() - .map(|field| field.ty(self.tcx, args)), + .map(|field| field.ty(tcx, args)), ), ), } @@ -278,7 +293,7 @@ impl<'tcx> ConstToPat<'tcx> { assert!(!def.is_union()); // Valtree construction would never succeed for unions. PatKind::Leaf { subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip( - def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx, args)), + def.non_enum_variant().fields.iter().map(|field| field.ty(tcx, args)), )), } } @@ -377,7 +392,7 @@ impl<'tcx> ConstToPat<'tcx> { let err = InvalidPattern { span, non_sm_ty: ty, - prefix: ty.prefix_string(self.tcx).to_string(), + prefix: ty.prefix_string(tcx).to_string(), }; return Err(tcx.dcx().create_err(err)); } diff --git a/tests/ui/consts/const_in_pattern/cross-crate-fail.rs b/tests/ui/consts/const_in_pattern/cross-crate-fail.rs index 163a47f43336..f02e780f30e3 100644 --- a/tests/ui/consts/const_in_pattern/cross-crate-fail.rs +++ b/tests/ui/consts/const_in_pattern/cross-crate-fail.rs @@ -9,15 +9,13 @@ fn main() { let _ = Defaulted; match None { consts::SOME => panic!(), - //~^ must be annotated with `#[derive(PartialEq)]` - + //~^ ERROR constant of non-structural type `CustomEq` in a pattern _ => {} } match None { ::SOME => panic!(), - //~^ must be annotated with `#[derive(PartialEq)]` - + //~^ ERROR constant of non-structural type `CustomEq` in a pattern _ => {} } } diff --git a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr index 81fc67e6aebb..7cada8836450 100644 --- a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr +++ b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr @@ -1,29 +1,33 @@ -error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `CustomEq` in a pattern --> $DIR/cross-crate-fail.rs:11:9 | LL | consts::SOME => panic!(), - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ constant of non-structural type | - ::: $DIR/auxiliary/consts.rs:11:1 + ::: $DIR/auxiliary/consts.rs:1:1 | +LL | pub struct CustomEq; + | ------------------- `CustomEq` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | pub const SOME: Option = Some(CustomEq); | -------------------------------- constant defined here | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details -error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]` - --> $DIR/cross-crate-fail.rs:18:9 +error: constant of non-structural type `CustomEq` in a pattern + --> $DIR/cross-crate-fail.rs:17:9 | LL | ::SOME => panic!(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type | - ::: $DIR/auxiliary/consts.rs:15:5 + ::: $DIR/auxiliary/consts.rs:1:1 | +LL | pub struct CustomEq; + | ------------------- `CustomEq` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const SOME: Option = Some(CustomEq); | ---------------------------- constant defined here | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.rs b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.rs index cf013c1a7906..91ef5ac53295 100644 --- a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.rs +++ b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.rs @@ -16,8 +16,7 @@ const BAR_BAZ: Foo = if 42 == 42 { fn main() { match Foo::Qux(NoEq) { - BAR_BAZ => panic!(), - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + BAR_BAZ => panic!(), //~ ERROR constant of non-structural type `Foo` in a pattern _ => {} } } diff --git a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr index 5e2fc6eca3c5..154c94c6d385 100644 --- a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr +++ b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr @@ -1,13 +1,15 @@ -error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `Foo` in a pattern --> $DIR/no-eq-branch-fail.rs:19:9 | +LL | enum Foo { + | -------- `Foo` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const BAR_BAZ: Foo = if 42 == 42 { | ------------------ constant defined here ... LL | BAR_BAZ => panic!(), - | ^^^^^^^ + | ^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.rs b/tests/ui/consts/const_in_pattern/reject_non_structural.rs index 52cb974c1df1..39e5f732a898 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.rs +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.rs @@ -17,9 +17,29 @@ struct NoPartialEq; #[derive(Copy, Clone, Debug)] struct NoDerive; +//~^ NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` +//~| NOTE must be annotated with `#[derive(PartialEq)]` // This impl makes `NoDerive` irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } +//~^ NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details +//~| NOTE StructuralPartialEq.html for details impl Eq for NoDerive { } @@ -38,63 +58,53 @@ fn main() { const ENUM: Derive = Derive::Some(NoDerive); //~ NOTE constant defined here match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const FIELD: OND = TrivialEq(Some(NoDerive)).0; //~ NOTE constant defined here match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const NO_DERIVE_SOME: OND = Some(NoDerive); const INDIRECT: OND = NO_DERIVE_SOME; //~ NOTE constant defined here match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const TUPLE: (OND, OND) = (None, Some(NoDerive)); //~ NOTE constant defined here match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); //~ NOTE constant defined here match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const ARRAY: [OND; 2] = [None, Some(NoDerive)]; //~ NOTE constant defined here match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const REPEAT: [OND; 2] = [Some(NoDerive); 2]; //~ NOTE constant defined here match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type trait Trait: Sized { const ASSOC: Option; } //~ NOTE constant defined here impl Trait for NoDerive { const ASSOC: Option = Some(NoDerive); } match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const BLOCK: OND = { NoDerive; Some(NoDerive) }; //~ NOTE constant defined here match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type const ADDR_OF: &OND = &Some(NoDerive); //~ NOTE constant defined here match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; - //~^ ERROR must be annotated with `#[derive(PartialEq)]` - //~| NOTE the traits must be derived - //~| NOTE StructuralPartialEq.html for details + //~^ ERROR constant of non-structural type `NoDerive` in a pattern + //~| NOTE constant of non-structural type } diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr index e8a69512e7ed..fa16d0b06a7f 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr @@ -1,113 +1,173 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:40:36 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:60:36 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const ENUM: Derive = Derive::Some(NoDerive); | ---------------------------- constant defined here LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; - | ^^^^ + | ^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:46:28 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:65:28 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const FIELD: OND = TrivialEq(Some(NoDerive)).0; | ---------------- constant defined here LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:53:27 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:71:27 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const INDIRECT: OND = NO_DERIVE_SOME; | ------------------- constant defined here LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; - | ^^^^^^^^ + | ^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:59:36 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:76:36 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const TUPLE: (OND, OND) = (None, Some(NoDerive)); | ----------------------- constant defined here LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:65:28 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:81:28 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); | -------------------------- constant defined here LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:71:36 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:86:36 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const ARRAY: [OND; 2] = [None, Some(NoDerive)]; | --------------------- constant defined here LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:77:33 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:91:33 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const REPEAT: [OND; 2] = [Some(NoDerive); 2]; | ---------------------- constant defined here LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; - | ^^^^^^ + | ^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:84:28 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:97:28 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | trait Trait: Sized { const ASSOC: Option; } | ------------------ ------------------------- constant defined here LL | impl Trait for NoDerive { const ASSOC: Option = Some(NoDerive); } LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:90:28 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:102:28 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const BLOCK: OND = { NoDerive; Some(NoDerive) }; | ---------------- constant defined here LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` - --> $DIR/reject_non_structural.rs:96:29 +error: constant of non-structural type `NoDerive` in a pattern + --> $DIR/reject_non_structural.rs:107:29 | +LL | struct NoDerive; + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const ADDR_OF: &OND = &Some(NoDerive); | ------------------- constant defined here LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; - | ^^^^^^^ + | ^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/reject_non_structural.rs:32:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 10 previous errors diff --git a/tests/ui/consts/issue-89088.rs b/tests/ui/consts/issue-89088.rs index 02a786e74651..f6dbf8f01250 100644 --- a/tests/ui/consts/issue-89088.rs +++ b/tests/ui/consts/issue-89088.rs @@ -13,7 +13,7 @@ fn main() { let var = A::Field(Cow::Borrowed("bar")); match &var { - FOO => todo!(), //~ERROR derive(PartialEq) + FOO => todo!(), //~ ERROR constant of non-structural type `Cow<'_, str>` in a pattern _ => todo!() } } diff --git a/tests/ui/consts/issue-89088.stderr b/tests/ui/consts/issue-89088.stderr index 740cc25647e5..56025e0d9b28 100644 --- a/tests/ui/consts/issue-89088.stderr +++ b/tests/ui/consts/issue-89088.stderr @@ -1,13 +1,15 @@ -error: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `Cow<'_, str>` in a pattern --> $DIR/issue-89088.rs:16:9 | LL | const FOO: &A = &A::Field(Cow::Borrowed("foo")); | ------------- constant defined here ... LL | FOO => todo!(), - | ^^^ + | ^^^ constant of non-structural type + --> $SRC_DIR/alloc/src/borrow.rs:LL:COL + | + = note: `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/consts/match_ice.rs b/tests/ui/consts/match_ice.rs index ed1fd78809b1..477a2de09a46 100644 --- a/tests/ui/consts/match_ice.rs +++ b/tests/ui/consts/match_ice.rs @@ -8,8 +8,7 @@ struct T; fn main() { const C: &S = &S; match C { - C => {} - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + C => {} //~ ERROR constant of non-structural type `S` in a pattern } const K: &T = &T; match K { diff --git a/tests/ui/consts/match_ice.stderr b/tests/ui/consts/match_ice.stderr index 0841ed050251..95e96bbbd677 100644 --- a/tests/ui/consts/match_ice.stderr +++ b/tests/ui/consts/match_ice.stderr @@ -1,13 +1,15 @@ -error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `S` in a pattern --> $DIR/match_ice.rs:11:9 | +LL | struct S; + | -------- `S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const C: &S = &S; | ----------- constant defined here LL | match C { LL | C => {} - | ^ + | ^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/pattern/issue-115599.rs b/tests/ui/pattern/issue-115599.rs index 1521d728d956..47fe6b87da94 100644 --- a/tests/ui/pattern/issue-115599.rs +++ b/tests/ui/pattern/issue-115599.rs @@ -3,5 +3,5 @@ const CONST_STRING: String = String::new(); fn main() { let empty_str = String::from(""); if let CONST_STRING = empty_str {} - //~^ ERROR to use a constant of type `Vec` in a pattern, `Vec` must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `Vec` in a pattern } diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index 65e3b08ac485..69d10728ccdd 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -1,13 +1,15 @@ -error: to use a constant of type `Vec` in a pattern, `Vec` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `Vec` in a pattern --> $DIR/issue-115599.rs:5:12 | LL | const CONST_STRING: String = String::new(); | -------------------------- constant defined here ... LL | if let CONST_STRING = empty_str {} - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ constant of non-structural type + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + | + = note: `Vec` must be annotated with `#[derive(PartialEq)]` to be usable in patterns | - = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs index f34093ef1498..f09dcf8498f3 100644 --- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs +++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs @@ -12,7 +12,7 @@ const CONSTANT: &&MyType = &&MyType; fn main() { if let CONSTANT = &&MyType { - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `MyType` in a pattern println!("did match!"); } } diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr index bcbcd0bc280d..f9da0430f2ef 100644 --- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr +++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `MyType` in a pattern --> $DIR/const-partial_eq-fallback-ice.rs:14:12 | +LL | struct MyType; + | ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const CONSTANT: &&MyType = &&MyType; | ------------------------ constant defined here ... LL | if let CONSTANT = &&MyType { - | ^^^^^^^^ + | ^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/const-partial_eq-fallback-ice.rs:5:1 + | +LL | impl PartialEq for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs index 65a85a5ed68f..e27c80480497 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs @@ -20,7 +20,7 @@ const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0)); fn main() { match WRAP_DIRECT_INLINE { WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_DIRECT_INLINE did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr index dffaafd88a08..8787d140e17f 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9 | +LL | struct NoDerive(#[allow(dead_code)] i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0)); | ------------------------------------ constant defined here ... LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-direct-struct-embedded.rs:11:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs index f840b4040b65..713ff23573d4 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs @@ -19,7 +19,7 @@ const WRAP_DIRECT_PARAM: WrapParam = WrapParam(NoDerive(0)); fn main() { match WRAP_DIRECT_PARAM { WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_DIRECT_PARAM did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr index 8da9fa71c536..ec836db02ad8 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-direct-struct-param.rs:21:9 | +LL | struct NoDerive(i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_DIRECT_PARAM: WrapParam = WrapParam(NoDerive(0)); | -------------------------------------------- constant defined here ... LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-direct-struct-param.rs:10:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs index 898acefc83cc..7766a4691923 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs @@ -20,7 +20,7 @@ const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0) fn main() { match WRAP_DOUBLY_INDIRECT_INLINE { WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr index 3cd6a184bbe2..fdc16fe300c2 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9 | +LL | struct NoDerive(#[allow(dead_code)] i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)); | ------------------------------------------------ constant defined here ... LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:11:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs index 7cbaada88a30..ed84900b6e91 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs @@ -20,7 +20,7 @@ const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam = & &WrapParam(& & NoDe fn main() { match WRAP_DOUBLY_INDIRECT_PARAM { WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr index 35693da99abf..b46fc041f14b 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9 | +LL | struct NoDerive(#[allow(dead_code)] i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam = & &WrapParam(& & NoDerive(0)); | -------------------------------------------------------- constant defined here ... LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-doubly-indirect-param.rs:11:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs index ac868efed6fd..5743d7a24d3a 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs @@ -20,7 +20,7 @@ const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0)); fn main() { match WRAP_INDIRECT_INLINE { WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_INDIRECT_INLINE did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr index 5312d61c4469..70f39aa01d82 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9 | +LL | struct NoDerive(#[allow(dead_code)] i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0)); | ----------------------------------------- constant defined here ... LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:11:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs index cbfabec6819e..9226f9c3ecde 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs @@ -20,7 +20,7 @@ const WRAP_INDIRECT_PARAM: & &WrapParam = & &WrapParam(NoDerive(0)); fn main() { match WRAP_INDIRECT_PARAM { WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `NoDerive` in a pattern _ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr index 2066c53e73a6..fceb3acb025e 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]` +error: constant of non-structural type `NoDerive` in a pattern --> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9 | +LL | struct NoDerive(#[allow(dead_code)] i32); + | --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const WRAP_INDIRECT_PARAM: & &WrapParam = & &WrapParam(NoDerive(0)); | ------------------------------------------------- constant defined here ... LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/cant-hide-behind-indirect-struct-param.rs:11:1 + | +LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs index 0fa2370c95bf..843c5a386490 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs @@ -13,27 +13,35 @@ #[derive(Debug)] struct B(i32); +//~^ NOTE `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +//~| NOTE `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns // Overriding `PartialEq` to use this strange notion of "equality" exposes // whether `match` is using structural-equality or method-dispatch // under the hood, which is the antithesis of rust-lang/rfcs#1445 impl PartialEq for B { +//~^ NOTE the `PartialEq` trait must be derived, manual `impl`s are not sufficient +//~| NOTE the `PartialEq` trait must be derived, manual `impl`s are not sufficient fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 } } fn main() { const RR_B0: & & B = & & B(0); const RR_B1: & & B = & & B(1); + //~^ NOTE constant defined here + //~| NOTE constant defined here match RR_B0 { RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `B` in a pattern + //~| NOTE constant of non-structural type _ => { } } match RR_B1 { RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `B` in a pattern + //~| NOTE constant of non-structural type _ => { } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr index 5cfe6dabc895..34fffd99c2c9 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr @@ -1,26 +1,38 @@ -error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]` - --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:29:9 +error: constant of non-structural type `B` in a pattern + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9 | +LL | struct B(i32); + | -------- `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const RR_B1: & & B = & & B(1); | ------------------ constant defined here ... LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:22:1 + | +LL | impl PartialEq for B { + | ^^^^^^^^^^^^^^^^^^^^ -error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]` - --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9 +error: constant of non-structural type `B` in a pattern + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:42:9 | +LL | struct B(i32); + | -------- `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const RR_B1: & & B = & & B(1); | ------------------ constant defined here ... LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } - | ^^^^^ + | ^^^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:22:1 + | +LL | impl PartialEq for B { + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs index 9020eb291f5c..74394698fbcd 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs @@ -1,3 +1,5 @@ +// Note: It is no longer true that both `Eq` and `PartialEq` must the derived, only the later. + #[derive(Eq)] struct Foo { x: u32 @@ -15,7 +17,7 @@ fn main() { let y = Foo { x: 1 }; match y { FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq)]` + //~^ ERROR constant of non-structural type `Foo` in a pattern _ => { } } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr index c471fe572548..bbcab3b62d0e 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr @@ -1,14 +1,20 @@ -error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]` - --> $DIR/match-requires-both-partialeq-and-eq.rs:17:9 +error: constant of non-structural type `Foo` in a pattern + --> $DIR/match-requires-both-partialeq-and-eq.rs:19:9 | +LL | struct Foo { + | ---------- `Foo` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const FOO: Foo = Foo { x: 0 }; | -------------- constant defined here ... LL | FOO => { } - | ^^^ + | ^^^ constant of non-structural type | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details +note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + --> $DIR/match-requires-both-partialeq-and-eq.rs:8:1 + | +LL | impl PartialEq for Foo { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error From 27a1880593a057da01373c4cdafbbed3d34d650f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 06:49:13 +0000 Subject: [PATCH 49/59] Add context to fall-through "const pattern of non-structural type" error Unify wording with the regular non-structural type error. --- compiler/rustc_mir_build/messages.ftl | 6 +++--- compiler/rustc_mir_build/src/errors.rs | 6 ++++-- compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs | 5 +++-- tests/ui/consts/const_in_pattern/issue-65466.stderr | 3 +++ .../ui/consts/const_in_pattern/reject_non_partial_eq.stderr | 3 +++ tests/ui/match/issue-72896-non-partial-eq-const.stderr | 3 +++ .../issue-61188-match-slice-forbidden-without-eq.stderr | 3 +++ 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 6122307e5bb9..f35252dbcc55 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -273,7 +273,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type .suggestion = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown .help = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern -mir_build_non_partial_eq_match = constant of non-structural type `{$non_peq_ty}` in a pattern +mir_build_non_partial_eq_match = constant of non-structural type `{$ty}` in a pattern .label = constant of non-structural type mir_build_pattern_not_covered = refutable pattern in {$origin} @@ -322,9 +322,9 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count -> *[other] them } into the body -mir_build_type_not_structural = constant of non-structural type `{$non_sm_ty}` in a pattern +mir_build_type_not_structural = constant of non-structural type `{$ty}` in a pattern .label = constant of non-structural type -mir_build_type_not_structural_def = `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns +mir_build_type_not_structural_def = `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details mir_build_type_not_structural_tip = the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index da4c78ddc4ec..49e18891fcab 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -888,7 +888,7 @@ pub(crate) struct TypeNotStructural<'tcx> { pub(crate) span: Span, #[label(mir_build_type_not_structural_def)] pub(crate) ty_def_span: Span, - pub(crate) non_sm_ty: Ty<'tcx>, + pub(crate) ty: Ty<'tcx>, #[note(mir_build_type_not_structural_tip)] pub(crate) manual_partialeq_impl_span: Option, #[note(mir_build_type_not_structural_more_info)] @@ -897,11 +897,13 @@ pub(crate) struct TypeNotStructural<'tcx> { #[derive(Diagnostic)] #[diag(mir_build_non_partial_eq_match)] +#[note(mir_build_type_not_structural_def)] +#[note(mir_build_type_not_structural_more_info)] pub(crate) struct TypeNotPartialEq<'tcx> { #[primary_span] #[label] pub(crate) span: Span, - pub(crate) non_peq_ty: Ty<'tcx>, + pub(crate) ty: Ty<'tcx>, } #[derive(Diagnostic)] diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 36c84f68f735..123a439c645a 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -190,7 +190,8 @@ impl<'tcx> ConstToPat<'tcx> { if !inlined_const_as_pat.references_error() { // Always check for `PartialEq` if we had no other errors yet. if !self.type_has_partial_eq_impl(ty) { - let err = TypeNotPartialEq { span: self.span, non_peq_ty: ty }; + let err = TypeNotPartialEq { span: self.span, ty }; + // FIXME: visit every type in `ty` and if it doesn't derive `PartialEq`, mention it. return self.mk_err(self.tcx.dcx().create_err(err), ty); } } @@ -265,7 +266,7 @@ impl<'tcx> ConstToPat<'tcx> { }); let err = TypeNotStructural { span, - non_sm_ty: ty, + ty, ty_def_span, manual_partialeq_impl_span, manual_partialeq_impl_note: manual_partialeq_impl_span.is_none(), diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index c51d14d39f88..bd9748b5dda9 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -6,6 +6,9 @@ LL | const C: &[O] = &[O::None]; ... LL | C => (), | ^ constant of non-structural type + | + = note: `&[O]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index 2c9cda7d1853..0ef5286e6893 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -6,6 +6,9 @@ LL | const NO_PARTIAL_EQ_NONE: Option = None; ... LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), | ^^^^^^^^^^^^^^^^^^ constant of non-structural type + | + = note: `Option` must be annotated with `#[derive(PartialEq)]` to be usable in patterns + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index 47323b3cd22c..4287fbc188d5 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -6,6 +6,9 @@ LL | const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; ... LL | CONST_SET => { /* ok */ } | ^^^^^^^^^ constant of non-structural type + | + = note: `EnumSet` must be annotated with `#[derive(PartialEq)]` to be usable in patterns + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index 33244b2841fb..4f83ca02c287 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -6,6 +6,9 @@ LL | const A: &[B] = &[]; ... LL | A => (), | ^ constant of non-structural type + | + = note: `&[B]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error From d136b3108def7af6d43229ba704ab21778f55125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 23:10:39 +0000 Subject: [PATCH 50/59] Add more context to fall-through "const pattern of non-structural type" error Point at types that need to be marked with `#[derive(PartialEq)]`. We use a visitor to look at a type that isn't structural, looking for all ADTs that don't derive `PartialEq`. These can either be manual `impl PartialEq`s or no `impl` at all, so we differentiate between those two cases to provide more context to the user. We also only point at types and impls from the local crate, otherwise show only a note. ``` error: constant of non-structural type `&[B]` in a pattern --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | LL | struct B(i32); | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns LL | LL | const A: &[B] = &[]; | ------------- constant defined here ... LL | A => (), | ^ constant of non-structural type | = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details ``` --- compiler/rustc_mir_build/src/errors.rs | 1 - .../src/thir/pattern/const_to_pat.rs | 198 ++++++++++++++---- .../const_in_pattern/issue-65466.stderr | 4 +- .../reject_non_partial_eq.stderr | 4 +- .../issue-72896-non-partial-eq-const.stderr | 4 +- ...88-match-slice-forbidden-without-eq.stderr | 4 +- 6 files changed, 169 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 49e18891fcab..3632da943e18 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -897,7 +897,6 @@ pub(crate) struct TypeNotStructural<'tcx> { #[derive(Diagnostic)] #[diag(mir_build_non_partial_eq_match)] -#[note(mir_build_type_not_structural_def)] #[note(mir_build_type_not_structural_more_info)] pub(crate) struct TypeNotPartialEq<'tcx> { #[primary_span] diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index 123a439c645a..feb6d2fcfe9c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -1,5 +1,6 @@ use rustc_abi::{FieldIdx, VariantIdx}; use rustc_apfloat::Float; +use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Diag, PResult}; use rustc_hir as hir; use rustc_index::Idx; @@ -7,9 +8,10 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::Obligation; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::thir::{FieldPat, Pat, PatKind}; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, ValTree}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypeVisitor, ValTree}; use rustc_middle::{mir, span_bug}; -use rustc_span::Span; +use rustc_span::def_id::DefId; +use rustc_span::{Span, sym}; use rustc_trait_selection::traits::ObligationCause; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use tracing::{debug, instrument, trace}; @@ -189,42 +191,16 @@ impl<'tcx> ConstToPat<'tcx> { if !inlined_const_as_pat.references_error() { // Always check for `PartialEq` if we had no other errors yet. - if !self.type_has_partial_eq_impl(ty) { - let err = TypeNotPartialEq { span: self.span, ty }; - // FIXME: visit every type in `ty` and if it doesn't derive `PartialEq`, mention it. - return self.mk_err(self.tcx.dcx().create_err(err), ty); + if !type_has_partial_eq_impl(self.tcx, typing_env, ty).0 { + let mut err = self.tcx.dcx().create_err(TypeNotPartialEq { span: self.span, ty }); + extend_type_not_partial_eq(self.tcx, typing_env, ty, &mut err); + return self.mk_err(err, ty); } } inlined_const_as_pat } - #[instrument(level = "trace", skip(self), ret)] - fn type_has_partial_eq_impl(&self, ty: Ty<'tcx>) -> bool { - let (infcx, param_env) = self.tcx.infer_ctxt().build_with_typing_env(self.typing_env); - // double-check there even *is* a semantic `PartialEq` to dispatch to. - // - // (If there isn't, then we can safely issue a hard - // error, because that's never worked, due to compiler - // using `PartialEq::eq` in this scenario in the past.) - let partial_eq_trait_id = - self.tcx.require_lang_item(hir::LangItem::PartialEq, Some(self.span)); - let partial_eq_obligation = Obligation::new( - self.tcx, - ObligationCause::dummy(), - param_env, - ty::TraitRef::new(self.tcx, partial_eq_trait_id, [ty, ty]), - ); - - // This *could* accept a type that isn't actually `PartialEq`, because region bounds get - // ignored. However that should be pretty much impossible since consts that do not depend on - // generics can only mention the `'static` lifetime, and how would one have a type that's - // `PartialEq` for some lifetime but *not* for `'static`? If this ever becomes a problem - // we'll need to leave some sort of trace of this requirement in the MIR so that borrowck - // can ensure that the type really implements `PartialEq`. - infcx.predicate_must_hold_modulo_regions(&partial_eq_obligation) - } - fn field_pats( &self, vals: impl Iterator, Ty<'tcx>)>, @@ -255,21 +231,23 @@ impl<'tcx> ConstToPat<'tcx> { // Extremely important check for all ADTs! Make sure they opted-in to be used in // patterns. debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty); + let (impls_partial_eq, derived, structural, impl_def_id) = + type_has_partial_eq_impl(self.tcx, self.typing_env, ty); + let (manual_partialeq_impl_span, manual_partialeq_impl_note) = + match (impls_partial_eq, derived, structural, impl_def_id) { + (_, _, true, _) => (None, false), + (_, false, _, Some(def_id)) if def_id.is_local() => { + (Some(tcx.def_span(def_id)), false) + } + _ => (None, true), + }; let ty_def_span = tcx.def_span(adt_def.did()); - let mut manual_partialeq_impl_span = None; - let partial_eq_trait_id = - tcx.require_lang_item(hir::LangItem::PartialEq, Some(self.span)); - tcx.for_each_relevant_impl(partial_eq_trait_id, ty, |def_id| { - if def_id.is_local() { - manual_partialeq_impl_span = Some(tcx.def_span(def_id)); - } - }); let err = TypeNotStructural { span, ty, ty_def_span, manual_partialeq_impl_span, - manual_partialeq_impl_note: manual_partialeq_impl_span.is_none(), + manual_partialeq_impl_note, }; return Err(tcx.dcx().create_err(err)); } @@ -402,3 +380,141 @@ impl<'tcx> ConstToPat<'tcx> { Ok(Box::new(Pat { span, ty, kind })) } } + +/// Given a type with type parameters, visit every ADT looking for types that need to +/// `#[derive(PartialEq)]` to be a structural type. +fn extend_type_not_partial_eq<'tcx>( + tcx: TyCtxt<'tcx>, + typing_env: ty::TypingEnv<'tcx>, + ty: Ty<'tcx>, + err: &mut Diag<'_>, +) { + /// Collect all types that need to be `StructuralPartialEq`. + struct UsedParamsNeedInstantiationVisitor<'tcx> { + tcx: TyCtxt<'tcx>, + typing_env: ty::TypingEnv<'tcx>, + /// The user has written `impl PartialEq for Ty` which means it's non-structual. + adts_with_manual_partialeq: FxHashSet, + /// The type has no `PartialEq` implementation, neither manual or derived. + adts_without_partialeq: FxHashSet, + /// The user has written `impl PartialEq for Ty` which means it's non-structual, + /// but we don't have a span to point at, so we'll just add them as a `note`. + manual: Vec>, + /// The type has no `PartialEq` implementation, neither manual or derived, but + /// we don't have a span to point at, so we'll just add them as a `note`. + without: Vec>, + } + + impl<'tcx> TypeVisitor> for UsedParamsNeedInstantiationVisitor<'tcx> { + fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result { + if let ty::Adt(def, _args) = ty.kind() { + let ty_def_id = def.did(); + let ty_def_span = self.tcx.def_span(ty_def_id); + let (impls_partial_eq, derived, structural, impl_def_id) = + type_has_partial_eq_impl(self.tcx, self.typing_env, ty); + match (impls_partial_eq, derived, structural, impl_def_id) { + (_, _, true, _) => {} + (true, false, _, Some(def_id)) if def_id.is_local() => { + self.adts_with_manual_partialeq.insert(self.tcx.def_span(def_id)); + } + (true, false, _, _) if ty_def_id.is_local() => { + self.adts_with_manual_partialeq.insert(ty_def_span); + } + (false, _, _, _) if ty_def_id.is_local() => { + self.adts_without_partialeq.insert(ty_def_span); + } + (true, false, _, _) => { + self.manual.push(ty); + } + (false, _, _, _) => { + self.without.push(ty); + } + _ => {} + }; + } + use rustc_middle::ty::TypeSuperVisitable; + ty.super_visit_with(self) + } + } + let mut v = UsedParamsNeedInstantiationVisitor { + tcx, + typing_env, + adts_with_manual_partialeq: FxHashSet::default(), + adts_without_partialeq: FxHashSet::default(), + manual: vec![], + without: vec![], + }; + v.visit_ty(ty); + #[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering + for span in v.adts_with_manual_partialeq { + err.span_note(span, "the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"); + } + #[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering + for span in v.adts_without_partialeq { + err.span_label( + span, + "must be annotated with `#[derive(PartialEq)]` to be usable in patterns", + ); + } + for ty in v.manual { + err.note(format!( + "`{ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details" + )); + } + for ty in v.without { + err.note(format!( + "`{ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns" + )); + } +} + +#[instrument(level = "trace", skip(tcx), ret)] +fn type_has_partial_eq_impl<'tcx>( + tcx: TyCtxt<'tcx>, + typing_env: ty::TypingEnv<'tcx>, + ty: Ty<'tcx>, +) -> ( + /* has impl */ bool, + /* is derived */ bool, + /* structural partial eq */ bool, + /* non-blanket impl */ Option, +) { + let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env); + // double-check there even *is* a semantic `PartialEq` to dispatch to. + // + // (If there isn't, then we can safely issue a hard + // error, because that's never worked, due to compiler + // using `PartialEq::eq` in this scenario in the past.) + let partial_eq_trait_id = tcx.require_lang_item(hir::LangItem::PartialEq, None); + let structural_partial_eq_trait_id = tcx.require_lang_item(hir::LangItem::StructuralPeq, None); + + let partial_eq_obligation = Obligation::new( + tcx, + ObligationCause::dummy(), + param_env, + ty::TraitRef::new(tcx, partial_eq_trait_id, [ty, ty]), + ); + + let mut automatically_derived = false; + let mut structural_peq = false; + let mut impl_def_id = None; + for def_id in tcx.non_blanket_impls_for_ty(partial_eq_trait_id, ty) { + automatically_derived = tcx.has_attr(def_id, sym::automatically_derived); + impl_def_id = Some(def_id); + } + for _ in tcx.non_blanket_impls_for_ty(structural_partial_eq_trait_id, ty) { + structural_peq = true; + } + // This *could* accept a type that isn't actually `PartialEq`, because region bounds get + // ignored. However that should be pretty much impossible since consts that do not depend on + // generics can only mention the `'static` lifetime, and how would one have a type that's + // `PartialEq` for some lifetime but *not* for `'static`? If this ever becomes a problem + // we'll need to leave some sort of trace of this requirement in the MIR so that borrowck + // can ensure that the type really implements `PartialEq`. + ( + infcx.predicate_must_hold_modulo_regions(&partial_eq_obligation), + automatically_derived, + structural_peq, + impl_def_id, + ) +} diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr index bd9748b5dda9..511a38bbc00d 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.stderr +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -1,13 +1,15 @@ error: constant of non-structural type `&[O]` in a pattern --> $DIR/issue-65466.rs:14:9 | +LL | struct B; + | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns +LL | LL | const C: &[O] = &[O::None]; | ---------------- constant defined here ... LL | C => (), | ^ constant of non-structural type | - = note: `&[O]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index 0ef5286e6893..43894f008862 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -1,13 +1,15 @@ error: constant of non-structural type `Option` in a pattern --> $DIR/reject_non_partial_eq.rs:28:9 | +LL | struct NoPartialEq(u32); + | ------------------ must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const NO_PARTIAL_EQ_NONE: Option = None; | --------------------------------------------- constant defined here ... LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), | ^^^^^^^^^^^^^^^^^^ constant of non-structural type | - = note: `Option` must be annotated with `#[derive(PartialEq)]` to be usable in patterns = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr index 4287fbc188d5..1f82d3e822ad 100644 --- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -1,13 +1,15 @@ error: constant of non-structural type `EnumSet` in a pattern --> $DIR/issue-72896-non-partial-eq-const.rs:19:9 | +LL | enum Enum8 { } + | ---------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns +... LL | const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; | ------------------------------- constant defined here ... LL | CONST_SET => { /* ok */ } | ^^^^^^^^^ constant of non-structural type | - = note: `EnumSet` must be annotated with `#[derive(PartialEq)]` to be usable in patterns = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index 4f83ca02c287..7d3b37686b86 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -1,13 +1,15 @@ error: constant of non-structural type `&[B]` in a pattern --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | +LL | struct B(i32); + | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns +LL | LL | const A: &[B] = &[]; | ------------- constant defined here ... LL | A => (), | ^ constant of non-structural type | - = note: `&[B]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details error: aborting due to 1 previous error From da58406c73524054e9915aee4aa44d415868be6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Nov 2024 23:10:52 +0000 Subject: [PATCH 51/59] fix test --- tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 8175fe6016ab..18935626af1c 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -7,12 +7,6 @@ LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -error: could not evaluate constant pattern - --> $DIR/ref_to_int_match.rs:7:14 - | -LL | 10..=BAR => {}, - | ^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. From 81291ec7eaf824d748ef8d3201d13df444ada4ef Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 4 Dec 2024 20:29:02 +0000 Subject: [PATCH 52/59] No need to create placeholders for GAT args in confirm_object_candidate --- .../src/traits/select/confirmation.rs | 54 +------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 19b4125e75cd..2fbe2e1e323b 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -16,9 +16,7 @@ use rustc_hir::lang_items::LangItem; use rustc_infer::infer::{DefineOpaqueTypes, HigherRankedType, InferOk}; use rustc_infer::traits::ObligationCauseCode; use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData}; -use rustc_middle::ty::{ - self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, Ty, TyCtxt, Upcast, -}; +use rustc_middle::ty::{self, GenericArgsRef, ToPolyTraitRef, Ty, TyCtxt, Upcast}; use rustc_middle::{bug, span_bug}; use rustc_span::def_id::DefId; use tracing::{debug, instrument}; @@ -638,60 +636,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // higher-ranked things. // Prevent, e.g., `dyn Iterator`. for bound in self.tcx().item_bounds(assoc_type).transpose_iter() { - let arg_bound = if defs.is_empty() { - bound.instantiate(tcx, trait_predicate.trait_ref.args) - } else { - let mut args = smallvec::SmallVec::with_capacity(defs.count()); - args.extend(trait_predicate.trait_ref.args.iter()); - let mut bound_vars: smallvec::SmallVec<[ty::BoundVariableKind; 8]> = - smallvec::SmallVec::with_capacity( - bound.skip_binder().kind().bound_vars().len() + defs.count(), - ); - bound_vars.extend(bound.skip_binder().kind().bound_vars().into_iter()); - GenericArgs::fill_single(&mut args, defs, &mut |param, _| match param.kind { - GenericParamDefKind::Type { .. } => { - let kind = ty::BoundTyKind::Param(param.def_id, param.name); - let bound_var = ty::BoundVariableKind::Ty(kind); - bound_vars.push(bound_var); - Ty::new_bound(tcx, ty::INNERMOST, ty::BoundTy { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind, - }) - .into() - } - GenericParamDefKind::Lifetime => { - let kind = ty::BoundRegionKind::Named(param.def_id, param.name); - let bound_var = ty::BoundVariableKind::Region(kind); - bound_vars.push(bound_var); - ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind, - }) - .into() - } - GenericParamDefKind::Const { .. } => { - let bound_var = ty::BoundVariableKind::Const; - bound_vars.push(bound_var); - ty::Const::new_bound( - tcx, - ty::INNERMOST, - ty::BoundVar::from_usize(bound_vars.len() - 1), - ) - .into() - } - }); - let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars); - let assoc_ty_args = tcx.mk_args(&args); - let bound = - bound.map_bound(|b| b.kind().skip_binder()).instantiate(tcx, assoc_ty_args); - ty::Binder::bind_with_vars(bound, bound_vars).upcast(tcx) - }; let normalized_bound = normalize_with_depth_to( self, obligation.param_env, obligation.cause.clone(), obligation.recursion_depth + 1, - arg_bound, + bound.instantiate(tcx, trait_predicate.trait_ref.args), &mut nested, ); nested.push(obligation.with(tcx, normalized_bound)); From 4e6a401b224342287469a1a294bba7ad10e8641c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Dec 2024 20:49:05 +0000 Subject: [PATCH 53/59] review comments: reword messages and simplify logic --- compiler/rustc_mir_build/messages.ftl | 2 +- .../src/thir/pattern/const_to_pat.rs | 64 +++++++------------ ...associated-const-type-parameter-pattern.rs | 8 +-- ...ciated-const-type-parameter-pattern.stderr | 16 ++--- tests/ui/consts/issue-73976-polymorphic.rs | 4 +- .../ui/consts/issue-73976-polymorphic.stderr | 8 +-- tests/ui/consts/issue-79137-toogeneric.rs | 2 +- tests/ui/consts/issue-79137-toogeneric.stderr | 4 +- .../inline-const/const-match-pat-generic.rs | 4 +- .../const-match-pat-generic.stderr | 4 +- 10 files changed, 48 insertions(+), 68 deletions(-) diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index f35252dbcc55..f647486f62ad 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -90,7 +90,7 @@ mir_build_const_param_in_pattern = constant parameters cannot be referenced in p .label = can't be used in patterns mir_build_const_param_in_pattern_def = constant defined here -mir_build_const_pattern_depends_on_generic_parameter = constant pattern depends on a generic parameter, which is not allowed +mir_build_const_pattern_depends_on_generic_parameter = constant pattern cannot depend on generic parameters .label = `const` depends on a generic parameter mir_build_could_not_eval_const_pattern = could not evaluate constant pattern diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index feb6d2fcfe9c..aed00aecefc9 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -1,7 +1,7 @@ use rustc_abi::{FieldIdx, VariantIdx}; use rustc_apfloat::Float; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{Diag, PResult}; +use rustc_errors::Diag; use rustc_hir as hir; use rustc_index::Idx; use rustc_infer::infer::TyCtxtInferExt; @@ -42,10 +42,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { match c.kind() { ty::ConstKind::Unevaluated(uv) => convert.unevaluated_to_pat(uv, ty), - ty::ConstKind::Value(_, val) => match convert.valtree_to_pat(val, ty) { - Ok(pat) => pat, - Err(err) => convert.mk_err(err, ty), - }, + ty::ConstKind::Value(_, val) => convert.valtree_to_pat(val, ty), _ => span_bug!(span, "Invalid `ConstKind` for `const_to_pat`: {:?}", c), } } @@ -151,7 +148,7 @@ impl<'tcx> ConstToPat<'tcx> { let generics = self.tcx.generics_of(def_id); let param = generics.type_param(*param_ty, self.tcx); let span = self.tcx.def_span(param.def_id); - e.span_label(span, "constant depends on this generic param"); + e.span_label(span, "constant depends on this generic parameter"); if let Some(ident) = self.tcx.def_ident_span(def_id) && self.tcx.sess.source_map().is_multiline(ident.between(span)) { @@ -184,10 +181,7 @@ impl<'tcx> ConstToPat<'tcx> { }; // Convert the valtree to a const. - let inlined_const_as_pat = match self.valtree_to_pat(valtree, ty) { - Ok(pat) => pat, - Err(err) => self.mk_err(err, ty), - }; + let inlined_const_as_pat = self.valtree_to_pat(valtree, ty); if !inlined_const_as_pat.references_error() { // Always check for `PartialEq` if we had no other errors yet. @@ -210,20 +204,14 @@ impl<'tcx> ConstToPat<'tcx> { let field = FieldIdx::new(idx); // Patterns can only use monomorphic types. let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty); - FieldPat { - field, - pattern: match self.valtree_to_pat(val, ty) { - Ok(pat) => pat, - Err(err) => self.mk_err(err, ty), - }, - } + FieldPat { field, pattern: self.valtree_to_pat(val, ty) } }) .collect() } // Recursive helper for `to_pat`; invoke that (instead of calling this directly). #[instrument(skip(self), level = "debug")] - fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> PResult<'_, Box>> { + fn valtree_to_pat(&self, cv: ValTree<'tcx>, ty: Ty<'tcx>) -> Box> { let span = self.span; let tcx = self.tcx; let kind = match ty.kind() { @@ -231,12 +219,12 @@ impl<'tcx> ConstToPat<'tcx> { // Extremely important check for all ADTs! Make sure they opted-in to be used in // patterns. debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty); - let (impls_partial_eq, derived, structural, impl_def_id) = + let (_impls_partial_eq, derived, structural, impl_def_id) = type_has_partial_eq_impl(self.tcx, self.typing_env, ty); let (manual_partialeq_impl_span, manual_partialeq_impl_note) = - match (impls_partial_eq, derived, structural, impl_def_id) { - (_, _, true, _) => (None, false), - (_, false, _, Some(def_id)) if def_id.is_local() => { + match (structural, impl_def_id) { + (true, _) => (None, false), + (_, Some(def_id)) if def_id.is_local() && !derived => { (Some(tcx.def_span(def_id)), false) } _ => (None, true), @@ -249,7 +237,7 @@ impl<'tcx> ConstToPat<'tcx> { manual_partialeq_impl_span, manual_partialeq_impl_note, }; - return Err(tcx.dcx().create_err(err)); + return self.mk_err(tcx.dcx().create_err(err), ty); } ty::Adt(adt_def, args) if adt_def.is_enum() => { let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap(); @@ -283,10 +271,7 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| match self.valtree_to_pat(*val, *elem_ty) { - Ok(pat) => pat, - Err(err) => self.mk_err(err, ty), - }) + .map(|val| self.valtree_to_pat(*val, *elem_ty)) .collect(), slice: None, suffix: Box::new([]), @@ -295,10 +280,7 @@ impl<'tcx> ConstToPat<'tcx> { prefix: cv .unwrap_branch() .iter() - .map(|val| match self.valtree_to_pat(*val, *elem_ty) { - Ok(pat) => pat, - Err(err) => self.mk_err(err, ty), - }) + .map(|val| self.valtree_to_pat(*val, *elem_ty)) .collect(), slice: None, suffix: Box::new([]), @@ -314,9 +296,10 @@ impl<'tcx> ConstToPat<'tcx> { // deref pattern. _ => { if !pointee_ty.is_sized(tcx, self.typing_env) && !pointee_ty.is_slice() { - return Err(tcx - .dcx() - .create_err(UnsizedPattern { span, non_sm_ty: *pointee_ty })); + return self.mk_err( + tcx.dcx().create_err(UnsizedPattern { span, non_sm_ty: *pointee_ty }), + ty, + ); } else { // `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when // matching against references, you can only use byte string literals. @@ -331,10 +314,7 @@ impl<'tcx> ConstToPat<'tcx> { _ => *pointee_ty, }; // References have the same valtree representation as their pointee. - let subpattern = match self.valtree_to_pat(cv, pointee_ty) { - Ok(pat) => pat, - Err(err) => self.mk_err(err, ty), - }; + let subpattern = self.valtree_to_pat(cv, pointee_ty); PatKind::Deref { subpattern } } } @@ -350,7 +330,7 @@ impl<'tcx> ConstToPat<'tcx> { if is_nan { // NaNs are not ever equal to anything so they make no sense as patterns. // Also see . - return Err(tcx.dcx().create_err(NaNPattern { span })); + return self.mk_err(tcx.dcx().create_err(NaNPattern { span }), ty); } else { PatKind::Constant { value: mir::Const::Ty(ty, ty::Const::new_value(tcx, cv, ty)), @@ -373,16 +353,16 @@ impl<'tcx> ConstToPat<'tcx> { non_sm_ty: ty, prefix: ty.prefix_string(tcx).to_string(), }; - return Err(tcx.dcx().create_err(err)); + return self.mk_err(tcx.dcx().create_err(err), ty); } }; - Ok(Box::new(Pat { span, ty, kind })) + Box::new(Pat { span, ty, kind }) } } /// Given a type with type parameters, visit every ADT looking for types that need to -/// `#[derive(PartialEq)]` to be a structural type. +/// `#[derive(PartialEq)]` for it to be a structural type. fn extend_type_not_partial_eq<'tcx>( tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.rs b/tests/ui/associated-consts/associated-const-type-parameter-pattern.rs index b5798adc71c8..e6c80a7e54e8 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.rs +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.rs @@ -18,17 +18,17 @@ impl Foo for Def { pub fn test(arg: EFoo) { match arg { A::X => println!("A::X"), - //~^ error: constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters B::X => println!("B::X"), - //~^ error: constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters _ => (), } } pub fn test_let_pat(arg: EFoo, A::X: EFoo) { - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters let A::X = arg; - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters } fn main() { diff --git a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr index 455831e8401c..a8256f775a68 100644 --- a/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr +++ b/tests/ui/associated-consts/associated-const-type-parameter-pattern.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { @@ -7,12 +7,12 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test(arg: EFoo) { - | - constant depends on this generic param + | - constant depends on this generic parameter LL | match arg { LL | A::X => println!("A::X"), | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/associated-const-type-parameter-pattern.rs:22:9 | LL | pub trait Foo { @@ -21,12 +21,12 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test(arg: EFoo) { - | - constant depends on this generic param + | - constant depends on this generic parameter ... LL | B::X => println!("B::X"), | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/associated-const-type-parameter-pattern.rs:30:9 | LL | pub trait Foo { @@ -35,12 +35,12 @@ LL | const X: EFoo; | ------------- constant defined here ... LL | pub fn test_let_pat(arg: EFoo, A::X: EFoo) { - | - constant depends on this generic param + | - constant depends on this generic parameter LL | LL | let A::X = arg; | ^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/associated-const-type-parameter-pattern.rs:28:48 | LL | pub trait Foo { @@ -51,7 +51,7 @@ LL | const X: EFoo; LL | pub fn test_let_pat(arg: EFoo, A::X: EFoo) { | - ^^^^ `const` depends on a generic parameter | | - | constant depends on this generic param + | constant depends on this generic parameter error: aborting due to 4 previous errors diff --git a/tests/ui/consts/issue-73976-polymorphic.rs b/tests/ui/consts/issue-73976-polymorphic.rs index 2c576d1f9ef0..98b4005792db 100644 --- a/tests/ui/consts/issue-73976-polymorphic.rs +++ b/tests/ui/consts/issue-73976-polymorphic.rs @@ -18,7 +18,7 @@ impl GetTypeId { const fn check_type_id() -> bool { matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters } pub struct GetTypeNameLen(T); @@ -29,7 +29,7 @@ impl GetTypeNameLen { const fn check_type_name_len() -> bool { matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters } fn main() { diff --git a/tests/ui/consts/issue-73976-polymorphic.stderr b/tests/ui/consts/issue-73976-polymorphic.stderr index 2f50e6ac2fd4..ec9512a26163 100644 --- a/tests/ui/consts/issue-73976-polymorphic.stderr +++ b/tests/ui/consts/issue-73976-polymorphic.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/issue-73976-polymorphic.rs:20:37 | LL | impl GetTypeId { @@ -7,11 +7,11 @@ LL | pub const VALUE: TypeId = TypeId::of::(); | ----------------------- constant defined here ... LL | const fn check_type_id() -> bool { - | - constant depends on this generic param + | - constant depends on this generic parameter LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | impl GetTypeNameLen { @@ -20,7 +20,7 @@ LL | pub const VALUE: usize = any::type_name::().len(); | ---------------------- constant defined here ... LL | const fn check_type_name_len() -> bool { - | - constant depends on this generic param + | - constant depends on this generic parameter LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter diff --git a/tests/ui/consts/issue-79137-toogeneric.rs b/tests/ui/consts/issue-79137-toogeneric.rs index a80c9f48d7bc..43e06f3d6766 100644 --- a/tests/ui/consts/issue-79137-toogeneric.rs +++ b/tests/ui/consts/issue-79137-toogeneric.rs @@ -10,7 +10,7 @@ impl GetVariantCount { const fn check_variant_count() -> bool { matches!(GetVariantCount::::VALUE, GetVariantCount::::VALUE) - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters } fn main() { diff --git a/tests/ui/consts/issue-79137-toogeneric.stderr b/tests/ui/consts/issue-79137-toogeneric.stderr index d36f3ecbb769..33e32a7d15dc 100644 --- a/tests/ui/consts/issue-79137-toogeneric.stderr +++ b/tests/ui/consts/issue-79137-toogeneric.stderr @@ -1,4 +1,4 @@ -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/issue-79137-toogeneric.rs:12:43 | LL | impl GetVariantCount { @@ -7,7 +7,7 @@ LL | pub const VALUE: usize = std::mem::variant_count::(); | ---------------------- constant defined here ... LL | const fn check_variant_count() -> bool { - | - constant depends on this generic param + | - constant depends on this generic parameter LL | matches!(GetVariantCount::::VALUE, GetVariantCount::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `const` depends on a generic parameter diff --git a/tests/ui/inline-const/const-match-pat-generic.rs b/tests/ui/inline-const/const-match-pat-generic.rs index 9d76fc2ad65b..889c015e9acb 100644 --- a/tests/ui/inline-const/const-match-pat-generic.rs +++ b/tests/ui/inline-const/const-match-pat-generic.rs @@ -5,7 +5,7 @@ fn foo() { match 0 { const { V } => {}, - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters _ => {}, } } @@ -17,7 +17,7 @@ const fn f(x: usize) -> usize { fn bar() { match 0 { const { f(V) } => {}, - //~^ ERROR constant pattern depends on a generic parameter + //~^ ERROR constant pattern cannot depend on generic parameters _ => {}, } } diff --git a/tests/ui/inline-const/const-match-pat-generic.stderr b/tests/ui/inline-const/const-match-pat-generic.stderr index cf48161b5e3d..7d9e1d9e407e 100644 --- a/tests/ui/inline-const/const-match-pat-generic.stderr +++ b/tests/ui/inline-const/const-match-pat-generic.stderr @@ -1,10 +1,10 @@ -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/const-match-pat-generic.rs:7:9 | LL | const { V } => {}, | ^^^^^^^^^^^ `const` depends on a generic parameter -error[E0158]: constant pattern depends on a generic parameter, which is not allowed +error[E0158]: constant pattern cannot depend on generic parameters --> $DIR/const-match-pat-generic.rs:19:9 | LL | const { f(V) } => {}, From 03aec5dbef301219a288c46401d2bf0079724929 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 16 Nov 2024 19:00:28 +0000 Subject: [PATCH 54/59] fn_sig_for_fn_abi should return a ty::FnSig, no need for a binder --- compiler/rustc_mir_transform/src/shim.rs | 4 +- compiler/rustc_ty_utils/src/abi.rs | 130 +++++++++-------------- 2 files changed, 52 insertions(+), 82 deletions(-) diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 809357ec1100..b8383e734e2b 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -747,8 +747,8 @@ fn build_call_shim<'tcx>( sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output); } - // FIXME(eddyb) avoid having this snippet both here and in - // `Instance::fn_sig` (introduce `InstanceKind::fn_sig`?). + // FIXME: Avoid having to adjust the signature both here and in + // `fn_sig_for_fn_abi`. if let ty::InstanceKind::VTableShim(..) = instance { // Modify fn(self, ...) to fn(self: *mut Self, ...) let mut inputs_and_output = sig.inputs_and_output.to_vec(); diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index a5a9125c8b50..b746d6299efd 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -31,20 +31,20 @@ fn fn_sig_for_fn_abi<'tcx>( tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, typing_env: ty::TypingEnv<'tcx>, -) -> ty::PolyFnSig<'tcx> { +) -> ty::FnSig<'tcx> { if let InstanceKind::ThreadLocalShim(..) = instance.def { - return ty::Binder::dummy(tcx.mk_fn_sig( + return tcx.mk_fn_sig( [], tcx.thread_local_ptr_ty(instance.def_id()), false, hir::Safety::Safe, rustc_abi::ExternAbi::Unadjusted, - )); + ); } let ty = instance.ty(tcx, typing_env); match *ty.kind() { - ty::FnDef(..) => { + ty::FnDef(def_id, args) => { // HACK(davidtwco,eddyb): This is a workaround for polymorphization considering // parameters unused if they show up in the signature, but not in the `mir::Body` // (i.e. due to being inside a projection that got normalized, see @@ -52,9 +52,8 @@ fn fn_sig_for_fn_abi<'tcx>( // track of a polymorphization `ParamEnv` to allow normalizing later. // // We normalize the `fn_sig` again after instantiating at a later point. - let mut sig = match *ty.kind() { - ty::FnDef(def_id, args) => tcx - .fn_sig(def_id) + let mut sig = tcx.instantiate_bound_regions_with_erased( + tcx.fn_sig(def_id) .map_bound(|fn_sig| { tcx.normalize_erasing_regions( ty::TypingEnv::non_body_analysis(tcx, def_id), @@ -62,62 +61,36 @@ fn fn_sig_for_fn_abi<'tcx>( ) }) .instantiate(tcx, args), - _ => unreachable!(), - }; + ); if let ty::InstanceKind::VTableShim(..) = instance.def { - // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`. - sig = sig.map_bound(|mut sig| { - let mut inputs_and_output = sig.inputs_and_output.to_vec(); - inputs_and_output[0] = Ty::new_mut_ptr(tcx, inputs_and_output[0]); - sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output); - sig - }); + let mut inputs_and_output = sig.inputs_and_output.to_vec(); + inputs_and_output[0] = Ty::new_mut_ptr(tcx, inputs_and_output[0]); + sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output); } + sig } ty::Closure(def_id, args) => { - let sig = args.as_closure().sig(); - - let bound_vars = - tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once( - ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), - ))); - let br = ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::ClosureEnv, - }; - let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); + let sig = tcx.instantiate_bound_regions_with_erased(args.as_closure().sig()); let env_ty = tcx.closure_env_ty( Ty::new_closure(tcx, def_id, args), args.as_closure().kind(), - env_region, + tcx.lifetimes.re_erased, ); - let sig = sig.skip_binder(); - ty::Binder::bind_with_vars( - tcx.mk_fn_sig( - iter::once(env_ty).chain(sig.inputs().iter().cloned()), - sig.output(), - sig.c_variadic, - sig.safety, - sig.abi, - ), - bound_vars, + tcx.mk_fn_sig( + iter::once(env_ty).chain(sig.inputs().iter().cloned()), + sig.output(), + sig.c_variadic, + sig.safety, + sig.abi, ) } ty::CoroutineClosure(def_id, args) => { let coroutine_ty = Ty::new_coroutine_closure(tcx, def_id, args); let sig = args.as_coroutine_closure().coroutine_closure_sig(); - let bound_vars = - tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once( - ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), - ))); - let br = ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::ClosureEnv, - }; - let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); + // When this `CoroutineClosure` comes from a `ConstructCoroutineInClosureShim`, // make sure we respect the `target_kind` in that shim. // FIXME(async_closures): This shouldn't be needed, and we should be populating @@ -138,42 +111,32 @@ fn fn_sig_for_fn_abi<'tcx>( coroutine_ty } } else { - tcx.closure_env_ty(coroutine_ty, coroutine_kind, env_region) + tcx.closure_env_ty(coroutine_ty, coroutine_kind, tcx.lifetimes.re_erased) }; - let sig = sig.skip_binder(); - ty::Binder::bind_with_vars( - tcx.mk_fn_sig( - iter::once(env_ty).chain([sig.tupled_inputs_ty]), - sig.to_coroutine_given_kind_and_upvars( - tcx, - args.as_coroutine_closure().parent_args(), - tcx.coroutine_for_closure(def_id), - coroutine_kind, - env_region, - args.as_coroutine_closure().tupled_upvars_ty(), - args.as_coroutine_closure().coroutine_captures_by_ref_ty(), - ), - sig.c_variadic, - sig.safety, - sig.abi, + let sig = tcx.instantiate_bound_regions_with_erased(sig); + + tcx.mk_fn_sig( + iter::once(env_ty).chain([sig.tupled_inputs_ty]), + sig.to_coroutine_given_kind_and_upvars( + tcx, + args.as_coroutine_closure().parent_args(), + tcx.coroutine_for_closure(def_id), + coroutine_kind, + tcx.lifetimes.re_erased, + args.as_coroutine_closure().tupled_upvars_ty(), + args.as_coroutine_closure().coroutine_captures_by_ref_ty(), ), - bound_vars, + sig.c_variadic, + sig.safety, + sig.abi, ) } ty::Coroutine(did, args) => { let coroutine_kind = tcx.coroutine_kind(did).unwrap(); let sig = args.as_coroutine().sig(); - let bound_vars = tcx.mk_bound_variable_kinds_from_iter(iter::once( - ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), - )); - let br = ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::ClosureEnv, - }; - - let env_ty = Ty::new_mut_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), ty); + let env_ty = Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, ty); let pin_did = tcx.require_lang_item(LangItem::Pin, None); let pin_adt_ref = tcx.adt_def(pin_did); @@ -268,7 +231,7 @@ fn fn_sig_for_fn_abi<'tcx>( } }; - let fn_sig = if let Some(resume_ty) = resume_ty { + if let Some(resume_ty) = resume_ty { tcx.mk_fn_sig( [env_ty, resume_ty], ret_ty, @@ -285,8 +248,7 @@ fn fn_sig_for_fn_abi<'tcx>( hir::Safety::Safe, rustc_abi::ExternAbi::Rust, ) - }; - ty::Binder::bind_with_vars(fn_sig, bound_vars) + } } _ => bug!("unexpected type {:?} in Instance::fn_sig", ty), } @@ -335,8 +297,16 @@ fn fn_abi_of_fn_ptr<'tcx>( query: ty::PseudoCanonicalInput<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List>)>, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> { let ty::PseudoCanonicalInput { typing_env, value: (sig, extra_args) } = query; + let cx = LayoutCx::new(tcx, typing_env); - fn_abi_new_uncached(&cx, sig, extra_args, None, None, false) + fn_abi_new_uncached( + &cx, + tcx.instantiate_bound_regions_with_erased(sig), + extra_args, + None, + None, + false, + ) } fn fn_abi_of_instance<'tcx>( @@ -567,7 +537,7 @@ fn fn_abi_sanity_check<'tcx>( #[tracing::instrument(level = "debug", skip(cx, caller_location, fn_def_id, force_thin_self_ptr))] fn fn_abi_new_uncached<'tcx>( cx: &LayoutCx<'tcx>, - sig: ty::PolyFnSig<'tcx>, + sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>], caller_location: Option>, fn_def_id: Option, @@ -575,7 +545,7 @@ fn fn_abi_new_uncached<'tcx>( force_thin_self_ptr: bool, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> { let tcx = cx.tcx(); - let sig = tcx.normalize_erasing_late_bound_regions(cx.typing_env, sig); + let sig = tcx.normalize_erasing_regions(cx.typing_env, sig); let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic); From 1c14127fd6985dddc5f66962b0ac265459a0ff58 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 4 Dec 2024 15:42:24 -0800 Subject: [PATCH 55/59] Update edition-guide and reference --- src/doc/edition-guide | 2 +- src/doc/reference | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/edition-guide b/src/doc/edition-guide index f48b0e842a39..128669297c8a 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit f48b0e842a3911c63240e955d042089e9e0894c7 +Subproject commit 128669297c8a7fdf771042eaec18b8adfaeaf0cd diff --git a/src/doc/reference b/src/doc/reference index 8a0b8a4158d9..ede56d1bbe13 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 8a0b8a4158d9aa961de423b7afcd95521c5deb6a +Subproject commit ede56d1bbe132bac476b5029cd6d7508ca9572e9 From 892d5850fb7a6b9e8ddabbf0c5db3292aef19667 Mon Sep 17 00:00:00 2001 From: kei519 Date: Thu, 5 Dec 2024 12:06:14 +0900 Subject: [PATCH 56/59] Add a new test ui/incoherent-inherent-impls/no-other-unrelated-errors to check E0116 does not cause unrelated errors rustc xxx (we do not know) to 1.82.0 emits unrelated errors when E0116 is present (see #125814). We do not know what caused and fixed it, but add a test to confirm rustc does not cause the same error in the future. --- .../no-other-unrelated-errors.rs | 8 ++++++++ .../no-other-unrelated-errors.stderr | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.rs create mode 100644 tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr diff --git a/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.rs b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.rs new file mode 100644 index 000000000000..8eaa0c9194a8 --- /dev/null +++ b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.rs @@ -0,0 +1,8 @@ +// E0116 caused other unrelated errors, so check no unrelated errors are emmitted. + +fn main() { + let x = "hello"; + x.split(" "); +} + +impl Vec {} //~ ERROR E0116 diff --git a/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr new file mode 100644 index 000000000000..2a33262f8389 --- /dev/null +++ b/tests/ui/incoherent-inherent-impls/no-other-unrelated-errors.stderr @@ -0,0 +1,11 @@ +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/no-other-unrelated-errors.rs:8:1 + | +LL | impl Vec {} + | ^^^^^^^^^^^^^^^ impl for type defined outside of crate + | + = note: define and implement a trait or new type instead + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0116`. From 5b75493d9958a519a743673a6707fd52af7cf3b7 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Thu, 5 Dec 2024 05:59:28 +0000 Subject: [PATCH 57/59] Revert "Rollup merge of #133817 - clubby789:bootstrap-eprintln, r=jieyouxu" This reverts commit 0585134e709de4a14e509158662fa569c155c195, reversing changes made to 5530869e0ff21d69e0eef1a4c4fd1f25bcbe7fbf. The PR unfortunately only converted the `ln!` instances, meaning that test output was messed up because stdout/stderr output interleaved when some `println!` instances were converted to `eprintln!` instances, while some `println!` instances remain unchanged. --- src/bootstrap/src/bin/main.rs | 20 +++---- src/bootstrap/src/bin/rustc.rs | 2 +- src/bootstrap/src/core/build_steps/check.rs | 2 +- src/bootstrap/src/core/build_steps/compile.rs | 10 ++-- src/bootstrap/src/core/build_steps/dist.rs | 2 +- src/bootstrap/src/core/build_steps/format.rs | 6 +- src/bootstrap/src/core/build_steps/setup.rs | 40 ++++++------- src/bootstrap/src/core/build_steps/suggest.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 6 +- src/bootstrap/src/core/builder/cargo.rs | 2 +- src/bootstrap/src/core/builder/mod.rs | 14 ++--- src/bootstrap/src/core/config/config.rs | 60 +++++++++---------- src/bootstrap/src/core/config/flags.rs | 4 +- src/bootstrap/src/core/download.rs | 26 ++++---- src/bootstrap/src/core/sanity.rs | 4 +- src/bootstrap/src/lib.rs | 28 ++++----- src/bootstrap/src/utils/cc_detect.rs | 10 ++-- src/bootstrap/src/utils/helpers.rs | 6 +- src/bootstrap/src/utils/metrics.rs | 2 +- src/bootstrap/src/utils/render_tests.rs | 36 ++++++----- src/bootstrap/src/utils/tarball.rs | 2 +- src/tools/compiletest/src/compute_diff.rs | 2 +- src/tools/compiletest/src/debuggers.rs | 6 +- src/tools/compiletest/src/lib.rs | 10 ++-- src/tools/compiletest/src/runtest.rs | 50 ++++++++-------- .../compiletest/src/runtest/codegen_units.rs | 22 +++---- .../compiletest/src/runtest/debuginfo.rs | 10 ++-- .../compiletest/src/runtest/rustdoc_json.rs | 2 +- src/tools/compiletest/src/runtest/ui.rs | 4 +- src/tools/compiletest/src/util.rs | 2 +- src/tools/tidy/src/error_codes.rs | 6 +- src/tools/tidy/src/features.rs | 8 +-- src/tools/tidy/src/unstable_book.rs | 8 +-- src/tools/tidy/src/x_version.rs | 2 +- 34 files changed, 206 insertions(+), 210 deletions(-) diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index 74dfe2e7ec80..ee813de1c9e2 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -48,9 +48,9 @@ fn main() { err => { drop(err); if let Ok(pid) = pid { - eprintln!("WARNING: build directory locked by process {pid}, waiting for lock"); + println!("WARNING: build directory locked by process {pid}, waiting for lock"); } else { - eprintln!("WARNING: build directory locked, waiting for lock"); + println!("WARNING: build directory locked, waiting for lock"); } let mut lock = t!(build_lock.write()); t!(lock.write(process::id().to_string().as_ref())); @@ -70,13 +70,13 @@ fn main() { // changelog warning, not the `x.py setup` message. let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. }); if suggest_setup { - eprintln!("WARNING: you have not made a `config.toml`"); - eprintln!( + println!("WARNING: you have not made a `config.toml`"); + println!( "HELP: consider running `./x.py setup` or copying `config.example.toml` by running \ `cp config.example.toml config.toml`" ); } else if let Some(suggestion) = &changelog_suggestion { - eprintln!("{suggestion}"); + println!("{suggestion}"); } let pre_commit = config.src.join(".git").join("hooks").join("pre-commit"); @@ -86,13 +86,13 @@ fn main() { Build::new(config).build(); if suggest_setup { - eprintln!("WARNING: you have not made a `config.toml`"); - eprintln!( + println!("WARNING: you have not made a `config.toml`"); + println!( "HELP: consider running `./x.py setup` or copying `config.example.toml` by running \ `cp config.example.toml config.toml`" ); } else if let Some(suggestion) = &changelog_suggestion { - eprintln!("{suggestion}"); + println!("{suggestion}"); } // Give a warning if the pre-commit script is in pre-commit and not pre-push. @@ -102,14 +102,14 @@ fn main() { if fs::read_to_string(pre_commit).is_ok_and(|contents| { contents.contains("https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570") }) { - eprintln!( + println!( "WARNING: You have the pre-push script installed to .git/hooks/pre-commit. \ Consider moving it to .git/hooks/pre-push instead, which runs less often." ); } if suggest_setup || changelog_suggestion.is_some() { - eprintln!("NOTE: this message was printed twice to make it more likely to be seen"); + println!("NOTE: this message was printed twice to make it more likely to be seen"); } if dump_bootstrap_shims { diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index e57ed488f973..88595ff7e519 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -306,7 +306,7 @@ fn main() { // should run on success, after this block. } if verbose > 0 { - eprintln!("\nDid not run successfully: {status}\n{cmd:?}\n-------------"); + println!("\nDid not run successfully: {status}\n{cmd:?}\n-------------"); } if let Some(mut on_fail) = on_fail { diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 2af2e83db8f7..d46c0ab7fefc 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -287,7 +287,7 @@ impl Step for CodegenBackend { fn run(self, builder: &Builder<'_>) { // FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved if builder.build.config.vendor && self.backend == "gcc" { - eprintln!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); + println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); return; } diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 4419b11ac197..0cacd6e4f37a 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1611,7 +1611,7 @@ impl Step for Sysroot { let sysroot = sysroot_dir(compiler.stage); builder - .verbose(|| eprintln!("Removing sysroot {} to avoid caching bugs", sysroot.display())); + .verbose(|| println!("Removing sysroot {} to avoid caching bugs", sysroot.display())); let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); @@ -1681,7 +1681,7 @@ impl Step for Sysroot { return true; } if !filtered_files.iter().all(|f| f != path.file_name().unwrap()) { - builder.verbose_than(1, || eprintln!("ignoring {}", path.display())); + builder.verbose_than(1, || println!("ignoring {}", path.display())); false } else { true @@ -2240,7 +2240,7 @@ pub fn stream_cargo( cargo.arg(arg); } - builder.verbose(|| eprintln!("running: {cargo:?}")); + builder.verbose(|| println!("running: {cargo:?}")); if builder.config.dry_run() { return true; @@ -2261,12 +2261,12 @@ pub fn stream_cargo( Ok(msg) => { if builder.config.json_output { // Forward JSON to stdout. - eprintln!("{line}"); + println!("{line}"); } cb(msg) } // If this was informational, just print it out and continue - Err(_) => eprintln!("{line}"), + Err(_) => println!("{line}"), } } diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 57fce206f954..0c739115165e 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -2080,7 +2080,7 @@ fn maybe_install_llvm( { let mut cmd = command(llvm_config); cmd.arg("--libfiles"); - builder.verbose(|| eprintln!("running {cmd:?}")); + builder.verbose(|| println!("running {cmd:?}")); let files = cmd.run_capture_stdout(builder).stdout(); let build_llvm_out = &builder.llvm_out(builder.config.build); let target_llvm_out = &builder.llvm_out(target); diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index d32e06d8748a..29a96f776728 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -107,10 +107,10 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) { if let Some(adjective) = adjective { format!("{adjective} ") } else { String::new() }; if len <= 10 { for path in paths { - eprintln!("fmt: {verb} {adjective}file {path}"); + println!("fmt: {verb} {adjective}file {path}"); } } else { - eprintln!("fmt: {verb} {len} {adjective}files"); + println!("fmt: {verb} {len} {adjective}files"); } } @@ -199,7 +199,7 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) { match get_modified_rs_files(build) { Ok(Some(files)) => { if files.is_empty() { - eprintln!("fmt info: No modified files detected for formatting."); + println!("fmt info: No modified files detected for formatting."); return; } diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 1af7b954f5ed..3a8f9e48c0da 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -134,7 +134,7 @@ impl Step for Profile { t!(fs::remove_file(path)); } _ => { - eprintln!("Exiting."); + println!("Exiting."); crate::exit!(1); } } @@ -184,15 +184,15 @@ pub fn setup(config: &Config, profile: Profile) { Profile::Dist => &["dist", "build"], }; - eprintln!(); + println!(); - eprintln!("To get started, try one of the following commands:"); + println!("To get started, try one of the following commands:"); for cmd in suggestions { - eprintln!("- `x.py {cmd}`"); + println!("- `x.py {cmd}`"); } if profile != Profile::Dist { - eprintln!( + println!( "For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html" ); } @@ -224,7 +224,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) { t!(fs::write(path, settings)); let include_path = profile.include_path(&config.src); - eprintln!("`x.py` will now use the configuration at {}", include_path.display()); + println!("`x.py` will now use the configuration at {}", include_path.display()); } /// Creates a toolchain link for stage1 using `rustup` @@ -256,7 +256,7 @@ impl Step for Link { } if !rustup_installed(builder) { - eprintln!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking."); + println!("WARNING: `rustup` is not installed; Skipping `stage1` toolchain linking."); return; } @@ -296,7 +296,7 @@ fn attempt_toolchain_link(builder: &Builder<'_>, stage_path: &str) { } if try_link_toolchain(builder, stage_path) { - eprintln!( + println!( "Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain" ); } else { @@ -321,14 +321,14 @@ fn toolchain_is_linked(builder: &Builder<'_>) -> bool { return false; } // The toolchain has already been linked. - eprintln!( + println!( "`stage1` toolchain already linked; not attempting to link `stage1` toolchain" ); } None => { // In this case, we don't know if the `stage1` toolchain has been linked; // but `rustup` failed, so let's not go any further. - eprintln!( + println!( "`rustup` failed to list current toolchains; not attempting to link `stage1` toolchain" ); } @@ -389,9 +389,9 @@ pub fn interactive_path() -> io::Result { input.parse() } - eprintln!("Welcome to the Rust project! What do you want to do with x.py?"); + println!("Welcome to the Rust project! What do you want to do with x.py?"); for ((letter, _), profile) in abbrev_all() { - eprintln!("{}) {}: {}", letter, profile, profile.purpose()); + println!("{}) {}: {}", letter, profile, profile.purpose()); } let template = loop { print!( @@ -488,7 +488,7 @@ fn install_git_hook_maybe(builder: &Builder<'_>, config: &Config) -> io::Result< return Ok(()); } - eprintln!( + println!( "\nRust's CI will automatically fail if it doesn't pass `tidy`, the internal tool for ensuring code quality. If you'd like, x.py can install a git hook for you that will automatically run `test tidy` before pushing your code to ensure your code is up to par. If you decide later that this behavior is @@ -496,7 +496,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." ); if prompt_user("Would you like to install the git hook?: [y/N]")? != Some(PromptResult::Yes) { - eprintln!("Ok, skipping installation!"); + println!("Ok, skipping installation!"); return Ok(()); } if !hooks_dir.exists() { @@ -513,7 +513,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." ); return Err(e); } - Ok(_) => eprintln!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"), + Ok(_) => println!("Linked `src/etc/pre-push.sh` to `.git/hooks/pre-push`"), }; Ok(()) } @@ -654,7 +654,7 @@ impl Step for Editor { if let Some(editor_kind) = editor_kind { while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {} } else { - eprintln!("Ok, skipping editor setup!"); + println!("Ok, skipping editor setup!"); } } Err(e) => eprintln!("Could not determine the editor: {e}"), @@ -687,7 +687,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu mismatched_settings = Some(false); } } - eprintln!( + println!( "\nx.py can automatically install the recommended `{settings_filename}` file for rustc development" ); @@ -706,7 +706,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu Some(PromptResult::Yes) => true, Some(PromptResult::Print) => false, _ => { - eprintln!("Ok, skipping settings!"); + println!("Ok, skipping settings!"); return Ok(true); } }; @@ -733,9 +733,9 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu _ => "Created", }; fs::write(&settings_path, editor.settings_template())?; - eprintln!("{verb} `{}`", settings_filename); + println!("{verb} `{}`", settings_filename); } else { - eprintln!("\n{}", editor.settings_template()); + println!("\n{}", editor.settings_template()); } Ok(should_create) } diff --git a/src/bootstrap/src/core/build_steps/suggest.rs b/src/bootstrap/src/core/build_steps/suggest.rs index 7b2d9fff8f5f..ba9b1b2fc331 100644 --- a/src/bootstrap/src/core/build_steps/suggest.rs +++ b/src/bootstrap/src/core/build_steps/suggest.rs @@ -66,6 +66,6 @@ pub fn suggest(builder: &Builder<'_>, run: bool) { build.build(); } } else { - eprintln!("HELP: consider using the `--run` flag to automatically run suggested tests"); + println!("HELP: consider using the `--run` flag to automatically run suggested tests"); } } diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 6da37530d963..161157acffe0 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -471,11 +471,11 @@ impl Miri { // We re-use the `cargo` from above. cargo.arg("--print-sysroot"); - builder.verbose(|| eprintln!("running: {cargo:?}")); + builder.verbose(|| println!("running: {cargo:?}")); let stdout = cargo.run_capture_stdout(builder).stdout(); // Output is "\n". let sysroot = stdout.trim_end(); - builder.verbose(|| eprintln!("`cargo miri setup --print-sysroot` said: {sysroot:?}")); + builder.verbose(|| println!("`cargo miri setup --print-sysroot` said: {sysroot:?}")); PathBuf::from(sysroot) } } @@ -2478,7 +2478,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> } } - builder.verbose(|| eprintln!("doc tests for: {}", markdown.display())); + builder.verbose(|| println!("doc tests for: {}", markdown.display())); let mut cmd = builder.rustdoc_cmd(compiler); builder.add_rust_test_threads(&mut cmd); // allow for unstable options such as new editions diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 38abca8b8da1..77f6edaabb24 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -523,7 +523,7 @@ impl Builder<'_> { let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8"); if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) { - eprintln!("using sysroot {sysroot_str}"); + println!("using sysroot {sysroot_str}"); } let mut rustflags = Rustflags::new(target); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index ffe3e053e724..026c26479d35 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -392,14 +392,14 @@ impl StepDescription { fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool { if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) { if !matches!(builder.config.dry_run, DryRun::SelfCheck) { - eprintln!("Skipping {pathset:?} because it is excluded"); + println!("Skipping {pathset:?} because it is excluded"); } return true; } if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) { builder.verbose(|| { - eprintln!( + println!( "{:?} not skipped for {:?} -- not in {:?}", pathset, self.name, builder.config.skip ) @@ -1437,11 +1437,11 @@ impl<'a> Builder<'a> { panic!("{}", out); } if let Some(out) = self.cache.get(&step) { - self.verbose_than(1, || eprintln!("{}c {:?}", " ".repeat(stack.len()), step)); + self.verbose_than(1, || println!("{}c {:?}", " ".repeat(stack.len()), step)); return out; } - self.verbose_than(1, || eprintln!("{}> {:?}", " ".repeat(stack.len()), step)); + self.verbose_than(1, || println!("{}> {:?}", " ".repeat(stack.len()), step)); stack.push(Box::new(step.clone())); } @@ -1462,7 +1462,7 @@ impl<'a> Builder<'a> { let step_string = format!("{step:?}"); let brace_index = step_string.find('{').unwrap_or(0); let type_string = type_name::(); - eprintln!( + println!( "[TIMING] {} {} -- {}.{:03}", &type_string.strip_prefix("bootstrap::").unwrap_or(type_string), &step_string[brace_index..], @@ -1479,9 +1479,7 @@ impl<'a> Builder<'a> { let cur_step = stack.pop().expect("step stack empty"); assert_eq!(cur_step.downcast_ref(), Some(&step)); } - self.verbose_than(1, || { - eprintln!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step) - }); + self.verbose_than(1, || println!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); self.cache.put(step, out.clone()); out } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index aa5cce2fb1b6..b06147055f2a 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1293,7 +1293,7 @@ impl Config { .map(|change_id| change_id.inner.map(crate::find_recent_config_change_ids)) { if !changes.is_empty() { - eprintln!( + println!( "WARNING: There have been changes to x.py since you last updated:\n{}", crate::human_readable_changes(&changes) ); @@ -1559,7 +1559,7 @@ impl Config { } if cargo_clippy.is_some() && rustc.is_none() { - eprintln!( + println!( "WARNING: Using `build.cargo-clippy` without `build.rustc` usually fails due to toolchain conflict." ); } @@ -1841,7 +1841,7 @@ impl Config { // FIXME: Remove this option at the end of 2024. if parallel_compiler.is_some() { - eprintln!( + println!( "WARNING: The `rust.parallel-compiler` option is deprecated and does nothing. The parallel compiler (with one thread) is now the default" ); } @@ -1873,7 +1873,7 @@ impl Config { if available_backends.contains(&backend) { panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'."); } else { - eprintln!("HELP: '{s}' for 'rust.codegen-backends' might fail. \ + println!("HELP: '{s}' for 'rust.codegen-backends' might fail. \ Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \ In this case, it would be referred to as '{backend}'."); } @@ -1902,7 +1902,7 @@ impl Config { // tests may fail due to using a different channel than the one used by the compiler during tests. if let Some(commit) = &config.download_rustc_commit { if is_user_configured_rust_channel { - eprintln!( + println!( "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel." ); @@ -1992,10 +1992,10 @@ impl Config { if config.llvm_from_ci { let warn = |option: &str| { - eprintln!( + println!( "WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build." ); - eprintln!( + println!( "HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false." ); }; @@ -2014,12 +2014,12 @@ impl Config { // if they've chosen a different value. if libzstd.is_some() { - eprintln!( + println!( "WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \ like almost all `llvm.*` options, will be ignored and set by the LLVM CI \ artifacts builder config." ); - eprintln!( + println!( "HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false." ); } @@ -2088,7 +2088,7 @@ impl Config { if available_backends.contains(&backend) { panic!("Invalid value '{s}' for 'target.{triple}.codegen-backends'. Instead, please use '{backend}'."); } else { - eprintln!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \ + println!("HELP: '{s}' for 'target.{triple}.codegen-backends' might fail. \ Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \ In this case, it would be referred to as '{backend}'."); } @@ -2304,7 +2304,7 @@ impl Config { if self.dry_run() { return Ok(()); } - self.verbose(|| eprintln!("running: {cmd:?}")); + self.verbose(|| println!("running: {cmd:?}")); build_helper::util::try_run(cmd, self.is_verbose()) } @@ -2479,7 +2479,7 @@ impl Config { // This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error // to not break CI. For non-CI environments, we should return an error. if CiEnv::is_ci() { - eprintln!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled."); + println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled."); return None; } else { panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used."); @@ -2490,8 +2490,8 @@ impl Config { let ci_config_toml = match self.get_builder_toml("ci-rustc") { Ok(ci_config_toml) => ci_config_toml, Err(e) if e.to_string().contains("unknown field") => { - eprintln!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled."); - eprintln!("HELP: Consider rebasing to a newer commit if available."); + println!("WARNING: CI rustc has some fields that are no longer supported in bootstrap; download-rustc will be disabled."); + println!("HELP: Consider rebasing to a newer commit if available."); return None; }, Err(e) => { @@ -2516,7 +2516,7 @@ impl Config { .is_some_and(|s| s == "1" || s == "true"); if disable_ci_rustc_if_incompatible && res.is_err() { - eprintln!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env."); + println!("WARNING: download-rustc is disabled with `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` env."); return None; } @@ -2701,7 +2701,7 @@ impl Config { return; } - eprintln!("Updating submodule {relative_path}"); + println!("Updating submodule {relative_path}"); self.check_run( helpers::git(Some(&self.src)) .run_always() @@ -2824,7 +2824,7 @@ impl Config { Some(StringOrBool::Bool(true)) => false, Some(StringOrBool::String(s)) if s == "if-unchanged" => { if !self.rust_info.is_managed_git_subrepository() { - eprintln!( + println!( "ERROR: `download-rustc=if-unchanged` is only compatible with Git managed sources." ); crate::exit!(1); @@ -2857,10 +2857,10 @@ impl Config { if if_unchanged { return None; } - eprintln!("ERROR: could not find commit hash for downloading rustc"); - eprintln!("HELP: maybe your repository history is too shallow?"); - eprintln!("HELP: consider setting `rust.download-rustc=false` in config.toml"); - eprintln!("HELP: or fetch enough history to include one upstream commit"); + println!("ERROR: could not find commit hash for downloading rustc"); + println!("HELP: maybe your repository history is too shallow?"); + println!("HELP: consider setting `rust.download-rustc=false` in config.toml"); + println!("HELP: or fetch enough history to include one upstream commit"); crate::exit!(1); } }; @@ -2899,7 +2899,7 @@ impl Config { let if_unchanged = || { if self.rust_info.is_from_tarball() { // Git is needed for running "if-unchanged" logic. - eprintln!( + println!( "WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`." ); return false; @@ -2948,10 +2948,10 @@ impl Config { // Only commits merged by bors will have CI artifacts. let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap(); if commit.is_empty() { - eprintln!("error: could not find commit hash for downloading components from CI"); - eprintln!("help: maybe your repository history is too shallow?"); - eprintln!("help: consider disabling `{option_name}`"); - eprintln!("help: or fetch enough history to include one upstream commit"); + println!("error: could not find commit hash for downloading components from CI"); + println!("help: maybe your repository history is too shallow?"); + println!("help: consider disabling `{option_name}`"); + println!("help: or fetch enough history to include one upstream commit"); crate::exit!(1); } @@ -2963,14 +2963,14 @@ impl Config { if has_changes { if if_unchanged { if self.is_verbose() { - eprintln!( + println!( "warning: saw changes to one of {modified_paths:?} since {commit}; \ ignoring `{option_name}`" ); } return None; } - eprintln!( + println!( "warning: `{option_name}` is enabled, but there are changes to one of {modified_paths:?}" ); } @@ -3007,7 +3007,7 @@ pub(crate) fn check_incompatible_options_for_ci_llvm( ($current:expr, $expected:expr) => { if let Some(current) = &$current { if Some(current) != $expected.as_ref() { - eprintln!( + println!( "WARNING: `llvm.{}` has no effect with `llvm.download-ci-llvm`. \ Current value: {:?}, Expected value(s): {}{:?}", stringify!($expected).replace("_", "-"), @@ -3112,7 +3112,7 @@ fn check_incompatible_options_for_ci_rustc( ($current:expr, $expected:expr, $config_section:expr) => { if let Some(current) = &$current { if Some(current) != $expected.as_ref() { - eprintln!( + println!( "WARNING: `{}` has no effect with `rust.download-rustc`. \ Current value: {:?}, Expected value(s): {}{:?}", format!("{}.{}", $config_section, stringify!($expected).replace("_", "-")), diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index 66b9f5ed84e6..bfeb811508c0 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -196,12 +196,12 @@ impl Flags { if let Ok(HelpVerboseOnly { help: true, verbose: 1.., cmd: subcommand }) = HelpVerboseOnly::try_parse_from(normalize_args(args)) { - eprintln!("NOTE: updating submodules before printing available paths"); + println!("NOTE: updating submodules before printing available paths"); let config = Config::parse(Self::parse(&[String::from("build")])); let build = Build::new(config); let paths = Builder::get_help(&build, subcommand); if let Some(s) = paths { - eprintln!("{s}"); + println!("{s}"); } else { panic!("No paths available for subcommand `{}`", subcommand.as_str()); } diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 05b91c518cf4..db35e6907e66 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -77,7 +77,7 @@ impl Config { if self.dry_run() && !cmd.run_always { return true; } - self.verbose(|| eprintln!("running: {cmd:?}")); + self.verbose(|| println!("running: {cmd:?}")); check_run(cmd, self.is_verbose()) } @@ -144,7 +144,7 @@ impl Config { /// Please see for more information fn fix_bin_or_dylib(&self, fname: &Path) { assert_eq!(SHOULD_FIX_BINS_AND_DYLIBS.get(), Some(&true)); - eprintln!("attempting to patch {}", fname.display()); + println!("attempting to patch {}", fname.display()); // Only build `.nix-deps` once. static NIX_DEPS_DIR: OnceLock = OnceLock::new(); @@ -206,7 +206,7 @@ impl Config { } fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { - self.verbose(|| eprintln!("download {url}")); + self.verbose(|| println!("download {url}")); // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. let tempfile = self.tempdir().join(dest_path.file_name().unwrap()); // While bootstrap itself only supports http and https downloads, downstream forks might @@ -226,7 +226,7 @@ impl Config { } fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { - eprintln!("downloading {url}"); + println!("downloading {url}"); // Try curl. If that fails and we are on windows, fallback to PowerShell. // options should be kept in sync with // src/bootstrap/src/core/download.rs @@ -341,7 +341,7 @@ impl Config { short_path = short_path.strip_prefix(pattern).unwrap_or(short_path); let dst_path = dst.join(short_path); self.verbose(|| { - eprintln!("extracting {} to {}", original_path.display(), dst.display()) + println!("extracting {} to {}", original_path.display(), dst.display()) }); if !t!(member.unpack_in(dst)) { panic!("path traversal attack ??"); @@ -365,7 +365,7 @@ impl Config { pub(crate) fn verify(&self, path: &Path, expected: &str) -> bool { use sha2::Digest; - self.verbose(|| eprintln!("verifying {}", path.display())); + self.verbose(|| println!("verifying {}", path.display())); if self.dry_run() { return false; @@ -391,7 +391,7 @@ impl Config { let verified = checksum == expected; if !verified { - eprintln!( + println!( "invalid checksum: \n\ found: {checksum}\n\ expected: {expected}", @@ -421,7 +421,7 @@ enum DownloadSource { /// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions. impl Config { pub(crate) fn download_clippy(&self) -> PathBuf { - self.verbose(|| eprintln!("downloading stage0 clippy artifacts")); + self.verbose(|| println!("downloading stage0 clippy artifacts")); let date = &self.stage0_metadata.compiler.date; let version = &self.stage0_metadata.compiler.version; @@ -518,7 +518,7 @@ impl Config { } pub(crate) fn download_ci_rustc(&self, commit: &str) { - self.verbose(|| eprintln!("using downloaded stage2 artifacts from CI (commit {commit})")); + self.verbose(|| println!("using downloaded stage2 artifacts from CI (commit {commit})")); let version = self.artifact_version_part(commit); // download-rustc doesn't need its own cargo, it can just use beta's. But it does need the @@ -539,7 +539,7 @@ impl Config { #[cfg(not(feature = "bootstrap-self-test"))] pub(crate) fn download_beta_toolchain(&self) { - self.verbose(|| eprintln!("downloading stage0 beta artifacts")); + self.verbose(|| println!("downloading stage0 beta artifacts")); let date = &self.stage0_metadata.compiler.date; let version = &self.stage0_metadata.compiler.version; @@ -677,7 +677,7 @@ impl Config { return; } else { self.verbose(|| { - eprintln!( + println!( "ignoring cached file {} due to failed verification", tarball.display() ) @@ -776,10 +776,10 @@ download-rustc = false t!(check_incompatible_options_for_ci_llvm(current_config_toml, ci_config_toml)); } Err(e) if e.to_string().contains("unknown field") => { - eprintln!( + println!( "WARNING: CI LLVM has some fields that are no longer supported in bootstrap; download-ci-llvm will be disabled." ); - eprintln!("HELP: Consider rebasing to a newer commit if available."); + println!("HELP: Consider rebasing to a newer commit if available."); } Err(e) => { eprintln!("ERROR: Failed to parse CI LLVM config.toml: {e}"); diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 71e7f40f0320..dcf68cbeeda7 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -237,11 +237,11 @@ than building it. stage0_supported_target_list.intersection(&missing_targets_hashset).collect(); if !duplicated_targets.is_empty() { - eprintln!( + println!( "Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list." ); for duplicated_target in duplicated_targets { - eprintln!(" {duplicated_target}"); + println!(" {duplicated_target}"); } std::process::exit(1); } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 5f778223d7da..0ecf61ffcd90 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -406,11 +406,11 @@ impl Build { .unwrap() .trim(); if local_release.split('.').take(2).eq(version.split('.').take(2)) { - build.verbose(|| eprintln!("auto-detected local-rebuild {local_release}")); + build.verbose(|| println!("auto-detected local-rebuild {local_release}")); build.local_rebuild = true; } - build.verbose(|| eprintln!("finding compilers")); + build.verbose(|| println!("finding compilers")); utils::cc_detect::find(&build); // When running `setup`, the profile is about to change, so any requirements we have now may // be different on the next invocation. Don't check for them until the next time x.py is @@ -418,7 +418,7 @@ impl Build { // // Similarly, for `setup` we don't actually need submodules or cargo metadata. if !matches!(build.config.cmd, Subcommand::Setup { .. }) { - build.verbose(|| eprintln!("running sanity check")); + build.verbose(|| println!("running sanity check")); crate::core::sanity::check(&mut build); // Make sure we update these before gathering metadata so we don't get an error about missing @@ -436,7 +436,7 @@ impl Build { // Now, update all existing submodules. build.update_existing_submodules(); - build.verbose(|| eprintln!("learning about cargo")); + build.verbose(|| println!("learning about cargo")); crate::core::metadata::build(&mut build); } @@ -605,7 +605,7 @@ impl Build { let stamp = dir.join(".stamp"); let mut cleared = false; if mtime(&stamp) < mtime(input) { - self.verbose(|| eprintln!("Dirty - {}", dir.display())); + self.verbose(|| println!("Dirty - {}", dir.display())); let _ = fs::remove_dir_all(dir); cleared = true; } else if stamp.exists() { @@ -890,7 +890,7 @@ impl Build { let executed_at = std::panic::Location::caller(); self.verbose(|| { - eprintln!("running: {command:?} (created at {created_at}, executed at {executed_at})") + println!("running: {command:?} (created at {created_at}, executed at {executed_at})") }); let cmd = command.as_command_mut(); @@ -947,7 +947,7 @@ Executed at: {executed_at}"#, let fail = |message: &str, output: CommandOutput| -> ! { if self.is_verbose() { - eprintln!("{message}"); + println!("{message}"); } else { let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present()); // If the command captures output, the user would not see any indication that @@ -957,16 +957,16 @@ Executed at: {executed_at}"#, if let Some(stdout) = output.stdout_if_present().take_if(|s| !s.trim().is_empty()) { - eprintln!("STDOUT:\n{stdout}\n"); + println!("STDOUT:\n{stdout}\n"); } if let Some(stderr) = output.stderr_if_present().take_if(|s| !s.trim().is_empty()) { - eprintln!("STDERR:\n{stderr}\n"); + println!("STDERR:\n{stderr}\n"); } - eprintln!("Command {command:?} has failed. Rerun with -v to see more details."); + println!("Command {command:?} has failed. Rerun with -v to see more details."); } else { - eprintln!("Command has failed. Rerun with -v to see more details."); + println!("Command has failed. Rerun with -v to see more details."); } } exit!(1); @@ -1011,7 +1011,7 @@ Executed at: {executed_at}"#, match self.config.dry_run { DryRun::SelfCheck => (), DryRun::Disabled | DryRun::UserSelected => { - eprintln!("{msg}"); + println!("{msg}"); } } } @@ -1666,7 +1666,7 @@ Executed at: {executed_at}"#, if self.config.dry_run() { return; } - self.verbose_than(1, || eprintln!("Copy/Link {src:?} to {dst:?}")); + self.verbose_than(1, || println!("Copy/Link {src:?} to {dst:?}")); if src == dst { return; } @@ -1775,7 +1775,7 @@ Executed at: {executed_at}"#, return; } let dst = dstdir.join(src.file_name().unwrap()); - self.verbose_than(1, || eprintln!("Install {src:?} to {dst:?}")); + self.verbose_than(1, || println!("Install {src:?} to {dst:?}")); t!(fs::create_dir_all(dstdir)); if !src.exists() { panic!("ERROR: File \"{}\" not found!", src.display()); diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index e8d5b60948aa..0df004694522 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -155,15 +155,15 @@ pub fn find_target(build: &Build, target: TargetSelection) { build.cxx.borrow_mut().insert(target, compiler); } - build.verbose(|| eprintln!("CC_{} = {:?}", target.triple, build.cc(target))); - build.verbose(|| eprintln!("CFLAGS_{} = {cflags:?}", target.triple)); + build.verbose(|| println!("CC_{} = {:?}", target.triple, build.cc(target))); + build.verbose(|| println!("CFLAGS_{} = {cflags:?}", target.triple)); if let Ok(cxx) = build.cxx(target) { let cxxflags = build.cflags(target, GitRepo::Rustc, CLang::Cxx); - build.verbose(|| eprintln!("CXX_{} = {cxx:?}", target.triple)); - build.verbose(|| eprintln!("CXXFLAGS_{} = {cxxflags:?}", target.triple)); + build.verbose(|| println!("CXX_{} = {cxx:?}", target.triple)); + build.verbose(|| println!("CXXFLAGS_{} = {cxxflags:?}", target.triple)); } if let Some(ar) = ar { - build.verbose(|| eprintln!("AR_{} = {ar:?}", target.triple)); + build.verbose(|| println!("AR_{} = {ar:?}", target.triple)); build.ar.borrow_mut().insert(target, ar); } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index c0d52fd34305..923cc2dfc28c 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -135,7 +135,7 @@ impl Drop for TimeIt { fn drop(&mut self) { let time = self.1.elapsed(); if !self.0 { - eprintln!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis()); + println!("\tfinished in {}.{:03} seconds", time.as_secs(), time.subsec_millis()); } } } @@ -267,12 +267,12 @@ pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool { let status = match cmd.as_command_mut().status() { Ok(status) => status, Err(e) => { - eprintln!("failed to execute command: {cmd:?}\nERROR: {e}"); + println!("failed to execute command: {cmd:?}\nERROR: {e}"); return false; } }; if !status.success() && print_cmd_on_fail { - eprintln!( + println!( "\n\ncommand did not execute successfully: {cmd:?}\n\ expected success, got: {status}\n\n" ); diff --git a/src/bootstrap/src/utils/metrics.rs b/src/bootstrap/src/utils/metrics.rs index 06d3add6281f..b51fd490535a 100644 --- a/src/bootstrap/src/utils/metrics.rs +++ b/src/bootstrap/src/utils/metrics.rs @@ -185,7 +185,7 @@ impl BuildMetrics { if version.format_version == CURRENT_FORMAT_VERSION { t!(serde_json::from_slice::(&contents)).invocations } else { - eprintln!( + println!( "WARNING: overriding existing build/metrics.json, as it's not \ compatible with build metrics format version {CURRENT_FORMAT_VERSION}." ); diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs index 27e1c5d01b77..eb2c8254dc0f 100644 --- a/src/bootstrap/src/utils/render_tests.rs +++ b/src/bootstrap/src/utils/render_tests.rs @@ -56,7 +56,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> let cmd = cmd.as_command_mut(); cmd.stdout(Stdio::piped()); - builder.verbose(|| eprintln!("running: {cmd:?}")); + builder.verbose(|| println!("running: {cmd:?}")); let mut process = cmd.spawn().unwrap(); @@ -71,7 +71,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> let result = process.wait_with_output().unwrap(); if !result.status.success() && builder.is_verbose() { - eprintln!( + println!( "\n\ncommand did not execute successfully: {cmd:?}\n\ expected success, got: {}", result.status @@ -135,9 +135,7 @@ impl<'a> Renderer<'a> { if self.up_to_date_tests > 0 { let n = self.up_to_date_tests; let s = if n > 1 { "s" } else { "" }; - eprintln!( - "help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n" - ); + println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n"); } } @@ -192,7 +190,7 @@ impl<'a> Renderer<'a> { if let Some(exec_time) = test.exec_time { print!(" ({exec_time:.2?})"); } - eprintln!(); + println!(); } fn render_test_outcome_terse(&mut self, outcome: Outcome<'_>, test: &TestOutcome) { @@ -202,7 +200,7 @@ impl<'a> Renderer<'a> { let executed = format!("{:>width$}", self.executed_tests - 1, width = total.len()); print!(" {executed}/{total}"); } - eprintln!(); + println!(); self.terse_tests_in_line = 0; } @@ -214,31 +212,31 @@ impl<'a> Renderer<'a> { fn render_suite_outcome(&self, outcome: Outcome<'_>, suite: &SuiteOutcome) { // The terse output doesn't end with a newline, so we need to add it ourselves. if !self.builder.config.verbose_tests { - eprintln!(); + println!(); } if !self.failures.is_empty() { - eprintln!("\nfailures:\n"); + println!("\nfailures:\n"); for failure in &self.failures { if failure.stdout.is_some() || failure.message.is_some() { - eprintln!("---- {} stdout ----", failure.name); + println!("---- {} stdout ----", failure.name); if let Some(stdout) = &failure.stdout { - eprintln!("{stdout}"); + println!("{stdout}"); } if let Some(message) = &failure.message { - eprintln!("NOTE: {message}"); + println!("NOTE: {message}"); } } } - eprintln!("\nfailures:"); + println!("\nfailures:"); for failure in &self.failures { - eprintln!(" {}", failure.name); + println!(" {}", failure.name); } } if !self.benches.is_empty() { - eprintln!("\nbenchmarks:"); + println!("\nbenchmarks:"); let mut rows = Vec::new(); for bench in &self.benches { @@ -253,13 +251,13 @@ impl<'a> Renderer<'a> { let max_1 = rows.iter().map(|r| r.1.len()).max().unwrap_or(0); let max_2 = rows.iter().map(|r| r.2.len()).max().unwrap_or(0); for row in &rows { - eprintln!(" {:max_1$} {:>max_2$}", row.0, row.1, row.2); + println!(" {:max_1$} {:>max_2$}", row.0, row.1, row.2); } } print!("\ntest result: "); self.builder.colored_stdout(|stdout| outcome.write_long(stdout)).unwrap(); - eprintln!( + println!( ". {} passed; {} failed; {} ignored; {} measured; {} filtered out{time}\n", suite.passed, suite.failed, @@ -276,7 +274,7 @@ impl<'a> Renderer<'a> { fn render_message(&mut self, message: Message) { match message { Message::Suite(SuiteMessage::Started { test_count }) => { - eprintln!("\nrunning {test_count} tests"); + println!("\nrunning {test_count} tests"); self.executed_tests = 0; self.terse_tests_in_line = 0; self.tests_count = Some(test_count); @@ -316,7 +314,7 @@ impl<'a> Renderer<'a> { self.failures.push(outcome); } Message::Test(TestMessage::Timeout { name }) => { - eprintln!("test {name} has been running for a long time"); + println!("test {name} has been running for a long time"); } Message::Test(TestMessage::Started) => {} // Not useful } diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index f60498a4872c..3c6c7a7fa180 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -344,7 +344,7 @@ impl<'a> Tarball<'a> { // For `x install` tarball files aren't needed, so we can speed up the process by not producing them. let compression_profile = if self.builder.kind == Kind::Install { self.builder.verbose(|| { - eprintln!("Forcing dist.compression-profile = 'no-op' for `x install`.") + println!("Forcing dist.compression-profile = 'no-op' for `x install`.") }); // "no-op" indicates that the rust-installer won't produce compressed tarball sources. "no-op" diff --git a/src/tools/compiletest/src/compute_diff.rs b/src/tools/compiletest/src/compute_diff.rs index 3ace6c5b6d71..92c80c27de03 100644 --- a/src/tools/compiletest/src/compute_diff.rs +++ b/src/tools/compiletest/src/compute_diff.rs @@ -144,7 +144,7 @@ where } if !wrote_data { - eprintln!("note: diff is identical to nightly rustdoc"); + println!("note: diff is identical to nightly rustdoc"); assert!(diff_output.metadata().unwrap().len() == 0); return false; } else if verbose { diff --git a/src/tools/compiletest/src/debuggers.rs b/src/tools/compiletest/src/debuggers.rs index e75c8a5993e5..b605bc813f19 100644 --- a/src/tools/compiletest/src/debuggers.rs +++ b/src/tools/compiletest/src/debuggers.rs @@ -20,7 +20,7 @@ pub(crate) fn configure_gdb(config: &Config) -> Option> { } if config.remote_test_client.is_some() && !config.target.contains("android") { - eprintln!( + println!( "WARNING: debuginfo tests are not available when \ testing with remote" ); @@ -28,7 +28,7 @@ pub(crate) fn configure_gdb(config: &Config) -> Option> { } if config.target.contains("android") { - eprintln!( + println!( "{} debug-info test uses tcp 5039 port.\ please reserve it", config.target @@ -50,7 +50,7 @@ pub(crate) fn configure_lldb(config: &Config) -> Option> { config.lldb_python_dir.as_ref()?; if let Some(350) = config.lldb_version { - eprintln!( + println!( "WARNING: The used version of LLDB (350) has a \ known issue that breaks debuginfo tests. See \ issue #32520 for more information. Skipping all \ diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 447568065f51..bf4a3124075e 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -188,8 +188,8 @@ pub fn parse_config(args: Vec) -> Config { let (argv0, args_) = args.split_first().unwrap(); if args.len() == 1 || args[1] == "-h" || args[1] == "--help" { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - eprintln!("{}", opts.usage(&message)); - eprintln!(); + println!("{}", opts.usage(&message)); + println!(); panic!() } @@ -200,8 +200,8 @@ pub fn parse_config(args: Vec) -> Config { if matches.opt_present("h") || matches.opt_present("help") { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - eprintln!("{}", opts.usage(&message)); - eprintln!(); + println!("{}", opts.usage(&message)); + println!(); panic!() } @@ -501,7 +501,7 @@ pub fn run_tests(config: Arc) { // easy to miss which tests failed, and as such fail to reproduce // the failure locally. - eprintln!( + println!( "Some tests failed in compiletest suite={}{} mode={} host={} target={}", config.suite, config diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8c747a1d93f6..84269fd44a1e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -774,20 +774,20 @@ impl<'test> TestCx<'test> { unexpected.len(), not_found.len() )); - eprintln!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline); + println!("status: {}\ncommand: {}\n", proc_res.status, proc_res.cmdline); if !unexpected.is_empty() { - eprintln!("{}", "--- unexpected errors (from JSON output) ---".green()); + println!("{}", "--- unexpected errors (from JSON output) ---".green()); for error in &unexpected { - eprintln!("{}", error.render_for_expected()); + println!("{}", error.render_for_expected()); } - eprintln!("{}", "---".green()); + println!("{}", "---".green()); } if !not_found.is_empty() { - eprintln!("{}", "--- not found errors (from test file) ---".red()); + println!("{}", "--- not found errors (from test file) ---".red()); for error in ¬_found { - eprintln!("{}", error.render_for_expected()); + println!("{}", error.render_for_expected()); } - eprintln!("{}", "---\n".red()); + println!("{}", "---\n".red()); } panic!("errors differ from expected"); } @@ -1876,18 +1876,18 @@ impl<'test> TestCx<'test> { fn maybe_dump_to_stdout(&self, out: &str, err: &str) { if self.config.verbose { - eprintln!("------stdout------------------------------"); - eprintln!("{}", out); - eprintln!("------stderr------------------------------"); - eprintln!("{}", err); - eprintln!("------------------------------------------"); + println!("------stdout------------------------------"); + println!("{}", out); + println!("------stderr------------------------------"); + println!("{}", err); + println!("------------------------------------------"); } } fn error(&self, err: &str) { match self.revision { - Some(rev) => eprintln!("\nerror in revision `{}`: {}", rev, err), - None => eprintln!("\nerror: {}", err), + Some(rev) => println!("\nerror in revision `{}`: {}", rev, err), + None => println!("\nerror: {}", err), } } @@ -1972,7 +1972,7 @@ impl<'test> TestCx<'test> { if !self.config.has_html_tidy { return; } - eprintln!("info: generating a diff against nightly rustdoc"); + println!("info: generating a diff against nightly rustdoc"); let suffix = self.safe_revision().map_or("nightly".into(), |path| path.to_owned() + "-nightly"); @@ -2082,7 +2082,7 @@ impl<'test> TestCx<'test> { .output() .unwrap(); assert!(output.status.success()); - eprintln!("{}", String::from_utf8_lossy(&output.stdout)); + println!("{}", String::from_utf8_lossy(&output.stdout)); eprintln!("{}", String::from_utf8_lossy(&output.stderr)); } else { use colored::Colorize; @@ -2482,7 +2482,7 @@ impl<'test> TestCx<'test> { )"# ) .replace_all(&output, |caps: &Captures<'_>| { - eprintln!("{}", &caps[0]); + println!("{}", &caps[0]); caps[0].replace(r"\", "/") }) .replace("\r\n", "\n") @@ -2581,16 +2581,16 @@ impl<'test> TestCx<'test> { if let Err(err) = fs::write(&actual_path, &actual) { self.fatal(&format!("failed to write {stream} to `{actual_path:?}`: {err}",)); } - eprintln!("Saved the actual {stream} to {actual_path:?}"); + println!("Saved the actual {stream} to {actual_path:?}"); let expected_path = expected_output_path(self.testpaths, self.revision, &self.config.compare_mode, stream); if !self.config.bless { if expected.is_empty() { - eprintln!("normalized {}:\n{}\n", stream, actual); + println!("normalized {}:\n{}\n", stream, actual); } else { - eprintln!("diff of {stream}:\n"); + println!("diff of {stream}:\n"); if let Some(diff_command) = self.config.diff_command.as_deref() { let mut args = diff_command.split_whitespace(); let name = args.next().unwrap(); @@ -2625,10 +2625,10 @@ impl<'test> TestCx<'test> { if let Err(err) = fs::write(&expected_path, &actual) { self.fatal(&format!("failed to write {stream} to `{expected_path:?}`: {err}")); } - eprintln!("Blessing the {stream} of {test_name} in {expected_path:?}"); + println!("Blessing the {stream} of {test_name} in {expected_path:?}"); } - eprintln!("\nThe actual {0} differed from the expected {0}.", stream); + println!("\nThe actual {0} differed from the expected {0}.", stream); if self.config.bless { 0 } else { 1 } } @@ -2707,7 +2707,7 @@ impl<'test> TestCx<'test> { fs::create_dir_all(&incremental_dir).unwrap(); if self.config.verbose { - eprintln!("init_incremental_test: incremental_dir={}", incremental_dir.display()); + println!("init_incremental_test: incremental_dir={}", incremental_dir.display()); } } @@ -2765,7 +2765,7 @@ impl ProcRes { } } - eprintln!( + println!( "status: {}\ncommand: {}\n{}\n{}\n", self.status, self.cmdline, @@ -2776,7 +2776,7 @@ impl ProcRes { pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! { if let Some(e) = err { - eprintln!("\nerror: {}", e); + println!("\nerror: {}", e); } self.print_info(); on_failure(); diff --git a/src/tools/compiletest/src/runtest/codegen_units.rs b/src/tools/compiletest/src/runtest/codegen_units.rs index 6acd140183d4..6c866cbef21a 100644 --- a/src/tools/compiletest/src/runtest/codegen_units.rs +++ b/src/tools/compiletest/src/runtest/codegen_units.rs @@ -64,13 +64,13 @@ impl TestCx<'_> { if !missing.is_empty() { missing.sort(); - eprintln!("\nThese items should have been contained but were not:\n"); + println!("\nThese items should have been contained but were not:\n"); for item in &missing { - eprintln!("{}", item); + println!("{}", item); } - eprintln!("\n"); + println!("\n"); } if !unexpected.is_empty() { @@ -80,24 +80,24 @@ impl TestCx<'_> { sorted }; - eprintln!("\nThese items were contained but should not have been:\n"); + println!("\nThese items were contained but should not have been:\n"); for item in sorted { - eprintln!("{}", item); + println!("{}", item); } - eprintln!("\n"); + println!("\n"); } if !wrong_cgus.is_empty() { wrong_cgus.sort_by_key(|pair| pair.0.name.clone()); - eprintln!("\nThe following items were assigned to wrong codegen units:\n"); + println!("\nThe following items were assigned to wrong codegen units:\n"); for &(ref expected_item, ref actual_item) in &wrong_cgus { - eprintln!("{}", expected_item.name); - eprintln!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units)); - eprintln!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units)); - eprintln!(); + println!("{}", expected_item.name); + println!(" expected: {}", codegen_units_to_str(&expected_item.codegen_units)); + println!(" actual: {}", codegen_units_to_str(&actual_item.codegen_units)); + println!(); } } diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 7322e730e53f..c621c22ac993 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -260,7 +260,7 @@ impl TestCx<'_> { cmdline, }; if adb.kill().is_err() { - eprintln!("Adb process is already finished."); + println!("Adb process is already finished."); } } else { let rust_src_root = @@ -275,7 +275,7 @@ impl TestCx<'_> { match self.config.gdb_version { Some(version) => { - eprintln!("NOTE: compiletest thinks it is using GDB version {}", version); + println!("NOTE: compiletest thinks it is using GDB version {}", version); if version > extract_gdb_version("7.4").unwrap() { // Add the directory containing the pretty printers to @@ -297,7 +297,7 @@ impl TestCx<'_> { } } _ => { - eprintln!( + println!( "NOTE: compiletest does not know which version of \ GDB it is using" ); @@ -392,10 +392,10 @@ impl TestCx<'_> { match self.config.lldb_version { Some(ref version) => { - eprintln!("NOTE: compiletest thinks it is using LLDB version {}", version); + println!("NOTE: compiletest thinks it is using LLDB version {}", version); } _ => { - eprintln!( + println!( "NOTE: compiletest does not know which version of \ LLDB it is using" ); diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index 84376d346af3..31fdb0a5d13b 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -29,7 +29,7 @@ impl TestCx<'_> { if !res.status.success() { self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| { - eprintln!("Rustdoc Output:"); + println!("Rustdoc Output:"); proc_res.print_info(); }) } diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index 414f1a6adb33..bb747c680292 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -109,10 +109,10 @@ impl TestCx<'_> { } if errors > 0 { - eprintln!("To update references, rerun the tests and pass the `--bless` flag"); + println!("To update references, rerun the tests and pass the `--bless` flag"); let relative_path_to_file = self.testpaths.relative_dir.join(self.testpaths.file.file_name().unwrap()); - eprintln!( + println!( "To only update this specific test, also pass `--test-args {}`", relative_path_to_file.display(), ); diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 7b50e62c29bb..bff02f1db9f0 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -30,7 +30,7 @@ fn path_div() -> &'static str { pub fn logv(config: &Config, s: String) { debug!("{}", s); if config.verbose { - eprintln!("{}", s); + println!("{}", s); } } diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs index 9dc49b57d599..e2d1b85797ff 100644 --- a/src/tools/tidy/src/error_codes.rs +++ b/src/tools/tidy/src/error_codes.rs @@ -38,7 +38,7 @@ const IGNORE_UI_TEST_CHECK: &[&str] = macro_rules! verbose_print { ($verbose:expr, $($fmt:tt)*) => { if $verbose { - eprintln!("{}", format_args!($($fmt)*)); + println!("{}", format_args!($($fmt)*)); } }; } @@ -49,8 +49,8 @@ pub fn check(root_path: &Path, search_paths: &[&Path], verbose: bool, bad: &mut // Stage 1: create list let error_codes = extract_error_codes(root_path, &mut errors); if verbose { - eprintln!("Found {} error codes", error_codes.len()); - eprintln!("Highest error code: `{}`", error_codes.iter().max().unwrap()); + println!("Found {} error codes", error_codes.len()); + println!("Highest error code: `{}`", error_codes.iter().max().unwrap()); } // Stage 2: check list has docs diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 4607d0415770..4f24eb212420 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -158,14 +158,14 @@ pub fn check( .collect::>(); for &(name, _) in gate_untested.iter() { - eprintln!("Expected a gate test for the feature '{name}'."); - eprintln!( + println!("Expected a gate test for the feature '{name}'."); + println!( "Hint: create a failing test file named 'tests/ui/feature-gates/feature-gate-{}.rs',\ \n with its failures due to missing usage of `#![feature({})]`.", name.replace("_", "-"), name ); - eprintln!( + println!( "Hint: If you already have such a test and don't want to rename it,\ \n you can also add a // gate-test-{} line to the test file.", name @@ -218,7 +218,7 @@ pub fn check( lines.sort(); for line in lines { - eprintln!("* {line}"); + println!("* {line}"); } } diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs index 06d238ef5e47..8be25b98df0d 100644 --- a/src/tools/tidy/src/unstable_book.rs +++ b/src/tools/tidy/src/unstable_book.rs @@ -118,16 +118,16 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) { // List unstable features that don't have Unstable Book sections. // Remove the comment marker if you want the list printed. /* - eprintln!("Lib features without unstable book sections:"); + println!("Lib features without unstable book sections:"); for feature_name in &unstable_lang_feature_names - &unstable_book_lang_features_section_file_names { - eprintln!(" * {} {:?}", feature_name, lib_features[&feature_name].tracking_issue); + println!(" * {} {:?}", feature_name, lib_features[&feature_name].tracking_issue); } - eprintln!("Lang features without unstable book sections:"); + println!("Lang features without unstable book sections:"); for feature_name in &unstable_lib_feature_names- &unstable_book_lib_features_section_file_names { - eprintln!(" * {} {:?}", feature_name, lang_features[&feature_name].tracking_issue); + println!(" * {} {:?}", feature_name, lang_features[&feature_name].tracking_issue); } // */ } diff --git a/src/tools/tidy/src/x_version.rs b/src/tools/tidy/src/x_version.rs index b43d56202c99..489343561e18 100644 --- a/src/tools/tidy/src/x_version.rs +++ b/src/tools/tidy/src/x_version.rs @@ -42,7 +42,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) { if let Some(expected) = get_x_wrapper_version(root, cargo) { if installed < expected { - return eprintln!( + return println!( "Current version of x is {installed}, but the latest version is {expected}\nConsider updating to the newer version of x by running `cargo install --path src/tools/x`" ); } From a122dde217459c1decbce3452323807154763206 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Thu, 5 Dec 2024 20:15:08 +0000 Subject: [PATCH 58/59] do not implement unsafe auto traits for types with unsafe fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which `auto` traits are implemented. Makes progress towards #132922. --- compiler/rustc_middle/src/ty/context.rs | 4 +++ compiler/rustc_middle/src/ty/sty.rs | 8 ++++++ .../src/solve/trait_goals.rs | 8 ++++++ .../src/traits/select/candidate_assembly.rs | 9 +++++++ compiler/rustc_type_ir/src/inherent.rs | 3 +++ compiler/rustc_type_ir/src/interner.rs | 3 +++ .../unsafe-fields/auto-traits.current.stderr | 17 ++++++++++++ .../ui/unsafe-fields/auto-traits.next.stderr | 17 ++++++++++++ tests/ui/unsafe-fields/auto-traits.rs | 26 +++++++++++++++++++ .../auxiliary/unsafe-fields-crate-dep.rs | 0 .../unsafe-fields-crate.rs | 0 .../unsafe-fields-crate.stderr | 0 .../unsafe-fields-parse.rs | 0 .../unsafe-fields-parse.stderr | 0 tests/ui/{ => unsafe-fields}/unsafe-fields.rs | 0 .../{ => unsafe-fields}/unsafe-fields.stderr | 0 16 files changed, 95 insertions(+) create mode 100644 tests/ui/unsafe-fields/auto-traits.current.stderr create mode 100644 tests/ui/unsafe-fields/auto-traits.next.stderr create mode 100644 tests/ui/unsafe-fields/auto-traits.rs rename tests/ui/{ => unsafe-fields}/auxiliary/unsafe-fields-crate-dep.rs (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields-crate.rs (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields-crate.stderr (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields-parse.rs (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields-parse.stderr (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields.rs (100%) rename tests/ui/{ => unsafe-fields}/unsafe-fields.stderr (100%) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 3cbb2a3acf59..d4835bb07f68 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -585,6 +585,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.trait_def(trait_def_id).implement_via_object } + fn trait_is_unsafe(self, trait_def_id: Self::DefId) -> bool { + self.trait_def(trait_def_id).safety == hir::Safety::Unsafe + } + fn is_impl_trait_in_trait(self, def_id: DefId) -> bool { self.is_impl_trait_in_trait(def_id) } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 142db8a17f04..474062218c97 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -978,6 +978,14 @@ impl<'tcx> rustc_type_ir::inherent::Ty> for Ty<'tcx> { fn async_destructor_ty(self, interner: TyCtxt<'tcx>) -> Ty<'tcx> { self.async_destructor_ty(interner) } + + fn has_unsafe_fields(self) -> bool { + if let ty::Adt(adt_def, ..) = self.kind() { + adt_def.all_fields().any(|x| x.safety == hir::Safety::Unsafe) + } else { + false + } + } } /// Type utilities diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 6641d2bf9249..12df35d30b8f 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -169,6 +169,14 @@ where return result; } + // Only consider auto impls of unsafe traits when there are no unsafe + // fields. + if ecx.cx().trait_is_unsafe(goal.predicate.def_id()) + && goal.predicate.self_ty().has_unsafe_fields() + { + return Err(NoSolution); + } + // We only look into opaque types during analysis for opaque types // outside of their defining scope. Doing so for opaques in the // defining scope may require calling `typeck` on the same item we're diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 32b4567aba4f..3e2c8467d322 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -18,6 +18,7 @@ use rustc_infer::traits::{ use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::{self, ToPolyTraitRef, Ty, TypeVisitableExt, TypingMode}; use rustc_middle::{bug, span_bug}; +use rustc_type_ir::Interner; use tracing::{debug, instrument, trace}; use super::SelectionCandidate::*; @@ -794,6 +795,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::Never | ty::Tuple(_) | ty::CoroutineWitness(..) => { + use rustc_type_ir::inherent::*; + + // Only consider auto impls of unsafe traits when there are + // no unsafe fields. + if self.tcx().trait_is_unsafe(def_id) && self_ty.has_unsafe_fields() { + return; + } + // Only consider auto impls if there are no manual impls for the root of `self_ty`. // // For example, we only consider auto candidates for `&i32: Auto` if no explicit impl diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index a201f2b1c11f..f45c94127bd0 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -136,6 +136,9 @@ pub trait Ty>: matches!(self.kind(), ty::FnPtr(..)) } + /// Checks whether this type is an ADT that has unsafe fields. + fn has_unsafe_fields(self) -> bool; + fn fn_sig(self, interner: I) -> ty::Binder> { match self.kind() { ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr), diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 0ae688848ebf..025ec7ae896d 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -270,6 +270,9 @@ pub trait Interner: fn trait_may_be_implemented_via_object(self, trait_def_id: Self::DefId) -> bool; + /// Returns `true` if this is an `unsafe trait`. + fn trait_is_unsafe(self, trait_def_id: Self::DefId) -> bool; + fn is_impl_trait_in_trait(self, def_id: Self::DefId) -> bool; fn delay_bug(self, msg: impl ToString) -> Self::ErrorGuaranteed; diff --git a/tests/ui/unsafe-fields/auto-traits.current.stderr b/tests/ui/unsafe-fields/auto-traits.current.stderr new file mode 100644 index 000000000000..53a97458b7cd --- /dev/null +++ b/tests/ui/unsafe-fields/auto-traits.current.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `UnsafeEnum: UnsafeAuto` is not satisfied + --> $DIR/auto-traits.rs:24:22 + | +LL | impl_unsafe_auto(UnsafeEnum::Safe(42)); + | ---------------- ^^^^^^^^^^^^^^^^^^^^ the trait `UnsafeAuto` is not implemented for `UnsafeEnum` + | | + | required by a bound introduced by this call + | +note: required by a bound in `impl_unsafe_auto` + --> $DIR/auto-traits.rs:20:29 + | +LL | fn impl_unsafe_auto(_: impl UnsafeAuto) {} + | ^^^^^^^^^^ required by this bound in `impl_unsafe_auto` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsafe-fields/auto-traits.next.stderr b/tests/ui/unsafe-fields/auto-traits.next.stderr new file mode 100644 index 000000000000..53a97458b7cd --- /dev/null +++ b/tests/ui/unsafe-fields/auto-traits.next.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `UnsafeEnum: UnsafeAuto` is not satisfied + --> $DIR/auto-traits.rs:24:22 + | +LL | impl_unsafe_auto(UnsafeEnum::Safe(42)); + | ---------------- ^^^^^^^^^^^^^^^^^^^^ the trait `UnsafeAuto` is not implemented for `UnsafeEnum` + | | + | required by a bound introduced by this call + | +note: required by a bound in `impl_unsafe_auto` + --> $DIR/auto-traits.rs:20:29 + | +LL | fn impl_unsafe_auto(_: impl UnsafeAuto) {} + | ^^^^^^^^^^ required by this bound in `impl_unsafe_auto` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsafe-fields/auto-traits.rs b/tests/ui/unsafe-fields/auto-traits.rs new file mode 100644 index 000000000000..e15d0000079e --- /dev/null +++ b/tests/ui/unsafe-fields/auto-traits.rs @@ -0,0 +1,26 @@ +//@ compile-flags: --crate-type=lib +//@ revisions: current next +//@[next] compile-flags: -Znext-solver + +#![feature(auto_traits)] +#![feature(unsafe_fields)] +#![allow(incomplete_features)] + +enum UnsafeEnum { + Safe(u8), + Unsafe { unsafe field: u8 }, +} + +auto trait SafeAuto {} + +fn impl_safe_auto(_: impl SafeAuto) {} + +unsafe auto trait UnsafeAuto {} + +fn impl_unsafe_auto(_: impl UnsafeAuto) {} + +fn tests() { + impl_safe_auto(UnsafeEnum::Safe(42)); + impl_unsafe_auto(UnsafeEnum::Safe(42)); + //~^ ERROR the trait bound `UnsafeEnum: UnsafeAuto` is not satisfied +} diff --git a/tests/ui/auxiliary/unsafe-fields-crate-dep.rs b/tests/ui/unsafe-fields/auxiliary/unsafe-fields-crate-dep.rs similarity index 100% rename from tests/ui/auxiliary/unsafe-fields-crate-dep.rs rename to tests/ui/unsafe-fields/auxiliary/unsafe-fields-crate-dep.rs diff --git a/tests/ui/unsafe-fields-crate.rs b/tests/ui/unsafe-fields/unsafe-fields-crate.rs similarity index 100% rename from tests/ui/unsafe-fields-crate.rs rename to tests/ui/unsafe-fields/unsafe-fields-crate.rs diff --git a/tests/ui/unsafe-fields-crate.stderr b/tests/ui/unsafe-fields/unsafe-fields-crate.stderr similarity index 100% rename from tests/ui/unsafe-fields-crate.stderr rename to tests/ui/unsafe-fields/unsafe-fields-crate.stderr diff --git a/tests/ui/unsafe-fields-parse.rs b/tests/ui/unsafe-fields/unsafe-fields-parse.rs similarity index 100% rename from tests/ui/unsafe-fields-parse.rs rename to tests/ui/unsafe-fields/unsafe-fields-parse.rs diff --git a/tests/ui/unsafe-fields-parse.stderr b/tests/ui/unsafe-fields/unsafe-fields-parse.stderr similarity index 100% rename from tests/ui/unsafe-fields-parse.stderr rename to tests/ui/unsafe-fields/unsafe-fields-parse.stderr diff --git a/tests/ui/unsafe-fields.rs b/tests/ui/unsafe-fields/unsafe-fields.rs similarity index 100% rename from tests/ui/unsafe-fields.rs rename to tests/ui/unsafe-fields/unsafe-fields.rs diff --git a/tests/ui/unsafe-fields.stderr b/tests/ui/unsafe-fields/unsafe-fields.stderr similarity index 100% rename from tests/ui/unsafe-fields.stderr rename to tests/ui/unsafe-fields/unsafe-fields.stderr From cfc3924d163bb6e665705abc8bd385df36754373 Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Fri, 6 Dec 2024 05:02:50 +0000 Subject: [PATCH 59/59] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 377639882c59..bc81038c961a 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -3b382642aba7cffbb2f47829b24635fad87bcf5c +706141b8d9090228343340378b1d4a2b095fa1fb