Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,8 +1771,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
let pat = self.lower_pat(pat);
let for_span =
self.mark_span_with_reason(DesugaringKind::ForLoop, self.lower_span(e.span), None);
let head_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
let pat_span = self.mark_span_with_reason(DesugaringKind::ForLoop, pat.span, None);
let for_ctxt = for_span.ctxt();

// Try to point both the head and pat spans to their position in the for loop
// rather than inside a macro.
let head_span =
head.span.find_ancestor_in_same_ctxt(e.span).unwrap_or(head.span).with_ctxt(for_ctxt);
let pat_span =
pat.span.find_ancestor_in_same_ctxt(e.span).unwrap_or(pat.span).with_ctxt(for_ctxt);

let loop_hir_id = self.lower_node_id(e.id);
let label = self.lower_label(opt_label, e.id, loop_hir_id);
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/async_block.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: async_block::main
Raw bytes (41): 0x[01, 01, 01, 05, 01, 07, 01, 07, 01, 00, 0a, 02, 01, 09, 00, 0a, 05, 00, 0e, 00, 13, 02, 01, 0d, 00, 13, 02, 07, 09, 00, 1b, 02, 00, 1c, 00, 22, 01, 02, 01, 00, 02]
Raw bytes (41): 0x[01, 01, 01, 05, 01, 07, 01, 07, 01, 00, 0a, 02, 01, 09, 00, 0a, 01, 00, 0e, 00, 13, 02, 01, 0d, 00, 13, 02, 07, 09, 00, 1b, 02, 00, 1c, 00, 22, 01, 02, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/async_block.rs
Number of expressions: 1
Expand All @@ -8,15 +8,15 @@ Number of file 0 mappings: 7
- Code(Counter(0)) at (prev + 7, 1) to (start + 0, 10)
- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 10)
= (c1 - c0)
- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 19)
- Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 19)
= (c1 - c0)
- Code(Expression(0, Sub)) at (prev + 7, 9) to (start + 0, 27)
= (c1 - c0)
- Code(Expression(0, Sub)) at (prev + 0, 28) to (start + 0, 34)
= (c1 - c0)
- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2)
Highest counter ID seen: c1
Highest counter ID seen: c0

