From c54301f114d6fab44e8305da328eece26f682456 Mon Sep 17 00:00:00 2001 From: cardigan1008 <211250058@smail.nju.edu.cn> Date: Thu, 9 May 2024 14:36:54 +0800 Subject: [PATCH 01/19] fix: Add if to check whether the previous node is Block --- compiler/rustc_middle/src/hir/map/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index c7aea137b6841..0deafb73d0ed9 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -563,6 +563,9 @@ impl<'hir> Map<'hir> { // We verify that indirectly by checking that the previous node is the // current node's body if node.body_id().map(|b| b.hir_id) == prev_hir_id => { + if let Node::Expr(Expr { kind: ExprKind::Block(_, _), ..}) = self.tcx.hir_node(prev_hir_id.unwrap()) { + return None; + } return Some(hir_id) } // Ignore `return`s on the first iteration From 62318b38ef591c70d9db875e88a04aa37c565828 Mon Sep 17 00:00:00 2001 From: cardigan1008 <211250058@smail.nju.edu.cn> Date: Thu, 9 May 2024 23:44:54 +0800 Subject: [PATCH 02/19] fix: Check whether next_node is else-less if in get_return_block Fix #124819, where a if-less block causes a wrong output. It is caused by get_return_block in get_fn_decl. In get_return_block, when a else-less if expression is the tail expression, the check for next_node will keep iterating. So it is necessary to make a early return in the check. --- compiler/rustc_middle/src/hir/map/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 0deafb73d0ed9..f4ecc0973ef29 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -549,6 +549,7 @@ impl<'hir> Map<'hir> { Node::Block(Block { expr: None, .. }) => return None, // The current node is not the tail expression of its parent. Node::Block(Block { expr: Some(e), .. }) if hir_id != e.hir_id => return None, + Node::Block(Block { expr: Some(e), ..}) if matches!(e.kind, ExprKind::If(_, _, None)) => return None, _ => {} } } @@ -563,9 +564,6 @@ impl<'hir> Map<'hir> { // We verify that indirectly by checking that the previous node is the // current node's body if node.body_id().map(|b| b.hir_id) == prev_hir_id => { - if let Node::Expr(Expr { kind: ExprKind::Block(_, _), ..}) = self.tcx.hir_node(prev_hir_id.unwrap()) { - return None; - } return Some(hir_id) } // Ignore `return`s on the first iteration From 1a3a54c513a9032582a092f20315031f8a485aaf Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 21 Apr 2024 18:05:02 +1000 Subject: [PATCH 03/19] coverage: Store expression operands as `BcbCounter` --- .../src/coverage/counters.rs | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index b98554ec00fa2..07a1862e5db63 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -35,6 +35,13 @@ impl Debug for BcbCounter { } } +#[derive(Debug)] +struct BcbExpression { + lhs: BcbCounter, + op: Op, + rhs: BcbCounter, +} + #[derive(Debug)] pub(super) enum CounterIncrementSite { Node { bcb: BasicCoverageBlock }, @@ -58,7 +65,7 @@ pub(super) struct CoverageCounters { bcb_edge_counters: FxHashMap<(BasicCoverageBlock, BasicCoverageBlock), BcbCounter>, /// Table of expression data, associating each expression ID with its /// corresponding operator (+ or -) and its LHS/RHS operands. - expressions: IndexVec, + expressions: IndexVec, } impl CoverageCounters { @@ -90,8 +97,7 @@ impl CoverageCounters { } fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter { - let expression = Expression { lhs: lhs.as_term(), op, rhs: rhs.as_term() }; - let id = self.expressions.push(expression); + let id = self.expressions.push(BcbExpression { lhs, op, rhs }); BcbCounter::Expression { id } } @@ -166,7 +172,21 @@ impl CoverageCounters { } pub(super) fn into_expressions(self) -> IndexVec { - self.expressions + let old_len = self.expressions.len(); + let expressions = self + .expressions + .into_iter() + .map(|BcbExpression { lhs, op, rhs }| Expression { + lhs: lhs.as_term(), + op, + rhs: rhs.as_term(), + }) + .collect::>(); + + // Expression IDs are indexes into this vector, so make sure we didn't + // accidentally invalidate them by changing its length. + assert_eq!(old_len, expressions.len()); + expressions } } From a68bb5e176ff7f250c0af00467a6793952be7489 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 21 Apr 2024 18:11:57 +1000 Subject: [PATCH 04/19] coverage: Memoize newly-created counter expressions This currently has no effect, but is expected to be useful when expanding support for branch coverage and MC/DC coverage. --- compiler/rustc_middle/src/mir/coverage.rs | 4 ++-- .../src/coverage/counters.rs | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/mir/coverage.rs b/compiler/rustc_middle/src/mir/coverage.rs index 477303e2434f4..8d754f76ae84e 100644 --- a/compiler/rustc_middle/src/mir/coverage.rs +++ b/compiler/rustc_middle/src/mir/coverage.rs @@ -187,8 +187,8 @@ impl Debug for CodeRegion { } } -#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)] -#[derive(TypeFoldable, TypeVisitable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)] +#[derive(TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)] pub enum Op { Subtract, Add, diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 07a1862e5db63..908b1495b669c 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -11,7 +11,7 @@ use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverage /// The coverage counter or counter expression associated with a particular /// BCB node or BCB edge. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub(super) enum BcbCounter { Counter { id: CounterId }, Expression { id: ExpressionId }, @@ -35,7 +35,7 @@ impl Debug for BcbCounter { } } -#[derive(Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] struct BcbExpression { lhs: BcbCounter, op: Op, @@ -63,9 +63,13 @@ pub(super) struct CoverageCounters { /// 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. bcb_edge_counters: FxHashMap<(BasicCoverageBlock, BasicCoverageBlock), BcbCounter>, + /// Table of expression data, associating each expression ID with its /// corresponding operator (+ or -) and its LHS/RHS operands. expressions: IndexVec, + /// Remember expressions that have already been created (or simplified), + /// so that we don't create unnecessary duplicates. + expressions_memo: FxHashMap, } impl CoverageCounters { @@ -83,6 +87,7 @@ impl CoverageCounters { bcb_counters: IndexVec::from_elem_n(None, num_bcbs), bcb_edge_counters: FxHashMap::default(), expressions: IndexVec::new(), + expressions_memo: FxHashMap::default(), }; MakeBcbCounters::new(&mut this, basic_coverage_blocks) @@ -97,7 +102,20 @@ impl CoverageCounters { } fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter { - let id = self.expressions.push(BcbExpression { lhs, op, rhs }); + 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 { + let id = expressions.push(new_expr); BcbCounter::Expression { id } } From d01df6f9aadf58a00357bd89b8fc25a44822ba77 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 14 May 2024 13:51:24 +1000 Subject: [PATCH 05/19] coverage: Simplify counter expressions using simple algebra Some of these cases currently don't occur in practice, but are included for completeness, and to avoid having to add them later as branch coverage and MC/DC coverage start building more complex expressions. --- .../src/coverage/counters.rs | 37 ++ tests/coverage/abort.cov-map | 42 +- tests/coverage/async.cov-map | 16 +- tests/coverage/async2.cov-map | 16 +- tests/coverage/async_block.cov-map | 16 +- tests/coverage/branch/generics.cov-map | 24 +- tests/coverage/branch/if-let.cov-map | 8 +- tests/coverage/branch/if.cov-map | 140 ++---- tests/coverage/branch/lazy-boolean.cov-map | 107 +++-- tests/coverage/branch/let-else.cov-map | 8 +- tests/coverage/branch/while.cov-map | 26 +- tests/coverage/closure.cov-map | 80 ++-- tests/coverage/closure_bug.cov-map | 109 ++--- tests/coverage/closure_macro.cov-map | 8 +- tests/coverage/closure_macro_async.cov-map | 8 +- tests/coverage/conditions.cov-map | 404 +++++++++--------- tests/coverage/coroutine.cov-map | 8 +- tests/coverage/dead_code.cov-map | 8 +- tests/coverage/drop_trait.cov-map | 8 +- tests/coverage/fn_sig_into_try.cov-map | 24 +- tests/coverage/generics.cov-map | 8 +- tests/coverage/if.cov-map | 8 +- tests/coverage/if_else.cov-map | 21 +- tests/coverage/if_not.cov-map | 38 +- tests/coverage/inline-dead.cov-map | 8 +- tests/coverage/inline.cov-map | 8 +- tests/coverage/inner_items.cov-map | 21 +- tests/coverage/issue-84561.cov-map | 167 +++----- tests/coverage/lazy_boolean.cov-map | 236 ++-------- tests/coverage/loops_branches.cov-map | 240 +++++------ tests/coverage/match_or_pattern.cov-map | 96 ++--- tests/coverage/no_cov_crate.cov-map | 16 +- tests/coverage/overflow.cov-map | 8 +- tests/coverage/simple_loop.cov-map | 23 +- tests/coverage/simple_match.cov-map | 35 +- tests/coverage/sort_groups.cov-map | 40 +- tests/coverage/try_error_result.cov-map | 32 +- tests/coverage/unicode.cov-map | 28 +- tests/coverage/uses_inline_crate.cov-map | 8 +- tests/coverage/while.cov-map | 8 +- ...ment_coverage.main.InstrumentCoverage.diff | 6 +- ...rage_cleanup.main.CleanupPostBorrowck.diff | 4 +- ...erage_cleanup.main.InstrumentCoverage.diff | 4 +- 43 files changed, 845 insertions(+), 1315 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index 908b1495b669c..b5968517d772d 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -115,6 +115,43 @@ impl CoverageCounters { 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 } } diff --git a/tests/coverage/abort.cov-map b/tests/coverage/abort.cov-map index 1c36f2871dd18..5673fa98ca606 100644 --- a/tests/coverage/abort.cov-map +++ b/tests/coverage/abort.cov-map @@ -1,45 +1,37 @@ Function name: abort::main -Raw bytes (105): 0x[01, 01, 12, 01, 47, 05, 09, 03, 0d, 42, 11, 03, 0d, 11, 3e, 42, 11, 03, 0d, 3b, 15, 11, 3e, 42, 11, 03, 0d, 15, 36, 3b, 15, 11, 3e, 42, 11, 03, 0d, 05, 09, 0d, 01, 0e, 01, 01, 1b, 03, 02, 0b, 00, 18, 42, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 3e, 02, 0a, 00, 0b, 3b, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 36, 00, 31, 00, 32, 33, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 31, 00, 32, 47, 01, 09, 00, 17, 0d, 02, 05, 01, 02] +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, 0e, 01, 01, 1b, 03, 02, 0b, 00, 18, 22, 01, 0c, 00, 19, 11, 00, 1a, 02, 0a, 0e, 02, 0a, 00, 0b, 22, 02, 0c, 00, 19, 15, 00, 1a, 00, 31, 1a, 00, 31, 00, 32, 22, 04, 0c, 00, 19, 05, 00, 1a, 00, 31, 09, 00, 31, 00, 32, 27, 01, 09, 00, 17, 0d, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 18 -- expression 0 operands: lhs = Counter(0), rhs = Expression(17, Add) +Number of expressions: 10 +- expression 0 operands: lhs = Counter(0), rhs = Expression(9, Add) - expression 1 operands: lhs = Counter(1), rhs = Counter(2) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Expression(16, Sub), rhs = Counter(4) +- expression 3 operands: lhs = Expression(8, Sub), rhs = Counter(4) - expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 5 operands: lhs = Counter(4), rhs = Expression(15, Sub) -- expression 6 operands: lhs = Expression(16, Sub), 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 8 operands: lhs = Expression(14, Add), rhs = Counter(5) -- expression 9 operands: lhs = Counter(4), rhs = Expression(15, Sub) -- expression 10 operands: lhs = Expression(16, Sub), rhs = Counter(4) -- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 12 operands: lhs = Counter(5), rhs = Expression(13, Sub) -- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(5) -- expression 14 operands: lhs = Counter(4), rhs = Expression(15, Sub) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(4) -- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 17 operands: lhs = Counter(1), rhs = Counter(2) +- 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 + 14, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) = (c0 + (c1 + c2)) -- Code(Expression(16, Sub)) at (prev + 1, 12) to (start + 0, 25) +- Code(Expression(8, Sub)) at (prev + 1, 12) to (start + 0, 25) = ((c0 + (c1 + c2)) - c3) - Code(Counter(4)) at (prev + 0, 26) to (start + 2, 10) -- Code(Expression(15, Sub)) at (prev + 2, 10) to (start + 0, 11) +- Code(Expression(3, Sub)) at (prev + 2, 10) to (start + 0, 11) = (((c0 + (c1 + c2)) - c3) - c4) -- Code(Expression(14, Add)) at (prev + 2, 12) to (start + 0, 25) - = (c4 + (((c0 + (c1 + c2)) - c3) - c4)) +- Code(Expression(8, Sub)) at (prev + 2, 12) to (start + 0, 25) + = ((c0 + (c1 + c2)) - c3) - Code(Counter(5)) at (prev + 0, 26) to (start + 0, 49) -- Code(Expression(13, Sub)) at (prev + 0, 49) to (start + 0, 50) - = ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5) -- Code(Expression(12, Add)) at (prev + 4, 12) to (start + 0, 25) - = (c5 + ((c4 + (((c0 + (c1 + c2)) - c3) - c4)) - c5)) +- Code(Expression(6, Sub)) at (prev + 0, 49) to (start + 0, 50) + = (((c0 + (c1 + c2)) - c3) - c5) +- Code(Expression(8, Sub)) at (prev + 4, 12) to (start + 0, 25) + = ((c0 + (c1 + c2)) - c3) - Code(Counter(1)) at (prev + 0, 26) to (start + 0, 49) - Code(Counter(2)) at (prev + 0, 49) to (start + 0, 50) -- Code(Expression(17, Add)) at (prev + 1, 9) to (start + 0, 23) +- Code(Expression(9, Add)) at (prev + 1, 9) to (start + 0, 23) = (c1 + c2) - Code(Counter(3)) at (prev + 2, 5) to (start + 1, 2) diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map index e06d1676358fb..7d16372375a7b 100644 --- a/tests/coverage/async.cov-map +++ b/tests/coverage/async.cov-map @@ -7,19 +7,17 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 9, 1) to (start + 0, 25) Function name: async::c::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 09, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 09, 19, 01, 0e, 05, 02, 09, 00, 0a, 02, 02, 09, 00, 0a, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 9, 25) to (start + 1, 14) - Code(Counter(1)) at (prev + 2, 9) to (start + 0, 10) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Function name: async::d Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 00, 14] @@ -188,19 +186,17 @@ Number of file 0 mappings: 9 = ((c1 + c2) + c3) Function name: async::j::c -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 37, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 07, 02, 05, 00, 06] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 37, 05, 01, 12, 05, 02, 0d, 00, 0e, 02, 0a, 0d, 00, 0e, 01, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 55, 5) to (start + 1, 18) - Code(Counter(1)) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(0, Sub)) at (prev + 10, 13) to (start + 0, 14) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 6) Function name: async::j::d Raw bytes (9): 0x[01, 01, 00, 01, 01, 46, 05, 00, 17] diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map index 28f319bfb80bd..e39a1d7dd2f92 100644 --- a/tests/coverage/async2.cov-map +++ b/tests/coverage/async2.cov-map @@ -7,17 +7,15 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 13, 1) to (start + 0, 23) Function name: async2::async_func::{closure#0} -Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 0d, 17, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 0d, 17, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 13, 23) to (start + 3, 9) - Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) - Code(Zero) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + Zero) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: async2::async_func_just_println Raw bytes (9): 0x[01, 01, 00, 01, 01, 15, 01, 00, 24] @@ -44,15 +42,13 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 25, 1) to (start + 7, 2) Function name: async2::non_async_func -Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 05, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 03, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 05, 01, 03, 09, 05, 03, 0a, 02, 06, 00, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 5, 1) to (start + 3, 9) - Code(Counter(1)) at (prev + 3, 10) to (start + 2, 6) - Code(Zero) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + Zero) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) diff --git a/tests/coverage/async_block.cov-map b/tests/coverage/async_block.cov-map index 104133f6e6786..e54c15c04362b 100644 --- a/tests/coverage/async_block.cov-map +++ b/tests/coverage/async_block.cov-map @@ -1,10 +1,9 @@ Function name: async_block::main -Raw bytes (38): 0x[01, 01, 02, 01, 05, 03, 05, 06, 01, 05, 01, 00, 0b, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 13, 05, 00, 14, 01, 16, 05, 07, 0a, 02, 06, 06, 03, 01, 00, 02] +Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 05, 01, 00, 0b, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 13, 05, 00, 14, 01, 16, 05, 07, 0a, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 5, 1) to (start + 0, 11) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 10) @@ -12,21 +11,18 @@ Number of file 0 mappings: 6 = (c0 + c1) - Code(Counter(1)) at (prev + 0, 20) to (start + 1, 22) - Code(Counter(1)) at (prev + 7, 10) to (start + 2, 6) -- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2) - = ((c0 + c1) - c1) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Function name: async_block::main::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 07, 1c, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 07, 1c, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 7, 28) to (start + 1, 23) - Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) - Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 10) diff --git a/tests/coverage/branch/generics.cov-map b/tests/coverage/branch/generics.cov-map index d729b0c260a54..2e5668c8b568e 100644 --- a/tests/coverage/branch/generics.cov-map +++ b/tests/coverage/branch/generics.cov-map @@ -1,10 +1,9 @@ Function name: generics::print_size::<()> -Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) - Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) @@ -13,16 +12,14 @@ Number of file 0 mappings: 5 - Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Function name: generics::print_size:: -Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) - Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) @@ -31,16 +28,14 @@ Number of file 0 mappings: 5 - Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Function name: generics::print_size:: -Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) - Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) @@ -49,6 +44,5 @@ Number of file 0 mappings: 5 - Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) diff --git a/tests/coverage/branch/if-let.cov-map b/tests/coverage/branch/if-let.cov-map index 0c7d986933e7d..0b098bc6497ce 100644 --- a/tests/coverage/branch/if-let.cov-map +++ b/tests/coverage/branch/if-let.cov-map @@ -1,10 +1,9 @@ Function name: if_let::if_let -Raw bytes (45): 0x[01, 01, 02, 05, 09, 09, 02, 07, 01, 0c, 01, 01, 10, 20, 02, 09, 03, 0c, 00, 13, 02, 00, 11, 00, 12, 05, 00, 16, 00, 1b, 02, 00, 1c, 02, 06, 09, 02, 0c, 02, 06, 07, 03, 05, 01, 02] +Raw bytes (43): 0x[01, 01, 01, 05, 09, 07, 01, 0c, 01, 01, 10, 20, 02, 09, 03, 0c, 00, 13, 02, 00, 11, 00, 12, 05, 00, 16, 00, 1b, 02, 00, 1c, 02, 06, 09, 02, 0c, 02, 06, 05, 03, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) - Branch { true: Expression(0, Sub), false: Counter(2) } at (prev + 3, 12) to (start + 0, 19) @@ -16,8 +15,7 @@ Number of file 0 mappings: 7 - Code(Expression(0, Sub)) at (prev + 0, 28) to (start + 2, 6) = (c1 - c2) - Code(Counter(2)) at (prev + 2, 12) to (start + 2, 6) -- Code(Expression(1, Add)) at (prev + 3, 5) to (start + 1, 2) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 3, 5) to (start + 1, 2) Function name: if_let::if_let_chain Raw bytes (66): 0x[01, 01, 04, 01, 05, 05, 09, 0f, 0d, 05, 09, 0a, 01, 17, 01, 00, 33, 20, 02, 05, 01, 0c, 00, 13, 02, 00, 11, 00, 12, 01, 00, 16, 00, 17, 20, 0d, 09, 01, 10, 00, 17, 0d, 00, 15, 00, 16, 02, 00, 1a, 00, 1b, 0d, 01, 05, 03, 06, 0f, 03, 0c, 02, 06, 0b, 03, 05, 01, 02] diff --git a/tests/coverage/branch/if.cov-map b/tests/coverage/branch/if.cov-map index 50f6216e06980..7f4ee980e2620 100644 --- a/tests/coverage/branch/if.cov-map +++ b/tests/coverage/branch/if.cov-map @@ -24,51 +24,17 @@ Number of file 0 mappings: 8 = (c4 + (c3 + (c1 - c2))) Function name: if::branch_not -Raw bytes (224): 0x[01, 01, 29, 05, 09, 09, 02, a3, 01, 0d, 09, 02, a3, 01, 0d, 09, 02, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 15, 8e, 01, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 12, 01, 0c, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 01, 09, 00, 11, 02, 01, 06, 00, 07, a3, 01, 01, 08, 00, 0a, 20, 9e, 01, 0d, 00, 08, 00, 0a, 9e, 01, 00, 0b, 02, 06, 0d, 02, 06, 00, 07, 9b, 01, 01, 08, 00, 0b, 20, 11, 96, 01, 00, 08, 00, 0b, 11, 00, 0c, 02, 06, 96, 01, 02, 06, 00, 07, 93, 01, 01, 08, 00, 0c, 20, 8e, 01, 15, 00, 08, 00, 0c, 8e, 01, 00, 0d, 02, 06, 15, 02, 06, 00, 07, 8b, 01, 01, 01, 00, 02] +Raw bytes (116): 0x[01, 01, 07, 05, 09, 05, 0d, 05, 0d, 05, 11, 05, 11, 05, 15, 05, 15, 12, 01, 0c, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 01, 09, 00, 11, 02, 01, 06, 00, 07, 05, 01, 08, 00, 0a, 20, 0a, 0d, 00, 08, 00, 0a, 0a, 00, 0b, 02, 06, 0d, 02, 06, 00, 07, 05, 01, 08, 00, 0b, 20, 11, 12, 00, 08, 00, 0b, 11, 00, 0c, 02, 06, 12, 02, 06, 00, 07, 05, 01, 08, 00, 0c, 20, 1a, 15, 00, 08, 00, 0c, 1a, 00, 0d, 02, 06, 15, 02, 06, 00, 07, 05, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 41 +Number of expressions: 7 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 6 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 7 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 8 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 9 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 10 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 11 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 12 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 13 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 14 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 15 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 16 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 17 operands: lhs = Counter(4), rhs = Expression(37, Sub) -- expression 18 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 19 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 20 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 21 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 22 operands: lhs = Expression(36, Add), rhs = Counter(5) -- expression 23 operands: lhs = Counter(4), rhs = Expression(37, Sub) -- expression 24 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 25 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 26 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 27 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 28 operands: lhs = Expression(36, Add), rhs = Counter(5) -- expression 29 operands: lhs = Counter(4), rhs = Expression(37, Sub) -- expression 30 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 31 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 32 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 33 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 34 operands: lhs = Counter(5), rhs = Expression(35, Sub) -- expression 35 operands: lhs = Expression(36, Add), rhs = Counter(5) -- expression 36 operands: lhs = Counter(4), rhs = Expression(37, Sub) -- expression 37 operands: lhs = Expression(38, Add), rhs = Counter(4) -- expression 38 operands: lhs = Counter(3), rhs = Expression(39, Sub) -- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(3) -- expression 40 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(4) +- expression 4 operands: lhs = Counter(1), rhs = Counter(4) +- expression 5 operands: lhs = Counter(1), rhs = Counter(5) +- expression 6 operands: lhs = Counter(1), rhs = Counter(5) Number of file 0 mappings: 18 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9) @@ -78,60 +44,39 @@ Number of file 0 mappings: 18 - Code(Counter(2)) at (prev + 1, 9) to (start + 0, 17) - Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 0, 7) = (c1 - c2) -- Code(Expression(40, Add)) at (prev + 1, 8) to (start + 0, 10) - = (c2 + (c1 - c2)) -- Branch { true: Expression(39, Sub), false: Counter(3) } at (prev + 0, 8) to (start + 0, 10) - true = ((c2 + (c1 - c2)) - c3) +- Code(Counter(1)) at (prev + 1, 8) to (start + 0, 10) +- Branch { true: Expression(2, Sub), false: Counter(3) } at (prev + 0, 8) to (start + 0, 10) + true = (c1 - c3) false = c3 -- Code(Expression(39, Sub)) at (prev + 0, 11) to (start + 2, 6) - = ((c2 + (c1 - c2)) - c3) +- Code(Expression(2, Sub)) at (prev + 0, 11) to (start + 2, 6) + = (c1 - c3) - Code(Counter(3)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(38, Add)) at (prev + 1, 8) to (start + 0, 11) - = (c3 + ((c2 + (c1 - c2)) - c3)) -- Branch { true: Counter(4), false: Expression(37, Sub) } at (prev + 0, 8) to (start + 0, 11) +- Code(Counter(1)) at (prev + 1, 8) to (start + 0, 11) +- Branch { true: Counter(4), false: Expression(4, Sub) } at (prev + 0, 8) to (start + 0, 11) true = c4 - false = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) + false = (c1 - c4) - Code(Counter(4)) at (prev + 0, 12) to (start + 2, 6) -- Code(Expression(37, Sub)) at (prev + 2, 6) to (start + 0, 7) - = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) -- Code(Expression(36, Add)) at (prev + 1, 8) to (start + 0, 12) - = (c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) -- Branch { true: Expression(35, Sub), false: Counter(5) } at (prev + 0, 8) to (start + 0, 12) - true = ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5) +- Code(Expression(4, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c1 - c4) +- Code(Counter(1)) at (prev + 1, 8) to (start + 0, 12) +- Branch { true: Expression(6, Sub), false: Counter(5) } at (prev + 0, 8) to (start + 0, 12) + true = (c1 - c5) false = c5 -- Code(Expression(35, Sub)) at (prev + 0, 13) to (start + 2, 6) - = ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5) +- Code(Expression(6, Sub)) at (prev + 0, 13) to (start + 2, 6) + = (c1 - c5) - Code(Counter(5)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(34, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c5 + ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5)) +- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) Function name: if::branch_not_as -Raw bytes (124): 0x[01, 01, 16, 05, 09, 09, 02, 57, 0d, 09, 02, 57, 0d, 09, 02, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 11, 4a, 4f, 11, 0d, 52, 57, 0d, 09, 02, 0e, 01, 1d, 01, 01, 10, 05, 03, 08, 00, 14, 20, 02, 09, 00, 08, 00, 14, 02, 00, 15, 02, 06, 09, 02, 06, 00, 07, 57, 01, 08, 00, 15, 20, 0d, 52, 00, 08, 00, 15, 0d, 00, 16, 02, 06, 52, 02, 06, 00, 07, 4f, 01, 08, 00, 16, 20, 4a, 11, 00, 08, 00, 16, 4a, 00, 17, 02, 06, 11, 02, 06, 00, 07, 47, 01, 01, 00, 02] +Raw bytes (90): 0x[01, 01, 05, 05, 09, 05, 0d, 05, 0d, 05, 11, 05, 11, 0e, 01, 1d, 01, 01, 10, 05, 03, 08, 00, 14, 20, 02, 09, 00, 08, 00, 14, 02, 00, 15, 02, 06, 09, 02, 06, 00, 07, 05, 01, 08, 00, 15, 20, 0d, 0a, 00, 08, 00, 15, 0d, 00, 16, 02, 06, 0a, 02, 06, 00, 07, 05, 01, 08, 00, 16, 20, 12, 11, 00, 08, 00, 16, 12, 00, 17, 02, 06, 11, 02, 06, 00, 07, 05, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 22 +Number of expressions: 5 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 6 operands: lhs = Counter(3), rhs = Expression(20, Sub) -- expression 7 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 8 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 9 operands: lhs = Expression(19, Add), rhs = Counter(4) -- expression 10 operands: lhs = Counter(3), rhs = Expression(20, Sub) -- expression 11 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 12 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 13 operands: lhs = Expression(19, Add), rhs = Counter(4) -- expression 14 operands: lhs = Counter(3), rhs = Expression(20, Sub) -- expression 15 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 16 operands: lhs = Counter(2), rhs = Expression(0, Sub) -- expression 17 operands: lhs = Counter(4), rhs = Expression(18, Sub) -- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(4) -- expression 19 operands: lhs = Counter(3), rhs = Expression(20, Sub) -- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(3) -- expression 21 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(1), rhs = Counter(3) +- expression 2 operands: lhs = Counter(1), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(4) +- expression 4 operands: lhs = Counter(1), rhs = Counter(4) Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 29, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 20) @@ -141,24 +86,21 @@ Number of file 0 mappings: 14 - Code(Expression(0, Sub)) at (prev + 0, 21) to (start + 2, 6) = (c1 - c2) - Code(Counter(2)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(21, Add)) at (prev + 1, 8) to (start + 0, 21) - = (c2 + (c1 - c2)) -- Branch { true: Counter(3), false: Expression(20, Sub) } at (prev + 0, 8) to (start + 0, 21) +- Code(Counter(1)) at (prev + 1, 8) to (start + 0, 21) +- Branch { true: Counter(3), false: Expression(2, Sub) } at (prev + 0, 8) to (start + 0, 21) true = c3 - false = ((c2 + (c1 - c2)) - c3) + false = (c1 - c3) - Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6) -- Code(Expression(20, Sub)) at (prev + 2, 6) to (start + 0, 7) - = ((c2 + (c1 - c2)) - c3) -- Code(Expression(19, Add)) at (prev + 1, 8) to (start + 0, 22) - = (c3 + ((c2 + (c1 - c2)) - c3)) -- Branch { true: Expression(18, Sub), false: Counter(4) } at (prev + 0, 8) to (start + 0, 22) - true = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) +- Code(Expression(2, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c1 - c3) +- Code(Counter(1)) at (prev + 1, 8) to (start + 0, 22) +- Branch { true: Expression(4, Sub), false: Counter(4) } at (prev + 0, 8) to (start + 0, 22) + true = (c1 - c4) false = c4 -- Code(Expression(18, Sub)) at (prev + 0, 23) to (start + 2, 6) - = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) +- Code(Expression(4, Sub)) at (prev + 0, 23) to (start + 2, 6) + = (c1 - c4) - Code(Counter(4)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(17, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) +- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) Function name: if::branch_or Raw bytes (56): 0x[01, 01, 04, 05, 09, 09, 0d, 0f, 11, 09, 0d, 08, 01, 35, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 20, 0d, 11, 00, 0d, 00, 0e, 0f, 00, 0f, 02, 06, 11, 02, 0c, 02, 06, 0b, 03, 01, 00, 02] diff --git a/tests/coverage/branch/lazy-boolean.cov-map b/tests/coverage/branch/lazy-boolean.cov-map index e2d731022d7cd..09ce91376733b 100644 --- a/tests/coverage/branch/lazy-boolean.cov-map +++ b/tests/coverage/branch/lazy-boolean.cov-map @@ -1,44 +1,35 @@ Function name: lazy_boolean::branch_and -Raw bytes (42): 0x[01, 01, 03, 09, 0a, 05, 09, 05, 09, 06, 01, 13, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 0a, 00, 0d, 00, 0e, 09, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (38): 0x[01, 01, 01, 05, 09, 06, 01, 13, 01, 01, 10, 05, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 02, 00, 0d, 00, 0e, 09, 00, 12, 00, 13, 05, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Counter(2), rhs = Expression(2, Sub) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 19, 1) to (start + 1, 16) -- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 4, 9) to (start + 0, 10) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 13) to (start + 0, 14) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 13) to (start + 0, 14) true = c2 false = (c1 - c2) - Code(Counter(2)) at (prev + 0, 18) to (start + 0, 19) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 1, 5) to (start + 1, 2) Function name: lazy_boolean::branch_or -Raw bytes (44): 0x[01, 01, 04, 09, 0e, 05, 09, 05, 09, 05, 09, 06, 01, 1b, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 0e, 00, 0d, 00, 0e, 0e, 00, 12, 00, 13, 03, 01, 05, 01, 02] +Raw bytes (38): 0x[01, 01, 01, 05, 09, 06, 01, 1b, 01, 01, 10, 05, 04, 09, 00, 0a, 05, 00, 0d, 00, 0e, 20, 09, 02, 00, 0d, 00, 0e, 02, 00, 12, 00, 13, 05, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 4 -- expression 0 operands: lhs = Counter(2), rhs = Expression(3, 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 = Counter(2) +Number of expressions: 1 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 27, 1) to (start + 1, 16) -- Code(Expression(0, Add)) at (prev + 4, 9) to (start + 0, 10) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 4, 9) to (start + 0, 10) - Code(Counter(1)) at (prev + 0, 13) to (start + 0, 14) -- Branch { true: Counter(2), false: Expression(3, Sub) } at (prev + 0, 13) to (start + 0, 14) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 13) to (start + 0, 14) true = c2 false = (c1 - c2) -- Code(Expression(3, Sub)) at (prev + 0, 18) to (start + 0, 19) +- Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 19) = (c1 - c2) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 1, 5) to (start + 1, 2) 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] @@ -105,73 +96,71 @@ Number of file 0 mappings: 19 = (((c6 + c7) + c8) + c9) Function name: lazy_boolean::nested_mixed -Raw bytes (159): 0x[01, 01, 18, 07, 22, 11, 36, 3b, 11, 09, 0d, 26, 0d, 05, 09, 05, 09, 05, 09, 26, 0d, 05, 09, 09, 0d, 3b, 11, 09, 0d, 3b, 11, 09, 0d, 19, 5f, 1d, 21, 03, 15, 15, 19, 52, 56, 15, 19, 03, 15, 19, 5f, 1d, 21, 13, 01, 31, 01, 01, 10, 03, 04, 09, 00, 0a, 05, 00, 0e, 00, 13, 20, 09, 26, 00, 0e, 00, 13, 26, 00, 17, 00, 1d, 20, 0d, 22, 00, 17, 00, 1d, 3b, 00, 23, 00, 28, 20, 11, 36, 00, 23, 00, 28, 36, 00, 2c, 00, 33, 03, 01, 05, 00, 11, 5b, 03, 09, 00, 0a, 03, 00, 0e, 00, 13, 20, 15, 56, 00, 0e, 00, 13, 15, 00, 17, 00, 1c, 20, 19, 52, 00, 17, 00, 1c, 4f, 00, 22, 00, 28, 20, 1d, 21, 00, 22, 00, 28, 1d, 00, 2c, 00, 33, 5b, 01, 05, 01, 02] +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] Number of files: 1 - file 0 => global file 1 -Number of expressions: 24 -- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(8, Sub) -- expression 1 operands: lhs = Counter(4), rhs = Expression(13, Sub) -- expression 2 operands: lhs = Expression(14, Add), rhs = Counter(4) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) -- expression 4 operands: lhs = Expression(9, Sub), rhs = Counter(3) +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 = 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 = Expression(9, Sub), rhs = Counter(3) -- expression 9 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(14, Add), rhs = Counter(4) +- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(4) - expression 12 operands: lhs = Counter(2), rhs = Counter(3) -- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(4) -- expression 14 operands: lhs = Counter(2), rhs = Counter(3) -- expression 15 operands: lhs = Counter(6), rhs = Expression(23, Add) -- expression 16 operands: lhs = Counter(7), rhs = Counter(8) -- expression 17 operands: lhs = Expression(0, Add), rhs = Counter(5) +- 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(20, Sub), rhs = Expression(21, Sub) -- expression 20 operands: lhs = Counter(5), rhs = Counter(6) -- expression 21 operands: lhs = Expression(0, Add), rhs = Counter(5) -- expression 22 operands: lhs = Counter(6), rhs = Expression(23, Add) -- expression 23 operands: lhs = Counter(7), rhs = Counter(8) +- 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 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) - = ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) + = ((c2 + c3) + ((c1 - c2) - c3)) - Code(Counter(1)) at (prev + 0, 14) to (start + 0, 19) -- Branch { true: Counter(2), false: Expression(9, Sub) } at (prev + 0, 14) to (start + 0, 19) +- Branch { true: Counter(2), false: Expression(7, Sub) } at (prev + 0, 14) to (start + 0, 19) true = c2 false = (c1 - c2) -- Code(Expression(9, Sub)) at (prev + 0, 23) to (start + 0, 29) +- Code(Expression(7, Sub)) at (prev + 0, 23) to (start + 0, 29) = (c1 - c2) -- Branch { true: Counter(3), false: Expression(8, Sub) } at (prev + 0, 23) to (start + 0, 29) +- Branch { true: Counter(3), false: Expression(6, Sub) } at (prev + 0, 23) to (start + 0, 29) true = c3 false = ((c1 - c2) - c3) -- Code(Expression(14, Add)) at (prev + 0, 35) to (start + 0, 40) +- Code(Expression(12, Add)) at (prev + 0, 35) to (start + 0, 40) = (c2 + c3) -- Branch { true: Counter(4), false: Expression(13, Sub) } at (prev + 0, 35) to (start + 0, 40) +- Branch { true: Counter(4), false: Expression(11, Sub) } at (prev + 0, 35) to (start + 0, 40) true = c4 false = ((c2 + c3) - c4) -- Code(Expression(13, Sub)) at (prev + 0, 44) to (start + 0, 51) +- Code(Expression(11, Sub)) at (prev + 0, 44) to (start + 0, 51) = ((c2 + c3) - c4) - Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 17) - = ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) -- Code(Expression(22, Add)) at (prev + 3, 9) to (start + 0, 10) + = ((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) - = ((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) -- Branch { true: Counter(5), false: Expression(21, Sub) } 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) true = c5 - false = (((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) - c5) + false = (((c2 + c3) + ((c1 - c2) - c3)) - c5) - Code(Counter(5)) at (prev + 0, 23) to (start + 0, 28) -- Branch { true: Counter(6), false: Expression(20, Sub) } at (prev + 0, 23) to (start + 0, 28) +- Branch { true: Counter(6), false: Expression(18, Sub) } at (prev + 0, 23) to (start + 0, 28) true = c6 false = (c5 - c6) -- Code(Expression(19, Add)) at (prev + 0, 34) to (start + 0, 40) - = ((c5 - c6) + (((c4 + ((c2 + c3) - c4)) + ((c1 - c2) - c3)) - c5)) +- Code(Expression(17, Add)) at (prev + 0, 34) to (start + 0, 40) + = ((c5 - c6) + (((c2 + c3) + ((c1 - c2) - c3)) - c5)) - 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(22, Add)) at (prev + 1, 5) to (start + 1, 2) +- Code(Expression(20, Add)) at (prev + 1, 5) to (start + 1, 2) = (c6 + (c7 + c8)) diff --git a/tests/coverage/branch/let-else.cov-map b/tests/coverage/branch/let-else.cov-map index c7f7adddbc295..0707993446478 100644 --- a/tests/coverage/branch/let-else.cov-map +++ b/tests/coverage/branch/let-else.cov-map @@ -1,10 +1,9 @@ Function name: let_else::let_else -Raw bytes (45): 0x[01, 01, 02, 05, 09, 09, 02, 07, 01, 0c, 01, 01, 10, 20, 02, 09, 03, 09, 00, 10, 02, 00, 0e, 00, 0f, 05, 00, 13, 00, 18, 09, 01, 09, 01, 0f, 02, 04, 05, 00, 0b, 07, 01, 01, 00, 02] +Raw bytes (43): 0x[01, 01, 01, 05, 09, 07, 01, 0c, 01, 01, 10, 20, 02, 09, 03, 09, 00, 10, 02, 00, 0e, 00, 0f, 05, 00, 13, 00, 18, 09, 01, 09, 01, 0f, 02, 04, 05, 00, 0b, 05, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) - Branch { true: Expression(0, Sub), false: Counter(2) } at (prev + 3, 9) to (start + 0, 16) @@ -16,6 +15,5 @@ Number of file 0 mappings: 7 - Code(Counter(2)) at (prev + 1, 9) to (start + 1, 15) - Code(Expression(0, Sub)) at (prev + 4, 5) to (start + 0, 11) = (c1 - c2) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c2 + (c1 - c2)) +- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) diff --git a/tests/coverage/branch/while.cov-map b/tests/coverage/branch/while.cov-map index 5a3ef096bedd9..fd05bbb69a556 100644 --- a/tests/coverage/branch/while.cov-map +++ b/tests/coverage/branch/while.cov-map @@ -1,42 +1,36 @@ Function name: while::while_cond -Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 0c, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 10, 20, 09, 0a, 00, 0b, 00, 10, 09, 00, 11, 02, 06, 0a, 03, 01, 00, 02] +Raw bytes (38): 0x[01, 01, 01, 05, 09, 06, 01, 0c, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 10, 20, 09, 05, 00, 0b, 00, 10, 09, 00, 11, 02, 06, 05, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 1 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 9) to (start + 0, 18) - Code(Expression(0, Add)) at (prev + 1, 11) to (start + 0, 16) = (c1 + c2) -- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 11) to (start + 0, 16) +- Branch { true: Counter(2), false: Counter(1) } at (prev + 0, 11) to (start + 0, 16) true = c2 - false = ((c1 + c2) - c2) + false = c1 - Code(Counter(2)) at (prev + 0, 17) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 3, 1) to (start + 0, 2) - = ((c1 + c2) - c2) +- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2) Function name: while::while_cond_not -Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 15, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 14, 20, 09, 0a, 00, 0b, 00, 14, 09, 00, 15, 02, 06, 0a, 03, 01, 00, 02] +Raw bytes (38): 0x[01, 01, 01, 05, 09, 06, 01, 15, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 14, 20, 09, 05, 00, 0b, 00, 14, 09, 00, 15, 02, 06, 05, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 1 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 21, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 9) to (start + 0, 18) - Code(Expression(0, Add)) at (prev + 1, 11) to (start + 0, 20) = (c1 + c2) -- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 11) to (start + 0, 20) +- Branch { true: Counter(2), false: Counter(1) } at (prev + 0, 11) to (start + 0, 20) true = c2 - false = ((c1 + c2) - c2) + false = c1 - Code(Counter(2)) at (prev + 0, 21) to (start + 2, 6) -- Code(Expression(2, Sub)) at (prev + 3, 1) to (start + 0, 2) - = ((c1 + c2) - c2) +- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2) 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] diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index 9f0d33745bcb5..f36ef7af7ac38 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -1,10 +1,9 @@ Function name: closure::main -Raw bytes (128): 0x[01, 01, 02, 01, 05, 05, 02, 18, 01, 09, 01, 0f, 0d, 01, 16, 0e, 06, 0a, 01, 10, 05, 13, 0d, 01, 1a, 0e, 06, 0a, 01, 10, 05, 0c, 16, 01, 16, 05, 0d, 18, 01, 19, 09, 01, 1e, 01, 04, 09, 00, 29, 01, 01, 09, 00, 2d, 01, 01, 09, 00, 24, 01, 05, 09, 00, 24, 01, 02, 09, 00, 21, 01, 04, 09, 00, 21, 01, 04, 09, 00, 28, 01, 09, 09, 00, 32, 01, 04, 09, 00, 33, 01, 07, 09, 00, 4b, 01, 08, 09, 00, 48, 01, 0a, 09, 00, 47, 01, 08, 09, 00, 44, 01, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 02, 04, 06, 00, 07, 07, 01, 05, 03, 02] +Raw bytes (126): 0x[01, 01, 01, 01, 05, 18, 01, 09, 01, 0f, 0d, 01, 16, 0e, 06, 0a, 01, 10, 05, 13, 0d, 01, 1a, 0e, 06, 0a, 01, 10, 05, 0c, 16, 01, 16, 05, 0d, 18, 01, 19, 09, 01, 1e, 01, 04, 09, 00, 29, 01, 01, 09, 00, 2d, 01, 01, 09, 00, 24, 01, 05, 09, 00, 24, 01, 02, 09, 00, 21, 01, 04, 09, 00, 21, 01, 04, 09, 00, 28, 01, 09, 09, 00, 32, 01, 04, 09, 00, 33, 01, 07, 09, 00, 4b, 01, 08, 09, 00, 48, 01, 0a, 09, 00, 47, 01, 08, 09, 00, 44, 01, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 02, 04, 06, 00, 07, 01, 01, 05, 03, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 24 - Code(Counter(0)) at (prev + 9, 1) to (start + 15, 13) - Code(Counter(0)) at (prev + 22, 14) to (start + 6, 10) @@ -30,8 +29,7 @@ Number of file 0 mappings: 24 - Code(Counter(1)) at (prev + 0, 17) to (start + 4, 6) - Code(Expression(0, Sub)) at (prev + 4, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 3, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 3, 2) Function name: closure::main::{closure#0} (unused) Raw bytes (24): 0x[01, 01, 00, 04, 00, 28, 05, 02, 14, 00, 02, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06] @@ -77,72 +75,60 @@ Number of file 0 mappings: 1 - Code(Zero) at (prev + 172, 13) to (start + 2, 14) Function name: closure::main::{closure#14} -Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, b3, 01, 0d, 02, 1b, 05, 02, 1e, 00, 25, 02, 00, 2f, 00, 33, 07, 01, 0d, 00, 0e] +Raw bytes (27): 0x[01, 01, 01, 01, 05, 04, 01, b3, 01, 0d, 02, 1b, 05, 02, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 01, 0d, 00, 0e] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 179, 13) to (start + 2, 27) - Code(Counter(1)) at (prev + 2, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 14) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) Function name: closure::main::{closure#15} -Raw bytes (41): 0x[01, 01, 03, 05, 0a, 01, 05, 01, 05, 06, 01, bb, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 03, 02, 09, 00, 0a] +Raw bytes (37): 0x[01, 01, 01, 01, 05, 06, 01, bb, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 187, 9) to (start + 0, 10) -- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27) - Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) -- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51) +- Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) -- Code(Expression(0, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Function name: closure::main::{closure#16} -Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, c5, 01, 0d, 02, 1b, 05, 02, 1e, 00, 25, 02, 00, 2f, 00, 33, 07, 01, 0d, 00, 0e] +Raw bytes (27): 0x[01, 01, 01, 01, 05, 04, 01, c5, 01, 0d, 02, 1b, 05, 02, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 01, 0d, 00, 0e] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 197, 13) to (start + 2, 27) - Code(Counter(1)) at (prev + 2, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 14) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) Function name: closure::main::{closure#17} -Raw bytes (41): 0x[01, 01, 03, 05, 0a, 01, 05, 01, 05, 06, 01, cd, 01, 09, 00, 0a, 03, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 0a, 00, 2f, 00, 33, 03, 02, 09, 00, 0a] +Raw bytes (37): 0x[01, 01, 01, 01, 05, 06, 01, cd, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 01, 11, 01, 1b, 05, 01, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 -- expression 0 operands: lhs = Counter(1), rhs = Expression(2, Sub) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 205, 9) to (start + 0, 10) -- Code(Expression(0, Add)) at (prev + 1, 13) to (start + 0, 21) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 17) to (start + 1, 27) - Code(Counter(1)) at (prev + 1, 30) to (start + 0, 37) -- Code(Expression(2, Sub)) at (prev + 0, 47) to (start + 0, 51) +- Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) -- Code(Expression(0, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Function name: closure::main::{closure#18} (unused) Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 12, 00, 13, 00, 01, 11, 01, 0e] @@ -156,49 +142,43 @@ Number of file 0 mappings: 4 - Code(Zero) at (prev + 1, 17) to (start + 1, 14) Function name: closure::main::{closure#19} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 01, 01, 11, 01, 0e] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 67, 13) to (start + 2, 28) - Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18) - Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 14) Function name: closure::main::{closure#1} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 52, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 52, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 01, 01, 09, 01, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 82, 5) to (start + 2, 20) - Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) - Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 9) to (start + 1, 6) Function name: closure::main::{closure#2} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 68, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 68, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 01, 01, 09, 01, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 104, 5) to (start + 2, 20) - Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) - Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 9) to (start + 1, 6) Function name: closure::main::{closure#3} (unused) Raw bytes (25): 0x[01, 01, 00, 04, 00, 81, 01, 05, 01, 14, 00, 01, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06] diff --git a/tests/coverage/closure_bug.cov-map b/tests/coverage/closure_bug.cov-map index 160b348bd6320..32e8db5fb2f4c 100644 --- a/tests/coverage/closure_bug.cov-map +++ b/tests/coverage/closure_bug.cov-map @@ -1,133 +1,84 @@ Function name: closure_bug::main -Raw bytes (201): 0x[01, 01, 26, 01, 05, 05, 02, 05, 02, 97, 01, 09, 05, 02, 09, 92, 01, 97, 01, 09, 05, 02, 09, 92, 01, 97, 01, 09, 05, 02, 8f, 01, 0d, 09, 92, 01, 97, 01, 09, 05, 02, 0d, 8a, 01, 8f, 01, 0d, 09, 92, 01, 97, 01, 09, 05, 02, 0d, 8a, 01, 8f, 01, 0d, 09, 92, 01, 97, 01, 09, 05, 02, 87, 01, 11, 0d, 8a, 01, 8f, 01, 0d, 09, 92, 01, 97, 01, 09, 05, 02, 11, 82, 01, 87, 01, 11, 0d, 8a, 01, 8f, 01, 0d, 09, 92, 01, 97, 01, 09, 05, 02, 11, 01, 07, 01, 03, 0a, 01, 09, 05, 01, 0e, 05, 01, 0f, 00, 17, 02, 00, 17, 00, 18, 97, 01, 02, 09, 00, 0a, 97, 01, 06, 05, 01, 0e, 09, 01, 0f, 00, 17, 92, 01, 00, 17, 00, 18, 8f, 01, 02, 09, 00, 0a, 8f, 01, 06, 05, 01, 0e, 0d, 01, 0f, 00, 17, 8a, 01, 00, 17, 00, 18, 87, 01, 02, 09, 00, 0a, 87, 01, 06, 05, 01, 0e, 11, 01, 0f, 00, 17, 82, 01, 00, 17, 00, 18, 7f, 01, 01, 00, 02] +Raw bytes (97): 0x[01, 01, 04, 01, 05, 01, 09, 01, 0d, 01, 11, 11, 01, 07, 01, 03, 0a, 01, 09, 05, 01, 0e, 05, 01, 0f, 00, 17, 02, 00, 17, 00, 18, 01, 02, 09, 00, 0a, 01, 06, 05, 01, 0e, 09, 01, 0f, 00, 17, 06, 00, 17, 00, 18, 01, 02, 09, 00, 0a, 01, 06, 05, 01, 0e, 0d, 01, 0f, 00, 17, 0a, 00, 17, 00, 18, 01, 02, 09, 00, 0a, 01, 06, 05, 01, 0e, 11, 01, 0f, 00, 17, 0e, 00, 17, 00, 18, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 38 +Number of expressions: 4 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 3 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 5 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 6 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 7 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 8 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 9 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 10 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 11 operands: lhs = Expression(35, Add), rhs = Counter(3) -- expression 12 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 13 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 14 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 15 operands: lhs = Counter(3), rhs = Expression(34, Sub) -- expression 16 operands: lhs = Expression(35, Add), rhs = Counter(3) -- expression 17 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 18 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 19 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 20 operands: lhs = Counter(3), rhs = Expression(34, Sub) -- expression 21 operands: lhs = Expression(35, Add), rhs = Counter(3) -- expression 22 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 23 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 24 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 25 operands: lhs = Expression(33, Add), rhs = Counter(4) -- expression 26 operands: lhs = Counter(3), rhs = Expression(34, Sub) -- expression 27 operands: lhs = Expression(35, Add), rhs = Counter(3) -- expression 28 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 29 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 30 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 31 operands: lhs = Counter(4), rhs = Expression(32, Sub) -- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(4) -- expression 33 operands: lhs = Counter(3), rhs = Expression(34, Sub) -- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(3) -- expression 35 operands: lhs = Counter(2), rhs = Expression(36, Sub) -- expression 36 operands: lhs = Expression(37, Add), rhs = Counter(2) -- expression 37 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- 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(4) Number of file 0 mappings: 17 - Code(Counter(0)) at (prev + 7, 1) to (start + 3, 10) - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 14) - Code(Counter(1)) at (prev + 1, 15) to (start + 0, 23) - Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 0, 24) = (c0 - c1) -- Code(Expression(37, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) -- Code(Expression(37, Add)) at (prev + 6, 5) to (start + 1, 14) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) +- Code(Counter(0)) at (prev + 6, 5) to (start + 1, 14) - Code(Counter(2)) at (prev + 1, 15) to (start + 0, 23) -- Code(Expression(36, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c1 + (c0 - c1)) - c2) -- Code(Expression(35, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c2 + ((c1 + (c0 - c1)) - c2)) -- Code(Expression(35, Add)) at (prev + 6, 5) to (start + 1, 14) - = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Expression(1, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c0 - c2) +- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) +- Code(Counter(0)) at (prev + 6, 5) to (start + 1, 14) - Code(Counter(3)) at (prev + 1, 15) to (start + 0, 23) -- Code(Expression(34, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3) -- Code(Expression(33, Add)) at (prev + 2, 9) to (start + 0, 10) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) -- Code(Expression(33, Add)) at (prev + 6, 5) to (start + 1, 14) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- Code(Expression(2, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c0 - c3) +- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) +- Code(Counter(0)) at (prev + 6, 5) to (start + 1, 14) - Code(Counter(4)) at (prev + 1, 15) to (start + 0, 23) -- Code(Expression(32, Sub)) at (prev + 0, 23) to (start + 0, 24) - = ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4) -- Code(Expression(31, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) +- Code(Expression(3, Sub)) at (prev + 0, 23) to (start + 0, 24) + = (c0 - c4) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: closure_bug::main::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0e, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 0e, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 01, 00, 29, 00, 2a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 14, 9) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25) - Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 0, 41) to (start + 0, 42) Function name: closure_bug::main::{closure#1} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 17, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 17, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 01, 00, 29, 00, 2a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 23, 9) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25) - Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 0, 41) to (start + 0, 42) Function name: closure_bug::main::{closure#2} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 20, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 20, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 01, 00, 29, 00, 2a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 32, 9) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25) - Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 0, 41) to (start + 0, 42) Function name: closure_bug::main::{closure#3} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 29, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 07, 00, 29, 00, 2a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 29, 09, 00, 12, 05, 00, 15, 00, 19, 02, 00, 23, 00, 28, 01, 00, 29, 00, 2a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 41, 9) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 21) to (start + 0, 25) - Code(Expression(0, Sub)) at (prev + 0, 35) to (start + 0, 40) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 0, 41) to (start + 0, 42) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 0, 41) to (start + 0, 42) diff --git a/tests/coverage/closure_macro.cov-map b/tests/coverage/closure_macro.cov-map index e43ed1f76f366..fd8fbd9fa7575 100644 --- a/tests/coverage/closure_macro.cov-map +++ b/tests/coverage/closure_macro.cov-map @@ -7,12 +7,11 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 29, 1) to (start + 2, 2) Function name: closure_macro::main -Raw bytes (38): 0x[01, 01, 02, 01, 05, 05, 02, 06, 01, 21, 01, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02] +Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 21, 01, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 33, 1) to (start + 1, 33) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 18) @@ -22,8 +21,7 @@ Number of file 0 mappings: 6 - Code(Counter(1)) at (prev + 0, 84) to (start + 0, 85) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 2, 11) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Function name: closure_macro::main::{closure#0} Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 00, 05, 01, 10, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 00, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index 212b67a8a3e1d..43b52008f33e3 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -15,12 +15,11 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 35, 1) to (start + 0, 43) Function name: closure_macro_async::test::{closure#0} -Raw bytes (38): 0x[01, 01, 02, 01, 05, 05, 02, 06, 01, 23, 2b, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 07, 03, 01, 00, 02] +Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 23, 2b, 01, 21, 02, 02, 09, 00, 12, 02, 00, 0f, 00, 54, 05, 00, 54, 00, 55, 02, 02, 09, 02, 0b, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 35, 43) to (start + 1, 33) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 18) @@ -30,8 +29,7 @@ Number of file 0 mappings: 6 - Code(Counter(1)) at (prev + 0, 84) to (start + 0, 85) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 2, 11) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Function name: closure_macro_async::test::{closure#0}::{closure#0} Raw bytes (35): 0x[01, 01, 03, 01, 05, 05, 0b, 09, 00, 05, 01, 12, 1c, 03, 21, 05, 04, 11, 01, 27, 02, 03, 11, 00, 16, 00, 00, 17, 00, 1e, 07, 02, 09, 00, 0a] diff --git a/tests/coverage/conditions.cov-map b/tests/coverage/conditions.cov-map index a6a427aca007f..17143775b7b40 100644 --- a/tests/coverage/conditions.cov-map +++ b/tests/coverage/conditions.cov-map @@ -1,259 +1,263 @@ Function name: conditions::main -Raw bytes (784): 0x[01, 01, 8e, 01, 09, 33, 37, 41, 3b, 3d, 35, 39, 05, 00, b7, 04, 09, 05, 00, 0d, 35, 26, 39, 0d, 35, 3b, 3d, 35, 39, 37, 41, 3b, 3d, 35, 39, b2, 04, 0d, b7, 04, 09, 05, 00, 45, 00, 83, 01, 49, 45, 00, 7e, 31, 83, 01, 49, 45, 00, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, 76, 51, 7a, 4d, 7e, 31, 83, 01, 49, 45, 00, a7, 01, 55, 4d, 51, a3, 01, 59, a7, 01, 55, 4d, 51, 49, 9f, 01, a3, 01, 59, a7, 01, 55, 4d, 51, 61, 00, e3, 01, 65, 61, 00, de, 01, 2d, e3, 01, 65, 61, 00, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, d6, 01, 6d, da, 01, 69, de, 01, 2d, e3, 01, 65, 61, 00, 8b, 02, 71, 69, 6d, 87, 02, 75, 8b, 02, 71, 69, 6d, ff, 01, 00, 65, 83, 02, 87, 02, 75, 8b, 02, 71, 69, 6d, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 79, 00, d7, 02, 7d, 79, 00, d2, 02, 29, d7, 02, 7d, 79, 00, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, ca, 02, 85, 01, ce, 02, 81, 01, d2, 02, 29, d7, 02, 7d, 79, 00, f3, 03, 89, 01, 81, 01, 85, 01, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, da, 03, 19, de, 03, 15, e2, 03, 25, e7, 03, 11, 7d, eb, 03, ef, 03, 8d, 01, f3, 03, 89, 01, 81, 01, 85, 01, 9b, 04, 1d, 15, 19, 97, 04, 21, 9b, 04, 1d, 15, 19, 8f, 04, 9f, 04, 11, 93, 04, 97, 04, 21, 9b, 04, 1d, 15, 19, a3, 04, ae, 04, a7, 04, 31, ab, 04, 2d, 25, 29, b2, 04, 0d, b7, 04, 09, 05, 00, 44, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 00, 02, 06, 00, 07, 03, 03, 09, 00, 0a, b7, 04, 00, 10, 00, 1d, 09, 01, 09, 01, 0a, b2, 04, 02, 0f, 00, 1c, 0d, 01, 0c, 00, 19, 26, 00, 1d, 00, 2a, 22, 00, 2e, 00, 3c, 37, 00, 3d, 02, 0a, 41, 02, 0a, 00, 0b, 33, 01, 09, 01, 12, ae, 04, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 83, 01, 02, 08, 00, 15, 49, 00, 16, 02, 06, 7e, 02, 0f, 00, 1c, 7a, 01, 0c, 00, 19, 76, 00, 1d, 00, 2a, 72, 00, 2e, 00, 3c, a3, 01, 00, 3d, 02, 0a, 59, 02, 0a, 00, 0b, 9f, 01, 01, 09, 00, 17, 31, 02, 09, 00, 0f, 9b, 01, 03, 08, 00, 0c, 5d, 01, 0d, 01, 10, 61, 01, 11, 02, 0a, 00, 02, 0a, 00, 0b, e3, 01, 02, 0c, 00, 19, 65, 00, 1a, 02, 0a, de, 01, 04, 11, 00, 1e, da, 01, 01, 10, 00, 1d, d6, 01, 00, 21, 00, 2e, d2, 01, 00, 32, 00, 40, 87, 02, 00, 41, 02, 0e, 75, 02, 0e, 00, 0f, 83, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, fb, 01, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, e7, 03, 02, 09, 00, 0a, d7, 02, 00, 10, 00, 1d, 7d, 00, 1e, 02, 06, d2, 02, 02, 0f, 00, 1c, ce, 02, 01, 0c, 00, 19, ca, 02, 00, 1d, 00, 2a, c6, 02, 00, 2e, 00, 3c, ef, 03, 00, 3d, 02, 0a, 8d, 01, 02, 0a, 00, 0b, eb, 03, 01, 09, 00, 17, 29, 02, 0d, 02, 0f, 8f, 04, 05, 09, 00, 0a, e7, 03, 00, 10, 00, 1d, 11, 00, 1e, 02, 06, e2, 03, 02, 0f, 00, 1c, de, 03, 01, 0c, 00, 19, da, 03, 00, 1d, 00, 2a, d6, 03, 00, 2e, 00, 3c, 97, 04, 00, 3d, 02, 0a, 21, 02, 0a, 00, 0b, 93, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, 8b, 04, 02, 01, 00, 02] +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, 06, 00, 07, 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, 0a, 00, 0b, 2b, 01, 09, 01, 12, ca, 04, 03, 09, 00, 0f, 03, 03, 09, 01, 0c, 45, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 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, 0a, 00, 0b, 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, 0a, 00, 0b, 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, 0e, 00, 0f, eb, 02, 01, 0d, 00, 1b, 2d, 02, 0d, 00, 13, 00, 02, 06, 00, 07, e3, 02, 02, 09, 01, 0c, 79, 01, 0d, 02, 06, 00, 02, 06, 00, 07, 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, 0a, 00, 0b, 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, 0a, 00, 0b, af, 04, 01, 09, 00, 17, 25, 02, 09, 00, 0f, a7, 04, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 142 -- expression 0 operands: lhs = Counter(2), rhs = Expression(12, Add) -- expression 1 operands: lhs = Expression(13, Add), rhs = Counter(16) -- expression 2 operands: lhs = Expression(14, Add), rhs = Counter(15) +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) -- expression 4 operands: lhs = Counter(1), rhs = Zero -- expression 5 operands: lhs = Expression(141, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Zero +- 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(9, Sub), rhs = Counter(14) -- expression 9 operands: lhs = Counter(3), rhs = Counter(13) -- expression 10 operands: lhs = Expression(14, Add), rhs = Counter(15) -- expression 11 operands: lhs = Counter(13), rhs = Counter(14) -- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(16) -- expression 13 operands: lhs = Expression(14, Add), rhs = Counter(15) -- expression 14 operands: lhs = Counter(13), rhs = Counter(14) -- expression 15 operands: lhs = Expression(140, Sub), rhs = Counter(3) -- expression 16 operands: lhs = Expression(141, Add), rhs = Counter(2) -- expression 17 operands: lhs = Counter(1), rhs = Zero -- expression 18 operands: lhs = Counter(17), rhs = Zero -- expression 19 operands: lhs = Expression(32, Add), rhs = Counter(18) -- expression 20 operands: lhs = Counter(17), rhs = Zero -- expression 21 operands: lhs = Expression(31, Sub), rhs = Counter(12) -- expression 22 operands: lhs = Expression(32, Add), rhs = Counter(18) -- expression 23 operands: lhs = Counter(17), rhs = Zero -- expression 24 operands: lhs = Expression(30, Sub), rhs = Counter(19) -- expression 25 operands: lhs = Expression(31, Sub), rhs = Counter(12) -- expression 26 operands: lhs = Expression(32, Add), rhs = Counter(18) -- expression 27 operands: lhs = Counter(17), rhs = Zero -- expression 28 operands: lhs = Expression(29, Sub), rhs = Counter(20) -- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(19) -- expression 30 operands: lhs = Expression(31, Sub), rhs = Counter(12) -- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(18) -- expression 32 operands: lhs = Counter(17), rhs = Zero -- expression 33 operands: lhs = Expression(41, Add), rhs = Counter(21) -- expression 34 operands: lhs = Counter(19), rhs = Counter(20) -- expression 35 operands: lhs = Expression(40, Add), rhs = Counter(22) -- expression 36 operands: lhs = Expression(41, Add), rhs = Counter(21) -- expression 37 operands: lhs = Counter(19), rhs = Counter(20) -- expression 38 operands: lhs = Counter(18), rhs = Expression(39, Add) -- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(22) -- expression 40 operands: lhs = Expression(41, Add), rhs = Counter(21) -- expression 41 operands: lhs = Counter(19), rhs = Counter(20) -- expression 42 operands: lhs = Counter(24), rhs = Zero -- expression 43 operands: lhs = Expression(56, Add), rhs = Counter(25) -- expression 44 operands: lhs = Counter(24), rhs = Zero -- expression 45 operands: lhs = Expression(55, Sub), rhs = Counter(11) -- expression 46 operands: lhs = Expression(56, Add), rhs = Counter(25) -- expression 47 operands: lhs = Counter(24), rhs = Zero -- expression 48 operands: lhs = Expression(54, Sub), rhs = Counter(26) -- expression 49 operands: lhs = Expression(55, Sub), rhs = Counter(11) -- expression 50 operands: lhs = Expression(56, Add), rhs = Counter(25) -- expression 51 operands: lhs = Counter(24), rhs = Zero -- expression 52 operands: lhs = Expression(53, Sub), rhs = Counter(27) -- expression 53 operands: lhs = Expression(54, Sub), rhs = Counter(26) -- expression 54 operands: lhs = Expression(55, Sub), rhs = Counter(11) -- expression 55 operands: lhs = Expression(56, Add), rhs = Counter(25) -- expression 56 operands: lhs = Counter(24), rhs = Zero -- expression 57 operands: lhs = Expression(66, Add), rhs = Counter(28) -- expression 58 operands: lhs = Counter(26), rhs = Counter(27) -- expression 59 operands: lhs = Expression(65, Add), rhs = Counter(29) -- expression 60 operands: lhs = Expression(66, Add), rhs = Counter(28) -- expression 61 operands: lhs = Counter(26), rhs = Counter(27) -- expression 62 operands: lhs = Expression(63, Add), rhs = Zero -- expression 63 operands: lhs = Counter(25), rhs = Expression(64, Add) -- expression 64 operands: lhs = Expression(65, Add), rhs = Counter(29) -- expression 65 operands: lhs = Expression(66, Add), rhs = Counter(28) -- expression 66 operands: lhs = Counter(26), rhs = Counter(27) -- expression 67 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 68 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 69 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 70 operands: lhs = Counter(32), rhs = Counter(33) -- expression 71 operands: lhs = Counter(30), rhs = Zero -- expression 72 operands: lhs = Expression(85, Add), rhs = Counter(31) -- expression 73 operands: lhs = Counter(30), rhs = Zero -- expression 74 operands: lhs = Expression(84, Sub), rhs = Counter(10) -- expression 75 operands: lhs = Expression(85, Add), rhs = Counter(31) -- expression 76 operands: lhs = Counter(30), rhs = Zero -- expression 77 operands: lhs = Expression(83, Sub), rhs = Counter(32) -- expression 78 operands: lhs = Expression(84, Sub), rhs = Counter(10) -- expression 79 operands: lhs = Expression(85, Add), rhs = Counter(31) -- expression 80 operands: lhs = Counter(30), rhs = Zero -- expression 81 operands: lhs = Expression(82, Sub), rhs = Counter(33) -- expression 82 operands: lhs = Expression(83, Sub), rhs = Counter(32) -- expression 83 operands: lhs = Expression(84, Sub), rhs = Counter(10) -- expression 84 operands: lhs = Expression(85, Add), rhs = Counter(31) -- expression 85 operands: lhs = Counter(30), rhs = Zero -- expression 86 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 87 operands: lhs = Counter(32), rhs = Counter(33) -- expression 88 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 89 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 90 operands: lhs = Counter(32), rhs = Counter(33) -- expression 91 operands: lhs = Counter(4), rhs = Expression(132, Add) -- expression 92 operands: lhs = Expression(133, Add), rhs = Counter(8) -- expression 93 operands: lhs = Expression(134, Add), rhs = Counter(7) -- expression 94 operands: lhs = Counter(5), rhs = Counter(6) -- expression 95 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 96 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 97 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 98 operands: lhs = Counter(32), rhs = Counter(33) -- expression 99 operands: lhs = Expression(121, Add), rhs = Counter(4) -- expression 100 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 101 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 102 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 103 operands: lhs = Counter(32), rhs = Counter(33) -- expression 104 operands: lhs = Expression(120, Sub), rhs = Counter(9) -- expression 105 operands: lhs = Expression(121, Add), rhs = Counter(4) -- expression 106 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 107 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 108 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 109 operands: lhs = Counter(32), rhs = Counter(33) -- expression 110 operands: lhs = Expression(119, Sub), rhs = Counter(5) -- expression 111 operands: lhs = Expression(120, Sub), rhs = Counter(9) -- expression 112 operands: lhs = Expression(121, Add), rhs = Counter(4) -- expression 113 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 114 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 115 operands: lhs = Expression(124, Add), rhs = Counter(34) +- 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(118, Sub), rhs = Counter(6) -- expression 118 operands: lhs = Expression(119, Sub), rhs = Counter(5) -- expression 119 operands: lhs = Expression(120, Sub), rhs = Counter(9) -- expression 120 operands: lhs = Expression(121, Add), rhs = Counter(4) -- expression 121 operands: lhs = Counter(31), rhs = Expression(122, Add) -- expression 122 operands: lhs = Expression(123, Add), rhs = Counter(35) -- expression 123 operands: lhs = Expression(124, Add), rhs = Counter(34) -- expression 124 operands: lhs = Counter(32), rhs = Counter(33) -- expression 125 operands: lhs = Expression(134, Add), rhs = Counter(7) -- expression 126 operands: lhs = Counter(5), rhs = Counter(6) -- expression 127 operands: lhs = Expression(133, Add), rhs = Counter(8) -- expression 128 operands: lhs = Expression(134, Add), rhs = Counter(7) -- expression 129 operands: lhs = Counter(5), rhs = Counter(6) -- expression 130 operands: lhs = Expression(131, Add), rhs = Expression(135, Add) -- expression 131 operands: lhs = Counter(4), rhs = Expression(132, Add) -- expression 132 operands: lhs = Expression(133, Add), rhs = Counter(8) -- expression 133 operands: lhs = Expression(134, Add), rhs = Counter(7) -- expression 134 operands: lhs = Counter(5), rhs = Counter(6) -- expression 135 operands: lhs = Expression(136, Add), rhs = Expression(139, Sub) -- expression 136 operands: lhs = Expression(137, Add), rhs = Counter(12) -- expression 137 operands: lhs = Expression(138, Add), rhs = Counter(11) -- expression 138 operands: lhs = Counter(9), rhs = Counter(10) -- expression 139 operands: lhs = Expression(140, Sub), rhs = Counter(3) -- expression 140 operands: lhs = Expression(141, Add), rhs = Counter(2) -- expression 141 operands: lhs = Counter(1), rhs = Zero +- 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) 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, 6) to (start + 0, 7) - Code(Expression(0, Add)) at (prev + 3, 9) to (start + 0, 10) = (c2 + (((c13 + c14) + c15) + c16)) -- Code(Expression(141, Add)) at (prev + 0, 16) to (start + 0, 29) - = (c1 + Zero) +- Code(Counter(0)) at (prev + 0, 16) to (start + 0, 29) - Code(Counter(2)) at (prev + 1, 9) to (start + 1, 10) -- Code(Expression(140, Sub)) at (prev + 2, 15) to (start + 0, 28) - = ((c1 + Zero) - c2) +- Code(Expression(147, Sub)) at (prev + 2, 15) to (start + 0, 28) + = (c0 - c2) - Code(Counter(3)) at (prev + 1, 12) to (start + 0, 25) -- Code(Expression(9, Sub)) at (prev + 0, 29) to (start + 0, 42) +- Code(Expression(7, Sub)) at (prev + 0, 29) to (start + 0, 42) = (c3 - c13) -- Code(Expression(8, Sub)) at (prev + 0, 46) to (start + 0, 60) +- Code(Expression(6, Sub)) at (prev + 0, 46) to (start + 0, 60) = ((c3 - c13) - c14) -- Code(Expression(13, Add)) at (prev + 0, 61) to (start + 2, 10) +- Code(Expression(11, Add)) at (prev + 0, 61) to (start + 2, 10) = ((c13 + c14) + c15) - Code(Counter(16)) at (prev + 2, 10) to (start + 0, 11) -- Code(Expression(12, Add)) at (prev + 1, 9) to (start + 1, 18) +- Code(Expression(10, Add)) at (prev + 1, 9) to (start + 1, 18) = (((c13 + c14) + c15) + c16) -- Code(Expression(139, Sub)) at (prev + 3, 9) to (start + 0, 15) - = (((c1 + Zero) - c2) - c3) +- Code(Expression(146, Sub)) at (prev + 3, 9) to (start + 0, 15) + = ((c0 - c2) - c3) - 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) - Code(Zero) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(32, Add)) at (prev + 2, 8) to (start + 0, 21) - = (c17 + Zero) +- 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(31, Sub)) at (prev + 2, 15) to (start + 0, 28) - = ((c17 + Zero) - c18) -- Code(Expression(30, Sub)) at (prev + 1, 12) to (start + 0, 25) - = (((c17 + Zero) - c18) - c12) -- Code(Expression(29, Sub)) at (prev + 0, 29) to (start + 0, 42) - = ((((c17 + Zero) - c18) - c12) - c19) -- Code(Expression(28, Sub)) at (prev + 0, 46) to (start + 0, 60) - = (((((c17 + Zero) - c18) - c12) - c19) - c20) -- Code(Expression(40, Add)) at (prev + 0, 61) to (start + 2, 10) +- 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) +- 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, 10) to (start + 0, 11) -- Code(Expression(39, Add)) at (prev + 1, 9) to (start + 0, 23) +- 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(38, Add)) at (prev + 3, 8) to (start + 0, 12) +- 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) - Code(Zero) at (prev + 2, 10) to (start + 0, 11) -- Code(Expression(56, Add)) at (prev + 2, 12) to (start + 0, 25) - = (c24 + Zero) +- Code(Counter(23)) at (prev + 2, 12) to (start + 0, 25) - Code(Counter(25)) at (prev + 0, 26) to (start + 2, 10) -- Code(Expression(55, Sub)) at (prev + 4, 17) to (start + 0, 30) - = ((c24 + Zero) - c25) -- Code(Expression(54, Sub)) at (prev + 1, 16) to (start + 0, 29) - = (((c24 + Zero) - c25) - c11) -- Code(Expression(53, Sub)) at (prev + 0, 33) to (start + 0, 46) - = ((((c24 + Zero) - c25) - c11) - c26) -- Code(Expression(52, Sub)) at (prev + 0, 50) to (start + 0, 64) - = (((((c24 + Zero) - c25) - c11) - c26) - c27) -- Code(Expression(65, Add)) at (prev + 0, 65) to (start + 2, 14) +- 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(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, 14) to (start + 0, 15) -- Code(Expression(64, Add)) at (prev + 1, 13) to (start + 0, 27) +- 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) - Code(Zero) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(62, Add)) at (prev + 2, 9) to (start + 1, 12) +- 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(Zero) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(121, Add)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(128, Add)) at (prev + 2, 9) to (start + 0, 10) = (c31 + (((c32 + c33) + c34) + c35)) -- Code(Expression(85, Add)) at (prev + 0, 16) to (start + 0, 29) - = (c30 + Zero) +- 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(84, Sub)) at (prev + 2, 15) to (start + 0, 28) - = ((c30 + Zero) - c31) -- Code(Expression(83, Sub)) at (prev + 1, 12) to (start + 0, 25) - = (((c30 + Zero) - c31) - c10) -- Code(Expression(82, Sub)) at (prev + 0, 29) to (start + 0, 42) - = ((((c30 + Zero) - c31) - c10) - c32) -- Code(Expression(81, Sub)) at (prev + 0, 46) to (start + 0, 60) - = (((((c30 + Zero) - c31) - c10) - c32) - c33) -- Code(Expression(123, Add)) at (prev + 0, 61) to (start + 2, 10) +- 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, 10) to (start + 0, 11) -- Code(Expression(122, Add)) at (prev + 1, 9) to (start + 0, 23) +- 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(131, Add)) at (prev + 5, 9) to (start + 0, 10) +- Code(Expression(138, Add)) at (prev + 5, 9) to (start + 0, 10) = (c4 + (((c5 + c6) + c7) + c8)) -- Code(Expression(121, Add)) at (prev + 0, 16) to (start + 0, 29) +- 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(120, Sub)) at (prev + 2, 15) to (start + 0, 28) +- Code(Expression(127, Sub)) at (prev + 2, 15) to (start + 0, 28) = ((c31 + (((c32 + c33) + c34) + c35)) - c4) -- Code(Expression(119, Sub)) at (prev + 1, 12) to (start + 0, 25) +- Code(Expression(126, Sub)) at (prev + 1, 12) to (start + 0, 25) = (((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) -- Code(Expression(118, Sub)) at (prev + 0, 29) to (start + 0, 42) +- Code(Expression(125, Sub)) at (prev + 0, 29) to (start + 0, 42) = ((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) -- Code(Expression(117, Sub)) at (prev + 0, 46) to (start + 0, 60) +- Code(Expression(124, Sub)) at (prev + 0, 46) to (start + 0, 60) = (((((c31 + (((c32 + c33) + c34) + c35)) - c4) - c9) - c5) - c6) -- Code(Expression(133, Add)) at (prev + 0, 61) to (start + 2, 10) +- Code(Expression(140, Add)) at (prev + 0, 61) to (start + 2, 10) = ((c5 + c6) + c7) - Code(Counter(8)) at (prev + 2, 10) to (start + 0, 11) -- Code(Expression(132, Add)) at (prev + 1, 9) to (start + 0, 23) +- 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(130, Add)) at (prev + 2, 1) to (start + 0, 2) - = ((c4 + (((c5 + c6) + c7) + c8)) + ((((c9 + c10) + c11) + c12) + (((c1 + Zero) - c2) - c3))) +- Code(Expression(137, Add)) at (prev + 2, 1) to (start + 0, 2) + = ((c4 + (((c5 + c6) + c7) + c8)) + ((((c9 + c10) + c11) + c12) + ((c0 - c2) - c3))) diff --git a/tests/coverage/coroutine.cov-map b/tests/coverage/coroutine.cov-map index 255708d365ee4..6ead788b82f9c 100644 --- a/tests/coverage/coroutine.cov-map +++ b/tests/coverage/coroutine.cov-map @@ -1,17 +1,15 @@ Function name: coroutine::get_u32 -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 0b, 01, 01, 0b, 05, 02, 09, 00, 0e, 02, 02, 09, 00, 28, 07, 02, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 0b, 01, 01, 0b, 05, 02, 09, 00, 0e, 02, 02, 09, 00, 28, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 11, 1) to (start + 1, 11) - Code(Counter(1)) at (prev + 2, 9) to (start + 0, 14) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 40) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) 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, 07, 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] diff --git a/tests/coverage/dead_code.cov-map b/tests/coverage/dead_code.cov-map index 0b8a40a8cde05..31599d9072c92 100644 --- a/tests/coverage/dead_code.cov-map +++ b/tests/coverage/dead_code.cov-map @@ -1,17 +1,15 @@ Function name: dead_code::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1b, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 1b, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 27, 1) to (start + 7, 15) - Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: dead_code::unused_fn (unused) Raw bytes (24): 0x[01, 01, 00, 04, 00, 0f, 01, 07, 0f, 00, 07, 10, 02, 06, 00, 02, 06, 00, 07, 00, 01, 01, 00, 02] diff --git a/tests/coverage/drop_trait.cov-map b/tests/coverage/drop_trait.cov-map index 203d1048b0547..eb9d7d7acfdfc 100644 --- a/tests/coverage/drop_trait.cov-map +++ b/tests/coverage/drop_trait.cov-map @@ -7,15 +7,13 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 9, 5) to (start + 2, 6) Function name: drop_trait::main -Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 0e, 01, 05, 0c, 05, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 0e, 01, 05, 0c, 05, 06, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 14, 1) to (start + 5, 12) - Code(Counter(1)) at (prev + 6, 9) to (start + 1, 22) - Code(Zero) at (prev + 2, 6) to (start + 4, 11) -- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2) - = (c1 + Zero) +- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 2) diff --git a/tests/coverage/fn_sig_into_try.cov-map b/tests/coverage/fn_sig_into_try.cov-map index c3969f8ce9990..49758954831a1 100644 --- a/tests/coverage/fn_sig_into_try.cov-map +++ b/tests/coverage/fn_sig_into_try.cov-map @@ -7,47 +7,41 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 10, 1) to (start + 5, 2) Function name: fn_sig_into_try::b -Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 11, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 11, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 3, 15) - Code(Zero) at (prev + 3, 15) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) = (c0 - Zero) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (Zero + (c0 - Zero)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: fn_sig_into_try::c -Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 18, 01, 03, 17, 00, 03, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 18, 01, 03, 17, 00, 03, 17, 00, 18, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 24, 1) to (start + 3, 23) - Code(Zero) at (prev + 3, 23) to (start + 0, 24) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) = (c0 - Zero) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (Zero + (c0 - Zero)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: fn_sig_into_try::d -Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 1f, 01, 04, 0f, 00, 04, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 1f, 01, 04, 0f, 00, 04, 0f, 00, 10, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 31, 1) to (start + 4, 15) - Code(Zero) at (prev + 4, 15) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) = (c0 - Zero) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (Zero + (c0 - Zero)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) diff --git a/tests/coverage/generics.cov-map b/tests/coverage/generics.cov-map index 6079a433cd04e..48e191c1156ff 100644 --- a/tests/coverage/generics.cov-map +++ b/tests/coverage/generics.cov-map @@ -31,15 +31,13 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 10, 5) to (start + 2, 6) Function name: generics::main -Raw bytes (26): 0x[01, 01, 01, 05, 00, 04, 01, 16, 01, 08, 0c, 05, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 03, 05, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 01, 08, 0c, 05, 09, 09, 01, 16, 00, 02, 06, 04, 0b, 01, 05, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(1), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 22, 1) to (start + 8, 12) - Code(Counter(1)) at (prev + 9, 9) to (start + 1, 22) - Code(Zero) at (prev + 2, 6) to (start + 4, 11) -- Code(Expression(0, Add)) at (prev + 5, 1) to (start + 0, 2) - = (c1 + Zero) +- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 2) diff --git a/tests/coverage/if.cov-map b/tests/coverage/if.cov-map index d7122f4b1a030..2b5ae97b406d4 100644 --- a/tests/coverage/if.cov-map +++ b/tests/coverage/if.cov-map @@ -1,15 +1,13 @@ Function name: if::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 12, 10, 05, 13, 05, 05, 06, 02, 05, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 04, 01, 12, 10, 05, 13, 05, 05, 06, 02, 05, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 4, 1) to (start + 18, 16) - Code(Counter(1)) at (prev + 19, 5) to (start + 5, 6) - Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) diff --git a/tests/coverage/if_else.cov-map b/tests/coverage/if_else.cov-map index 7163681d3a049..c2111917e559e 100644 --- a/tests/coverage/if_else.cov-map +++ b/tests/coverage/if_else.cov-map @@ -1,25 +1,18 @@ Function name: if_else::main -Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 04, 01, 08, 10, 05, 09, 05, 05, 06, 02, 08, 09, 02, 10, 1b, 06, 09, 00, 10, 09, 01, 05, 05, 06, 16, 07, 05, 05, 06, 13, 06, 01, 00, 02] +Raw bytes (43): 0x[01, 01, 02, 01, 05, 01, 09, 07, 01, 04, 01, 08, 10, 05, 09, 05, 05, 06, 02, 08, 09, 02, 10, 01, 06, 09, 00, 10, 09, 01, 05, 05, 06, 06, 07, 05, 05, 06, 01, 06, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 7 +Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub) -- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 4, 1) to (start + 8, 16) - Code(Counter(1)) at (prev + 9, 5) to (start + 5, 6) - Code(Expression(0, Sub)) at (prev + 8, 9) to (start + 2, 16) = (c0 - c1) -- Code(Expression(6, Add)) at (prev + 6, 9) to (start + 0, 16) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 6, 9) to (start + 0, 16) - Code(Counter(2)) at (prev + 1, 5) to (start + 5, 6) -- Code(Expression(5, Sub)) at (prev + 7, 5) to (start + 5, 6) - = ((c1 + (c0 - c1)) - c2) -- Code(Expression(4, Add)) at (prev + 6, 1) to (start + 0, 2) - = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Expression(1, Sub)) at (prev + 7, 5) to (start + 5, 6) + = (c0 - c2) +- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 2) diff --git a/tests/coverage/if_not.cov-map b/tests/coverage/if_not.cov-map index 3c660551dea15..9e11ed787a887 100644 --- a/tests/coverage/if_not.cov-map +++ b/tests/coverage/if_not.cov-map @@ -1,39 +1,23 @@ Function name: if_not::if_not -Raw bytes (86): 0x[01, 01, 10, 01, 05, 05, 02, 3f, 09, 05, 02, 09, 3a, 3f, 09, 05, 02, 37, 0d, 09, 3a, 3f, 09, 05, 02, 0d, 32, 37, 0d, 09, 3a, 3f, 09, 05, 02, 0a, 01, 05, 01, 03, 0d, 02, 04, 05, 02, 06, 05, 02, 06, 00, 07, 3f, 03, 09, 01, 0d, 3a, 02, 05, 02, 06, 09, 02, 06, 00, 07, 37, 03, 09, 01, 0d, 32, 02, 05, 02, 06, 0d, 02, 0c, 02, 06, 2f, 03, 01, 00, 02] +Raw bytes (60): 0x[01, 01, 03, 01, 05, 01, 09, 01, 0d, 0a, 01, 05, 01, 03, 0d, 02, 04, 05, 02, 06, 05, 02, 06, 00, 07, 01, 03, 09, 01, 0d, 06, 02, 05, 02, 06, 09, 02, 06, 00, 07, 01, 03, 09, 01, 0d, 0a, 02, 05, 02, 06, 0d, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 16 +Number of expressions: 3 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(15, Add), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Counter(2), rhs = Expression(14, Sub) -- expression 5 operands: lhs = Expression(15, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 7 operands: lhs = Expression(13, Add), rhs = Counter(3) -- expression 8 operands: lhs = Counter(2), rhs = Expression(14, Sub) -- expression 9 operands: lhs = Expression(15, Add), rhs = Counter(2) -- expression 10 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 11 operands: lhs = Counter(3), rhs = Expression(12, Sub) -- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(3) -- expression 13 operands: lhs = Counter(2), rhs = Expression(14, Sub) -- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(2) -- expression 15 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(2) +- expression 2 operands: lhs = Counter(0), rhs = Counter(3) Number of file 0 mappings: 10 - Code(Counter(0)) at (prev + 5, 1) to (start + 3, 13) - Code(Expression(0, Sub)) at (prev + 4, 5) to (start + 2, 6) = (c0 - c1) - Code(Counter(1)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(15, Add)) at (prev + 3, 9) to (start + 1, 13) - = (c1 + (c0 - c1)) -- Code(Expression(14, Sub)) at (prev + 2, 5) to (start + 2, 6) - = ((c1 + (c0 - c1)) - c2) +- Code(Counter(0)) at (prev + 3, 9) to (start + 1, 13) +- Code(Expression(1, Sub)) at (prev + 2, 5) to (start + 2, 6) + = (c0 - c2) - Code(Counter(2)) at (prev + 2, 6) to (start + 0, 7) -- Code(Expression(13, Add)) at (prev + 3, 9) to (start + 1, 13) - = (c2 + ((c1 + (c0 - c1)) - c2)) -- Code(Expression(12, Sub)) at (prev + 2, 5) to (start + 2, 6) - = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3) +- Code(Counter(0)) at (prev + 3, 9) to (start + 1, 13) +- Code(Expression(2, Sub)) at (prev + 2, 5) to (start + 2, 6) + = (c0 - c3) - Code(Counter(3)) at (prev + 2, 12) to (start + 2, 6) -- Code(Expression(11, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) diff --git a/tests/coverage/inline-dead.cov-map b/tests/coverage/inline-dead.cov-map index f77781ca02839..96b907cbe1532 100644 --- a/tests/coverage/inline-dead.cov-map +++ b/tests/coverage/inline-dead.cov-map @@ -7,19 +7,17 @@ Number of file 0 mappings: 1 - Code(Zero) at (prev + 23, 1) to (start + 2, 2) Function name: inline_dead::live:: -Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 0e, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 0e, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 14, 1) to (start + 1, 9) - Code(Zero) at (prev + 2, 9) to (start + 0, 15) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c0 - Zero) -- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) - = (Zero + (c0 - Zero)) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Function name: inline_dead::main Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 01, 03, 0a, 01, 06, 05, 01, 02] diff --git a/tests/coverage/inline.cov-map b/tests/coverage/inline.cov-map index 001c333ae6d90..2366a3bc5345a 100644 --- a/tests/coverage/inline.cov-map +++ b/tests/coverage/inline.cov-map @@ -1,18 +1,16 @@ Function name: inline::display:: -Raw bytes (33): 0x[01, 01, 02, 01, 05, 03, 05, 05, 01, 29, 01, 00, 22, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 10, 05, 00, 11, 02, 06, 06, 03, 05, 01, 02] +Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 29, 01, 00, 22, 05, 01, 09, 00, 0a, 03, 00, 0e, 00, 10, 05, 00, 11, 02, 06, 01, 03, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1) Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 41, 1) to (start + 0, 34) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 10) - Code(Expression(0, Add)) at (prev + 0, 14) to (start + 0, 16) = (c0 + c1) - Code(Counter(1)) at (prev + 0, 17) to (start + 2, 6) -- Code(Expression(1, Sub)) at (prev + 3, 5) to (start + 1, 2) - = ((c0 + c1) - c1) +- Code(Counter(0)) at (prev + 3, 5) to (start + 1, 2) Function name: inline::error Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 01, 14] diff --git a/tests/coverage/inner_items.cov-map b/tests/coverage/inner_items.cov-map index 3f39d74efbaca..6ccc3f0bafc8d 100644 --- a/tests/coverage/inner_items.cov-map +++ b/tests/coverage/inner_items.cov-map @@ -15,29 +15,22 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 40, 9) to (start + 3, 10) Function name: inner_items::main -Raw bytes (53): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 07, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 1b, 24, 08, 00, 0f, 09, 00, 10, 02, 06, 16, 02, 06, 00, 07, 13, 02, 09, 05, 02] +Raw bytes (43): 0x[01, 01, 02, 01, 05, 01, 09, 07, 01, 03, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 01, 24, 08, 00, 0f, 09, 00, 10, 02, 06, 06, 02, 06, 00, 07, 01, 02, 09, 05, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 7 +Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub) -- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 3, 1) to (start + 7, 15) - Code(Counter(1)) at (prev + 7, 16) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(6, Add)) at (prev + 36, 8) to (start + 0, 15) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 36, 8) to (start + 0, 15) - Code(Counter(2)) at (prev + 0, 16) to (start + 2, 6) -- Code(Expression(5, Sub)) at (prev + 2, 6) to (start + 0, 7) - = ((c1 + (c0 - c1)) - c2) -- Code(Expression(4, Add)) at (prev + 2, 9) to (start + 5, 2) - = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Expression(1, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c2) +- Code(Counter(0)) at (prev + 2, 9) to (start + 5, 2) Function name: inner_items::main::in_func Raw bytes (9): 0x[01, 01, 00, 01, 01, 12, 05, 04, 06] diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index ab66a2fffce1b..c4087d9369d87 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -1,17 +1,15 @@ Function name: ::fmt -Raw bytes (29): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 8a, 01, 05, 01, 25, 05, 01, 25, 00, 26, 02, 01, 09, 00, 0f, 07, 01, 05, 00, 06] +Raw bytes (27): 0x[01, 01, 01, 01, 05, 04, 01, 8a, 01, 05, 01, 25, 05, 01, 25, 00, 26, 02, 01, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 138, 5) to (start + 1, 37) - Code(Counter(1)) at (prev + 1, 37) to (start + 0, 38) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 0, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Function name: issue_84561::main Raw bytes (10): 0x[01, 01, 00, 01, 01, b4, 01, 01, 04, 02] @@ -22,51 +20,30 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 180, 1) to (start + 4, 2) Function name: issue_84561::test1 -Raw bytes (78): 0x[01, 01, 0e, 05, 06, 01, 05, 09, 36, 03, 09, 0d, 2e, 33, 0d, 09, 36, 03, 09, 11, 26, 2b, 11, 0d, 2e, 33, 0d, 09, 36, 03, 09, 09, 01, 9a, 01, 01, 01, 0b, 05, 01, 0c, 00, 1e, 03, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 33, 01, 0d, 01, 0b, 0d, 01, 0c, 00, 1e, 2b, 01, 05, 03, 0b, 11, 03, 0c, 00, 1e, 23, 01, 01, 00, 02] +Raw bytes (50): 0x[01, 01, 00, 09, 01, 9a, 01, 01, 01, 0b, 05, 01, 0c, 00, 1e, 01, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 01, 01, 0d, 01, 0b, 0d, 01, 0c, 00, 1e, 01, 01, 05, 03, 0b, 11, 03, 0c, 00, 1e, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 14 -- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) -- expression 2 operands: lhs = Counter(2), rhs = Expression(13, Sub) -- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 4 operands: lhs = Counter(3), rhs = Expression(11, Sub) -- expression 5 operands: lhs = Expression(12, Add), rhs = Counter(3) -- expression 6 operands: lhs = Counter(2), rhs = Expression(13, Sub) -- expression 7 operands: lhs = Expression(0, Add), rhs = Counter(2) -- expression 8 operands: lhs = Counter(4), rhs = Expression(9, Sub) -- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(4) -- expression 10 operands: lhs = Counter(3), rhs = Expression(11, Sub) -- expression 11 operands: lhs = Expression(12, Add), rhs = Counter(3) -- expression 12 operands: lhs = Counter(2), rhs = Expression(13, Sub) -- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of expressions: 0 Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 154, 1) to (start + 1, 11) - Code(Counter(1)) at (prev + 1, 12) to (start + 0, 30) -- Code(Expression(0, Add)) at (prev + 1, 5) to (start + 0, 11) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11) - Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30) -- Code(Expression(12, Add)) at (prev + 1, 13) to (start + 1, 11) - = (c2 + ((c1 + (c0 - c1)) - c2)) +- Code(Counter(0)) at (prev + 1, 13) to (start + 1, 11) - Code(Counter(3)) at (prev + 1, 12) to (start + 0, 30) -- Code(Expression(10, Add)) at (prev + 1, 5) to (start + 3, 11) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 3, 11) - Code(Counter(4)) at (prev + 3, 12) to (start + 0, 30) -- Code(Expression(8, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: issue_84561::test2 -Raw bytes (24): 0x[01, 01, 02, 05, 06, 01, 05, 03, 01, b0, 01, 01, 01, 10, 05, 01, 11, 00, 23, 03, 01, 01, 00, 02] +Raw bytes (20): 0x[01, 01, 00, 03, 01, b0, 01, 01, 01, 10, 05, 01, 11, 00, 23, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Counter(1), rhs = Expression(1, Sub) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 176, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 35) -- Code(Expression(0, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: issue_84561::test2::call_print Raw bytes (10): 0x[01, 01, 00, 01, 01, a7, 01, 09, 02, 0a] @@ -77,10 +54,10 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 167, 9) to (start + 2, 10) Function name: issue_84561::test3 -Raw bytes (436): 0x[01, 01, 41, 05, 00, 0d, 00, 15, 00, 12, 00, 15, 00, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 00, fe, 01, 82, 02, 00, 69, 6d, 69, 6d, 82, 02, 00, 69, 6d, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 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, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Raw bytes (375): 0x[01, 01, 31, 05, 00, 0d, 00, 15, 00, 12, 00, 15, 00, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, be, 01, c2, 01, 79, 69, 6d, 69, 6d, 69, 6d, c2, 01, 00, 69, 6d, c2, 01, 79, 69, 6d, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, b6, 01, 00, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, 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, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 77, 03, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, bb, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, c2, 01, 02, 0d, 00, 17, c2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, b6, 01, 02, 05, 00, 0f, b2, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 65 +Number of expressions: 49 - expression 0 operands: lhs = Counter(1), rhs = Zero - expression 1 operands: lhs = Counter(3), rhs = Zero - expression 2 operands: lhs = Counter(5), rhs = Zero @@ -98,54 +75,38 @@ Number of expressions: 65 - expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20) - expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18) - expression 16 operands: lhs = Counter(17), rhs = Zero -- expression 17 operands: lhs = Counter(23), rhs = Expression(34, Sub) -- expression 18 operands: lhs = Expression(35, Add), rhs = Counter(23) -- expression 19 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 17 operands: lhs = Expression(30, Sub), rhs = Counter(21) +- expression 18 operands: lhs = Counter(20), rhs = Zero +- expression 19 operands: lhs = Expression(30, Sub), rhs = Counter(21) - expression 20 operands: lhs = Counter(20), rhs = Zero -- expression 21 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 22 operands: lhs = Counter(20), rhs = Zero -- expression 23 operands: lhs = Expression(35, Add), rhs = Counter(23) -- expression 24 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 25 operands: lhs = Counter(20), rhs = Zero -- expression 26 operands: lhs = Expression(33, Add), rhs = Counter(24) -- expression 27 operands: lhs = Counter(23), rhs = Expression(34, Sub) -- expression 28 operands: lhs = Expression(35, Add), rhs = Counter(23) -- expression 29 operands: lhs = Expression(36, Sub), rhs = Counter(21) +- expression 21 operands: lhs = Expression(29, Add), rhs = Counter(23) +- expression 22 operands: lhs = Expression(30, Sub), rhs = Counter(21) +- expression 23 operands: lhs = Counter(20), rhs = Zero +- expression 24 operands: lhs = Expression(29, Add), rhs = Counter(24) +- expression 25 operands: lhs = Expression(30, Sub), rhs = Counter(21) +- expression 26 operands: lhs = Counter(20), rhs = Zero +- expression 27 operands: lhs = Expression(28, Sub), rhs = Counter(25) +- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(24) +- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(21) - expression 30 operands: lhs = Counter(20), rhs = Zero -- expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(25) -- expression 32 operands: lhs = Expression(33, Add), rhs = Counter(24) -- expression 33 operands: lhs = Counter(23), rhs = Expression(34, Sub) -- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(23) -- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 36 operands: lhs = Counter(20), rhs = Zero -- expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub) -- expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 39 operands: lhs = Zero, rhs = Expression(63, Sub) -- expression 40 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 41 operands: lhs = Counter(26), rhs = Counter(27) -- expression 42 operands: lhs = Zero, rhs = Expression(63, Sub) -- expression 43 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 44 operands: lhs = Counter(26), rhs = Counter(27) -- expression 45 operands: lhs = Counter(26), rhs = Counter(27) -- expression 46 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 47 operands: lhs = Counter(26), rhs = Counter(27) -- expression 48 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 49 operands: lhs = Zero, rhs = Expression(63, Sub) -- expression 50 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 51 operands: lhs = Counter(26), rhs = Counter(27) -- expression 52 operands: lhs = Expression(60, Add), rhs = Counter(31) -- expression 53 operands: lhs = Counter(29), rhs = Expression(61, Sub) -- expression 54 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 55 operands: lhs = Zero, rhs = Expression(63, Sub) -- expression 56 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 57 operands: lhs = Counter(26), rhs = Counter(27) -- expression 58 operands: lhs = Expression(59, Sub), rhs = Zero -- expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31) -- expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub) -- expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 62 operands: lhs = Zero, rhs = Expression(63, Sub) -- expression 63 operands: lhs = Expression(64, Sub), rhs = Zero -- expression 64 operands: lhs = Counter(26), rhs = Counter(27) +- expression 31 operands: lhs = Counter(29), rhs = Expression(47, Sub) +- expression 32 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 33 operands: lhs = Counter(26), rhs = Counter(27) +- expression 34 operands: lhs = Counter(26), rhs = Counter(27) +- expression 35 operands: lhs = Counter(26), rhs = Counter(27) +- expression 36 operands: lhs = Expression(48, Sub), rhs = Zero +- expression 37 operands: lhs = Counter(26), rhs = Counter(27) +- expression 38 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 39 operands: lhs = Counter(26), rhs = Counter(27) +- expression 40 operands: lhs = Expression(46, Add), rhs = Counter(31) +- expression 41 operands: lhs = Counter(29), rhs = Expression(47, Sub) +- expression 42 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 43 operands: lhs = Counter(26), rhs = Counter(27) +- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(31) +- expression 46 operands: lhs = Counter(29), rhs = Expression(47, Sub) +- expression 47 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 48 operands: lhs = Counter(26), rhs = Counter(27) 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) @@ -187,37 +148,37 @@ Number of file 0 mappings: 51 - Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19) = (((c17 - Zero) + c18) - c20) - Code(Zero) at (prev + 3, 13) to (start + 0, 29) -- Code(Expression(33, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c23 + (((c20 - Zero) + c21) - c23)) -- Code(Expression(35, Add)) at (prev + 1, 12) to (start + 0, 19) +- Code(Expression(29, Add)) at (prev + 3, 5) to (start + 0, 15) + = ((c20 - Zero) + c21) +- Code(Expression(29, Add)) at (prev + 1, 12) to (start + 0, 19) = ((c20 - Zero) + c21) - Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19) -- Code(Expression(34, Sub)) at (prev + 2, 13) to (start + 0, 19) +- Code(Expression(21, Sub)) at (prev + 2, 13) to (start + 0, 19) = (((c20 - Zero) + c21) - c23) -- Code(Expression(32, Sub)) at (prev + 4, 5) to (start + 2, 19) - = ((c23 + (((c20 - Zero) + c21) - c23)) - c24) +- Code(Expression(28, Sub)) at (prev + 4, 5) to (start + 2, 19) + = (((c20 - Zero) + c21) - c24) - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) -- Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19) - = (((c23 + (((c20 - Zero) + c21) - c23)) - c24) - c25) -- Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) +- Code(Expression(27, Sub)) at (prev + 2, 13) to (start + 0, 19) + = ((((c20 - Zero) + c21) - c24) - c25) +- Code(Expression(46, Add)) at (prev + 3, 5) to (start + 0, 15) + = (c29 + ((c26 - c27) - c30)) - 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(62, Add)) at (prev + 2, 13) to (start + 0, 23) - = (Zero + ((c26 - c27) - Zero)) -- Code(Expression(64, Sub)) at (prev + 1, 20) to (start + 0, 27) +- Code(Expression(48, Sub)) at (prev + 2, 13) to (start + 0, 23) + = (c26 - c27) +- Code(Expression(48, Sub)) at (prev + 1, 20) to (start + 0, 27) = (c26 - c27) - Code(Zero) at (prev + 1, 21) to (start + 0, 27) -- Code(Expression(63, Sub)) at (prev + 2, 21) to (start + 0, 27) +- Code(Expression(36, Sub)) at (prev + 2, 21) to (start + 0, 27) = ((c26 - c27) - Zero) -- Code(Expression(61, Sub)) at (prev + 4, 13) to (start + 0, 19) - = ((Zero + ((c26 - c27) - Zero)) - c30) +- Code(Expression(47, 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(59, Sub)) at (prev + 2, 5) to (start + 0, 15) - = ((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31) -- Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31) - Zero) +- Code(Expression(45, Sub)) at (prev + 2, 5) to (start + 0, 15) + = ((c29 + ((c26 - c27) - c30)) - c31) +- Code(Expression(44, Sub)) at (prev + 3, 9) to (start + 0, 34) + = (((c29 + ((c26 - c27) - c30)) - c31) - Zero) - Code(Zero) at (prev + 2, 5) to (start + 0, 15) - Code(Zero) at (prev + 3, 9) to (start + 0, 44) - Code(Zero) at (prev + 2, 1) to (start + 0, 2) diff --git a/tests/coverage/lazy_boolean.cov-map b/tests/coverage/lazy_boolean.cov-map index 03dbb59d26b5c..8dca205d33f2d 100644 --- a/tests/coverage/lazy_boolean.cov-map +++ b/tests/coverage/lazy_boolean.cov-map @@ -1,219 +1,49 @@ Function name: lazy_boolean::main -Raw bytes (636): 0x[01, 01, a4, 01, 01, 05, 09, 8a, 05, 8f, 05, 09, 05, 02, 05, 02, 8f, 05, 09, 05, 02, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 09, 8a, 05, 8f, 05, 09, 05, 02, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 1d, e2, 04, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, df, 04, 21, 1d, e2, 04, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 21, da, 04, df, 04, 21, 1d, e2, 04, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, d7, 04, 25, 21, da, 04, df, 04, 21, 1d, e2, 04, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 25, d2, 04, d7, 04, 25, 21, da, 04, df, 04, 21, 1d, e2, 04, e7, 04, 1d, 19, ea, 04, ef, 04, 19, 15, f2, 04, f7, 04, 15, 11, fa, 04, ff, 04, 11, 0d, 82, 05, 87, 05, 0d, 09, 8a, 05, 8f, 05, 09, 05, 02, 1c, 01, 04, 01, 07, 0f, 05, 07, 10, 04, 06, 02, 04, 06, 00, 07, 87, 05, 02, 09, 00, 11, 8f, 05, 02, 0d, 00, 12, 8a, 05, 02, 0d, 00, 12, ff, 04, 03, 09, 00, 11, 87, 05, 02, 0d, 00, 12, 82, 05, 02, 0d, 00, 12, f7, 04, 02, 09, 00, 11, ff, 04, 00, 14, 00, 19, 11, 00, 1d, 00, 22, ef, 04, 01, 09, 00, 11, f7, 04, 00, 14, 00, 19, 15, 00, 1d, 00, 22, ef, 04, 03, 09, 01, 10, ea, 04, 02, 05, 03, 06, 19, 03, 06, 00, 07, e7, 04, 03, 09, 00, 10, 1d, 01, 05, 03, 06, e2, 04, 05, 05, 03, 06, df, 04, 05, 08, 00, 10, da, 04, 00, 11, 02, 06, 21, 02, 06, 00, 07, d7, 04, 02, 08, 00, 0f, 25, 00, 10, 02, 06, d2, 04, 02, 0c, 02, 06, cf, 04, 03, 01, 00, 02] +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, 06, 00, 07, 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, 06, 00, 07, 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, 06, 00, 07, 01, 02, 08, 00, 0f, 25, 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: 164 +Number of expressions: 7 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 2 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 4 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 5 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 7 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 8 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 9 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 10 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 11 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 12 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 13 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 14 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 15 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 16 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 17 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 18 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 19 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 20 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 21 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 22 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 23 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 24 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 25 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 26 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 27 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 28 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 29 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 30 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 31 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 32 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 33 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 34 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 35 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 36 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 37 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 38 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 39 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 40 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 41 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 42 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 43 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 44 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 45 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 46 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 47 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 48 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 49 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 50 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 51 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 52 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 53 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 54 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 55 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 56 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 57 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 58 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 59 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 60 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 61 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 62 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 63 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 64 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 65 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 66 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 67 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 68 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 69 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 70 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 71 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 72 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 73 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 74 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 75 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 76 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 77 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 78 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 79 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 80 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 81 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 82 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 83 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 84 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 85 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 86 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 87 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 88 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 89 operands: lhs = Counter(7), rhs = Expression(152, Sub) -- expression 90 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 91 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 92 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 93 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 94 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 95 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 96 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 97 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 98 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 99 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 100 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 101 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 102 operands: lhs = Expression(151, Add), rhs = Counter(8) -- expression 103 operands: lhs = Counter(7), rhs = Expression(152, Sub) -- expression 104 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 105 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 106 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 107 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 108 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 109 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 110 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 111 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 112 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 113 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 114 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 115 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 116 operands: lhs = Counter(8), rhs = Expression(150, Sub) -- expression 117 operands: lhs = Expression(151, Add), rhs = Counter(8) -- expression 118 operands: lhs = Counter(7), rhs = Expression(152, Sub) -- expression 119 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 120 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 121 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 122 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 123 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 124 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 125 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 126 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 127 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 128 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 129 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 130 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 131 operands: lhs = Expression(149, Add), rhs = Counter(9) -- expression 132 operands: lhs = Counter(8), rhs = Expression(150, Sub) -- expression 133 operands: lhs = Expression(151, Add), rhs = Counter(8) -- expression 134 operands: lhs = Counter(7), rhs = Expression(152, Sub) -- expression 135 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 136 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 137 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 138 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 139 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 140 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 141 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 142 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 143 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 144 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 145 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 146 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 147 operands: lhs = Counter(9), rhs = Expression(148, Sub) -- expression 148 operands: lhs = Expression(149, Add), rhs = Counter(9) -- expression 149 operands: lhs = Counter(8), rhs = Expression(150, Sub) -- expression 150 operands: lhs = Expression(151, Add), rhs = Counter(8) -- expression 151 operands: lhs = Counter(7), rhs = Expression(152, Sub) -- expression 152 operands: lhs = Expression(153, Add), rhs = Counter(7) -- expression 153 operands: lhs = Counter(6), rhs = Expression(154, Sub) -- expression 154 operands: lhs = Expression(155, Add), rhs = Counter(6) -- expression 155 operands: lhs = Counter(5), rhs = Expression(156, Sub) -- expression 156 operands: lhs = Expression(157, Add), rhs = Counter(5) -- expression 157 operands: lhs = Counter(4), rhs = Expression(158, Sub) -- expression 158 operands: lhs = Expression(159, Add), rhs = Counter(4) -- expression 159 operands: lhs = Counter(3), rhs = Expression(160, Sub) -- expression 160 operands: lhs = Expression(161, Add), rhs = Counter(3) -- expression 161 operands: lhs = Counter(2), rhs = Expression(162, Sub) -- expression 162 operands: lhs = Expression(163, Add), rhs = Counter(2) -- expression 163 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- 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) 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) - Code(Expression(0, Sub)) at (prev + 4, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(161, Add)) at (prev + 2, 9) to (start + 0, 17) - = (c2 + ((c1 + (c0 - c1)) - c2)) -- Code(Expression(163, Add)) at (prev + 2, 13) to (start + 0, 18) - = (c1 + (c0 - c1)) -- Code(Expression(162, Sub)) at (prev + 2, 13) to (start + 0, 18) - = ((c1 + (c0 - c1)) - c2) -- Code(Expression(159, Add)) at (prev + 3, 9) to (start + 0, 17) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) -- Code(Expression(161, Add)) at (prev + 2, 13) to (start + 0, 18) - = (c2 + ((c1 + (c0 - c1)) - c2)) -- Code(Expression(160, Sub)) at (prev + 2, 13) to (start + 0, 18) - = ((c2 + ((c1 + (c0 - c1)) - c2)) - c3) -- Code(Expression(157, Add)) at (prev + 2, 9) to (start + 0, 17) - = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) -- Code(Expression(159, Add)) at (prev + 0, 20) to (start + 0, 25) - = (c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) +- 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) +- 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) +- 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(Expression(155, Add)) at (prev + 1, 9) to (start + 0, 17) - = (c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) -- Code(Expression(157, Add)) at (prev + 0, 20) to (start + 0, 25) - = (c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) +- 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(Expression(155, Add)) at (prev + 3, 9) to (start + 1, 16) - = (c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) -- Code(Expression(154, Sub)) at (prev + 2, 5) to (start + 3, 6) - = ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6) +- 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, 6) to (start + 0, 7) -- Code(Expression(153, Add)) at (prev + 3, 9) to (start + 0, 16) - = (c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 16) - Code(Counter(7)) at (prev + 1, 5) to (start + 3, 6) -- Code(Expression(152, Sub)) at (prev + 5, 5) to (start + 3, 6) - = ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7) -- Code(Expression(151, Add)) at (prev + 5, 8) to (start + 0, 16) - = (c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) -- Code(Expression(150, Sub)) at (prev + 0, 17) to (start + 2, 6) - = ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8) +- Code(Expression(4, Sub)) at (prev + 5, 5) to (start + 3, 6) + = (c0 - c7) +- 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, 6) to (start + 0, 7) -- Code(Expression(149, Add)) at (prev + 2, 8) to (start + 0, 15) - = (c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) +- Code(Counter(0)) at (prev + 2, 8) to (start + 0, 15) - Code(Counter(9)) at (prev + 0, 16) to (start + 2, 6) -- Code(Expression(148, Sub)) at (prev + 2, 12) to (start + 2, 6) - = ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9) -- Code(Expression(147, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c9 + ((c8 + ((c7 + ((c6 + ((c5 + ((c4 + ((c3 + ((c2 + ((c1 + (c0 - c1)) - c2)) - c3)) - c4)) - c5)) - c6)) - c7)) - c8)) - c9)) +- Code(Expression(6, Sub)) at (prev + 2, 12) to (start + 2, 6) + = (c0 - c9) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) diff --git a/tests/coverage/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map index 8dc35321133b8..9187dcbd86518 100644 --- a/tests/coverage/loops_branches.cov-map +++ b/tests/coverage/loops_branches.cov-map @@ -1,57 +1,50 @@ Function name: ::fmt -Raw bytes (249): 0x[01, 01, 31, 05, 00, 00, 02, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, bf, 01, c3, 01, 0d, 00, 11, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, a3, 01, 19, 25, a6, 01, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 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, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, b6, 01, 03, 0d, 00, 0e, bb, 01, 00, 12, 00, 17, b6, 01, 01, 10, 00, 14, b2, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, ae, 01, 01, 12, 00, 13, ab, 01, 01, 11, 00, 22, a6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 9f, 01, 01, 05, 00, 06] +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, 0e, 00, 0f, 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, 12, 00, 13, 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] Number of files: 1 - file 0 => global file 1 -Number of expressions: 49 +Number of expressions: 42 - expression 0 operands: lhs = Counter(1), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) -- expression 2 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 3 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 4 operands: lhs = Counter(3), rhs = Zero -- expression 5 operands: lhs = Counter(4), rhs = Zero -- expression 6 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 7 operands: lhs = Counter(3), rhs = Zero -- expression 8 operands: lhs = Counter(4), rhs = Zero -- expression 9 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 10 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 11 operands: lhs = Counter(3), rhs = Zero -- expression 12 operands: lhs = Counter(4), rhs = Zero -- expression 13 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 14 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 15 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 16 operands: lhs = Counter(3), rhs = Zero -- expression 17 operands: lhs = Counter(4), rhs = Zero -- expression 18 operands: lhs = Expression(44, Sub), rhs = Zero -- expression 19 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 20 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 21 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 22 operands: lhs = Counter(3), rhs = Zero -- expression 23 operands: lhs = Counter(4), rhs = Zero -- expression 24 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 25 operands: lhs = Expression(44, Sub), rhs = Zero -- expression 26 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 27 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 28 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 29 operands: lhs = Counter(3), rhs = Zero -- expression 30 operands: lhs = Counter(4), rhs = Zero -- expression 31 operands: lhs = Expression(42, Add), rhs = Counter(4) -- expression 32 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 33 operands: lhs = Expression(44, Sub), rhs = Zero -- expression 34 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 35 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 36 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 37 operands: lhs = Counter(3), rhs = Zero -- expression 38 operands: lhs = Counter(4), rhs = Zero -- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(6) -- expression 40 operands: lhs = Counter(9), rhs = Expression(41, Sub) -- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(4) -- expression 42 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 43 operands: lhs = Expression(44, Sub), rhs = Zero -- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(6) -- expression 46 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) -- expression 47 operands: lhs = Counter(3), rhs = Zero -- expression 48 operands: lhs = Counter(4), 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 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) @@ -59,87 +52,78 @@ Number of file 0 mappings: 20 - Code(Zero) at (prev + 0, 28) to (start + 0, 30) - Code(Expression(0, Sub)) at (prev + 1, 14) to (start + 0, 15) = (c1 - Zero) -- Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 30) - = (Zero + (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(Zero) at (prev + 1, 16) to (start + 1, 10) -- Code(Expression(45, Sub)) at (prev + 3, 13) to (start + 0, 14) +- Code(Expression(38, Sub)) at (prev + 3, 13) to (start + 0, 14) = (((c3 + Zero) + (c4 + Zero)) - c6) -- Code(Expression(46, Add)) at (prev + 0, 18) to (start + 0, 23) +- Code(Expression(39, Add)) at (prev + 0, 18) to (start + 0, 23) = ((c3 + Zero) + (c4 + Zero)) -- Code(Expression(45, Sub)) at (prev + 1, 16) to (start + 0, 20) +- Code(Expression(38, Sub)) at (prev + 1, 16) to (start + 0, 20) = (((c3 + Zero) + (c4 + Zero)) - c6) -- Code(Expression(44, Sub)) at (prev + 1, 20) to (start + 0, 25) +- Code(Expression(37, Sub)) at (prev + 1, 20) to (start + 0, 25) = ((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(43, Sub)) at (prev + 1, 18) to (start + 0, 19) +- Code(Expression(17, Sub)) at (prev + 1, 18) to (start + 0, 19) = (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero) -- Code(Expression(42, Add)) at (prev + 1, 17) to (start + 0, 34) - = (Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) -- Code(Expression(41, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4) +- 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(Zero) at (prev + 1, 20) to (start + 1, 14) - Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) -- Code(Expression(39, Add)) at (prev + 1, 5) to (start + 0, 6) - = ((c9 + ((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4)) + c6) +- Code(Expression(34, Add)) at (prev + 1, 5) to (start + 0, 6) + = ((c9 + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - c4)) + c6) Function name: ::fmt -Raw bytes (253): 0x[01, 01, 33, 01, 00, 02, 00, 00, 0e, 02, 00, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, c7, 01, cb, 01, 00, 0d, 00, 15, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, be, 01, 00, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, ba, 01, 00, be, 01, 00, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, 00, b6, 01, ba, 01, 00, be, 01, 00, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, b3, 01, 15, 00, b6, 01, ba, 01, 00, be, 01, 00, c3, 01, 19, c7, 01, cb, 01, 00, 0d, 00, 15, ab, 01, 25, ae, 01, 19, b3, 01, 15, 00, b6, 01, ba, 01, 00, be, 01, 00, c3, 01, 19, c7, 01, cb, 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, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, be, 01, 02, 0d, 00, 0e, c3, 01, 00, 12, 00, 17, be, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, ba, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b6, 01, 01, 12, 00, 13, b3, 01, 01, 11, 00, 22, ae, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, a7, 01, 01, 05, 00, 06] +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, 0e, 00, 0f, 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, 12, 00, 13, 9a, 01, 01, 11, 00, 22, 96, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, 8f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 51 +Number of expressions: 43 - expression 0 operands: lhs = Counter(0), rhs = Zero - expression 1 operands: lhs = Expression(0, Sub), rhs = Zero -- expression 2 operands: lhs = Zero, rhs = Expression(3, Sub) -- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero -- expression 4 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 5 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 6 operands: lhs = Zero, rhs = Counter(3) -- expression 7 operands: lhs = Zero, rhs = Counter(5) -- expression 8 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 9 operands: lhs = Zero, rhs = Counter(3) -- expression 10 operands: lhs = Zero, rhs = Counter(5) -- expression 11 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 12 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 13 operands: lhs = Zero, rhs = Counter(3) -- expression 14 operands: lhs = Zero, rhs = Counter(5) -- expression 15 operands: lhs = Expression(47, Sub), rhs = Zero -- expression 16 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 17 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 18 operands: lhs = Zero, rhs = Counter(3) -- expression 19 operands: lhs = Zero, rhs = Counter(5) -- expression 20 operands: lhs = Expression(46, Sub), rhs = Zero -- expression 21 operands: lhs = Expression(47, Sub), rhs = Zero -- expression 22 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 23 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 24 operands: lhs = Zero, rhs = Counter(3) -- expression 25 operands: lhs = Zero, rhs = Counter(5) -- expression 26 operands: lhs = Zero, rhs = Expression(45, Sub) -- expression 27 operands: lhs = Expression(46, Sub), rhs = Zero -- expression 28 operands: lhs = Expression(47, Sub), rhs = Zero -- expression 29 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 30 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 31 operands: lhs = Zero, rhs = Counter(3) -- expression 32 operands: lhs = Zero, rhs = Counter(5) -- expression 33 operands: lhs = Expression(44, Add), rhs = Counter(5) -- expression 34 operands: lhs = Zero, rhs = Expression(45, Sub) -- expression 35 operands: lhs = Expression(46, Sub), rhs = Zero -- expression 36 operands: lhs = Expression(47, Sub), rhs = Zero -- expression 37 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 38 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 39 operands: lhs = Zero, rhs = Counter(3) -- expression 40 operands: lhs = Zero, rhs = Counter(5) -- expression 41 operands: lhs = Expression(42, Add), rhs = Counter(9) -- expression 42 operands: lhs = Expression(43, Sub), rhs = Counter(6) -- expression 43 operands: lhs = Expression(44, Add), rhs = Counter(5) -- expression 44 operands: lhs = Zero, rhs = Expression(45, Sub) -- expression 45 operands: lhs = Expression(46, Sub), rhs = Zero -- expression 46 operands: lhs = Expression(47, Sub), rhs = Zero -- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(6) -- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(50, Add) -- expression 49 operands: lhs = Zero, rhs = Counter(3) -- expression 50 operands: lhs = Zero, rhs = Counter(5) +- expression 2 operands: lhs = Expression(40, Add), rhs = Counter(6) +- expression 3 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) +- 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) 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) @@ -147,31 +131,31 @@ Number of file 0 mappings: 20 = (c0 - Zero) - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) -- Code(Expression(3, Sub)) at (prev + 1, 14) to (start + 0, 15) +- Code(Expression(1, Sub)) at (prev + 1, 14) to (start + 0, 15) = ((c0 - Zero) - Zero) -- Code(Expression(2, Add)) at (prev + 1, 13) to (start + 0, 30) - = (Zero + ((c0 - Zero) - 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(47, Sub)) at (prev + 2, 13) to (start + 0, 14) +- Code(Expression(39, Sub)) at (prev + 2, 13) to (start + 0, 14) = (((Zero + c3) + (Zero + c5)) - c6) -- Code(Expression(48, Add)) at (prev + 0, 18) to (start + 0, 23) +- Code(Expression(40, Add)) at (prev + 0, 18) to (start + 0, 23) = ((Zero + c3) + (Zero + c5)) -- Code(Expression(47, Sub)) at (prev + 1, 16) to (start + 0, 21) +- Code(Expression(39, Sub)) at (prev + 1, 16) to (start + 0, 21) = (((Zero + c3) + (Zero + c5)) - c6) - Code(Zero) at (prev + 0, 22) to (start + 1, 14) -- Code(Expression(46, Sub)) at (prev + 2, 20) to (start + 0, 25) +- Code(Expression(38, Sub)) at (prev + 2, 20) to (start + 0, 25) = ((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(45, Sub)) at (prev + 1, 18) to (start + 0, 19) +- Code(Expression(18, Sub)) at (prev + 1, 18) to (start + 0, 19) = (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero) -- Code(Expression(44, Add)) at (prev + 1, 17) to (start + 0, 34) - = (Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) -- Code(Expression(43, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5) +- 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(41, Add)) at (prev + 1, 5) to (start + 0, 6) - = ((((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5) + c6) + c9) +- Code(Expression(35, Add)) at (prev + 1, 5) to (start + 0, 6) + = (((((((Zero + c3) + (Zero + c5)) - c6) - Zero) - c5) + c6) + c9) Function name: loops_branches::main Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02] diff --git a/tests/coverage/match_or_pattern.cov-map b/tests/coverage/match_or_pattern.cov-map index d63407a99c35f..60b7024533d2e 100644 --- a/tests/coverage/match_or_pattern.cov-map +++ b/tests/coverage/match_or_pattern.cov-map @@ -1,83 +1,75 @@ Function name: match_or_pattern::main -Raw bytes (202): 0x[01, 01, 23, 01, 05, 05, 02, 09, 0d, 2f, 11, 09, 0d, 2b, 15, 2f, 11, 09, 0d, 15, 26, 2b, 15, 2f, 11, 09, 0d, 19, 1d, 57, 21, 19, 1d, 53, 25, 57, 21, 19, 1d, 25, 4e, 53, 25, 57, 21, 19, 1d, 29, 2d, 7f, 31, 29, 2d, 7b, 35, 7f, 31, 29, 2d, 35, 76, 7b, 35, 7f, 31, 29, 2d, 39, 3d, 8b, 01, 41, 39, 3d, 19, 01, 01, 01, 08, 0f, 05, 08, 10, 03, 06, 02, 03, 06, 00, 07, 07, 01, 0b, 00, 11, 11, 03, 1b, 00, 1d, 2f, 01, 0e, 00, 10, 2b, 02, 08, 00, 0f, 15, 00, 10, 03, 06, 26, 03, 06, 00, 07, 23, 01, 0b, 00, 11, 21, 01, 1b, 00, 1d, 57, 01, 0e, 00, 10, 53, 02, 08, 00, 0f, 25, 00, 10, 03, 06, 4e, 03, 06, 00, 07, 4b, 01, 0b, 00, 11, 31, 01, 1b, 00, 1d, 7f, 01, 0e, 00, 10, 7b, 02, 08, 00, 0f, 35, 00, 10, 03, 06, 76, 03, 06, 00, 07, 73, 01, 0b, 00, 11, 41, 01, 1b, 00, 1d, 8b, 01, 01, 0e, 00, 10, 87, 01, 02, 01, 00, 02] +Raw bytes (185): 0x[01, 01, 1c, 01, 05, 09, 0d, 23, 11, 09, 0d, 1f, 15, 23, 11, 09, 0d, 23, 11, 09, 0d, 19, 1d, 43, 21, 19, 1d, 3f, 25, 43, 21, 19, 1d, 43, 21, 19, 1d, 29, 2d, 63, 31, 29, 2d, 5f, 35, 63, 31, 29, 2d, 63, 31, 29, 2d, 39, 3d, 6f, 41, 39, 3d, 19, 01, 01, 01, 08, 0f, 05, 08, 10, 03, 06, 02, 03, 06, 00, 07, 01, 01, 0b, 00, 11, 11, 03, 1b, 00, 1d, 23, 01, 0e, 00, 10, 1f, 02, 08, 00, 0f, 15, 00, 10, 03, 06, 12, 03, 06, 00, 07, 1f, 01, 0b, 00, 11, 21, 01, 1b, 00, 1d, 43, 01, 0e, 00, 10, 3f, 02, 08, 00, 0f, 25, 00, 10, 03, 06, 32, 03, 06, 00, 07, 3f, 01, 0b, 00, 11, 31, 01, 1b, 00, 1d, 63, 01, 0e, 00, 10, 5f, 02, 08, 00, 0f, 35, 00, 10, 03, 06, 52, 03, 06, 00, 07, 5f, 01, 0b, 00, 11, 41, 01, 1b, 00, 1d, 6f, 01, 0e, 00, 10, 6b, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 35 +Number of expressions: 28 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 2 operands: lhs = Counter(2), rhs = Counter(3) -- expression 3 operands: lhs = Expression(11, Add), rhs = Counter(4) -- expression 4 operands: lhs = Counter(2), rhs = Counter(3) -- expression 5 operands: lhs = Expression(10, Add), rhs = Counter(5) -- expression 6 operands: lhs = Expression(11, Add), rhs = Counter(4) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) -- expression 8 operands: lhs = Counter(5), rhs = Expression(9, Sub) -- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(5) -- expression 10 operands: lhs = Expression(11, Add), rhs = Counter(4) -- expression 11 operands: lhs = Counter(2), rhs = Counter(3) -- expression 12 operands: lhs = Counter(6), rhs = Counter(7) -- expression 13 operands: lhs = Expression(21, Add), rhs = Counter(8) +- expression 1 operands: lhs = Counter(2), rhs = Counter(3) +- expression 2 operands: lhs = Expression(8, Add), rhs = Counter(4) +- expression 3 operands: lhs = Counter(2), rhs = Counter(3) +- expression 4 operands: lhs = Expression(7, Add), rhs = Counter(5) +- expression 5 operands: lhs = Expression(8, Add), rhs = Counter(4) +- expression 6 operands: lhs = Counter(2), rhs = Counter(3) +- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(4) +- expression 8 operands: lhs = Counter(2), rhs = Counter(3) +- expression 9 operands: lhs = Counter(6), rhs = Counter(7) +- expression 10 operands: lhs = Expression(16, Add), rhs = Counter(8) +- expression 11 operands: lhs = Counter(6), rhs = Counter(7) +- expression 12 operands: lhs = Expression(15, Add), rhs = Counter(9) +- expression 13 operands: lhs = Expression(16, Add), rhs = Counter(8) - expression 14 operands: lhs = Counter(6), rhs = Counter(7) -- expression 15 operands: lhs = Expression(20, Add), rhs = Counter(9) -- expression 16 operands: lhs = Expression(21, Add), rhs = Counter(8) -- expression 17 operands: lhs = Counter(6), rhs = Counter(7) -- expression 18 operands: lhs = Counter(9), rhs = Expression(19, Sub) -- expression 19 operands: lhs = Expression(20, Add), rhs = Counter(9) -- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(8) -- expression 21 operands: lhs = Counter(6), rhs = Counter(7) +- expression 15 operands: lhs = Expression(16, Add), rhs = Counter(8) +- expression 16 operands: lhs = Counter(6), rhs = Counter(7) +- expression 17 operands: lhs = Counter(10), rhs = Counter(11) +- expression 18 operands: lhs = Expression(24, Add), rhs = Counter(12) +- expression 19 operands: lhs = Counter(10), rhs = Counter(11) +- expression 20 operands: lhs = Expression(23, Add), rhs = Counter(13) +- expression 21 operands: lhs = Expression(24, Add), rhs = Counter(12) - expression 22 operands: lhs = Counter(10), rhs = Counter(11) -- expression 23 operands: lhs = Expression(31, Add), rhs = Counter(12) +- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(12) - expression 24 operands: lhs = Counter(10), rhs = Counter(11) -- expression 25 operands: lhs = Expression(30, Add), rhs = Counter(13) -- expression 26 operands: lhs = Expression(31, Add), rhs = Counter(12) -- expression 27 operands: lhs = Counter(10), rhs = Counter(11) -- expression 28 operands: lhs = Counter(13), rhs = Expression(29, Sub) -- expression 29 operands: lhs = Expression(30, Add), rhs = Counter(13) -- expression 30 operands: lhs = Expression(31, Add), rhs = Counter(12) -- expression 31 operands: lhs = Counter(10), rhs = Counter(11) -- expression 32 operands: lhs = Counter(14), rhs = Counter(15) -- expression 33 operands: lhs = Expression(34, Add), rhs = Counter(16) -- expression 34 operands: lhs = Counter(14), rhs = Counter(15) +- expression 25 operands: lhs = Counter(14), rhs = Counter(15) +- expression 26 operands: lhs = Expression(27, Add), rhs = Counter(16) +- expression 27 operands: lhs = Counter(14), rhs = Counter(15) Number of file 0 mappings: 25 - Code(Counter(0)) at (prev + 1, 1) to (start + 8, 15) - Code(Counter(1)) at (prev + 8, 16) to (start + 3, 6) - Code(Expression(0, Sub)) at (prev + 3, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 11) to (start + 0, 17) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 11) to (start + 0, 17) - Code(Counter(4)) at (prev + 3, 27) to (start + 0, 29) -- Code(Expression(11, Add)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(8, Add)) at (prev + 1, 14) to (start + 0, 16) = (c2 + c3) -- Code(Expression(10, Add)) at (prev + 2, 8) to (start + 0, 15) +- Code(Expression(7, Add)) at (prev + 2, 8) to (start + 0, 15) = ((c2 + c3) + c4) - Code(Counter(5)) at (prev + 0, 16) to (start + 3, 6) -- Code(Expression(9, Sub)) at (prev + 3, 6) to (start + 0, 7) +- Code(Expression(4, Sub)) at (prev + 3, 6) to (start + 0, 7) = (((c2 + c3) + c4) - c5) -- Code(Expression(8, Add)) at (prev + 1, 11) to (start + 0, 17) - = (c5 + (((c2 + c3) + c4) - c5)) +- Code(Expression(7, Add)) at (prev + 1, 11) to (start + 0, 17) + = ((c2 + c3) + c4) - Code(Counter(8)) at (prev + 1, 27) to (start + 0, 29) -- Code(Expression(21, Add)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(16, Add)) at (prev + 1, 14) to (start + 0, 16) = (c6 + c7) -- Code(Expression(20, Add)) at (prev + 2, 8) to (start + 0, 15) +- Code(Expression(15, Add)) at (prev + 2, 8) to (start + 0, 15) = ((c6 + c7) + c8) - Code(Counter(9)) at (prev + 0, 16) to (start + 3, 6) -- Code(Expression(19, Sub)) at (prev + 3, 6) to (start + 0, 7) +- Code(Expression(12, Sub)) at (prev + 3, 6) to (start + 0, 7) = (((c6 + c7) + c8) - c9) -- Code(Expression(18, Add)) at (prev + 1, 11) to (start + 0, 17) - = (c9 + (((c6 + c7) + c8) - c9)) +- Code(Expression(15, Add)) at (prev + 1, 11) to (start + 0, 17) + = ((c6 + c7) + c8) - Code(Counter(12)) at (prev + 1, 27) to (start + 0, 29) -- Code(Expression(31, Add)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(24, Add)) at (prev + 1, 14) to (start + 0, 16) = (c10 + c11) -- Code(Expression(30, Add)) at (prev + 2, 8) to (start + 0, 15) +- Code(Expression(23, Add)) at (prev + 2, 8) to (start + 0, 15) = ((c10 + c11) + c12) - Code(Counter(13)) at (prev + 0, 16) to (start + 3, 6) -- Code(Expression(29, Sub)) at (prev + 3, 6) to (start + 0, 7) +- Code(Expression(20, Sub)) at (prev + 3, 6) to (start + 0, 7) = (((c10 + c11) + c12) - c13) -- Code(Expression(28, Add)) at (prev + 1, 11) to (start + 0, 17) - = (c13 + (((c10 + c11) + c12) - c13)) +- Code(Expression(23, Add)) at (prev + 1, 11) to (start + 0, 17) + = ((c10 + c11) + c12) - Code(Counter(16)) at (prev + 1, 27) to (start + 0, 29) -- Code(Expression(34, Add)) at (prev + 1, 14) to (start + 0, 16) +- Code(Expression(27, Add)) at (prev + 1, 14) to (start + 0, 16) = (c14 + c15) -- Code(Expression(33, Add)) at (prev + 2, 1) to (start + 0, 2) +- Code(Expression(26, Add)) at (prev + 2, 1) to (start + 0, 2) = ((c14 + c15) + c16) diff --git a/tests/coverage/no_cov_crate.cov-map b/tests/coverage/no_cov_crate.cov-map index 05b6448bbd24a..e623f6480b90e 100644 --- a/tests/coverage/no_cov_crate.cov-map +++ b/tests/coverage/no_cov_crate.cov-map @@ -47,32 +47,28 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 63, 5) to (start + 11, 6) Function name: no_cov_crate::nested_fns::outer_both_covered::inner -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 67, 9) to (start + 1, 23) - Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) - Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 10) Function name: no_cov_crate::nested_fns::outer_not_covered::inner -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 26, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 07, 03, 09, 00, 0a] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 26, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 38, 9) to (start + 1, 23) - Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14) - Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 3, 9) to (start + 0, 10) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 10) diff --git a/tests/coverage/overflow.cov-map b/tests/coverage/overflow.cov-map index 39a5c05f879ad..cb31f3d1f3e4d 100644 --- a/tests/coverage/overflow.cov-map +++ b/tests/coverage/overflow.cov-map @@ -27,17 +27,15 @@ Number of file 0 mappings: 9 - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) Function name: overflow::might_overflow -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 05, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 01, 01, 09, 05, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 5, 1) to (start + 1, 18) - Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 5, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 9) to (start + 5, 2) diff --git a/tests/coverage/simple_loop.cov-map b/tests/coverage/simple_loop.cov-map index 0a342cb3673a8..541f7bf8fbdcb 100644 --- a/tests/coverage/simple_loop.cov-map +++ b/tests/coverage/simple_loop.cov-map @@ -1,27 +1,18 @@ Function name: simple_loop::main -Raw bytes (57): 0x[01, 01, 09, 01, 05, 23, 09, 05, 02, 1f, 09, 23, 09, 05, 02, 1f, 09, 23, 09, 05, 02, 07, 01, 04, 01, 09, 10, 05, 0a, 05, 05, 06, 02, 05, 06, 00, 07, 1f, 05, 0d, 02, 0e, 1a, 04, 0d, 00, 12, 09, 02, 0a, 03, 0a, 1a, 06, 01, 00, 02] +Raw bytes (43): 0x[01, 01, 02, 01, 05, 01, 09, 07, 01, 04, 01, 09, 10, 05, 0a, 05, 05, 06, 02, 05, 06, 00, 07, 07, 05, 0d, 02, 0e, 01, 04, 0d, 00, 12, 09, 02, 0a, 03, 0a, 01, 06, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 9 +Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(8, Add), rhs = Counter(2) -- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 3 operands: lhs = Expression(7, Add), rhs = Counter(2) -- expression 4 operands: lhs = Expression(8, Add), rhs = Counter(2) -- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(2) -- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(2) -- expression 8 operands: lhs = Counter(1), rhs = Expression(0, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Counter(2) Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 4, 1) to (start + 9, 16) - Code(Counter(1)) at (prev + 10, 5) to (start + 5, 6) - Code(Expression(0, Sub)) at (prev + 5, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(7, Add)) at (prev + 5, 13) to (start + 2, 14) - = ((c1 + (c0 - c1)) + c2) -- Code(Expression(6, Sub)) at (prev + 4, 13) to (start + 0, 18) - = (((c1 + (c0 - c1)) + c2) - c2) +- Code(Expression(1, Add)) at (prev + 5, 13) to (start + 2, 14) + = (c0 + c2) +- Code(Counter(0)) at (prev + 4, 13) to (start + 0, 18) - Code(Counter(2)) at (prev + 2, 10) to (start + 3, 10) -- Code(Expression(6, Sub)) at (prev + 6, 1) to (start + 0, 2) - = (((c1 + (c0 - c1)) + c2) - c2) +- Code(Counter(0)) at (prev + 6, 1) to (start + 0, 2) diff --git a/tests/coverage/simple_match.cov-map b/tests/coverage/simple_match.cov-map index 7c242e2c328db..49819b23482f3 100644 --- a/tests/coverage/simple_match.cov-map +++ b/tests/coverage/simple_match.cov-map @@ -1,32 +1,29 @@ Function name: simple_match::main -Raw bytes (78): 0x[01, 01, 0c, 01, 05, 2b, 2f, 05, 02, 09, 0d, 27, 11, 2b, 2f, 05, 02, 09, 0d, 27, 11, 2b, 2f, 05, 02, 09, 0d, 0a, 01, 04, 01, 07, 0f, 05, 07, 10, 02, 06, 02, 02, 06, 00, 07, 27, 05, 09, 00, 0d, 22, 05, 0d, 00, 16, 09, 02, 0d, 00, 0e, 22, 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, 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, 06, 00, 07, 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: 12 +Number of expressions: 9 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(10, Add), rhs = Expression(11, Add) -- expression 2 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 3 operands: lhs = Counter(2), rhs = Counter(3) -- expression 4 operands: lhs = Expression(9, Add), rhs = Counter(4) -- expression 5 operands: lhs = Expression(10, Add), rhs = Expression(11, Add) -- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 7 operands: lhs = Counter(2), rhs = Counter(3) -- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(4) -- expression 9 operands: lhs = Expression(10, Add), rhs = Expression(11, Add) -- expression 10 operands: lhs = Counter(1), rhs = Expression(0, Sub) -- expression 11 operands: lhs = Counter(2), rhs = Counter(3) +- expression 1 operands: lhs = Counter(0), rhs = Expression(8, Add) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- 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 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) 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, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(9, Add)) at (prev + 5, 9) to (start + 0, 13) - = ((c1 + (c0 - c1)) + (c2 + c3)) -- Code(Expression(8, Sub)) at (prev + 5, 13) to (start + 0, 22) - = (((c1 + (c0 - c1)) + (c2 + c3)) - c4) +- Code(Expression(7, Add)) at (prev + 5, 9) to (start + 0, 13) + = (c0 + (c2 + c3)) +- Code(Expression(6, Sub)) at (prev + 5, 13) to (start + 0, 22) + = ((c0 + (c2 + c3)) - c4) - Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14) -- Code(Expression(8, Sub)) at (prev + 2, 17) to (start + 2, 18) - = (((c1 + (c0 - c1)) + (c2 + c3)) - c4) +- Code(Expression(6, Sub)) at (prev + 2, 17) to (start + 2, 18) + = ((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/sort_groups.cov-map b/tests/coverage/sort_groups.cov-map index 3cbda6fbe1ab8..361b70fb74f76 100644 --- a/tests/coverage/sort_groups.cov-map +++ b/tests/coverage/sort_groups.cov-map @@ -1,77 +1,67 @@ Function name: sort_groups::generic_fn::<&str> -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) - Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: sort_groups::generic_fn::<()> -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) - Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: sort_groups::generic_fn:: -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) - Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: sort_groups::generic_fn:: -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) - Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Function name: sort_groups::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 23, 05, 04, 24, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 06, 01, 04, 23, 05, 04, 24, 02, 06, 02, 02, 06, 00, 07, 01, 01, 05, 02, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 6, 1) to (start + 4, 35) - Code(Counter(1)) at (prev + 4, 36) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 2, 2) Function name: sort_groups::other_fn Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map index 83f1869a31e6c..49e6c7ceefca4 100644 --- a/tests/coverage/try_error_result.cov-map +++ b/tests/coverage/try_error_result.cov-map @@ -1,62 +1,54 @@ Function name: ::get_thing_2 -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 29, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 1a, 07, 02, 05, 00, 06] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 29, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 1a, 01, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 41, 5) to (start + 1, 24) - Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20) - Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 26) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 6) Function name: ::call -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 34, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 13, 07, 02, 05, 00, 06] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 34, 05, 01, 18, 05, 02, 0d, 00, 14, 02, 02, 0d, 00, 13, 01, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 52, 5) to (start + 1, 24) - Code(Counter(1)) at (prev + 2, 13) to (start + 0, 20) - Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 5) to (start + 0, 6) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 6) Function name: try_error_result::call -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 07, 02, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 04, 01, 01, 14, 05, 02, 09, 00, 10, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 4, 1) to (start + 1, 20) - Code(Counter(1)) at (prev + 2, 9) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 15) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Function name: try_error_result::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 73, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 07, 01, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 73, 01, 02, 0c, 05, 03, 05, 00, 06, 02, 02, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 115, 1) to (start + 2, 12) - Code(Counter(1)) at (prev + 3, 5) to (start + 0, 6) - Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 11) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) 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] diff --git a/tests/coverage/unicode.cov-map b/tests/coverage/unicode.cov-map index aedfb2071c144..06a2c930498b5 100644 --- a/tests/coverage/unicode.cov-map +++ b/tests/coverage/unicode.cov-map @@ -1,31 +1,27 @@ Function name: unicode::main -Raw bytes (67): 0x[01, 01, 09, 01, 05, 03, 05, 1e, 0d, 22, 09, 03, 05, 11, 1b, 1e, 0d, 22, 09, 03, 05, 09, 01, 0e, 01, 00, 0b, 05, 01, 09, 00, 0c, 03, 00, 10, 00, 1b, 05, 00, 1c, 00, 28, 22, 02, 08, 00, 25, 09, 00, 29, 00, 46, 11, 00, 47, 02, 06, 1b, 02, 06, 00, 07, 17, 02, 05, 01, 02] +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, 06, 00, 07, 0f, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 9 +Number of expressions: 6 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1) -- expression 2 operands: lhs = Expression(7, Sub), rhs = Counter(3) -- expression 3 operands: lhs = Expression(8, Sub), rhs = Counter(2) -- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(1) -- expression 5 operands: lhs = Counter(4), rhs = Expression(6, Add) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(3) -- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(2) -- expression 8 operands: lhs = Expression(0, Add), 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) 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) - Code(Expression(0, Add)) at (prev + 0, 16) to (start + 0, 27) = (c0 + c1) - Code(Counter(1)) at (prev + 0, 28) to (start + 0, 40) -- Code(Expression(8, Sub)) at (prev + 2, 8) to (start + 0, 37) - = ((c0 + c1) - c1) +- 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(6, Add)) at (prev + 2, 6) to (start + 0, 7) - = ((((c0 + c1) - c1) - c2) + c3) -- Code(Expression(5, Add)) at (prev + 2, 5) to (start + 1, 2) - = (c4 + ((((c0 + c1) - c1) - c2) + c3)) +- Code(Expression(4, Add)) at (prev + 2, 6) to (start + 0, 7) + = ((c0 - c2) + c3) +- Code(Expression(3, Add)) at (prev + 2, 5) to (start + 1, 2) + = (c4 + ((c0 - c2) + c3)) Function name: unicode::ä»– (unused) Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 19, 00, 25] diff --git a/tests/coverage/uses_inline_crate.cov-map b/tests/coverage/uses_inline_crate.cov-map index 6b621825c8861..55ceb46b0602d 100644 --- a/tests/coverage/uses_inline_crate.cov-map +++ b/tests/coverage/uses_inline_crate.cov-map @@ -7,19 +7,17 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 44, 1) to (start + 2, 2) Function name: used_inline_crate::used_inline_function -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 14, 01, 06, 0f, 05, 06, 10, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 01, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 14, 01, 06, 0f, 05, 06, 10, 02, 06, 02, 02, 06, 00, 07, 01, 01, 05, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 20, 1) to (start + 6, 15) - Code(Counter(1)) at (prev + 6, 16) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c1 + (c0 - c1)) +- Code(Counter(0)) at (prev + 1, 5) to (start + 1, 2) Function name: used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec> Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 02, 02] diff --git a/tests/coverage/while.cov-map b/tests/coverage/while.cov-map index c6557b48e27dc..4d813a935a058 100644 --- a/tests/coverage/while.cov-map +++ b/tests/coverage/while.cov-map @@ -1,15 +1,13 @@ Function name: while::main -Raw bytes (28): 0x[01, 01, 02, 01, 00, 03, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 02, 06, 06, 03, 01, 00, 02] +Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Expression(0, Add), rhs = Zero Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20) = (c0 + Zero) - Code(Zero) at (prev + 0, 21) to (start + 2, 6) -- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2) - = ((c0 + Zero) - Zero) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) diff --git a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff index 3606a9e393231..01876b494c5d0 100644 --- a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff @@ -8,12 +8,11 @@ let mut _3: !; + coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Add, rhs: Counter(1) }; -+ coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Subtract, rhs: Counter(1) }; + coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:10:1 - 10:11; + coverage Code(Expression(0)) => $DIR/instrument_coverage.rs:11:5 - 12:17; -+ coverage Code(Expression(1)) => $DIR/instrument_coverage.rs:13:13 - 13:18; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:13:13 - 13:18; + coverage Code(Counter(1)) => $DIR/instrument_coverage.rs:14:10 - 14:11; -+ coverage Code(Expression(1)) => $DIR/instrument_coverage.rs:16:1 - 16:2; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:16:1 - 16:2; + bb0: { + Coverage::CounterIncrement(0); @@ -35,7 +34,6 @@ } bb4: { -+ Coverage::ExpressionUsed(1); _0 = const (); StorageDead(_2); return; diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff index 34d011540b9c1..efb1559baf5eb 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -8,11 +8,10 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; - coverage ExpressionId(1) => Expression { lhs: Counter(1), op: Add, rhs: Expression(0) }; coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1 - 14:36; coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37 - 14:39; coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39 - 14:40; - coverage Code(Expression(1)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; + coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8 - 14:36; bb0: { @@ -44,7 +43,6 @@ } bb4: { - Coverage::ExpressionUsed(1); StorageDead(_1); return; } diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff index 6756d5c1e1b2c..a0fe9a5c05cd1 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -8,11 +8,10 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) + coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; -+ coverage ExpressionId(1) => Expression { lhs: Counter(1), op: Add, rhs: Expression(0) }; + coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1 - 14:36; + coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37 - 14:39; + coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39 - 14:40; -+ coverage Code(Expression(1)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; + coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8 - 14:36; + bb0: { @@ -41,7 +40,6 @@ } bb4: { -+ Coverage::ExpressionUsed(1); StorageDead(_1); return; } From 42119ff45c75e5e3ced06f1f45a9e4853fb5bca9 Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Tue, 14 May 2024 16:10:05 +0200 Subject: [PATCH 06/19] create a feature gate --- compiler/rustc_ast_passes/src/feature_gate.rs | 1 + compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + tests/ui/feature-gates/feature-gate-global-registration.rs | 1 + 4 files changed, 5 insertions(+) create mode 100644 tests/ui/feature-gates/feature-gate-global-registration.rs diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 6622caaaab412..a522f04b21db3 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -560,6 +560,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { gate_all!(postfix_match, "postfix match is experimental"); gate_all!(mut_ref, "mutable by-reference bindings are experimental"); gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental"); + gate_all!(global_registration, "global registration is experimental"); if !visitor.features.never_patterns { if let Some(spans) = spans.get(&sym::never_patterns) { diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 60b386acf9106..a25b7ef10a427 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -487,6 +487,8 @@ declare_features! ( (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. (incomplete, generic_const_items, "1.73.0", Some(113521)), + /// Allows registring static items globally, possibly across crates, to iterate over at runtime. + (unstable, global_registration, "CURRENT_RUSTC_VERSION", Some(125119)), /// Allows using `..=X` as a patterns in slices. (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)), /// Allows `if let` guard in match arms. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d41059e8c24a4..192c7a27bd6d9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -928,6 +928,7 @@ symbols! { global_alloc_ty, global_allocator, global_asm, + global_registration, globs, gt, half_open_range_patterns, diff --git a/tests/ui/feature-gates/feature-gate-global-registration.rs b/tests/ui/feature-gates/feature-gate-global-registration.rs new file mode 100644 index 0000000000000..77072727ec501 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-global-registration.rs @@ -0,0 +1 @@ +//! WIP From c811acb1f36cdeb45b46c490b7a308851347dc0d Mon Sep 17 00:00:00 2001 From: cardigan1008 <211250058@smail.nju.edu.cn> Date: Thu, 16 May 2024 21:10:07 +0800 Subject: [PATCH 07/19] feat: add unit test --- tests/ui/return/tail-expr-if-as-return.rs | 5 +++++ tests/ui/return/tail-expr-if-as-return.stderr | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/ui/return/tail-expr-if-as-return.rs create mode 100644 tests/ui/return/tail-expr-if-as-return.stderr diff --git a/tests/ui/return/tail-expr-if-as-return.rs b/tests/ui/return/tail-expr-if-as-return.rs new file mode 100644 index 0000000000000..119ffccc6a945 --- /dev/null +++ b/tests/ui/return/tail-expr-if-as-return.rs @@ -0,0 +1,5 @@ +fn main() { + if true { + "" //~ ERROR mismatched types [E0308] + } +} diff --git a/tests/ui/return/tail-expr-if-as-return.stderr b/tests/ui/return/tail-expr-if-as-return.stderr new file mode 100644 index 0000000000000..2631f1e426ded --- /dev/null +++ b/tests/ui/return/tail-expr-if-as-return.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/tail-expr-if-as-return.rs:3:9 + | +LL | / if true { +LL | | "" + | | ^^ expected `()`, found `&str` +LL | | } + | |_____- expected this to be `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. From 9f730e92f24ebd21b94112e46a0e44bdf7730e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 3 May 2024 21:42:34 +0000 Subject: [PATCH 08/19] Suggest setting lifetime in borrowck error involving types with elided lifetimes ``` error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5 | LL | fn foo(mut x: Ref, y: Ref) { | ----- - has type `Ref<'_, '1>` | | | has type `Ref<'_, '2>` LL | x.b = y.b; | ^^^^^^^^^ assignment requires that `'1` must outlive `'2` | help: consider introducing a named lifetime parameter | LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) { | ++++ ++++++++ ++++++++ ``` As can be seen above, it currently doesn't try to compare the `ty::Ty` lifetimes that diverged vs the `hir::Ty` to correctly suggest the following ``` help: consider introducing a named lifetime parameter | LL | fn foo<'a>(mut x: Ref<'_, 'a>, y: Ref<'_, 'a>) { | ++++ ++++++++ ++++++++ ``` but I believe this to still be an improvement over the status quo. CC #40990. --- compiler/rustc_infer/src/errors/mod.rs | 105 +++++++++++++----- ...ne-existing-name-if-else-using-impl.stderr | 5 + ...e-existing-name-return-type-is-anon.stderr | 5 + ...turn-one-existing-name-self-is-anon.stderr | 5 + .../ex2b-push-no-existing-names.stderr | 5 + ...oth-anon-regions-both-are-structs-2.stderr | 5 + ...oth-anon-regions-both-are-structs-3.stderr | 5 + ...-both-anon-regions-both-are-structs.stderr | 5 + ...3-both-anon-regions-one-is-struct-2.stderr | 5 + ...3-both-anon-regions-one-is-struct-3.stderr | 5 + ...3-both-anon-regions-one-is-struct-4.stderr | 5 + ...ex3-both-anon-regions-one-is-struct.stderr | 5 + ...f_types_pin_lifetime_mismatch-async.stderr | 5 + ...ry_self_types_pin_lifetime_mismatch.stderr | 5 + 14 files changed, 140 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 2acaeac24398d..039472398964b 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -4,6 +4,7 @@ use rustc_errors::{ MultiSpan, SubdiagMessageOp, Subdiagnostic, }; use rustc_hir as hir; +use rustc_hir::intravisit::{walk_ty, Visitor}; use rustc_hir::FnRetTy; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::print::TraitRefPrintOnlyTraitPath; @@ -355,18 +356,6 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { _f: &F, ) { let mut mk_suggestion = || { - let ( - hir::Ty { kind: hir::TyKind::Ref(lifetime_sub, _), .. }, - hir::Ty { kind: hir::TyKind::Ref(lifetime_sup, _), .. }, - ) = (self.ty_sub, self.ty_sup) - else { - return false; - }; - - if !lifetime_sub.is_anonymous() || !lifetime_sup.is_anonymous() { - return false; - }; - let Some(anon_reg) = self.tcx.is_suitable_region(self.sub) else { return false; }; @@ -393,21 +382,77 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { let suggestion_param_name = suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| "'a".to_owned()); - debug!(?lifetime_sup.ident.span); - debug!(?lifetime_sub.ident.span); - let make_suggestion = |ident: Ident| { - let sugg = if ident.name == kw::Empty { - format!("{suggestion_param_name}, ") - } else if ident.name == kw::UnderscoreLifetime && ident.span.is_empty() { - format!("{suggestion_param_name} ") - } else { - suggestion_param_name.clone() - }; - (ident.span, sugg) - }; - let mut suggestions = - vec![make_suggestion(lifetime_sub.ident), make_suggestion(lifetime_sup.ident)]; + struct ImplicitLifetimeFinder { + suggestions: Vec<(Span, String)>, + suggestion_param_name: String, + } + impl<'v> Visitor<'v> for ImplicitLifetimeFinder { + fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) { + let make_suggestion = |ident: Ident| { + if ident.name == kw::Empty && ident.span.is_empty() { + format!("{}, ", self.suggestion_param_name) + } else if ident.name == kw::UnderscoreLifetime && ident.span.is_empty() { + format!("{} ", self.suggestion_param_name) + } else { + self.suggestion_param_name.clone() + } + }; + match ty.kind { + hir::TyKind::Path(hir::QPath::Resolved(_, path)) => { + for segment in path.segments { + if let Some(args) = segment.args { + if args.args.iter().all(|arg| { + matches!( + arg, + hir::GenericArg::Lifetime(lifetime) + if lifetime.ident.name == kw::Empty + ) + }) { + self.suggestions.push(( + segment.ident.span.shrink_to_hi(), + format!( + "<{}>", + args.args + .iter() + .map(|_| self.suggestion_param_name.clone()) + .collect::>() + .join(", ") + ), + )); + } else { + for arg in args.args { + if let hir::GenericArg::Lifetime(lifetime) = arg + && lifetime.is_anonymous() + { + self.suggestions.push(( + lifetime.ident.span, + make_suggestion(lifetime.ident), + )); + } + } + } + } + } + } + hir::TyKind::Ref(lifetime, ..) if lifetime.is_anonymous() => { + self.suggestions + .push((lifetime.ident.span, make_suggestion(lifetime.ident))); + } + _ => {} + } + walk_ty(self, ty); + } + } + let mut visitor = ImplicitLifetimeFinder { + suggestions: vec![], + suggestion_param_name: suggestion_param_name.clone(), + }; + visitor.visit_ty(self.ty_sub); + visitor.visit_ty(self.ty_sup); + if visitor.suggestions.is_empty() { + return false; + } if introduce_new { let new_param_suggestion = if let Some(first) = generics.params.iter().find(|p| !p.name.ident().span.is_empty()) @@ -417,15 +462,15 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { (generics.span, format!("<{suggestion_param_name}>")) }; - suggestions.push(new_param_suggestion); + visitor.suggestions.push(new_param_suggestion); } - - diag.multipart_suggestion( + diag.multipart_suggestion_verbose( fluent::infer_lifetime_param_suggestion, - suggestions, + visitor.suggestions, Applicability::MaybeIncorrect, ); diag.arg("is_impl", is_impl); + true }; if mk_suggestion() && self.add_note { diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr index 5827b2fe695a6..6bc82910b06a5 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr @@ -8,6 +8,11 @@ LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { LL | LL | if x > y { x } else { y } | ^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 { + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index da454b8fd8637..cdcdc0c07e3ab 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -8,6 +8,11 @@ LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { LL | LL | x | ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 { + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index a1dfff883a004..f106d45b9acdd 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -8,6 +8,11 @@ LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { LL | LL | if true { x } else { self } | ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo { + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr b/tests/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr index df1d03d517032..6f7127d4c4c4e 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.stderr @@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec>, y: Ref) { | has type `&mut Vec>` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &mut Vec>, y: Ref<'a, i32>) { + | ++++ +++ +++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr index 4f1cb1e797221..f8ad923cce8a5 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut x: Ref, y: Ref) { | has type `Ref<'_, '2>` LL | x.b = y.b; | ^^^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: Ref<'a, 'a>) { + | ++++ ++++++++ ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr index 3a1947973b551..a1149779d2c6d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr @@ -8,6 +8,11 @@ LL | fn foo(mut x: Ref) { | has type `Ref<'2, '_>` LL | x.a = x.b; | ^^^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut x: Ref<'a, 'a>) { + | ++++ ++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr index c778f77366abc..017bfa7146317 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut x: Vec, y: Ref) { | has type `Vec>` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut x: Vec>, y: Ref<'a>) { + | ++++ ++++ ++++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr index bbd62902d9f44..0980de92d350e 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut x: Ref, y: &u32) { | has type `Ref<'_, '1>` LL | y = x.b; | ^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: &'a u32) { + | ++++ ++++++++ ++ error[E0384]: cannot assign to immutable argument `y` --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5 diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr index 60ca416845515..d9c7530b64c57 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut y: Ref, x: &u32) { | has type `Ref<'_, '2>` LL | y.b = x; | ^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut y: Ref<'a, 'a>, x: &'a u32) { + | ++++ ++++++++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr index 98e490c3827b5..d07b821444ccc 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut y: Ref, x: &u32) { | has type `Ref<'_, '2>` LL | y.b = x; | ^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut y: Ref<'a, 'a>, x: &'a u32) { + | ++++ ++++++++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr index ea1cc1f18a4dc..ef28ddeacc5e2 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.stderr @@ -7,6 +7,11 @@ LL | fn foo(mut x: Ref, y: &u32) { | has type `Ref<'_, '2>` LL | x.b = y; | ^^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(mut x: Ref<'a, 'a>, y: &'a u32) { + | ++++ ++++++++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index 0b4c0a7fecec4..bb643ab827222 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -34,6 +34,11 @@ LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | | | | | let's call the lifetime of this reference `'1` | lifetime `'a` defined here + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | async fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &() { arg } + | ++ error: aborting due to 3 previous errors diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index 209dae9c1b3e8..bbb2ef4641e72 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -33,6 +33,11 @@ LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | -- ---- has type `Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | | | lifetime `'a` defined here + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &() { arg } + | ++ error: aborting due to 3 previous errors From 120049fab4e293c19fa1c5a09d68f89bcd940b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 5 May 2024 03:42:47 +0000 Subject: [PATCH 09/19] Always constrain the return type in lifetime suggestion ``` error: lifetime may not live long enough --> f205.rs:8:16 | 7 | fn resolve_symbolic_reference(&self, reference: Option) -> Option { | - --------- has type `Option>` | | | let's call the lifetime of this reference `'2` 8 | return reference; | ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter | 7 | fn resolve_symbolic_reference<'a>(&'a self, reference: Option>) -> Option> { | ++++ ++ ++++ ++++ ``` The correct suggestion would be ``` help: consider introducing a named lifetime parameter | 7 | fn resolve_symbolic_reference<'a>(&self, reference: Option>) -> Option> { | ++++ ++++ ++++ ``` but we are not doing the analysis to detect that yet. If we constrain `&'a self`, then the return type with a borrow will implicitly take its lifetime from `'a`, it is better to make it explicit in the suggestion, in case that `&self` *doesn't* need to be `'a`, but the return does. --- compiler/rustc_infer/src/errors/mod.rs | 5 ++++ tests/ui/lifetimes/issue-17728.stderr | 4 +-- ...e-existing-name-return-type-is-anon.stderr | 4 +-- ...th-anon-regions-return-type-is-anon.stderr | 4 +-- .../ex3-both-anon-regions-self-is-anon.stderr | 4 +-- ...ry_self_types_pin_lifetime_mismatch.stderr | 12 ++++---- tests/ui/self/elision/lt-ref-self.stderr | 24 ++++++++-------- tests/ui/self/elision/ref-mut-self.stderr | 24 ++++++++-------- tests/ui/self/elision/ref-mut-struct.stderr | 20 ++++++------- tests/ui/self/elision/ref-self.stderr | 28 +++++++++---------- tests/ui/self/elision/ref-struct.stderr | 20 ++++++------- 11 files changed, 77 insertions(+), 72 deletions(-) diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 039472398964b..4db79af10a559 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -450,6 +450,11 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { }; visitor.visit_ty(self.ty_sub); visitor.visit_ty(self.ty_sup); + if let Some(fn_decl) = node.fn_decl() + && let hir::FnRetTy::Return(ty) = fn_decl.output + { + visitor.visit_ty(ty); + } if visitor.suggestions.is_empty() { return false; } diff --git a/tests/ui/lifetimes/issue-17728.stderr b/tests/ui/lifetimes/issue-17728.stderr index 23547f722a116..da4ce2dd2911d 100644 --- a/tests/ui/lifetimes/issue-17728.stderr +++ b/tests/ui/lifetimes/issue-17728.stderr @@ -29,8 +29,8 @@ LL | Some(entry) => Ok(entry), | help: consider introducing a named lifetime parameter | -LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> Result<&Room, &str> { - | ++++ ++ ++ +LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> Result<&'a Room, &'a str> { + | ++++ ++ ++ ++ ++ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index cdcdc0c07e3ab..5cfa571722402 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -11,8 +11,8 @@ LL | x | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 { - | ++ +LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + | ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index e934ce7c040ef..fd15d516999cf 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -10,8 +10,8 @@ LL | x | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 { - | ++ ++ +LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + | ++ ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index dde271d100c58..0a312cf93c8de 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -10,8 +10,8 @@ LL | if true { x } else { self } | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a Foo) -> &Foo { - | ++ ++ +LL | fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo { + | ++ ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index bbb2ef4641e72..3e2bbd37f33fd 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -9,8 +9,8 @@ LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f } - | ++++ ++ ++ +LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { f } + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:9:69 @@ -23,8 +23,8 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ++++ ++ ++ +LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { (self, f) } + | ++++ ++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:15:58 @@ -36,8 +36,8 @@ LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &() { arg } - | ++ +LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { arg } + | ++ ++ error: aborting due to 3 previous errors diff --git a/tests/ui/self/elision/lt-ref-self.stderr b/tests/ui/self/elision/lt-ref-self.stderr index 216737a2c7330..5eaaa7698b6e4 100644 --- a/tests/ui/self/elision/lt-ref-self.stderr +++ b/tests/ui/self/elision/lt-ref-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:18:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:23:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:28:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:33:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:38:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/ref-mut-self.stderr b/tests/ui/self/elision/ref-mut-self.stderr index 12b64a3f6dcb5..8fea05e493dcd 100644 --- a/tests/ui/self/elision/ref-mut-self.stderr +++ b/tests/ui/self/elision/ref-mut-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:18:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:23:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:28:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:33:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:38:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/ref-mut-struct.stderr b/tests/ui/self/elision/ref-mut-struct.stderr index cde16ce8ba414..26dcfcb6dd0b1 100644 --- a/tests/ui/self/elision/ref-mut-struct.stderr +++ b/tests/ui/self/elision/ref-mut-struct.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:16:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:21:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:26:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:31:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: aborting due to 5 previous errors diff --git a/tests/ui/self/elision/ref-self.stderr b/tests/ui/self/elision/ref-self.stderr index 35693257c9919..8654032b0476b 100644 --- a/tests/ui/self/elision/ref-self.stderr +++ b/tests/ui/self/elision/ref-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:28:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:33:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:38:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:43:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:48:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:53:9 @@ -100,8 +100,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 { - | ++++ ++ ++ +LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &'a u8 { + | ++++ ++ ++ ++ error: aborting due to 7 previous errors diff --git a/tests/ui/self/elision/ref-struct.stderr b/tests/ui/self/elision/ref-struct.stderr index a3d3cebeba9c5..653ecc612d572 100644 --- a/tests/ui/self/elision/ref-struct.stderr +++ b/tests/ui/self/elision/ref-struct.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:16:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:21:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:26:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:31:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &u32 { - | ++++ ++ ++ +LL | fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ ++ error: aborting due to 5 previous errors From d1d585d039ace2ea72db8772166773a80a661905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 7 May 2024 19:35:25 +0000 Subject: [PATCH 10/19] Account for owning item lifetimes in suggestion and annotate tests as `run-rustfix` ``` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:12:9 | LL | fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` | | | let's call the lifetime of this reference `'2` LL | f | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ ``` --- compiler/rustc_infer/src/errors/mod.rs | 42 ++++++++++++- ...ne-existing-name-return-type-is-anon.fixed | 17 ++++++ ...n-one-existing-name-return-type-is-anon.rs | 6 +- ...e-existing-name-return-type-is-anon.stderr | 2 +- ...oth-anon-regions-return-type-is-anon.fixed | 14 +++++ ...3-both-anon-regions-return-type-is-anon.rs | 4 +- ...th-anon-regions-return-type-is-anon.stderr | 2 +- ...itrary_self_types_pin_lifetime_mismatch.rs | 3 + ...ry_self_types_pin_lifetime_mismatch.stderr | 4 +- tests/ui/self/elision/lt-ref-self-async.fixed | 45 ++++++++++++++ tests/ui/self/elision/lt-ref-self-async.rs | 4 +- .../ui/self/elision/lt-ref-self-async.stderr | 12 ++-- tests/ui/self/elision/lt-ref-self.fixed | 44 ++++++++++++++ tests/ui/self/elision/lt-ref-self.rs | 3 +- tests/ui/self/elision/lt-ref-self.stderr | 24 ++++---- tests/ui/self/elision/ref-mut-self.fixed | 44 ++++++++++++++ tests/ui/self/elision/ref-mut-self.rs | 3 +- tests/ui/self/elision/ref-mut-self.stderr | 12 ++-- tests/ui/self/elision/ref-mut-struct.fixed | 37 ++++++++++++ tests/ui/self/elision/ref-mut-struct.rs | 3 +- tests/ui/self/elision/ref-mut-struct.stderr | 10 ++-- tests/ui/self/elision/ref-self.fixed | 59 +++++++++++++++++++ tests/ui/self/elision/ref-self.rs | 5 +- tests/ui/self/elision/ref-self.stderr | 14 ++--- tests/ui/self/elision/ref-struct.fixed | 37 ++++++++++++ tests/ui/self/elision/ref-struct.rs | 3 +- tests/ui/self/elision/ref-struct.stderr | 10 ++-- 27 files changed, 404 insertions(+), 59 deletions(-) create mode 100644 tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed create mode 100644 tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed create mode 100644 tests/ui/self/elision/lt-ref-self-async.fixed create mode 100644 tests/ui/self/elision/lt-ref-self.fixed create mode 100644 tests/ui/self/elision/ref-mut-self.fixed create mode 100644 tests/ui/self/elision/ref-mut-struct.fixed create mode 100644 tests/ui/self/elision/ref-self.fixed create mode 100644 tests/ui/self/elision/ref-struct.fixed diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 4db79af10a559..f60ecb3f453ae 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -1,4 +1,5 @@ use hir::GenericParamKind; +use rustc_data_structures::fx::FxHashSet; use rustc_errors::{ codes::*, Applicability, Diag, DiagMessage, DiagStyledString, EmissionGuarantee, IntoDiagArg, MultiSpan, SubdiagMessageOp, Subdiagnostic, @@ -362,13 +363,27 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { let node = self.tcx.hir_node_by_def_id(anon_reg.def_id); let is_impl = matches!(&node, hir::Node::ImplItem(_)); - let generics = match node { + let (generics, parent_generics) = match node { hir::Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, ref generics, ..), .. }) | hir::Node::TraitItem(&hir::TraitItem { ref generics, .. }) - | hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics, + | hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => ( + generics, + match self.tcx.parent_hir_node(self.tcx.local_def_id_to_hir_id(anon_reg.def_id)) + { + hir::Node::Item(hir::Item { + kind: hir::ItemKind::Trait(_, _, ref generics, ..), + .. + }) + | hir::Node::Item(hir::Item { + kind: hir::ItemKind::Impl(hir::Impl { ref generics, .. }), + .. + }) => Some(generics), + _ => None, + }, + ), _ => return false, }; @@ -379,8 +394,29 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { .map(|p| p.name.ident().name) .find(|i| *i != kw::UnderscoreLifetime); let introduce_new = suggestion_param_name.is_none(); + + let mut default = "'a".to_string(); + if let Some(parent_generics) = parent_generics { + let used: FxHashSet<_> = parent_generics + .params + .iter() + .filter(|p| matches!(p.kind, GenericParamKind::Lifetime { .. })) + .map(|p| p.name.ident().name) + .filter(|i| *i != kw::UnderscoreLifetime) + .map(|l| l.to_string()) + .collect(); + if let Some(lt) = + ('a'..='z').map(|it| format!("'{it}")).find(|it| !used.contains(it)) + { + // We want a lifetime that *isn't* present in the `trait` or `impl` that assoc + // `fn` belongs to. We could suggest reusing one of their lifetimes, but it is + // likely to be an over-constraining lifetime requirement, so we always add a + // lifetime to the `fn`. + default = lt; + } + } let suggestion_param_name = - suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| "'a".to_owned()); + suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| default); struct ImplicitLifetimeFinder { suggestions: Vec<(Span, String)>, diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed new file mode 100644 index 0000000000000..b5513818f63e8 --- /dev/null +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed @@ -0,0 +1,17 @@ +//@ run-rustfix +#![allow(dead_code)] +struct Foo { + field: i32, +} + +impl Foo { + fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + + x + //~^ ERROR lifetime may not live long enough + + } + +} + +fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs index 49993aca3cadd..52646ff89eb24 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs @@ -1,5 +1,7 @@ +//@ run-rustfix +#![allow(dead_code)] struct Foo { - field: i32 + field: i32, } impl Foo { @@ -12,4 +14,4 @@ impl Foo { } -fn main() { } +fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index 5cfa571722402..e2f42cbfb286d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:10:5 | LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | -- - let's call the lifetime of this reference `'1` diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed new file mode 100644 index 0000000000000..d9f454f346cef --- /dev/null +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed @@ -0,0 +1,14 @@ +//@ run-rustfix +#![allow(dead_code)] +struct Foo { + field: i32, +} + +impl Foo { + fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + x + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs index 3ffd7be4e73fe..bf66a551a80ee 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs @@ -1,5 +1,7 @@ +//@ run-rustfix +#![allow(dead_code)] struct Foo { - field: i32 + field: i32, } impl Foo { diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index fd15d516999cf..778634e95be56 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:5 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs index f1a3fb0185db7..3b2c8c7bc791f 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs @@ -6,6 +6,9 @@ impl Foo { fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } //~^ lifetime may not live long enough + // For this suggestion to be right, we'd need to also suggest `self: Pin<&'a Self>`, which we + // don't, but we provide a follow up suggestion to do so, so I condider that good at least for + // now. fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } //~^ lifetime may not live long enough } diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index 3e2bbd37f33fd..773f9362ec53f 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -13,7 +13,7 @@ LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { f } | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:9:69 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:12:69 | LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } | - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` @@ -27,7 +27,7 @@ LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &' | ++++ ++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:15:58 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:18:58 | LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | -- ---- has type `Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` diff --git a/tests/ui/self/elision/lt-ref-self-async.fixed b/tests/ui/self/elision/lt-ref-self-async.fixed new file mode 100644 index 0000000000000..6d875ef0cec17 --- /dev/null +++ b/tests/ui/self/elision/lt-ref-self-async.fixed @@ -0,0 +1,45 @@ +//@ edition:2018 +//@ run-rustfix +#![allow(non_snake_case, dead_code)] + +use std::pin::Pin; + +struct Struct<'a> { data: &'a u32 } + +impl<'a> Struct<'a> { + // Test using `&self` sugar: + + async fn ref_self<'b>(&'b self, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } + + // Test using `&Self` explicitly: + + async fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } + + async fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } + + async fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } + + async fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } + + async fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &u32 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/lt-ref-self-async.rs b/tests/ui/self/elision/lt-ref-self-async.rs index 8eb4a48a9c932..a70e22ab77ad0 100644 --- a/tests/ui/self/elision/lt-ref-self-async.rs +++ b/tests/ui/self/elision/lt-ref-self-async.rs @@ -1,6 +1,6 @@ //@ edition:2018 - -#![allow(non_snake_case)] +//@ run-rustfix +#![allow(non_snake_case, dead_code)] use std::pin::Pin; diff --git a/tests/ui/self/elision/lt-ref-self-async.stderr b/tests/ui/self/elision/lt-ref-self-async.stderr index 29d60ed663523..c8b49de7671ef 100644 --- a/tests/ui/self/elision/lt-ref-self-async.stderr +++ b/tests/ui/self/elision/lt-ref-self-async.stderr @@ -10,7 +10,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { +LL | async fn ref_self<'b>(&'b self, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough @@ -25,7 +25,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { +LL | async fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough @@ -40,7 +40,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { +LL | async fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough @@ -55,7 +55,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { +LL | async fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough @@ -70,7 +70,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &u32 { +LL | async fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough @@ -85,7 +85,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | async fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &u32 { +LL | async fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/lt-ref-self.fixed b/tests/ui/self/elision/lt-ref-self.fixed new file mode 100644 index 0000000000000..c9faa86c441b4 --- /dev/null +++ b/tests/ui/self/elision/lt-ref-self.fixed @@ -0,0 +1,44 @@ +//@ run-rustfix +#![allow(non_snake_case, dead_code)] + +use std::pin::Pin; + +struct Struct<'a> { data: &'a u32 } + +impl<'a> Struct<'a> { + // Test using `&self` sugar: + + fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } + + // Test using `&Self` explicitly: + + fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/lt-ref-self.rs b/tests/ui/self/elision/lt-ref-self.rs index d37ed5acbcb2e..fbd0665b22d23 100644 --- a/tests/ui/self/elision/lt-ref-self.rs +++ b/tests/ui/self/elision/lt-ref-self.rs @@ -1,4 +1,5 @@ -#![allow(non_snake_case)] +//@ run-rustfix +#![allow(non_snake_case, dead_code)] use std::pin::Pin; diff --git a/tests/ui/self/elision/lt-ref-self.stderr b/tests/ui/self/elision/lt-ref-self.stderr index 5eaaa7698b6e4..53b662bcb693c 100644 --- a/tests/ui/self/elision/lt-ref-self.stderr +++ b/tests/ui/self/elision/lt-ref-self.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:11:9 + --> $DIR/lt-ref-self.rs:12:9 | LL | fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -10,11 +10,11 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { +LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:18:9 + --> $DIR/lt-ref-self.rs:19:9 | LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -25,11 +25,11 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { +LL | fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:23:9 + --> $DIR/lt-ref-self.rs:24:9 | LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -40,11 +40,11 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { +LL | fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:28:9 + --> $DIR/lt-ref-self.rs:29:9 | LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -55,11 +55,11 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { +LL | fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:33:9 + --> $DIR/lt-ref-self.rs:34:9 | LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -70,11 +70,11 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { +LL | fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:38:9 + --> $DIR/lt-ref-self.rs:39:9 | LL | fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -85,7 +85,7 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { +LL | fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/ref-mut-self.fixed b/tests/ui/self/elision/ref-mut-self.fixed new file mode 100644 index 0000000000000..90e50221a19bc --- /dev/null +++ b/tests/ui/self/elision/ref-mut-self.fixed @@ -0,0 +1,44 @@ +//@ run-rustfix +#![allow(non_snake_case, dead_code)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&mut self` sugar: + + fn ref_self<'a>(&'a mut self, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + // Test using `&mut Self` explicitly: + + fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/ref-mut-self.rs b/tests/ui/self/elision/ref-mut-self.rs index bb82e6be74897..a09fcdfcbb2fd 100644 --- a/tests/ui/self/elision/ref-mut-self.rs +++ b/tests/ui/self/elision/ref-mut-self.rs @@ -1,4 +1,5 @@ -#![allow(non_snake_case)] +//@ run-rustfix +#![allow(non_snake_case, dead_code)] use std::pin::Pin; diff --git a/tests/ui/self/elision/ref-mut-self.stderr b/tests/ui/self/elision/ref-mut-self.stderr index 8fea05e493dcd..a09034e5f71d7 100644 --- a/tests/ui/self/elision/ref-mut-self.stderr +++ b/tests/ui/self/elision/ref-mut-self.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:11:9 + --> $DIR/ref-mut-self.rs:12:9 | LL | fn ref_self(&mut self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:18:9 + --> $DIR/ref-mut-self.rs:19:9 | LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:23:9 + --> $DIR/ref-mut-self.rs:24:9 | LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:28:9 + --> $DIR/ref-mut-self.rs:29:9 | LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:33:9 + --> $DIR/ref-mut-self.rs:34:9 | LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &' | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-self.rs:38:9 + --> $DIR/ref-mut-self.rs:39:9 | LL | fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/ref-mut-struct.fixed b/tests/ui/self/elision/ref-mut-struct.fixed new file mode 100644 index 0000000000000..275fafbad53a5 --- /dev/null +++ b/tests/ui/self/elision/ref-mut-struct.fixed @@ -0,0 +1,37 @@ +//@ run-rustfix +#![allow(non_snake_case, dead_code)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&mut Struct` explicitly: + + fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/ref-mut-struct.rs b/tests/ui/self/elision/ref-mut-struct.rs index ca8bd8da1335a..6bfdca62bca73 100644 --- a/tests/ui/self/elision/ref-mut-struct.rs +++ b/tests/ui/self/elision/ref-mut-struct.rs @@ -1,4 +1,5 @@ -#![allow(non_snake_case)] +//@ run-rustfix +#![allow(non_snake_case, dead_code)] use std::pin::Pin; diff --git a/tests/ui/self/elision/ref-mut-struct.stderr b/tests/ui/self/elision/ref-mut-struct.stderr index 26dcfcb6dd0b1..19b09272504e3 100644 --- a/tests/ui/self/elision/ref-mut-struct.stderr +++ b/tests/ui/self/elision/ref-mut-struct.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ref-mut-struct.rs:11:9 + --> $DIR/ref-mut-struct.rs:12:9 | LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-struct.rs:16:9 + --> $DIR/ref-mut-struct.rs:17:9 | LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &'a u32 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-struct.rs:21:9 + --> $DIR/ref-mut-struct.rs:22:9 | LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &'a u32 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-struct.rs:26:9 + --> $DIR/ref-mut-struct.rs:27:9 | LL | fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) - | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-mut-struct.rs:31:9 + --> $DIR/ref-mut-struct.rs:32:9 | LL | fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/ref-self.fixed b/tests/ui/self/elision/ref-self.fixed new file mode 100644 index 0000000000000..41b11c2d77a3d --- /dev/null +++ b/tests/ui/self/elision/ref-self.fixed @@ -0,0 +1,59 @@ +//@ run-rustfix +#![feature(arbitrary_self_types)] +#![allow(non_snake_case, dead_code)] + +use std::marker::PhantomData; +use std::ops::Deref; +use std::pin::Pin; + +struct Struct {} + +struct Wrap(T, PhantomData

); + +impl Deref for Wrap { + type Target = T; + fn deref(&self) -> &T { &self.0 } +} + +impl Struct { + // Test using `&self` sugar: + + fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + // Test using `&Self` explicitly: + + fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &'a u8 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/ref-self.rs b/tests/ui/self/elision/ref-self.rs index dd07fe1b00be3..9b204e2a43ba4 100644 --- a/tests/ui/self/elision/ref-self.rs +++ b/tests/ui/self/elision/ref-self.rs @@ -1,11 +1,12 @@ +//@ run-rustfix #![feature(arbitrary_self_types)] -#![allow(non_snake_case)] +#![allow(non_snake_case, dead_code)] use std::marker::PhantomData; use std::ops::Deref; use std::pin::Pin; -struct Struct { } +struct Struct {} struct Wrap(T, PhantomData

); diff --git a/tests/ui/self/elision/ref-self.stderr b/tests/ui/self/elision/ref-self.stderr index 8654032b0476b..b17667827bb78 100644 --- a/tests/ui/self/elision/ref-self.stderr +++ b/tests/ui/self/elision/ref-self.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ref-self.rs:21:9 + --> $DIR/ref-self.rs:22:9 | LL | fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:28:9 + --> $DIR/ref-self.rs:29:9 | LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:33:9 + --> $DIR/ref-self.rs:34:9 | LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:38:9 + --> $DIR/ref-self.rs:39:9 | LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:43:9 + --> $DIR/ref-self.rs:44:9 | LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u3 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:48:9 + --> $DIR/ref-self.rs:49:9 | LL | fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -89,7 +89,7 @@ LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u3 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:53:9 + --> $DIR/ref-self.rs:54:9 | LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/ref-struct.fixed b/tests/ui/self/elision/ref-struct.fixed new file mode 100644 index 0000000000000..1c26c84c08848 --- /dev/null +++ b/tests/ui/self/elision/ref-struct.fixed @@ -0,0 +1,37 @@ +//@ run-rustfix +#![allow(non_snake_case, dead_code)] + +use std::pin::Pin; + +struct Struct { } + +impl Struct { + // Test using `&Struct` explicitly: + + fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } + + fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + f + //~^ ERROR lifetime may not live long enough + } +} + +fn main() { } diff --git a/tests/ui/self/elision/ref-struct.rs b/tests/ui/self/elision/ref-struct.rs index 13a42cd1aed92..78b894765aa41 100644 --- a/tests/ui/self/elision/ref-struct.rs +++ b/tests/ui/self/elision/ref-struct.rs @@ -1,4 +1,5 @@ -#![allow(non_snake_case)] +//@ run-rustfix +#![allow(non_snake_case, dead_code)] use std::pin::Pin; diff --git a/tests/ui/self/elision/ref-struct.stderr b/tests/ui/self/elision/ref-struct.stderr index 653ecc612d572..157e0d407932a 100644 --- a/tests/ui/self/elision/ref-struct.stderr +++ b/tests/ui/self/elision/ref-struct.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ref-struct.rs:11:9 + --> $DIR/ref-struct.rs:12:9 | LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-struct.rs:16:9 + --> $DIR/ref-struct.rs:17:9 | LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-struct.rs:21:9 + --> $DIR/ref-struct.rs:22:9 | LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-struct.rs:26:9 + --> $DIR/ref-struct.rs:27:9 | LL | fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &' | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-struct.rs:31:9 + --> $DIR/ref-struct.rs:32:9 | LL | fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` From ee5a157b4a9d51788d7306af63b3e3ef063ec49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 7 May 2024 19:45:51 +0000 Subject: [PATCH 11/19] Run `rustfmt` on modified tests --- ...ne-existing-name-return-type-is-anon.fixed | 11 +++--- ...n-one-existing-name-return-type-is-anon.rs | 11 +++--- ...e-existing-name-return-type-is-anon.stderr | 19 +++++----- ...oth-anon-regions-return-type-is-anon.fixed | 12 +++---- ...3-both-anon-regions-return-type-is-anon.rs | 12 +++---- ...th-anon-regions-return-type-is-anon.stderr | 18 +++++----- ...itrary_self_types_pin_lifetime_mismatch.rs | 15 ++++---- ...ry_self_types_pin_lifetime_mismatch.stderr | 36 ++++++++++--------- tests/ui/self/elision/lt-ref-self-async.fixed | 6 ++-- tests/ui/self/elision/lt-ref-self-async.rs | 6 ++-- .../ui/self/elision/lt-ref-self-async.stderr | 12 +++---- tests/ui/self/elision/lt-ref-self.fixed | 6 ++-- tests/ui/self/elision/lt-ref-self.rs | 6 ++-- tests/ui/self/elision/lt-ref-self.stderr | 12 +++---- tests/ui/self/elision/ref-mut-self.fixed | 4 +-- tests/ui/self/elision/ref-mut-self.rs | 4 +-- tests/ui/self/elision/ref-mut-struct.fixed | 4 +-- tests/ui/self/elision/ref-mut-struct.rs | 4 +-- tests/ui/self/elision/ref-self.fixed | 6 ++-- tests/ui/self/elision/ref-self.rs | 6 ++-- tests/ui/self/elision/ref-self.stderr | 14 ++++---- tests/ui/self/elision/ref-struct.fixed | 4 +-- tests/ui/self/elision/ref-struct.rs | 4 +-- 23 files changed, 122 insertions(+), 110 deletions(-) diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed index b5513818f63e8..3408463ce4990 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed @@ -5,13 +5,10 @@ struct Foo { } impl Foo { - fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - - x - //~^ ERROR lifetime may not live long enough - - } - + fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + x + //~^ ERROR lifetime may not live long enough + } } fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs index 52646ff89eb24..c8dd958b37c6a 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs @@ -5,13 +5,10 @@ struct Foo { } impl Foo { - fn foo<'a>(&self, x: &'a i32) -> &i32 { - - x - //~^ ERROR lifetime may not live long enough - - } - + fn foo<'a>(&self, x: &'a i32) -> &i32 { + x + //~^ ERROR lifetime may not live long enough + } } fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index e2f42cbfb286d..ca6ee1c25cdd4 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -1,18 +1,17 @@ error: lifetime may not live long enough - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:10:5 + --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:9:9 | -LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { - | -- - let's call the lifetime of this reference `'1` - | | - | lifetime `'a` defined here -LL | -LL | x - | ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` +LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { + | -- - let's call the lifetime of this reference `'1` + | | + | lifetime `'a` defined here +LL | x + | ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - | ++ ++ +LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + | ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed index d9f454f346cef..3408463ce4990 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed @@ -1,14 +1,14 @@ //@ run-rustfix #![allow(dead_code)] struct Foo { - field: i32, + field: i32, } impl Foo { - fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - x - //~^ ERROR lifetime may not live long enough - } + fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + x + //~^ ERROR lifetime may not live long enough + } } -fn main() { } +fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs index bf66a551a80ee..0225d8c79616c 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.rs @@ -1,14 +1,14 @@ //@ run-rustfix #![allow(dead_code)] struct Foo { - field: i32, + field: i32, } impl Foo { - fn foo<'a>(&self, x: &i32) -> &i32 { - x - //~^ ERROR lifetime may not live long enough - } + fn foo<'a>(&self, x: &i32) -> &i32 { + x + //~^ ERROR lifetime may not live long enough + } } -fn main() { } +fn main() {} diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index 778634e95be56..a81b5cfad5a5b 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -1,17 +1,17 @@ error: lifetime may not live long enough - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:5 + --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:9 | -LL | fn foo<'a>(&self, x: &i32) -> &i32 { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | x - | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` +LL | fn foo<'a>(&self, x: &i32) -> &i32 { + | - - let's call the lifetime of this reference `'1` + | | + | let's call the lifetime of this reference `'2` +LL | x + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - | ++ ++ ++ +LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + | ++ ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs index 3b2c8c7bc791f..784afa8b40f89 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs @@ -3,20 +3,23 @@ use std::pin::Pin; struct Foo; impl Foo { - fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - //~^ lifetime may not live long enough + fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { + f //~ ERROR lifetime may not live long enough + } // For this suggestion to be right, we'd need to also suggest `self: Pin<&'a Self>`, which we // don't, but we provide a follow up suggestion to do so, so I condider that good at least for // now. - fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - //~^ lifetime may not live long enough + fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { + (self, f) //~ ERROR lifetime may not live long enough + } } type Alias = Pin; impl Foo { - fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - //~^ lifetime may not live long enough + fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { + arg //~ ERROR lifetime may not live long enough + } } fn main() {} diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index 773f9362ec53f..549b03b061bc9 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -1,42 +1,46 @@ error: lifetime may not live long enough - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:7:9 | -LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | - - ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - | | | - | | let's call the lifetime of this reference `'1` +LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { + | - - let's call the lifetime of this reference `'1` + | | | let's call the lifetime of this reference `'2` +LL | f + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { f } +LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:12:69 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:9 | -LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - | | | - | | let's call the lifetime of this reference `'1` +LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { + | - - let's call the lifetime of this reference `'1` + | | | let's call the lifetime of this reference `'2` +LL | (self, f) + | ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { (self, f) } +LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { | ++++ ++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:18:58 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:9 | -LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | -- ---- has type `Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` +LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { + | -- ---- has type `Pin<&'1 Foo>` | | | lifetime `'a` defined here +LL | arg + | ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { arg } +LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { | ++ ++ error: aborting due to 3 previous errors diff --git a/tests/ui/self/elision/lt-ref-self-async.fixed b/tests/ui/self/elision/lt-ref-self-async.fixed index 6d875ef0cec17..aa1d62012da03 100644 --- a/tests/ui/self/elision/lt-ref-self-async.fixed +++ b/tests/ui/self/elision/lt-ref-self-async.fixed @@ -4,7 +4,9 @@ use std::pin::Pin; -struct Struct<'a> { data: &'a u32 } +struct Struct<'a> { + data: &'a u32, +} impl<'a> Struct<'a> { // Test using `&self` sugar: @@ -42,4 +44,4 @@ impl<'a> Struct<'a> { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/lt-ref-self-async.rs b/tests/ui/self/elision/lt-ref-self-async.rs index a70e22ab77ad0..38de0fd39f086 100644 --- a/tests/ui/self/elision/lt-ref-self-async.rs +++ b/tests/ui/self/elision/lt-ref-self-async.rs @@ -4,7 +4,9 @@ use std::pin::Pin; -struct Struct<'a> { data: &'a u32 } +struct Struct<'a> { + data: &'a u32, +} impl<'a> Struct<'a> { // Test using `&self` sugar: @@ -42,4 +44,4 @@ impl<'a> Struct<'a> { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/lt-ref-self-async.stderr b/tests/ui/self/elision/lt-ref-self-async.stderr index c8b49de7671ef..b84044f754887 100644 --- a/tests/ui/self/elision/lt-ref-self-async.stderr +++ b/tests/ui/self/elision/lt-ref-self-async.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:13:9 + --> $DIR/lt-ref-self-async.rs:15:9 | LL | async fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | async fn ref_self<'b>(&'b self, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:20:9 + --> $DIR/lt-ref-self-async.rs:22:9 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | async fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:25:9 + --> $DIR/lt-ref-self-async.rs:27:9 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | async fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:30:9 + --> $DIR/lt-ref-self-async.rs:32:9 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | async fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &u32 { | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:35:9 + --> $DIR/lt-ref-self-async.rs:37:9 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -74,7 +74,7 @@ LL | async fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> | ++++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self-async.rs:40:9 + --> $DIR/lt-ref-self-async.rs:42:9 | LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/lt-ref-self.fixed b/tests/ui/self/elision/lt-ref-self.fixed index c9faa86c441b4..ff0c057fe427e 100644 --- a/tests/ui/self/elision/lt-ref-self.fixed +++ b/tests/ui/self/elision/lt-ref-self.fixed @@ -3,7 +3,9 @@ use std::pin::Pin; -struct Struct<'a> { data: &'a u32 } +struct Struct<'a> { + data: &'a u32, +} impl<'a> Struct<'a> { // Test using `&self` sugar: @@ -41,4 +43,4 @@ impl<'a> Struct<'a> { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/lt-ref-self.rs b/tests/ui/self/elision/lt-ref-self.rs index fbd0665b22d23..4cd97c5b729bd 100644 --- a/tests/ui/self/elision/lt-ref-self.rs +++ b/tests/ui/self/elision/lt-ref-self.rs @@ -3,7 +3,9 @@ use std::pin::Pin; -struct Struct<'a> { data: &'a u32 } +struct Struct<'a> { + data: &'a u32, +} impl<'a> Struct<'a> { // Test using `&self` sugar: @@ -41,4 +43,4 @@ impl<'a> Struct<'a> { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/lt-ref-self.stderr b/tests/ui/self/elision/lt-ref-self.stderr index 53b662bcb693c..237175ac7635e 100644 --- a/tests/ui/self/elision/lt-ref-self.stderr +++ b/tests/ui/self/elision/lt-ref-self.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:12:9 + --> $DIR/lt-ref-self.rs:14:9 | LL | fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:19:9 + --> $DIR/lt-ref-self.rs:21:9 | LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:24:9 + --> $DIR/lt-ref-self.rs:26:9 | LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:29:9 + --> $DIR/lt-ref-self.rs:31:9 | LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:34:9 + --> $DIR/lt-ref-self.rs:36:9 | LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u3 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/lt-ref-self.rs:39:9 + --> $DIR/lt-ref-self.rs:41:9 | LL | fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/ref-mut-self.fixed b/tests/ui/self/elision/ref-mut-self.fixed index 90e50221a19bc..7886d0979761a 100644 --- a/tests/ui/self/elision/ref-mut-self.fixed +++ b/tests/ui/self/elision/ref-mut-self.fixed @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&mut self` sugar: @@ -41,4 +41,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-mut-self.rs b/tests/ui/self/elision/ref-mut-self.rs index a09fcdfcbb2fd..87dab2a9ab421 100644 --- a/tests/ui/self/elision/ref-mut-self.rs +++ b/tests/ui/self/elision/ref-mut-self.rs @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&mut self` sugar: @@ -41,4 +41,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-mut-struct.fixed b/tests/ui/self/elision/ref-mut-struct.fixed index 275fafbad53a5..188d3bb517e04 100644 --- a/tests/ui/self/elision/ref-mut-struct.fixed +++ b/tests/ui/self/elision/ref-mut-struct.fixed @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&mut Struct` explicitly: @@ -34,4 +34,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-mut-struct.rs b/tests/ui/self/elision/ref-mut-struct.rs index 6bfdca62bca73..c227fa8bbfc6e 100644 --- a/tests/ui/self/elision/ref-mut-struct.rs +++ b/tests/ui/self/elision/ref-mut-struct.rs @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&mut Struct` explicitly: @@ -34,4 +34,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-self.fixed b/tests/ui/self/elision/ref-self.fixed index 41b11c2d77a3d..1369bb83e9708 100644 --- a/tests/ui/self/elision/ref-self.fixed +++ b/tests/ui/self/elision/ref-self.fixed @@ -12,7 +12,9 @@ struct Wrap(T, PhantomData

); impl Deref for Wrap { type Target = T; - fn deref(&self) -> &T { &self.0 } + fn deref(&self) -> &T { + &self.0 + } } impl Struct { @@ -56,4 +58,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-self.rs b/tests/ui/self/elision/ref-self.rs index 9b204e2a43ba4..4b4b8aa5b511d 100644 --- a/tests/ui/self/elision/ref-self.rs +++ b/tests/ui/self/elision/ref-self.rs @@ -12,7 +12,9 @@ struct Wrap(T, PhantomData

); impl Deref for Wrap { type Target = T; - fn deref(&self) -> &T { &self.0 } + fn deref(&self) -> &T { + &self.0 + } } impl Struct { @@ -56,4 +58,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-self.stderr b/tests/ui/self/elision/ref-self.stderr index b17667827bb78..a39a6a15385ea 100644 --- a/tests/ui/self/elision/ref-self.stderr +++ b/tests/ui/self/elision/ref-self.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/ref-self.rs:22:9 + --> $DIR/ref-self.rs:24:9 | LL | fn ref_self(&self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:29:9 + --> $DIR/ref-self.rs:31:9 | LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -29,7 +29,7 @@ LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:34:9 + --> $DIR/ref-self.rs:36:9 | LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -44,7 +44,7 @@ LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:39:9 + --> $DIR/ref-self.rs:41:9 | LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:44:9 + --> $DIR/ref-self.rs:46:9 | LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u3 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:49:9 + --> $DIR/ref-self.rs:51:9 | LL | fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | - - let's call the lifetime of this reference `'1` @@ -89,7 +89,7 @@ LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u3 | ++++ ++ ++ ++ error: lifetime may not live long enough - --> $DIR/ref-self.rs:54:9 + --> $DIR/ref-self.rs:56:9 | LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | - - let's call the lifetime of this reference `'1` diff --git a/tests/ui/self/elision/ref-struct.fixed b/tests/ui/self/elision/ref-struct.fixed index 1c26c84c08848..a9ecbc9c3aecd 100644 --- a/tests/ui/self/elision/ref-struct.fixed +++ b/tests/ui/self/elision/ref-struct.fixed @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&Struct` explicitly: @@ -34,4 +34,4 @@ impl Struct { } } -fn main() { } +fn main() {} diff --git a/tests/ui/self/elision/ref-struct.rs b/tests/ui/self/elision/ref-struct.rs index 78b894765aa41..733a175e7a1de 100644 --- a/tests/ui/self/elision/ref-struct.rs +++ b/tests/ui/self/elision/ref-struct.rs @@ -3,7 +3,7 @@ use std::pin::Pin; -struct Struct { } +struct Struct {} impl Struct { // Test using `&Struct` explicitly: @@ -34,4 +34,4 @@ impl Struct { } } -fn main() { } +fn main() {} From 1775e7b93d4142eb2e4c75c2d49a9c4d8541d7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 7 May 2024 19:54:16 +0000 Subject: [PATCH 12/19] Tweak suggested lifetimes to modify return type instead of `&self` receiver Do not suggest constraining the `&self` param, but rather the return type. If that is wrong (because it is not sufficient), a follow up error will tell the user to fix it. This way we lower the chances of *over* constraining, but still get the cake of "correctly" contrained in two steps. This is a correct suggestion: ``` error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:9 | LL | fn foo<'a>(&self, x: &i32) -> &i32 { | - - let's call the lifetime of this reference `'1` | | | let's call the lifetime of this reference `'2` LL | x | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&self, x: &'a i32) -> &'a i32 { | ++ ++ ``` While this is incomplete because it should suggestino `&'a self` ``` error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19 | LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | - - let's call the lifetime of this reference `'1` | | | let's call the lifetime of this reference `'2` LL | if true { x } else { self } | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | ++ ++ ``` but the follow up error is ``` error: lifetime may not live long enough --> tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.rs:7:30 | 6 | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | -- - let's call the lifetime of this reference `'1` | | | lifetime `'a` defined here 7 | if true { x } else { self } | ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` | help: consider introducing a named lifetime parameter and update trait if needed | 6 | fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo { | ++ ``` --- compiler/rustc_infer/src/errors/mod.rs | 10 +++++-- tests/ui/lifetimes/issue-17728.stderr | 4 +-- ...ne-existing-name-return-type-is-anon.fixed | 2 +- ...e-existing-name-return-type-is-anon.stderr | 4 +-- ...oth-anon-regions-return-type-is-anon.fixed | 2 +- ...th-anon-regions-return-type-is-anon.stderr | 4 +-- .../ex3-both-anon-regions-self-is-anon.stderr | 4 +-- ...ry_self_types_pin_lifetime_mismatch.stderr | 12 ++++---- tests/ui/self/elision/lt-ref-self.fixed | 12 ++++---- tests/ui/self/elision/lt-ref-self.stderr | 24 ++++++++-------- tests/ui/self/elision/ref-mut-self.fixed | 12 ++++---- tests/ui/self/elision/ref-mut-self.stderr | 24 ++++++++-------- tests/ui/self/elision/ref-mut-struct.fixed | 10 +++---- tests/ui/self/elision/ref-mut-struct.stderr | 20 ++++++------- tests/ui/self/elision/ref-self.fixed | 14 +++++----- tests/ui/self/elision/ref-self.stderr | 28 +++++++++---------- tests/ui/self/elision/ref-struct.fixed | 10 +++---- tests/ui/self/elision/ref-struct.stderr | 20 ++++++------- 18 files changed, 111 insertions(+), 105 deletions(-) diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index f60ecb3f453ae..9998f089588aa 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -484,13 +484,19 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { suggestions: vec![], suggestion_param_name: suggestion_param_name.clone(), }; - visitor.visit_ty(self.ty_sub); - visitor.visit_ty(self.ty_sup); if let Some(fn_decl) = node.fn_decl() && let hir::FnRetTy::Return(ty) = fn_decl.output { visitor.visit_ty(ty); } + if visitor.suggestions.is_empty() { + // Do not suggest constraining the `&self` param, but rather the return type. + // If that is wrong (because it is not sufficient), a follow up error will tell the + // user to fix it. This way we lower the chances of *over* constraining, but still + // get the cake of "correctly" contrained in two steps. + visitor.visit_ty(self.ty_sup); + } + visitor.visit_ty(self.ty_sub); if visitor.suggestions.is_empty() { return false; } diff --git a/tests/ui/lifetimes/issue-17728.stderr b/tests/ui/lifetimes/issue-17728.stderr index da4ce2dd2911d..eb4381ea99eef 100644 --- a/tests/ui/lifetimes/issue-17728.stderr +++ b/tests/ui/lifetimes/issue-17728.stderr @@ -29,8 +29,8 @@ LL | Some(entry) => Ok(entry), | help: consider introducing a named lifetime parameter | -LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> Result<&'a Room, &'a str> { - | ++++ ++ ++ ++ ++ +LL | fn attemptTraverse<'a>(&self, room: &'a Room, directionStr: &str) -> Result<&'a Room, &'a str> { + | ++++ ++ ++ ++ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed index 3408463ce4990..40eee22fc321d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed @@ -5,7 +5,7 @@ struct Foo { } impl Foo { - fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + fn foo<'a>(&self, x: &'a i32) -> &'a i32 { x //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index ca6ee1c25cdd4..345f099542d91 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -10,8 +10,8 @@ LL | x | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - | ++ ++ +LL | fn foo<'a>(&self, x: &'a i32) -> &'a i32 { + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed index 3408463ce4990..40eee22fc321d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.fixed @@ -5,7 +5,7 @@ struct Foo { } impl Foo { - fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { + fn foo<'a>(&self, x: &'a i32) -> &'a i32 { x //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index a81b5cfad5a5b..dd45c8b1cb77a 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -10,8 +10,8 @@ LL | x | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 { - | ++ ++ ++ +LL | fn foo<'a>(&self, x: &'a i32) -> &'a i32 { + | ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index 0a312cf93c8de..997537f1ecd9f 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -10,8 +10,8 @@ LL | if true { x } else { self } | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo { - | ++ ++ ++ +LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { + | ++ ++ error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index 549b03b061bc9..98f493f3f91d0 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { - | ++++ ++ ++ ++ +LL | fn a<'a>(self: Pin<&Foo>, f: &'a Foo) -> &'a Foo { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:9 @@ -25,8 +25,8 @@ LL | (self, f) | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { - | ++++ ++ ++ ++ ++ +LL | fn c<'a>(self: Pin<&Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { + | ++++ ++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:9 @@ -40,8 +40,8 @@ LL | arg | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { - | ++ ++ +LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &'a () { + | ++ error: aborting due to 3 previous errors diff --git a/tests/ui/self/elision/lt-ref-self.fixed b/tests/ui/self/elision/lt-ref-self.fixed index ff0c057fe427e..1d90eacea50d8 100644 --- a/tests/ui/self/elision/lt-ref-self.fixed +++ b/tests/ui/self/elision/lt-ref-self.fixed @@ -10,34 +10,34 @@ struct Struct<'a> { impl<'a> Struct<'a> { // Test using `&self` sugar: - fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { + fn ref_self<'b>(&self, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } // Test using `&Self` explicitly: - fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 { + fn ref_Self<'b>(self: &Self, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } - fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 { + fn box_ref_Self<'b>(self: Box<&Self>, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } - fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 { + fn pin_ref_Self<'b>(self: Pin<&Self>, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } - fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } - fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { f //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/self/elision/lt-ref-self.stderr b/tests/ui/self/elision/lt-ref-self.stderr index 237175ac7635e..5c8e0a7a742a9 100644 --- a/tests/ui/self/elision/lt-ref-self.stderr +++ b/tests/ui/self/elision/lt-ref-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn ref_self<'b>(&self, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:21:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn ref_Self<'b>(self: &Self, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:26:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn box_ref_Self<'b>(self: Box<&Self>, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:31:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn pin_ref_Self<'b>(self: Pin<&Self>, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:36:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn box_box_ref_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:41:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { - | ++++ ++ ++ ++ +LL | fn box_pin_Self<'b>(self: Box>, f: &'b u32) -> &'b u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/ref-mut-self.fixed b/tests/ui/self/elision/ref-mut-self.fixed index 7886d0979761a..42e8050f65e35 100644 --- a/tests/ui/self/elision/ref-mut-self.fixed +++ b/tests/ui/self/elision/ref-mut-self.fixed @@ -8,34 +8,34 @@ struct Struct {} impl Struct { // Test using `&mut self` sugar: - fn ref_self<'a>(&'a mut self, f: &'a u32) -> &'a u32 { + fn ref_self<'a>(&mut self, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } // Test using `&mut Self` explicitly: - fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &'a u32 { + fn ref_Self<'a>(self: &mut Self, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &'a u32 { + fn box_ref_Self<'a>(self: Box<&mut Self>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &'a u32 { + fn pin_ref_Self<'a>(self: Pin<&mut Self>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/self/elision/ref-mut-self.stderr b/tests/ui/self/elision/ref-mut-self.stderr index a09034e5f71d7..620706fdbdbc7 100644 --- a/tests/ui/self/elision/ref-mut-self.stderr +++ b/tests/ui/self/elision/ref-mut-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_self<'a>(&mut self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:19:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_Self<'a>(self: &mut Self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:24:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_ref_Self<'a>(self: Box<&mut Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:29:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn pin_ref_Self<'a>(self: Pin<&mut Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:34:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:39:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/tests/ui/self/elision/ref-mut-struct.fixed b/tests/ui/self/elision/ref-mut-struct.fixed index 188d3bb517e04..f7a84d4a45c7c 100644 --- a/tests/ui/self/elision/ref-mut-struct.fixed +++ b/tests/ui/self/elision/ref-mut-struct.fixed @@ -8,27 +8,27 @@ struct Struct {} impl Struct { // Test using `&mut Struct` explicitly: - fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &'a u32 { + fn ref_Struct<'a>(self: &mut Struct, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &'a u32 { + fn box_ref_Struct<'a>(self: Box<&mut Struct>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &'a u32 { + fn pin_ref_Struct<'a>(self: Pin<&mut Struct>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/self/elision/ref-mut-struct.stderr b/tests/ui/self/elision/ref-mut-struct.stderr index 19b09272504e3..cce07f827184e 100644 --- a/tests/ui/self/elision/ref-mut-struct.stderr +++ b/tests/ui/self/elision/ref-mut-struct.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_Struct<'a>(self: &mut Struct, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:17:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_ref_Struct<'a>(self: Box<&mut Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:22:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn pin_ref_Struct<'a>(self: Pin<&mut Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:27:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:32:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_pin_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/tests/ui/self/elision/ref-self.fixed b/tests/ui/self/elision/ref-self.fixed index 1369bb83e9708..8bf5a0bb22322 100644 --- a/tests/ui/self/elision/ref-self.fixed +++ b/tests/ui/self/elision/ref-self.fixed @@ -20,39 +20,39 @@ impl Deref for Wrap { impl Struct { // Test using `&self` sugar: - fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { + fn ref_self<'a>(&self, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } // Test using `&Self` explicitly: - fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { + fn ref_Self<'a>(self: &Self, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { + fn box_ref_Self<'a>(self: Box<&Self>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { + fn pin_ref_Self<'a>(self: Pin<&Self>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &'a u8 { + fn wrap_ref_Self_Self<'a>(self: Wrap<&Self, Self>, f: &'a u8) -> &'a u8 { f //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/self/elision/ref-self.stderr b/tests/ui/self/elision/ref-self.stderr index a39a6a15385ea..c4ec8c55a003f 100644 --- a/tests/ui/self/elision/ref-self.stderr +++ b/tests/ui/self/elision/ref-self.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_self<'a>(&self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:31:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_Self<'a>(self: &Self, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:36:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_ref_Self<'a>(self: Box<&Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:41:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn pin_ref_Self<'a>(self: Pin<&Self>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:46:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_box_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:51:9 @@ -85,8 +85,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_pin_ref_Self<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:56:9 @@ -100,8 +100,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &'a u8 { - | ++++ ++ ++ ++ +LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&Self, Self>, f: &'a u8) -> &'a u8 { + | ++++ ++ ++ error: aborting due to 7 previous errors diff --git a/tests/ui/self/elision/ref-struct.fixed b/tests/ui/self/elision/ref-struct.fixed index a9ecbc9c3aecd..411f601319563 100644 --- a/tests/ui/self/elision/ref-struct.fixed +++ b/tests/ui/self/elision/ref-struct.fixed @@ -8,27 +8,27 @@ struct Struct {} impl Struct { // Test using `&Struct` explicitly: - fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &'a u32 { + fn ref_Struct<'a>(self: &Struct, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &'a u32 { + fn box_ref_Struct<'a>(self: Box<&Struct>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &'a u32 { + fn pin_ref_Struct<'a>(self: Pin<&Struct>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } - fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { f //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/self/elision/ref-struct.stderr b/tests/ui/self/elision/ref-struct.stderr index 157e0d407932a..860186c835321 100644 --- a/tests/ui/self/elision/ref-struct.stderr +++ b/tests/ui/self/elision/ref-struct.stderr @@ -10,8 +10,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn ref_Struct<'a>(self: &Struct, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:17:9 @@ -25,8 +25,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_ref_Struct<'a>(self: Box<&Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:22:9 @@ -40,8 +40,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn pin_ref_Struct<'a>(self: Pin<&Struct>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:27:9 @@ -55,8 +55,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_box_ref_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:32:9 @@ -70,8 +70,8 @@ LL | f | help: consider introducing a named lifetime parameter and update trait if needed | -LL | fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { - | ++++ ++ ++ ++ +LL | fn box_pin_Struct<'a>(self: Box>, f: &'a u32) -> &'a u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors From cf5702ee91dd9ba93c19aae9e663e613a577d02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 17 May 2024 21:23:47 +0000 Subject: [PATCH 13/19] Detect when a lifetime is being reused in suggestion --- compiler/rustc_infer/messages.ftl | 5 ++++- compiler/rustc_infer/src/errors/mod.rs | 1 + tests/ui/lifetimes/issue-90170-elision-mismatch.stderr | 2 +- .../ex1-return-one-existing-name-if-else-using-impl.stderr | 2 +- .../ex1-return-one-existing-name-return-type-is-anon.stderr | 2 +- .../ex1-return-one-existing-name-self-is-anon.stderr | 2 +- .../ex3-both-anon-regions-return-type-is-anon.stderr | 2 +- .../ex3-both-anon-regions-self-is-anon.stderr | 2 +- .../arbitrary_self_types_pin_lifetime_mismatch-async.stderr | 2 +- .../self/arbitrary_self_types_pin_lifetime_mismatch.stderr | 2 +- 10 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_infer/messages.ftl b/compiler/rustc_infer/messages.ftl index 64f52ea7ac196..8f1c4ad462a67 100644 --- a/compiler/rustc_infer/messages.ftl +++ b/compiler/rustc_infer/messages.ftl @@ -164,7 +164,10 @@ infer_label_bad = {$bad_kind -> infer_lf_bound_not_satisfied = lifetime bound not satisfied infer_lifetime_mismatch = lifetime mismatch -infer_lifetime_param_suggestion = consider introducing a named lifetime parameter{$is_impl -> +infer_lifetime_param_suggestion = consider {$is_reuse -> + [true] reusing + *[false] introducing +} a named lifetime parameter{$is_impl -> [true] {" "}and update trait if needed *[false] {""} } diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index 9998f089588aa..8bb0dc39143ce 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -517,6 +517,7 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { Applicability::MaybeIncorrect, ); diag.arg("is_impl", is_impl); + diag.arg("is_reuse", !introduce_new); true }; diff --git a/tests/ui/lifetimes/issue-90170-elision-mismatch.stderr b/tests/ui/lifetimes/issue-90170-elision-mismatch.stderr index 48fb3fb4a2293..82511d07b0efc 100644 --- a/tests/ui/lifetimes/issue-90170-elision-mismatch.stderr +++ b/tests/ui/lifetimes/issue-90170-elision-mismatch.stderr @@ -35,7 +35,7 @@ LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` | -help: consider introducing a named lifetime parameter +help: consider reusing a named lifetime parameter | LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } | ++ ++ diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr index 6bc82910b06a5..2caab3df6b85b 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.stderr @@ -9,7 +9,7 @@ LL | LL | if x > y { x } else { y } | ^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 { | ++ diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr index 345f099542d91..c743351a67025 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.stderr @@ -8,7 +8,7 @@ LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { LL | x | ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&self, x: &'a i32) -> &'a i32 { | ++ diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr index f106d45b9acdd..4ed6c3bc92d7d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.stderr @@ -9,7 +9,7 @@ LL | LL | if true { x } else { self } | ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&'a self, x: &'a Foo) -> &'a Foo { | ++ diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr index dd45c8b1cb77a..673a87a4537c4 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.stderr @@ -8,7 +8,7 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 { LL | x | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&self, x: &'a i32) -> &'a i32 { | ++ ++ diff --git a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr index 997537f1ecd9f..64bd448a0747d 100644 --- a/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr +++ b/tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.stderr @@ -8,7 +8,7 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo { LL | if true { x } else { self } | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | ++ ++ diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index bb643ab827222..b00260fa0efa4 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -35,7 +35,7 @@ LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } | | let's call the lifetime of this reference `'1` | lifetime `'a` defined here | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | async fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &() { arg } | ++ diff --git a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr index 98f493f3f91d0..57527dd31df35 100644 --- a/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr @@ -38,7 +38,7 @@ LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { LL | arg | ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | -help: consider introducing a named lifetime parameter and update trait if needed +help: consider reusing a named lifetime parameter and update trait if needed | LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &'a () { | ++ From 95c0e5c6a86ca467b0fb7043bd56dee82418ac5f Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 16 May 2024 02:07:31 -0700 Subject: [PATCH 14/19] Remove `Rvalue::CheckedBinaryOp` --- compiler/rustc_borrowck/src/lib.rs | 3 +- .../src/polonius/loan_invalidations.rs | 3 +- compiler/rustc_borrowck/src/type_check/mod.rs | 4 +- compiler/rustc_codegen_cranelift/src/base.rs | 13 +++--- .../src/codegen_i128.rs | 2 + compiler/rustc_codegen_cranelift/src/num.rs | 3 ++ compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 36 +++++++++------- .../rustc_const_eval/src/interpret/step.rs | 14 +++---- .../src/transform/check_consts/check.rs | 2 +- .../src/transform/check_consts/qualifs.rs | 2 +- .../src/transform/check_consts/resolver.rs | 1 - .../src/transform/validate.rs | 29 +------------ compiler/rustc_const_eval/src/util/mod.rs | 9 ++-- compiler/rustc_middle/src/mir/pretty.rs | 3 -- compiler/rustc_middle/src/mir/statement.rs | 1 - compiler/rustc_middle/src/mir/syntax.rs | 19 +++++---- compiler/rustc_middle/src/mir/tcx.rs | 34 ++++++++++++--- compiler/rustc_middle/src/mir/visit.rs | 3 +- .../src/build/custom/parse/instruction.rs | 12 ++++-- .../src/build/expr/as_rvalue.rs | 4 +- .../src/impls/borrowed_locals.rs | 1 - .../src/move_paths/builder.rs | 3 +- .../rustc_mir_dataflow/src/value_analysis.rs | 1 - .../src/dataflow_const_prop.rs | 6 ++- compiler/rustc_mir_transform/src/dest_prop.rs | 2 +- compiler/rustc_mir_transform/src/gvn.rs | 27 +++++------- .../src/known_panics_lint.rs | 42 +++++++------------ .../src/lower_intrinsics.rs | 8 ++-- .../rustc_mir_transform/src/promote_consts.rs | 5 ++- .../rustc_smir/src/rustc_smir/convert/mir.rs | 29 ++++++++----- compiler/rustc_ty_utils/src/consts.rs | 6 +-- .../custom/operators.f.built.after.mir | 2 +- .../checked_add.main.GVN.panic-abort.diff | 2 +- .../checked_add.main.GVN.panic-unwind.diff | 2 +- .../indirect.main.GVN.panic-abort.diff | 2 +- .../indirect.main.GVN.panic-unwind.diff | 2 +- ...inherit_overflow.main.GVN.panic-abort.diff | 2 +- ...nherit_overflow.main.GVN.panic-unwind.diff | 2 +- .../return_place.add.GVN.panic-abort.diff | 2 +- .../return_place.add.GVN.panic-unwind.diff | 2 +- ...ed.main.DataflowConstProp.panic-abort.diff | 4 +- ...d.main.DataflowConstProp.panic-unwind.diff | 4 +- ...ow.main.DataflowConstProp.panic-abort.diff | 2 +- ...w.main.DataflowConstProp.panic-unwind.diff | 2 +- ...vn.arithmetic_checked.GVN.panic-abort.diff | 12 +++--- ...n.arithmetic_checked.GVN.panic-unwind.diff | 12 +++--- ...nt#0}.SimplifyCfg-promote-consts.after.mir | 2 +- tests/mir-opt/lower_intrinsics.rs | 6 +-- ..._overflow.LowerIntrinsics.panic-abort.diff | 6 +-- ...overflow.LowerIntrinsics.panic-unwind.diff | 6 +-- ...o_variable.main.GVN.32bit.panic-abort.diff | 2 +- ..._variable.main.GVN.32bit.panic-unwind.diff | 2 +- ...o_variable.main.GVN.64bit.panic-abort.diff | 2 +- ..._variable.main.GVN.64bit.panic-unwind.diff | 2 +- ...acementOfAggregates.32bit.panic-abort.diff | 2 +- ...cementOfAggregates.32bit.panic-unwind.diff | 2 +- ...acementOfAggregates.64bit.panic-abort.diff | 2 +- ...cementOfAggregates.64bit.panic-unwind.diff | 2 +- tests/run-make/const_fn_mir/dump.mir | 4 +- 59 files changed, 209 insertions(+), 212 deletions(-) diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index abe57e26af461..1d5801467da89 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1312,8 +1312,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); } - Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) - | Rvalue::CheckedBinaryOp(_bin_op, box (operand1, operand2)) => { + Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => { self.consume_operand(location, (operand1, span), flow_state); self.consume_operand(location, (operand2, span), flow_state); } diff --git a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs index a1e59977ede5a..6979910a02d73 100644 --- a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs +++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs @@ -302,8 +302,7 @@ impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> { ); } - Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) - | Rvalue::CheckedBinaryOp(_bin_op, box (operand1, operand2)) => { + Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => { self.consume_operand(location, operand1); self.consume_operand(location, operand2); } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 2740e9689c51f..0890d3cf4563b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2417,8 +2417,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.check_operand(op, location); } - Rvalue::BinaryOp(_, box (left, right)) - | Rvalue::CheckedBinaryOp(_, box (left, right)) => { + Rvalue::BinaryOp(_, box (left, right)) => { self.check_operand(left, location); self.check_operand(right, location); } @@ -2445,7 +2444,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | Rvalue::Cast(..) | Rvalue::ShallowInitBox(..) | Rvalue::BinaryOp(..) - | Rvalue::CheckedBinaryOp(..) | Rvalue::NullaryOp(..) | Rvalue::CopyForDeref(..) | Rvalue::UnaryOp(..) diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 5846689643fdd..8d778f736d671 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -609,14 +609,11 @@ fn codegen_stmt<'tcx>( let lhs = codegen_operand(fx, &lhs_rhs.0); let rhs = codegen_operand(fx, &lhs_rhs.1); - let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs); - lval.write_cvalue(fx, res); - } - Rvalue::CheckedBinaryOp(bin_op, ref lhs_rhs) => { - let lhs = codegen_operand(fx, &lhs_rhs.0); - let rhs = codegen_operand(fx, &lhs_rhs.1); - - let res = crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs); + let res = if let Some(bin_op) = bin_op.overflowing_to_wrapping() { + crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs) + } else { + crate::num::codegen_binop(fx, bin_op, lhs, rhs) + }; lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, ref operand) => { diff --git a/compiler/rustc_codegen_cranelift/src/codegen_i128.rs b/compiler/rustc_codegen_cranelift/src/codegen_i128.rs index 4a5ef352151f3..e16b77648d12f 100644 --- a/compiler/rustc_codegen_cranelift/src/codegen_i128.rs +++ b/compiler/rustc_codegen_cranelift/src/codegen_i128.rs @@ -70,6 +70,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne | BinOp::Cmp => None, BinOp::Shl | BinOp::ShlUnchecked | BinOp::Shr | BinOp::ShrUnchecked => None, + BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(), } } @@ -132,6 +133,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>( Some(out_place.to_cvalue(fx)) } BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(), + BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(), BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Div | BinOp::Rem => unreachable!(), BinOp::Cmp => unreachable!(), diff --git a/compiler/rustc_codegen_cranelift/src/num.rs b/compiler/rustc_codegen_cranelift/src/num.rs index 4d96a26ea4fa8..fb18f45d7dcad 100644 --- a/compiler/rustc_codegen_cranelift/src/num.rs +++ b/compiler/rustc_codegen_cranelift/src/num.rs @@ -179,6 +179,9 @@ pub(crate) fn codegen_int_binop<'tcx>( } } BinOp::Offset => unreachable!("Offset is not an integer operation"), + BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => { + unreachable!("Overflow binops handled by `codegen_checked_int_binop`") + } // Compare binops handles by `codegen_binop`. BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge | BinOp::Cmp => { unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty); diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 936ed41a294b5..1d731988d33b3 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -572,6 +572,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } + mir::Rvalue::BinaryOp(op_with_overflow, box (ref lhs, ref rhs)) + if let Some(op) = op_with_overflow.overflowing_to_wrapping() => + { + let lhs = self.codegen_operand(bx, lhs); + let rhs = self.codegen_operand(bx, rhs); + let result = self.codegen_scalar_checked_binop( + bx, + op, + lhs.immediate(), + rhs.immediate(), + lhs.layout.ty, + ); + let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty); + let operand_ty = Ty::new_tup(bx.tcx(), &[val_ty, bx.tcx().types.bool]); + OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) } + } mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => { let lhs = self.codegen_operand(bx, lhs); let rhs = self.codegen_operand(bx, rhs); @@ -600,20 +616,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { layout: bx.cx().layout_of(op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty)), } } - mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => { - let lhs = self.codegen_operand(bx, lhs); - let rhs = self.codegen_operand(bx, rhs); - let result = self.codegen_scalar_checked_binop( - bx, - op, - lhs.immediate(), - rhs.immediate(), - lhs.layout.ty, - ); - let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty); - let operand_ty = Ty::new_tup(bx.tcx(), &[val_ty, bx.tcx().types.bool]); - OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) } - } mir::Rvalue::UnaryOp(op, ref operand) => { let operand = self.codegen_operand(bx, operand); @@ -924,6 +926,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.select(is_lt, bx.cx().const_i8(Ordering::Less as i8), ge) } } + mir::BinOp::AddWithOverflow + | mir::BinOp::SubWithOverflow + | mir::BinOp::MulWithOverflow => { + bug!("{op:?} needs to return a pair, so call codegen_scalar_checked_binop instead") + } } } @@ -1036,7 +1043,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::Rvalue::Cast(..) | // (*) mir::Rvalue::ShallowInitBox(..) | // (*) mir::Rvalue::BinaryOp(..) | - mir::Rvalue::CheckedBinaryOp(..) | mir::Rvalue::UnaryOp(..) | mir::Rvalue::Discriminant(..) | mir::Rvalue::NullaryOp(..) | diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index ee415c380de17..cb72d55a9ba18 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -167,15 +167,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let left = self.read_immediate(&self.eval_operand(left, layout)?)?; let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout); let right = self.read_immediate(&self.eval_operand(right, layout)?)?; - self.binop_ignore_overflow(bin_op, &left, &right, &dest)?; - } - - CheckedBinaryOp(bin_op, box (ref left, ref right)) => { - // Due to the extra boolean in the result, we can never reuse the `dest.layout`. - let left = self.read_immediate(&self.eval_operand(left, None)?)?; - let layout = util::binop_right_homogeneous(bin_op).then_some(left.layout); - let right = self.read_immediate(&self.eval_operand(right, layout)?)?; - self.binop_with_overflow(bin_op, &left, &right, &dest)?; + if let Some(bin_op) = bin_op.overflowing_to_wrapping() { + self.binop_with_overflow(bin_op, &left, &right, &dest)?; + } else { + self.binop_ignore_overflow(bin_op, &left, &right, &dest)?; + } } UnaryOp(un_op, ref operand) => { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 5edf5bb39dd4c..c8c54143f6185 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -580,7 +580,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } } - Rvalue::BinaryOp(op, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(op, box (lhs, rhs)) => { + Rvalue::BinaryOp(op, box (lhs, rhs)) => { let lhs_ty = lhs.ty(self.body, self.tcx); let rhs_ty = rhs.ty(self.body, self.tcx); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index eae0e2f27dbdb..7e8a208659b97 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -261,7 +261,7 @@ where | Rvalue::Cast(_, operand, _) | Rvalue::ShallowInitBox(operand, _) => in_operand::(cx, in_local, operand), - Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => { + Rvalue::BinaryOp(_, box (lhs, rhs)) => { in_operand::(cx, in_local, lhs) || in_operand::(cx, in_local, rhs) } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs index 5ae3ffaaec2f2..011341472b433 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs @@ -200,7 +200,6 @@ where | mir::Rvalue::Repeat(..) | mir::Rvalue::Len(..) | mir::Rvalue::BinaryOp(..) - | mir::Rvalue::CheckedBinaryOp(..) | mir::Rvalue::NullaryOp(..) | mir::Rvalue::UnaryOp(..) | mir::Rvalue::Discriminant(..) diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index fdc7f6a69cba1..3a2b2c5f3002d 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -1037,8 +1037,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ) } } - AddUnchecked | SubUnchecked | MulUnchecked | Shl | ShlUnchecked | Shr - | ShrUnchecked => { + AddUnchecked | AddWithOverflow | SubUnchecked | SubWithOverflow + | MulUnchecked | MulWithOverflow | Shl | ShlUnchecked | Shr | ShrUnchecked => { for x in [a, b] { check_kinds!( x, @@ -1067,31 +1067,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } } } - Rvalue::CheckedBinaryOp(op, vals) => { - use BinOp::*; - let a = vals.0.ty(&self.body.local_decls, self.tcx); - let b = vals.1.ty(&self.body.local_decls, self.tcx); - match op { - Add | Sub | Mul => { - for x in [a, b] { - check_kinds!( - x, - "Cannot perform checked arithmetic on type {:?}", - ty::Uint(..) | ty::Int(..) - ) - } - if a != b { - self.fail( - location, - format!( - "Cannot perform checked arithmetic on unequal types {a:?} and {b:?}" - ), - ); - } - } - _ => self.fail(location, format!("There is no checked version of {op:?}")), - } - } Rvalue::UnaryOp(op, operand) => { let a = operand.ty(&self.body.local_decls, self.tcx); match op { diff --git a/compiler/rustc_const_eval/src/util/mod.rs b/compiler/rustc_const_eval/src/util/mod.rs index 0c3b59a0e78ec..66a1addfb525e 100644 --- a/compiler/rustc_const_eval/src/util/mod.rs +++ b/compiler/rustc_const_eval/src/util/mod.rs @@ -19,7 +19,9 @@ pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { match op { Add | AddUnchecked | Sub | SubUnchecked | Mul | MulUnchecked | Div | Rem | BitXor | BitAnd | BitOr | Offset | Shl | ShlUnchecked | Shr | ShrUnchecked => true, - Eq | Ne | Lt | Le | Gt | Ge | Cmp => false, + AddWithOverflow | SubWithOverflow | MulWithOverflow | Eq | Ne | Lt | Le | Gt | Ge | Cmp => { + false + } } } @@ -29,8 +31,9 @@ pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { pub fn binop_right_homogeneous(op: mir::BinOp) -> bool { use rustc_middle::mir::BinOp::*; match op { - Add | AddUnchecked | Sub | SubUnchecked | Mul | MulUnchecked | Div | Rem | BitXor - | BitAnd | BitOr | Eq | Ne | Lt | Le | Gt | Ge | Cmp => true, + Add | AddUnchecked | AddWithOverflow | Sub | SubUnchecked | SubWithOverflow | Mul + | MulUnchecked | MulWithOverflow | Div | Rem | BitXor | BitAnd | BitOr | Eq | Ne | Lt + | Le | Gt | Ge | Cmp => true, Offset | Shl | ShlUnchecked | Shr | ShrUnchecked => false, } } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 5aaa1c30cade0..7e8598b49df43 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -971,9 +971,6 @@ impl<'tcx> Debug for Rvalue<'tcx> { with_no_trimmed_paths!(write!(fmt, "{place:?} as {ty} ({kind:?})")) } BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{op:?}({a:?}, {b:?})"), - CheckedBinaryOp(ref op, box (ref a, ref b)) => { - write!(fmt, "Checked{op:?}({a:?}, {b:?})") - } UnaryOp(ref op, ref a) => write!(fmt, "{op:?}({a:?})"), Discriminant(ref place) => write!(fmt, "discriminant({place:?})"), NullaryOp(ref op, ref t) => { diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index 375f1f15a39ed..4d9a931d69791 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -438,7 +438,6 @@ impl<'tcx> Rvalue<'tcx> { _, ) | Rvalue::BinaryOp(_, _) - | Rvalue::CheckedBinaryOp(_, _) | Rvalue::NullaryOp(_, _) | Rvalue::UnaryOp(_, _) | Rvalue::Discriminant(_) diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index e124b478f4193..2b28496faec73 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1295,18 +1295,12 @@ pub enum Rvalue<'tcx> { /// truncated as needed. /// * The `Bit*` operations accept signed integers, unsigned integers, or bools with matching /// types and return a value of that type. + /// * The `FooWithOverflow` are like the `Foo`, but returning `(T, bool)` instead of just `T`, + /// where the `bool` is true if the result is not equal to the infinite-precision result. /// * The remaining operations accept signed integers, unsigned integers, or floats with /// matching types and return a value of that type. BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>), - /// Same as `BinaryOp`, but yields `(T, bool)` with a `bool` indicating an error condition. - /// - /// For addition, subtraction, and multiplication on integers the error condition is set when - /// the infinite precision result would not be equal to the actual result. - /// - /// Other combinations of types and operators are unsupported. - CheckedBinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>), - /// Computes a value as described by the operation. NullaryOp(NullOp<'tcx>, Ty<'tcx>), @@ -1449,14 +1443,23 @@ pub enum BinOp { Add, /// Like `Add`, but with UB on overflow. (Integers only.) AddUnchecked, + /// Like `Add`, but returns `(T, bool)` of both the wrapped result + /// and a bool indicating whether it overflowed. + AddWithOverflow, /// The `-` operator (subtraction) Sub, /// Like `Sub`, but with UB on overflow. (Integers only.) SubUnchecked, + /// Like `Sub`, but returns `(T, bool)` of both the wrapped result + /// and a bool indicating whether it overflowed. + SubWithOverflow, /// The `*` operator (multiplication) Mul, /// Like `Mul`, but with UB on overflow. (Integers only.) MulUnchecked, + /// Like `Mul`, but returns `(T, bool)` of both the wrapped result + /// and a bool indicating whether it overflowed. + MulWithOverflow, /// The `/` operator (division) /// /// For integer types, division by zero is UB, as is `MIN / -1` for signed. diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 4994679ad5dad..e1ae2e0866675 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -179,12 +179,6 @@ impl<'tcx> Rvalue<'tcx> { let rhs_ty = rhs.ty(local_decls, tcx); op.ty(tcx, lhs_ty, rhs_ty) } - Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => { - let lhs_ty = lhs.ty(local_decls, tcx); - let rhs_ty = rhs.ty(local_decls, tcx); - let ty = op.ty(tcx, lhs_ty, rhs_ty); - Ty::new_tup(tcx, &[ty, tcx.types.bool]) - } Rvalue::UnaryOp(UnOp::Not | UnOp::Neg, ref operand) => operand.ty(local_decls, tcx), Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx), Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(..), _) => { @@ -263,6 +257,11 @@ impl<'tcx> BinOp { assert_eq!(lhs_ty, rhs_ty); lhs_ty } + &BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => { + // these should be integers of the same size. + assert_eq!(lhs_ty, rhs_ty); + Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool]) + } &BinOp::Shl | &BinOp::ShlUnchecked | &BinOp::Shr @@ -315,6 +314,9 @@ impl BinOp { BinOp::Le => hir::BinOpKind::Le, BinOp::Ge => hir::BinOpKind::Ge, BinOp::Cmp + | BinOp::AddWithOverflow + | BinOp::SubWithOverflow + | BinOp::MulWithOverflow | BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked @@ -325,4 +327,24 @@ impl BinOp { } } } + + /// If this is a `FooWithOverflow`, return `Some(Foo)`. + pub fn overflowing_to_wrapping(self) -> Option { + Some(match self { + BinOp::AddWithOverflow => BinOp::Add, + BinOp::SubWithOverflow => BinOp::Sub, + BinOp::MulWithOverflow => BinOp::Mul, + _ => return None, + }) + } + + /// If this is a `Foo`, return `Some(FooWithOverflow)`. + pub fn wrapping_to_overflowing(self) -> Option { + Some(match self { + BinOp::Add => BinOp::AddWithOverflow, + BinOp::Sub => BinOp::SubWithOverflow, + BinOp::Mul => BinOp::MulWithOverflow, + _ => return None, + }) + } } diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index d97abc3f1904f..8901fd42d9366 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -696,8 +696,7 @@ macro_rules! make_mir_visitor { self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)); } - Rvalue::BinaryOp(_bin_op, box(lhs, rhs)) - | Rvalue::CheckedBinaryOp(_bin_op, box(lhs, rhs)) => { + Rvalue::BinaryOp(_bin_op, box(lhs, rhs)) => { self.visit_operand(lhs, location); self.visit_operand(rhs, location); } diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs index c669d3fd6230d..6f8cfc3af4473 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs @@ -195,9 +195,15 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { }, @call(mir_checked, args) => { parse_by_kind!(self, args[0], _, "binary op", - ExprKind::Binary { op, lhs, rhs } => Ok(Rvalue::CheckedBinaryOp( - *op, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?)) - )), + ExprKind::Binary { op, lhs, rhs } => { + if let Some(op_with_overflow) = op.wrapping_to_overflowing() { + Ok(Rvalue::BinaryOp( + op_with_overflow, Box::new((self.parse_operand(*lhs)?, self.parse_operand(*rhs)?)) + )) + } else { + Err(self.expr_error(expr_id, "No WithOverflow form of this operator")) + } + }, ) }, @call(mir_offset, args) => { diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 0b2248d049afc..60a2827a3e292 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -568,11 +568,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let result_tup = Ty::new_tup(self.tcx, &[ty, bool_ty]); let result_value = self.temp(result_tup, span); + let op_with_overflow = op.wrapping_to_overflowing().unwrap(); + self.cfg.push_assign( block, source_info, result_value, - Rvalue::CheckedBinaryOp(op, Box::new((lhs.to_copy(), rhs.to_copy()))), + Rvalue::BinaryOp(op_with_overflow, Box::new((lhs.to_copy(), rhs.to_copy()))), ); let val_fld = FieldIdx::ZERO; let of_fld = FieldIdx::new(1); diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs index bdc70de58e84b..706bb796349fb 100644 --- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs +++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs @@ -109,7 +109,6 @@ where | Rvalue::Repeat(..) | Rvalue::Len(..) | Rvalue::BinaryOp(..) - | Rvalue::CheckedBinaryOp(..) | Rvalue::NullaryOp(..) | Rvalue::UnaryOp(..) | Rvalue::Discriminant(..) diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 6ae7df79d3094..521ecb1b9a594 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -420,8 +420,7 @@ impl<'b, 'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> Gatherer<'b, 'a, 'tcx, F> { | Rvalue::Cast(_, ref operand, _) | Rvalue::ShallowInitBox(ref operand, _) | Rvalue::UnaryOp(_, ref operand) => self.gather_operand(operand), - Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs)) - | Rvalue::CheckedBinaryOp(ref _binop, box (ref lhs, ref rhs)) => { + Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs)) => { self.gather_operand(lhs); self.gather_operand(rhs); } diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 807bef0741178..1e5322dd99b8a 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -184,7 +184,6 @@ pub trait ValueAnalysis<'tcx> { | Rvalue::Len(..) | Rvalue::Cast(..) | Rvalue::BinaryOp(..) - | Rvalue::CheckedBinaryOp(..) | Rvalue::NullaryOp(..) | Rvalue::UnaryOp(..) | Rvalue::Discriminant(..) diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index a42d64f86be18..3d24a56cdd7c6 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -165,7 +165,9 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { } } } - Rvalue::CheckedBinaryOp(op, box (left, right)) => { + Rvalue::BinaryOp(overflowing_op, box (left, right)) + if let Some(op) = overflowing_op.overflowing_to_wrapping() => + { // Flood everything now, so we can use `insert_value_idx` directly later. state.flood(target.as_ref(), self.map()); @@ -175,7 +177,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { let overflow_target = self.map().apply(target, TrackElem::Field(1_u32.into())); if value_target.is_some() || overflow_target.is_some() { - let (val, overflow) = self.binary_op(state, *op, left, right); + let (val, overflow) = self.binary_op(state, op, left, right); if let Some(value_target) = value_target { // We have flooded `target` earlier. diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 1bc383fccc72b..b1016c0867c62 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -564,7 +564,7 @@ impl WriteInfo { | Rvalue::ShallowInitBox(op, _) => { self.add_operand(op); } - Rvalue::BinaryOp(_, ops) | Rvalue::CheckedBinaryOp(_, ops) => { + Rvalue::BinaryOp(_, ops) => { for op in [&ops.0, &ops.1] { self.add_operand(op); } diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 123166a764d8d..1f3e407180b5f 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -831,23 +831,18 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { // on both operands for side effect. let lhs = lhs?; let rhs = rhs?; - if let Some(value) = self.simplify_binary(op, false, ty, lhs, rhs) { - return Some(value); - } - Value::BinaryOp(op, lhs, rhs) - } - Rvalue::CheckedBinaryOp(op, box (ref mut lhs, ref mut rhs)) => { - let ty = lhs.ty(self.local_decls, self.tcx); - let lhs = self.simplify_operand(lhs, location); - let rhs = self.simplify_operand(rhs, location); - // Only short-circuit options after we called `simplify_operand` - // on both operands for side effect. - let lhs = lhs?; - let rhs = rhs?; - if let Some(value) = self.simplify_binary(op, true, ty, lhs, rhs) { - return Some(value); + + if let Some(op) = op.overflowing_to_wrapping() { + if let Some(value) = self.simplify_binary(op, true, ty, lhs, rhs) { + return Some(value); + } + Value::CheckedBinaryOp(op, lhs, rhs) + } else { + if let Some(value) = self.simplify_binary(op, false, ty, lhs, rhs) { + return Some(value); + } + Value::BinaryOp(op, lhs, rhs) } - Value::CheckedBinaryOp(op, lhs, rhs) } Rvalue::UnaryOp(op, ref mut arg) => { let arg = self.simplify_operand(arg, location)?; diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index d0a5a6cada8fa..38fc37a3a3131 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -399,16 +399,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } Rvalue::BinaryOp(op, box (left, right)) => { trace!("checking BinaryOp(op = {:?}, left = {:?}, right = {:?})", op, left, right); - self.check_binary_op(*op, left, right, location)?; - } - Rvalue::CheckedBinaryOp(op, box (left, right)) => { - trace!( - "checking CheckedBinaryOp(op = {:?}, left = {:?}, right = {:?})", - op, - left, - right - ); - self.check_binary_op(*op, left, right, location)?; + let op = op.overflowing_to_wrapping().unwrap_or(*op); + self.check_binary_op(op, left, right, location)?; } // Do not try creating references (#67862) @@ -555,24 +547,18 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { let right = self.eval_operand(right)?; let right = self.use_ecx(|this| this.ecx.read_immediate(&right))?; - let val = - self.use_ecx(|this| this.ecx.wrapping_binary_op(bin_op, &left, &right))?; - val.into() - } - - CheckedBinaryOp(bin_op, box (ref left, ref right)) => { - let left = self.eval_operand(left)?; - let left = self.use_ecx(|this| this.ecx.read_immediate(&left))?; - - let right = self.eval_operand(right)?; - let right = self.use_ecx(|this| this.ecx.read_immediate(&right))?; - - let (val, overflowed) = - self.use_ecx(|this| this.ecx.overflowing_binary_op(bin_op, &left, &right))?; - let overflowed = ImmTy::from_bool(overflowed, self.tcx); - Value::Aggregate { - variant: VariantIdx::ZERO, - fields: [Value::from(val), overflowed.into()].into_iter().collect(), + if let Some(bin_op) = bin_op.overflowing_to_wrapping() { + let (val, overflowed) = + self.use_ecx(|this| this.ecx.overflowing_binary_op(bin_op, &left, &right))?; + let overflowed = ImmTy::from_bool(overflowed, self.tcx); + Value::Aggregate { + variant: VariantIdx::ZERO, + fields: [Value::from(val), overflowed.into()].into_iter().collect(), + } + } else { + let val = + self.use_ecx(|this| this.ecx.wrapping_binary_op(bin_op, &left, &right))?; + val.into() } } diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 43d8c45bb2dd9..221301b2ceb04 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -140,16 +140,16 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { rhs = args.next().unwrap(); } let bin_op = match intrinsic.name { - sym::add_with_overflow => BinOp::Add, - sym::sub_with_overflow => BinOp::Sub, - sym::mul_with_overflow => BinOp::Mul, + sym::add_with_overflow => BinOp::AddWithOverflow, + sym::sub_with_overflow => BinOp::SubWithOverflow, + sym::mul_with_overflow => BinOp::MulWithOverflow, _ => bug!("unexpected intrinsic"), }; block.statements.push(Statement { source_info: terminator.source_info, kind: StatementKind::Assign(Box::new(( *destination, - Rvalue::CheckedBinaryOp(bin_op, Box::new((lhs.node, rhs.node))), + Rvalue::BinaryOp(bin_op, Box::new((lhs.node, rhs.node))), ))), }); terminator.kind = TerminatorKind::Goto { target }; diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index b3116c002d3ce..34aa31baab79d 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -470,7 +470,7 @@ impl<'tcx> Validator<'_, 'tcx> { self.validate_operand(operand)?; } - Rvalue::BinaryOp(op, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(op, box (lhs, rhs)) => { + Rvalue::BinaryOp(op, box (lhs, rhs)) => { let op = *op; let lhs_ty = lhs.ty(self.body, self.tcx); @@ -539,10 +539,13 @@ impl<'tcx> Validator<'_, 'tcx> { | BinOp::Offset | BinOp::Add | BinOp::AddUnchecked + | BinOp::AddWithOverflow | BinOp::Sub | BinOp::SubUnchecked + | BinOp::SubWithOverflow | BinOp::Mul | BinOp::MulUnchecked + | BinOp::MulWithOverflow | BinOp::BitXor | BinOp::BitAnd | BinOp::BitOr diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs index 452ab04c44c54..d89caabab3e1a 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/mir.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/mir.rs @@ -1,5 +1,6 @@ //! Conversion of internal Rust compiler `mir` items to stable ones. +use rustc_middle::bug; use rustc_middle::mir; use rustc_middle::mir::interpret::alloc_range; use rustc_middle::mir::mono::MonoItem; @@ -183,16 +184,21 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> { op.stable(tables), ty.stable(tables), ), - BinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::BinaryOp( - bin_op.stable(tables), - ops.0.stable(tables), - ops.1.stable(tables), - ), - CheckedBinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::CheckedBinaryOp( - bin_op.stable(tables), - ops.0.stable(tables), - ops.1.stable(tables), - ), + BinaryOp(bin_op, ops) => { + if let Some(bin_op) = bin_op.overflowing_to_wrapping() { + stable_mir::mir::Rvalue::CheckedBinaryOp( + bin_op.stable(tables), + ops.0.stable(tables), + ops.1.stable(tables), + ) + } else { + stable_mir::mir::Rvalue::BinaryOp( + bin_op.stable(tables), + ops.0.stable(tables), + ops.1.stable(tables), + ) + } + } NullaryOp(null_op, ty) => { stable_mir::mir::Rvalue::NullaryOp(null_op.stable(tables), ty.stable(tables)) } @@ -485,10 +491,13 @@ impl<'tcx> Stable<'tcx> for mir::BinOp { match self { BinOp::Add => stable_mir::mir::BinOp::Add, BinOp::AddUnchecked => stable_mir::mir::BinOp::AddUnchecked, + BinOp::AddWithOverflow => bug!("AddWithOverflow should have been translated already"), BinOp::Sub => stable_mir::mir::BinOp::Sub, BinOp::SubUnchecked => stable_mir::mir::BinOp::SubUnchecked, + BinOp::SubWithOverflow => bug!("AddWithOverflow should have been translated already"), BinOp::Mul => stable_mir::mir::BinOp::Mul, BinOp::MulUnchecked => stable_mir::mir::BinOp::MulUnchecked, + BinOp::MulWithOverflow => bug!("AddWithOverflow should have been translated already"), BinOp::Div => stable_mir::mir::BinOp::Div, BinOp::Rem => stable_mir::mir::BinOp::Rem, BinOp::BitXor => stable_mir::mir::BinOp::BitXor, diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index fec02f515caf3..b40a0d0a58e4a 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -81,9 +81,9 @@ fn destructure_const<'tcx>( fn check_binop(op: mir::BinOp) -> bool { use mir::BinOp::*; match op { - Add | AddUnchecked | Sub | SubUnchecked | Mul | MulUnchecked | Div | Rem | BitXor - | BitAnd | BitOr | Shl | ShlUnchecked | Shr | ShrUnchecked | Eq | Lt | Le | Ne | Ge - | Gt | Cmp => true, + Add | AddUnchecked | AddWithOverflow | Sub | SubUnchecked | SubWithOverflow | Mul + | MulUnchecked | MulWithOverflow | Div | Rem | BitXor | BitAnd | BitOr | Shl + | ShlUnchecked | Shr | ShrUnchecked | Eq | Lt | Le | Ne | Ge | Gt | Cmp => true, Offset => false, } } diff --git a/tests/mir-opt/building/custom/operators.f.built.after.mir b/tests/mir-opt/building/custom/operators.f.built.after.mir index 33eb6b720e87c..cac82f7b3ea3b 100644 --- a/tests/mir-opt/building/custom/operators.f.built.after.mir +++ b/tests/mir-opt/building/custom/operators.f.built.after.mir @@ -21,7 +21,7 @@ fn f(_1: i32, _2: bool) -> i32 { _2 = Le(_1, _1); _2 = Ge(_1, _1); _2 = Gt(_1, _1); - _3 = CheckedAdd(_1, _1); + _3 = AddWithOverflow(_1, _1); _2 = (_3.1: bool); _1 = (_3.0: i32); _0 = _1; diff --git a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff index d5117b2f63846..0e93c167ebc96 100644 --- a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff @@ -11,7 +11,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 1_u32, const 1_u32); +- _2 = AddWithOverflow(const 1_u32, const 1_u32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable]; + _2 = const (2_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff index 2118d37672c0b..589eed5776c9f 100644 --- a/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff @@ -11,7 +11,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 1_u32, const 1_u32); +- _2 = AddWithOverflow(const 1_u32, const 1_u32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; + _2 = const (2_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff index 8301a4c1aa864..f24b9755eaea6 100644 --- a/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff @@ -14,7 +14,7 @@ StorageLive(_1); StorageLive(_2); - _2 = const 2_u32 as u8 (IntToInt); -- _3 = CheckedAdd(_2, const 1_u8); +- _3 = AddWithOverflow(_2, const 1_u8); - assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind unreachable]; + _2 = const 2_u8; + _3 = const (3_u8, false); diff --git a/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff index 8dcbfd2c2c11e..44ff313b5328b 100644 --- a/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff @@ -14,7 +14,7 @@ StorageLive(_1); StorageLive(_2); - _2 = const 2_u32 as u8 (IntToInt); -- _3 = CheckedAdd(_2, const 1_u8); +- _3 = AddWithOverflow(_2, const 1_u8); - assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; + _2 = const 2_u8; + _3 = const (3_u8, false); diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff index 8c5a0df94f428..de9cb7a47a2be 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff @@ -19,7 +19,7 @@ StorageLive(_3); _3 = const 1_u8; StorageLive(_4); -- _4 = CheckedAdd(_2, _3); +- _4 = AddWithOverflow(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; + _4 = const (0_u8, true); + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff index 7887a8a907277..1f19a13c1e8cf 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff @@ -19,7 +19,7 @@ StorageLive(_3); _3 = const 1_u8; StorageLive(_4); -- _4 = CheckedAdd(_2, _3); +- _4 = AddWithOverflow(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + _4 = const (0_u8, true); + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff index 51f8227c36b41..b2d40daa80c4c 100644 --- a/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff @@ -6,7 +6,7 @@ let mut _1: (u32, bool); bb0: { -- _1 = CheckedAdd(const 2_u32, const 2_u32); +- _1 = AddWithOverflow(const 2_u32, const 2_u32); - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind unreachable]; + _1 = const (4_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff index 8174b4edea65c..2eafc51cd3db6 100644 --- a/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff @@ -6,7 +6,7 @@ let mut _1: (u32, bool); bb0: { -- _1 = CheckedAdd(const 2_u32, const 2_u32); +- _1 = AddWithOverflow(const 2_u32, const 2_u32); - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; + _1 = const (4_u32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff index b35538f897283..53663c6476bdc 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-abort.diff @@ -40,7 +40,7 @@ + _4 = const 1_i32; StorageLive(_5); - _5 = _2; -- _6 = CheckedAdd(_4, _5); +- _6 = AddWithOverflow(_4, _5); - assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> [success: bb1, unwind unreachable]; + _5 = const 2_i32; + _6 = const (3_i32, false); @@ -57,7 +57,7 @@ StorageLive(_8); StorageLive(_9); - _9 = _7; -- _10 = CheckedAdd(_9, const 1_i32); +- _10 = AddWithOverflow(_9, const 1_i32); - assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> [success: bb2, unwind unreachable]; + _9 = const i32::MAX; + _10 = const (i32::MIN, true); diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff index 05c9696923371..34feb2a640629 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff @@ -40,7 +40,7 @@ + _4 = const 1_i32; StorageLive(_5); - _5 = _2; -- _6 = CheckedAdd(_4, _5); +- _6 = AddWithOverflow(_4, _5); - assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> [success: bb1, unwind continue]; + _5 = const 2_i32; + _6 = const (3_i32, false); @@ -57,7 +57,7 @@ StorageLive(_8); StorageLive(_9); - _9 = _7; -- _10 = CheckedAdd(_9, const 1_i32); +- _10 = AddWithOverflow(_9, const 1_i32); - assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> [success: bb2, unwind continue]; + _9 = const i32::MAX; + _10 = const (i32::MIN, true); diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff index ca1bd737caf06..8d62de0c82152 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff @@ -19,7 +19,7 @@ StorageLive(_3); _3 = const 1_u8; StorageLive(_4); -- _4 = CheckedAdd(_2, _3); +- _4 = AddWithOverflow(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind unreachable]; + _4 = const (0_u8, true); + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff index 0d7fe9360c117..25624851cb34d 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff @@ -19,7 +19,7 @@ StorageLive(_3); _3 = const 1_u8; StorageLive(_4); -- _4 = CheckedAdd(_2, _3); +- _4 = AddWithOverflow(_2, _3); - assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + _4 = const (0_u8, true); + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff index a45d9920a6847..5bf22af6ae83d 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff @@ -31,9 +31,9 @@ StorageLive(_3); StorageLive(_4); _4 = _1; -- _5 = CheckedAdd(_4, const 0_u64); +- _5 = AddWithOverflow(_4, const 0_u64); - assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind unreachable]; -+ _5 = CheckedAdd(_1, const 0_u64); ++ _5 = AddWithOverflow(_1, const 0_u64); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", _1, const 0_u64) -> [success: bb1, unwind unreachable]; } @@ -52,7 +52,7 @@ StorageLive(_7); StorageLive(_8); _8 = _1; -- _9 = CheckedSub(_8, const 0_u64); +- _9 = SubWithOverflow(_8, const 0_u64); - assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind unreachable]; + _9 = _5; + assert(!const false, "attempt to compute `{} - {}`, which would overflow", _1, const 0_u64) -> [success: bb3, unwind unreachable]; @@ -76,7 +76,7 @@ _12 = _1; StorageLive(_13); _13 = _1; -- _14 = CheckedSub(_12, _13); +- _14 = SubWithOverflow(_12, _13); - assert(!move (_14.1: bool), "attempt to compute `{} - {}`, which would overflow", move _12, move _13) -> [success: bb5, unwind unreachable]; + _14 = const (0_u64, false); + assert(!const false, "attempt to compute `{} - {}`, which would overflow", _1, _1) -> [success: bb5, unwind unreachable]; @@ -99,7 +99,7 @@ StorageLive(_16); StorageLive(_17); _17 = _1; -- _18 = CheckedMul(_17, const 0_u64); +- _18 = MulWithOverflow(_17, const 0_u64); - assert(!move (_18.1: bool), "attempt to compute `{} * {}`, which would overflow", move _17, const 0_u64) -> [success: bb7, unwind unreachable]; + _18 = const (0_u64, false); + assert(!const false, "attempt to compute `{} * {}`, which would overflow", _1, const 0_u64) -> [success: bb7, unwind unreachable]; @@ -120,7 +120,7 @@ StorageLive(_20); StorageLive(_21); _21 = _1; -- _22 = CheckedMul(_21, const 1_u64); +- _22 = MulWithOverflow(_21, const 1_u64); - assert(!move (_22.1: bool), "attempt to compute `{} * {}`, which would overflow", move _21, const 1_u64) -> [success: bb9, unwind unreachable]; + _22 = _5; + assert(!const false, "attempt to compute `{} * {}`, which would overflow", _1, const 1_u64) -> [success: bb9, unwind unreachable]; diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff index 9033b392bd4c1..18d2029e44500 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff @@ -31,9 +31,9 @@ StorageLive(_3); StorageLive(_4); _4 = _1; -- _5 = CheckedAdd(_4, const 0_u64); +- _5 = AddWithOverflow(_4, const 0_u64); - assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind continue]; -+ _5 = CheckedAdd(_1, const 0_u64); ++ _5 = AddWithOverflow(_1, const 0_u64); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", _1, const 0_u64) -> [success: bb1, unwind continue]; } @@ -52,7 +52,7 @@ StorageLive(_7); StorageLive(_8); _8 = _1; -- _9 = CheckedSub(_8, const 0_u64); +- _9 = SubWithOverflow(_8, const 0_u64); - assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind continue]; + _9 = _5; + assert(!const false, "attempt to compute `{} - {}`, which would overflow", _1, const 0_u64) -> [success: bb3, unwind continue]; @@ -76,7 +76,7 @@ _12 = _1; StorageLive(_13); _13 = _1; -- _14 = CheckedSub(_12, _13); +- _14 = SubWithOverflow(_12, _13); - assert(!move (_14.1: bool), "attempt to compute `{} - {}`, which would overflow", move _12, move _13) -> [success: bb5, unwind continue]; + _14 = const (0_u64, false); + assert(!const false, "attempt to compute `{} - {}`, which would overflow", _1, _1) -> [success: bb5, unwind continue]; @@ -99,7 +99,7 @@ StorageLive(_16); StorageLive(_17); _17 = _1; -- _18 = CheckedMul(_17, const 0_u64); +- _18 = MulWithOverflow(_17, const 0_u64); - assert(!move (_18.1: bool), "attempt to compute `{} * {}`, which would overflow", move _17, const 0_u64) -> [success: bb7, unwind continue]; + _18 = const (0_u64, false); + assert(!const false, "attempt to compute `{} * {}`, which would overflow", _1, const 0_u64) -> [success: bb7, unwind continue]; @@ -120,7 +120,7 @@ StorageLive(_20); StorageLive(_21); _21 = _1; -- _22 = CheckedMul(_21, const 1_u64); +- _22 = MulWithOverflow(_21, const 1_u64); - assert(!move (_22.1: bool), "attempt to compute `{} * {}`, which would overflow", move _21, const 1_u64) -> [success: bb9, unwind continue]; + _22 = _5; + assert(!const false, "attempt to compute `{} * {}`, which would overflow", _1, const 1_u64) -> [success: bb9, unwind continue]; diff --git a/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir b/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir index 7dafeabaacc74..7d2e97f8d564b 100644 --- a/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir +++ b/tests/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir @@ -5,7 +5,7 @@ let mut _1: (usize, bool); bb0: { - _1 = CheckedAdd(const 1_usize, const 1_usize); + _1 = AddWithOverflow(const 1_usize, const 1_usize); assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_usize, const 1_usize) -> [success: bb1, unwind: bb2]; } diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 12e526ab0741d..180bfd0a92462 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -184,9 +184,9 @@ pub fn assume() { // EMIT_MIR lower_intrinsics.with_overflow.LowerIntrinsics.diff pub fn with_overflow(a: i32, b: i32) { // CHECK-LABEL: fn with_overflow( - // CHECK: CheckedAdd( - // CHECK: CheckedSub( - // CHECK: CheckedMul( + // CHECK: AddWithOverflow( + // CHECK: SubWithOverflow( + // CHECK: MulWithOverflow( let _x = core::intrinsics::add_with_overflow(a, b); let _y = core::intrinsics::sub_with_overflow(a, b); diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-abort.diff index da84449aaa524..efbbeeeac73da 100644 --- a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-abort.diff @@ -31,7 +31,7 @@ StorageLive(_5); _5 = _2; - _3 = add_with_overflow::(move _4, move _5) -> [return: bb1, unwind unreachable]; -+ _3 = CheckedAdd(move _4, move _5); ++ _3 = AddWithOverflow(move _4, move _5); + goto -> bb1; } @@ -44,7 +44,7 @@ StorageLive(_8); _8 = _2; - _6 = sub_with_overflow::(move _7, move _8) -> [return: bb2, unwind unreachable]; -+ _6 = CheckedSub(move _7, move _8); ++ _6 = SubWithOverflow(move _7, move _8); + goto -> bb2; } @@ -57,7 +57,7 @@ StorageLive(_11); _11 = _2; - _9 = mul_with_overflow::(move _10, move _11) -> [return: bb3, unwind unreachable]; -+ _9 = CheckedMul(move _10, move _11); ++ _9 = MulWithOverflow(move _10, move _11); + goto -> bb3; } diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-unwind.diff index da84449aaa524..efbbeeeac73da 100644 --- a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.panic-unwind.diff @@ -31,7 +31,7 @@ StorageLive(_5); _5 = _2; - _3 = add_with_overflow::(move _4, move _5) -> [return: bb1, unwind unreachable]; -+ _3 = CheckedAdd(move _4, move _5); ++ _3 = AddWithOverflow(move _4, move _5); + goto -> bb1; } @@ -44,7 +44,7 @@ StorageLive(_8); _8 = _2; - _6 = sub_with_overflow::(move _7, move _8) -> [return: bb2, unwind unreachable]; -+ _6 = CheckedSub(move _7, move _8); ++ _6 = SubWithOverflow(move _7, move _8); + goto -> bb2; } @@ -57,7 +57,7 @@ StorageLive(_11); _11 = _2; - _9 = mul_with_overflow::(move _10, move _11) -> [return: bb3, unwind unreachable]; -+ _9 = CheckedMul(move _10, move _11); ++ _9 = MulWithOverflow(move _10, move _11); + goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff index 0e7e1f971ec34..2f34a62b3d136 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -24,7 +24,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 2_i32, const 2_i32); +- _2 = AddWithOverflow(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; + _2 = const (4_i32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff index 9071a3339c080..da7add371a5bf 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -24,7 +24,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 2_i32, const 2_i32); +- _2 = AddWithOverflow(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + _2 = const (4_i32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff index 0e7e1f971ec34..2f34a62b3d136 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -24,7 +24,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 2_i32, const 2_i32); +- _2 = AddWithOverflow(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; + _2 = const (4_i32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff index 9071a3339c080..da7add371a5bf 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -24,7 +24,7 @@ bb0: { StorageLive(_1); -- _2 = CheckedAdd(const 2_i32, const 2_i32); +- _2 = AddWithOverflow(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + _2 = const (4_i32, false); + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff index 5f2a096bb1f76..802bfbbcdc5fa 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-abort.diff @@ -26,7 +26,7 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); + _2 = AddWithOverflow(const 2_i32, const 2_i32); assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff index a49546f158c8b..de94a55740318 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff @@ -26,7 +26,7 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); + _2 = AddWithOverflow(const 2_i32, const 2_i32); assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff index 5f2a096bb1f76..802bfbbcdc5fa 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-abort.diff @@ -26,7 +26,7 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); + _2 = AddWithOverflow(const 2_i32, const 2_i32); assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff index a49546f158c8b..de94a55740318 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff @@ -26,7 +26,7 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); + _2 = AddWithOverflow(const 2_i32, const 2_i32); assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } diff --git a/tests/run-make/const_fn_mir/dump.mir b/tests/run-make/const_fn_mir/dump.mir index ced170bbeee2f..b1802c990cf89 100644 --- a/tests/run-make/const_fn_mir/dump.mir +++ b/tests/run-make/const_fn_mir/dump.mir @@ -5,7 +5,7 @@ fn foo() -> i32 { let mut _1: (i32, bool); bb0: { - _1 = CheckedAdd(const 5_i32, const 6_i32); + _1 = AddWithOverflow(const 5_i32, const 6_i32); assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue]; } @@ -21,7 +21,7 @@ fn foo() -> i32 { let mut _1: (i32, bool); bb0: { - _1 = CheckedAdd(const 5_i32, const 6_i32); + _1 = AddWithOverflow(const 5_i32, const 6_i32); assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue]; } From d83c65e9873002f657a32051ba51a7d17883b2f8 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 16 May 2024 03:00:48 -0700 Subject: [PATCH 15/19] Fix clippy --- src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs | 4 ++-- src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs index 06229ac938f9a..7b4fd8a210edf 100644 --- a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs +++ b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs @@ -149,7 +149,7 @@ impl TypeVisitor> for ContainsRegion { } fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { - use rustc_middle::mir::Rvalue::{Aggregate, BinaryOp, Cast, CheckedBinaryOp, Repeat, UnaryOp, Use}; + use rustc_middle::mir::Rvalue::{Aggregate, BinaryOp, Cast, Repeat, UnaryOp, Use}; let mut visit_op = |op: &mir::Operand<'_>| match op { mir::Operand::Copy(p) | mir::Operand::Move(p) => visit(p.local), @@ -159,7 +159,7 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { match rvalue { Use(op) | Repeat(op, _) | Cast(_, op, _) | UnaryOp(_, op) => visit_op(op), Aggregate(_, ops) => ops.iter().for_each(visit_op), - BinaryOp(_, box (lhs, rhs)) | CheckedBinaryOp(_, box (lhs, rhs)) => { + BinaryOp(_, box (lhs, rhs)) => { visit_op(lhs); visit_op(rhs); }, diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 95851a2eed814..ff9f06531ea11 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -161,7 +161,7 @@ fn check_rvalue<'tcx>( "transmute can attempt to turn pointers into integers, so is unstable in const fn".into(), )), // binops are fine on integers - Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => { + Rvalue::BinaryOp(_, box (lhs, rhs)) => { check_operand(tcx, lhs, span, body)?; check_operand(tcx, rhs, span, body)?; let ty = lhs.ty(body, tcx); From 1d9757cd849989691becceb15e0e7c2ec37a3452 Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Mon, 20 May 2024 09:18:49 +0200 Subject: [PATCH 16/19] add todo test for feature gate --- .../feature-gate-global-registration.rs | 4 +++- .../feature-gate-global-registration.stderr | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/ui/feature-gates/feature-gate-global-registration.stderr diff --git a/tests/ui/feature-gates/feature-gate-global-registration.rs b/tests/ui/feature-gates/feature-gate-global-registration.rs index 77072727ec501..6ac3671209033 100644 --- a/tests/ui/feature-gates/feature-gate-global-registration.rs +++ b/tests/ui/feature-gates/feature-gate-global-registration.rs @@ -1 +1,3 @@ -//! WIP +todo!(); //~ ERROR + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-global-registration.stderr b/tests/ui/feature-gates/feature-gate-global-registration.stderr new file mode 100644 index 0000000000000..70538ae6f317d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-global-registration.stderr @@ -0,0 +1,13 @@ +error: expected one of `!` or `::`, found `(` + --> $DIR/feature-gate-global-registration.rs:1:1 + | +LL | todo!(); + | ^^^^^^^ + | | + | expected one of `!` or `::` + | in this macro invocation + | + = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + From 7b0fd3b93182c41cae52934421aa732af002e99a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 20 May 2024 12:09:11 +0200 Subject: [PATCH 17/19] Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs` --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/rustdoc-scrape-examples-whitespace/Makefile | 5 ----- tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs | 6 ++++++ 3 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 tests/run-make/rustdoc-scrape-examples-whitespace/Makefile create mode 100644 tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index e08d7ff046d86..9b879f33778fd 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -236,7 +236,6 @@ run-make/rustc-macro-dep-files/Makefile run-make/rustdoc-io-error/Makefile run-make/rustdoc-scrape-examples-macros/Makefile run-make/rustdoc-scrape-examples-multiple/Makefile -run-make/rustdoc-scrape-examples-whitespace/Makefile run-make/rustdoc-verify-output-files/Makefile run-make/rustdoc-with-output-option/Makefile run-make/rustdoc-with-short-out-dir-option/Makefile diff --git a/tests/run-make/rustdoc-scrape-examples-whitespace/Makefile b/tests/run-make/rustdoc-scrape-examples-whitespace/Makefile deleted file mode 100644 index 7786ff762cb30..0000000000000 --- a/tests/run-make/rustdoc-scrape-examples-whitespace/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -deps := ex - -include ../rustdoc-scrape-examples-multiple/scrape.mk - -all: scrape diff --git a/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs b/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs new file mode 100644 index 0000000000000..e9c54fa392237 --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs @@ -0,0 +1,6 @@ +#[path = "../rustdoc-scrape-examples-remap/scrape.rs"] +mod scrape; + +fn main() { + scrape::scrape(&[]); +} From a4efe6fe27eb3dcd48518dd7318319acec30efd3 Mon Sep 17 00:00:00 2001 From: Joshua Wong Date: Sun, 19 May 2024 19:10:45 -0500 Subject: [PATCH 18/19] add codegen test for issue 120493 --- tests/codegen/vec-in-place.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/codegen/vec-in-place.rs b/tests/codegen/vec-in-place.rs index 7a175dc4f7e1c..c6b77363a4e50 100644 --- a/tests/codegen/vec-in-place.rs +++ b/tests/codegen/vec-in-place.rs @@ -90,3 +90,25 @@ pub fn vec_iterator_cast_deaggregate_fold(vec: Vec) -> Vec<[u64; 4]> { // correct. vec.into_iter().map(|e| unsafe { std::mem::transmute(e) }).collect() } + +// CHECK-LABEL: @vec_iterator_cast_unwrap_drop +#[no_mangle] +pub fn vec_iterator_cast_unwrap_drop(vec: Vec>) -> Vec { + // CHECK-NOT: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} + // CHECK-NOT: call + // CHECK-NOT: %{{.*}} = mul + // CHECK-NOT: %{{.*}} = udiv + + vec.into_iter().map(|Wrapper(e)| e).collect() +} + +// CHECK-LABEL: @vec_iterator_cast_wrap_drop +#[no_mangle] +pub fn vec_iterator_cast_wrap_drop(vec: Vec) -> Vec> { + // CHECK-NOT: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} + // CHECK-NOT: call + // CHECK-NOT: %{{.*}} = mul + // CHECK-NOT: %{{.*}} = udiv + + vec.into_iter().map(Wrapper).collect() +} From a2e0f10639bd2c8828267ade0a06ce7a477ce685 Mon Sep 17 00:00:00 2001 From: Felix S Klock II Date: Mon, 20 May 2024 11:55:20 -0400 Subject: [PATCH 19/19] address nit --- compiler/rustc_feature/src/unstable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index a25b7ef10a427..b374c0df42a56 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -487,7 +487,7 @@ declare_features! ( (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. (incomplete, generic_const_items, "1.73.0", Some(113521)), - /// Allows registring static items globally, possibly across crates, to iterate over at runtime. + /// Allows registering static items globally, possibly across crates, to iterate over at runtime. (unstable, global_registration, "CURRENT_RUSTC_VERSION", Some(125119)), /// Allows using `..=X` as a patterns in slices. (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)),