Skip to content

Commit 83c4505

Browse files
committed
Fix issue rust-lang#50415.
1 parent 698b956 commit 83c4505

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/librustc/hir/lowering.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3121,9 +3121,9 @@ impl<'a> LoweringContext<'a> {
31213121
}
31223122
// Desugar `<start>..=<end>` to `std::ops::RangeInclusive::new(<start>, <end>)`
31233123
ExprKind::Range(Some(ref e1), Some(ref e2), RangeLimits::Closed) => {
3124-
// FIXME: Use head_sp directly after RangeInclusive::new() is stabilized in stage0.
3124+
// FIXME: Use e.span directly after RangeInclusive::new() is stabilized in stage0.
31253125
let span = self.allow_internal_unstable(CompilerDesugaringKind::DotFill, e.span);
3126-
let id = self.lower_node_id(e.id);
3126+
let id = self.next_id();
31273127
let e1 = self.lower_expr(e1);
31283128
let e2 = self.lower_expr(e2);
31293129
let ty_path = P(self.std_path(span, &["ops", "RangeInclusive"], false));

src/test/run-pass/issue-50415.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
// -------- Simplified test case --------
13+
14+
let _ = || 0..=1;
15+
16+
// -------- Original test case --------
17+
18+
let full_length = 1024;
19+
let range = {
20+
// do some stuff, omit here
21+
None
22+
};
23+
24+
let range = range.map(|(s, t)| s..=t).unwrap_or(0..=(full_length-1));
25+
26+
assert_eq!(range, 0..=1023);
27+
}

0 commit comments

Comments
 (0)