Function name: async_block::main::{closure#0}
Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 09, 1c, 00, 1d, 01, 01, 10, 00, 17, 05, 00, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a]
Expand Down
4 changes: 2 additions & 2 deletions tests/coverage/async_block.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
LL| |extern crate executor;
LL| |
LL| 1|fn main() {
LL| 17| for i in 0..16 {
^16
LL| 16| for i in 0..16 {
^1
LL| 16| let future = async {
LL| 16| if i >= 12 {
LL| 4| println!("big");
Expand Down
32 changes: 16 additions & 16 deletions tests/coverage/continue.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: continue::main
Raw bytes (241): 0x[01, 01, 1a, 05, 01, 05, 13, 01, 09, 05, 13, 01, 09, 0d, 01, 0d, 27, 01, 11, 0d, 27, 01, 11, 15, 01, 15, 33, 01, 19, 1d, 01, 1d, 47, 01, 21, 1d, 47, 01, 21, 25, 01, 25, 53, 01, 29, 25, 01, 2d, 01, 63, 2d, 01, 31, 2d, 01, 25, 01, 03, 01, 00, 0a, 01, 01, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 02, 09, 00, 0e, 01, 00, 11, 00, 12, 05, 01, 0e, 00, 13, 02, 01, 0f, 00, 16, 09, 02, 11, 00, 19, 0e, 02, 12, 02, 0e, 0e, 04, 09, 00, 0e, 0d, 02, 0e, 00, 13, 16, 01, 0f, 00, 16, 22, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 22, 03, 09, 00, 0e, 15, 02, 0e, 00, 13, 2a, 01, 0f, 00, 16, 19, 01, 15, 02, 0e, 2e, 04, 11, 00, 19, 19, 03, 09, 00, 0e, 1d, 02, 0e, 00, 13, 36, 01, 0c, 00, 13, 21, 01, 0d, 00, 15, 42, 01, 09, 00, 0a, 42, 01, 09, 00, 0e, 25, 02, 0e, 00, 13, 56, 01, 0f, 00, 16, 4e, 01, 16, 02, 0e, 29, 03, 12, 02, 0e, 56, 04, 09, 00, 0e, 2d, 02, 0e, 00, 13, 31, 01, 0f, 00, 16, 66, 01, 16, 02, 0e, 5e, 04, 11, 00, 16, 66, 03, 09, 00, 0e, 01, 02, 0d, 00, 0e, 01, 01, 01, 00, 02]
Raw bytes (241): 0x[01, 01, 1a, 05, 01, 05, 13, 01, 09, 05, 13, 01, 09, 0d, 01, 0d, 27, 01, 11, 0d, 27, 01, 11, 15, 01, 15, 33, 01, 19, 1d, 01, 1d, 47, 01, 21, 1d, 47, 01, 21, 25, 01, 25, 53, 01, 29, 25, 01, 31, 01, 63, 31, 01, 2d, 31, 01, 25, 01, 03, 01, 00, 0a, 01, 01, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 02, 09, 00, 0e, 01, 00, 11, 00, 12, 01, 01, 0e, 00, 13, 02, 01, 0f, 00, 16, 09, 02, 11, 00, 19, 0e, 02, 12, 02, 0e, 0e, 04, 09, 00, 0e, 01, 02, 0e, 00, 13, 16, 01, 0f, 00, 16, 22, 01, 16, 02, 0e, 11, 04, 11, 00, 19, 22, 03, 09, 00, 0e, 01, 02, 0e, 00, 13, 2a, 01, 0f, 00, 16, 19, 01, 15, 02, 0e, 2e, 04, 11, 00, 19, 19, 03, 09, 00, 0e, 01, 02, 0e, 00, 13, 36, 01, 0c, 00, 13, 21, 01, 0d, 00, 15, 42, 01, 09, 00, 0a, 42, 01, 09, 00, 0e, 01, 02, 0e, 00, 13, 56, 01, 0f, 00, 16, 4e, 01, 16, 02, 0e, 29, 03, 12, 02, 0e, 56, 04, 09, 00, 0e, 01, 02, 0e, 00, 13, 2d, 01, 0f, 00, 16, 66, 01, 16, 02, 0e, 5e, 04, 11, 00, 16, 66, 03, 09, 00, 0e, 01, 02, 0d, 00, 0e, 01, 01, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/continue.rs
Number of expressions: 26
Expand All @@ -25,64 +25,64 @@ Number of expressions: 26
- expression 19 operands: lhs = Counter(9), rhs = Expression(20, Add)
- expression 20 operands: lhs = Counter(0), rhs = Counter(10)
- expression 21 operands: lhs = Counter(9), rhs = Counter(0)
- expression 22 operands: lhs = Counter(11), rhs = Counter(0)
- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(11)
- expression 24 operands: lhs = Counter(0), rhs = Counter(12)
- expression 25 operands: lhs = Counter(11), rhs = Counter(0)
- expression 22 operands: lhs = Counter(12), rhs = Counter(0)
- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(12)
- expression 24 operands: lhs = Counter(0), rhs = Counter(11)
- expression 25 operands: lhs = Counter(12), rhs = Counter(0)
Number of file 0 mappings: 37
- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 10)
- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 16)
- Code(Counter(0)) at (prev + 0, 19) to (start + 0, 46)
- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 14)
- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 18)
- Code(Counter(1)) at (prev + 1, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 1, 14) to (start + 0, 19)
- Code(Expression(0, Sub)) at (prev + 1, 15) to (start + 0, 22)
= (c1 - c0)
- Code(Counter(2)) at (prev + 2, 17) to (start + 0, 25)
- Code(Expression(3, Sub)) at (prev + 2, 18) to (start + 2, 14)
= (c1 - (c0 + c2))
- Code(Expression(3, Sub)) at (prev + 4, 9) to (start + 0, 14)
= (c1 - (c0 + c2))
- Code(Counter(3)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 2, 14) to (start + 0, 19)
- Code(Expression(5, Sub)) at (prev + 1, 15) to (start + 0, 22)
= (c3 - c0)
- Code(Expression(8, Sub)) at (prev + 1, 22) to (start + 2, 14)
= (c3 - (c0 + c4))
- Code(Counter(4)) at (prev + 4, 17) to (start + 0, 25)
- Code(Expression(8, Sub)) at (prev + 3, 9) to (start + 0, 14)
= (c3 - (c0 + c4))
- Code(Counter(5)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 2, 14) to (start + 0, 19)
- Code(Expression(10, Sub)) at (prev + 1, 15) to (start + 0, 22)
= (c5 - c0)
- Code(Counter(6)) at (prev + 1, 21) to (start + 2, 14)
- Code(Expression(11, Sub)) at (prev + 4, 17) to (start + 0, 25)
= (c5 - (c0 + c6))
- Code(Counter(6)) at (prev + 3, 9) to (start + 0, 14)
- Code(Counter(7)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 2, 14) to (start + 0, 19)
- Code(Expression(13, Sub)) at (prev + 1, 12) to (start + 0, 19)
= (c7 - c0)
- Code(Counter(8)) at (prev + 1, 13) to (start + 0, 21)
- Code(Expression(16, Sub)) at (prev + 1, 9) to (start + 0, 10)
= (c7 - (c0 + c8))
- Code(Expression(16, Sub)) at (prev + 1, 9) to (start + 0, 14)
= (c7 - (c0 + c8))
- Code(Counter(9)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(0)) at (prev + 2, 14) to (start + 0, 19)
- Code(Expression(21, Sub)) at (prev + 1, 15) to (start + 0, 22)
= (c9 - c0)
- Code(Expression(19, Sub)) at (prev + 1, 22) to (start + 2, 14)
= (c9 - (c0 + c10))
- Code(Counter(10)) at (prev + 3, 18) to (start + 2, 14)
- Code(Expression(21, Sub)) at (prev + 4, 9) to (start + 0, 14)
= (c9 - c0)
- Code(Counter(11)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(12)) at (prev + 1, 15) to (start + 0, 22)
- Code(Counter(0)) at (prev + 2, 14) to (start + 0, 19)
- Code(Counter(11)) at (prev + 1, 15) to (start + 0, 22)
- Code(Expression(25, Sub)) at (prev + 1, 22) to (start + 2, 14)
= (c11 - c0)
= (c12 - c0)
- Code(Expression(23, Sub)) at (prev + 4, 17) to (start + 0, 22)
= ((c0 + c12) - c11)
= ((c0 + c11) - c12)
- Code(Expression(25, Sub)) at (prev + 3, 9) to (start + 0, 14)
= (c11 - c0)
= (c12 - c0)
- Code(Counter(0)) at (prev + 2, 13) to (start + 0, 14)
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
Highest counter ID seen: c12
Highest counter ID seen: c11

10 changes: 5 additions & 5 deletions tests/coverage/continue.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
LL| 1| let is_true = std::env::args().len() == 1;
LL| |
LL| 1| let mut x = 0;
LL| 11| for _ in 0..10 {
LL| 1| for _ in 0..10 {
LL| 10| match is_true {
LL| | true => {
LL| 10| continue;
Expand All @@ -15,7 +15,7 @@
LL| | }
LL| 0| x = 3;
LL| | }
LL| 11| for _ in 0..10 {
LL| 1| for _ in 0..10 {
LL| 10| match is_true {
LL| 0| false => {
LL| 0| x = 1;
Expand All @@ -26,7 +26,7 @@
LL| | }
LL| 0| x = 3;
LL| | }
LL| 11| for _ in 0..10 {
LL| 1| for _ in 0..10 {
LL| 10| match is_true {
LL| 10| true => {
LL| 10| x = 1;
Expand All @@ -37,13 +37,13 @@
LL| | }
LL| 10| x = 3;
LL| | }
LL| 11| for _ in 0..10 {
LL| 1| for _ in 0..10 {
LL| 10| if is_true {
LL| 10| continue;
LL| 0| }
LL| 0| x = 3;
LL| | }
LL| 11| for _ in 0..10 {
LL| 1| for _ in 0..10 {
LL| 10| match is_true {
LL| 0| false => {
LL| 0| x = 1;
Expand Down
13 changes: 6 additions & 7 deletions tests/coverage/inline.cov-map
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Function name: inline::display::<char>
Raw bytes (36): 0x[01, 01, 01, 05, 01, 06, 01, 29, 01, 00, 21, 02, 01, 09, 00, 0a, 05, 00, 0e, 00, 10, 02, 00, 11, 02, 06, 01, 03, 05, 00, 0d, 01, 01, 01, 00, 02]
Raw bytes (36): 0x[01, 01, 01, 05, 01, 06, 01, 29, 01, 00, 21, 02, 01, 09, 00, 0a, 01, 00, 0e, 00, 10, 02, 00, 11, 02, 06, 01, 03, 05, 00, 0d, 01, 01, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/inline.rs
Number of expressions: 1
Expand All @@ -8,12 +8,12 @@ Number of file 0 mappings: 6
- Code(Counter(0)) at (prev + 41, 1) to (start + 0, 33)
- Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 10)
= (c1 - c0)
- Code(Counter(1)) at (prev + 0, 14) to (start + 0, 16)
- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 16)
- Code(Expression(0, Sub)) at (prev + 0, 17) to (start + 2, 6)
= (c1 - c0)
- Code(Counter(0)) at (prev + 3, 5) to (start + 0, 13)
- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2)
Highest counter ID seen: c1
Highest counter ID seen: c0

Function name: inline::error
Raw bytes (14): 0x[01, 01, 00, 02, 01, 31, 01, 00, 0b, 01, 01, 05, 00, 0b]
Expand Down Expand Up @@ -50,7 +50,7 @@ Number of file 0 mappings: 4
Highest counter ID seen: c0

Function name: inline::permutate::<char>
Raw bytes (142): 0x[01, 01, 0e, 01, 05, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 01, 37, 05, 09, 16, 01, 0f, 01, 00, 38, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 13, 01, 00, 14, 00, 16, 01, 01, 08, 00, 0e, 05, 00, 0f, 02, 06, 02, 02, 0f, 00, 14, 2e, 01, 0d, 00, 0e, 09, 00, 12, 00, 13, 09, 00, 15, 00, 16, 2e, 00, 17, 04, 0a, 2e, 01, 0d, 00, 11, 2e, 00, 12, 00, 14, 2e, 00, 16, 00, 17, 2e, 00, 19, 00, 1a, 2e, 01, 0d, 00, 16, 2e, 00, 17, 00, 19, 2e, 00, 1b, 00, 20, 2e, 01, 0d, 00, 11, 2e, 00, 12, 00, 14, 32, 02, 0c, 02, 06, 01, 03, 01, 00, 02]
Raw bytes (137): 0x[01, 01, 0e, 01, 05, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 0d, 09, 01, 37, 05, 09, 15, 01, 0f, 01, 00, 38, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 13, 01, 00, 14, 00, 16, 01, 01, 08, 00, 0e, 05, 00, 0f, 02, 06, 02, 02, 0f, 00, 14, 2e, 01, 0d, 00, 0e, 09, 00, 12, 00, 16, 2e, 00, 17, 04, 0a, 2e, 01, 0d, 00, 11, 2e, 00, 12, 00, 14, 2e, 00, 16, 00, 17, 2e, 00, 19, 00, 1a, 2e, 01, 0d, 00, 16, 2e, 00, 17, 00, 19, 2e, 00, 1b, 00, 20, 2e, 01, 0d, 00, 11, 2e, 00, 12, 00, 14, 32, 02, 0c, 02, 06, 01, 03, 01, 00, 02]
Number of files: 1
- file 0 => $DIR/inline.rs
Number of expressions: 14
Expand All @@ -68,7 +68,7 @@ Number of expressions: 14
- expression 11 operands: lhs = Counter(3), rhs = Counter(2)
- expression 12 operands: lhs = Counter(0), rhs = Expression(13, Add)
- expression 13 operands: lhs = Counter(1), rhs = Counter(2)
Number of file 0 mappings: 22
Number of file 0 mappings: 21
- Code(Counter(0)) at (prev + 15, 1) to (start + 0, 56)
- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10)
- Code(Counter(0)) at (prev + 0, 13) to (start + 0, 19)
Expand All @@ -79,8 +79,7 @@ Number of file 0 mappings: 22
= (c0 - c1)
- Code(Expression(11, Sub)) at (prev + 1, 13) to (start + 0, 14)
= (c3 - c2)
- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 19)
- Code(Counter(2)) at (prev + 0, 21) to (start + 0, 22)
- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 22)
- Code(Expression(11, Sub)) at (prev + 0, 23) to (start + 4, 10)
= (c3 - c2)
- Code(Expression(11, Sub)) at (prev + 1, 13) to (start + 0, 17)
Expand Down
6 changes: 3 additions & 3 deletions tests/coverage/inline.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
LL| 6| display(xs);
LL| 10| } else if k < n {
LL| 15| for i in k..n {
^10^10
^10
LL| 15| swap(xs, i, k);
LL| 15| permutate(xs, k + 1);
LL| 15| swap(xs, i, k);
Expand All @@ -40,8 +40,8 @@
LL| 30|}
LL| |
LL| 6|fn display<T: Display>(xs: &[T]) {
LL| 24| for x in xs {
^18
LL| 18| for x in xs {
^6
LL| 18| print!("{}", x);
LL| 18| }
LL| 6| println!();
Expand Down
Loading
Loading