Skip to content

Commit 5438f58

Browse files
committed
Use inner ctxt when lowering ExprKind::Paren
1 parent 9e13cd3 commit 5438f58

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
272272
ExprKind::Paren(ref ex) => {
273273
let mut ex = self.lower_expr_mut(ex);
274274
// Include parens in span, but only if it is a super-span.
275+
// Use the inner ctxt to maintain desugaring marker for `(a..b)`
275276
if e.span.contains(ex.span) {
276-
ex.span = self.lower_span(e.span);
277+
ex.span = self.lower_span(e.span.with_ctxt(ex.span.ctxt()));
277278
}
278279
// Merge attributes into the inner expression.
279280
if !e.attrs.is_empty() {

src/test/ui/iterators/collect-into-array.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator
2-
--> $DIR/collect-into-array.rs:3:31
2+
--> $DIR/collect-into-array.rs:3:32
33
|
44
LL | let whatever: [u32; 10] = (0..10).collect();
5-
| ^^^^^^^ ------- required by a bound introduced by this call
6-
| |
7-
| try collecting into a `Vec<{integer}>`, then using `.try_into()`
5+
| ^^^^^ ------- required by a bound introduced by this call
6+
| |
7+
| try collecting into a `Vec<{integer}>`, then using `.try_into()`
88
|
99
= help: the trait `FromIterator<{integer}>` is not implemented for `[u32; 10]`
1010
note: required by a bound in `collect`

src/test/ui/iterators/collect-into-slice.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
2222
| ^ required by this bound in `collect`
2323

2424
error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
25-
--> $DIR/collect-into-slice.rs:8:30
25+
--> $DIR/collect-into-slice.rs:8:31
2626
|
2727
LL | let some_generated_vec = (0..10).collect();
28-
| ^^^^^^^ ------- required by a bound introduced by this call
29-
| |
30-
| try explicitly collecting into a `Vec<{integer}>`
28+
| ^^^^^ ------- required by a bound introduced by this call
29+
| |
30+
| try explicitly collecting into a `Vec<{integer}>`
3131
|
3232
= help: the trait `FromIterator<{integer}>` is not implemented for `[i32]`
3333
note: required by a bound in `collect`

0 commit comments

Comments
 (0)