Skip to content

Commit bdb9f3e

Browse files
committed
shift bindings to accommodate new lifetime/dtor rules.
(My fix to for-loops (21984) did not deal with similar problems in if-let expressions, so those binding shifts stay.)
1 parent 5936278 commit bdb9f3e

File tree

11 files changed

+27
-12
lines changed

11 files changed

+27
-12
lines changed

src/librustc_resolve/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21962196

21972197
// Search for external modules.
21982198
if namespace == TypeNS {
2199-
if let Some(module) = module_.external_module_children.borrow().get(&name).cloned() {
2199+
// FIXME (21114): In principle unclear `child` *has* to be lifted.
2200+
let child = module_.external_module_children.borrow().get(&name).cloned();
2201+
if let Some(module) = child {
22002202
let name_bindings =
22012203
Rc::new(Resolver::create_name_bindings_from_module(module));
22022204
debug!("lower name bindings succeeded");
@@ -2481,7 +2483,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
24812483

24822484
// Finally, search through external children.
24832485
if namespace == TypeNS {
2484-
if let Some(module) = module_.external_module_children.borrow().get(&name).cloned() {
2486+
// FIXME (21114): In principle unclear `child` *has* to be lifted.
2487+
let child = module_.external_module_children.borrow().get(&name).cloned();
2488+
if let Some(module) = child {
24852489
let name_bindings =
24862490
Rc::new(Resolver::create_name_bindings_from_module(module));
24872491
return Success((Target::new(module_,

src/librustc_typeck/check/method/probe.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
525525
trait_def_id);
526526

527527
let trait_impls = self.tcx().trait_impls.borrow();
528-
let impl_def_ids = match trait_impls.get(&trait_def_id) {
528+
let impl_def_ids = trait_impls.get(&trait_def_id);
529+
let impl_def_ids = match impl_def_ids {
529530
None => { return; }
530531
Some(impls) => impls,
531532
};

src/libstd/old_io/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
//! ```rust
5151
//! use std::old_io as io;
5252
//!
53-
//! for line in io::stdin().lock().lines() {
53+
//! let mut stdin = io::stdin();
54+
//! for line in stdin.lock().lines() {
5455
//! print!("{}", line.unwrap());
5556
//! }
5657
//! ```

src/libstd/old_io/stdio.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ impl StdinReader {
143143
/// ```rust
144144
/// use std::old_io;
145145
///
146-
/// for line in old_io::stdin().lock().lines() {
146+
/// let mut stdin = old_io::stdin();
147+
/// for line in stdin.lock().lines() {
147148
/// println!("{}", line.unwrap());
148149
/// }
149150
/// ```

src/test/auxiliary/issue-2631-a.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ pub type header_map = HashMap<String, Rc<RefCell<Vec<Rc<String>>>>>;
1919

2020
// the unused ty param is necessary so this gets monomorphized
2121
pub fn request<T>(req: &header_map) {
22-
let _x = req["METHOD".to_string()].clone().borrow().clone()[0].clone();
22+
let data = req["METHOD".to_string()].clone();
23+
let _x = data.borrow().clone()[0].clone();
2324
}

src/test/bench/shootout-k-nucleotide.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ fn main() {
295295
let fd = std::old_io::File::open(&Path::new("shootout-k-nucleotide.data"));
296296
get_sequence(&mut std::old_io::BufferedReader::new(fd), ">THREE")
297297
} else {
298-
get_sequence(&mut *std::old_io::stdin().lock(), ">THREE")
298+
let mut stdin = std::old_io::stdin();
299+
let mut stdin = stdin.lock();
300+
get_sequence(&mut *stdin, ">THREE")
299301
};
300302
let input = Arc::new(input);
301303

src/test/bench/sudoku.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ fn main() {
274274
let mut sudoku = if use_default {
275275
Sudoku::from_vec(&DEFAULT_SUDOKU)
276276
} else {
277-
Sudoku::read(&mut *old_io::stdin().lock())
277+
let mut stdin = old_io::stdin();
278+
let mut stdin = stdin.lock();
279+
Sudoku::read(&mut *stdin)
278280
};
279281
sudoku.solve();
280282
sudoku.write(&mut old_io::stdout());

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ fn parent() {
3737
}
3838

3939
fn child() {
40-
for line in old_io::stdin().lock().lines() {
40+
let mut stdin = old_io::stdin();
41+
for line in stdin.lock().lines() {
4142
println!("{}", line.unwrap());
4243
}
4344
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ fn main() {
2727
fn child() {
2828
old_io::stdout().write_line("foo").unwrap();
2929
old_io::stderr().write_line("bar").unwrap();
30-
assert_eq!(old_io::stdin().lock().read_line().err().unwrap().kind, old_io::EndOfFile);
30+
let mut stdin = old_io::stdin();
31+
assert_eq!(stdin.lock().read_line().err().unwrap().kind, old_io::EndOfFile);
3132
}
3233

3334
fn test() {

src/test/run-pass/multidispatch-conditional-impl-not-considered.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ impl Bar {
2929

3030
fn main() {
3131
let b = RefCell::new(Bar);
32-
b.borrow().foo()
32+
b.borrow().foo();
3333
}

src/test/run-pass/overloaded-autoderef.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ struct Point {
2222
}
2323

2424
pub fn main() {
25+
let box_5 = box 5u;
2526
assert_eq!(Rc::new(5u).to_uint(), Some(5));
26-
assert_eq!((box &box &Rc::new(box box &box 5u)).to_uint(), Some(5));
27+
assert_eq!((box &box &Rc::new(box box &box_5)).to_uint(), Some(5));
2728
let point = Rc::new(Point {x: 2, y: 4});
2829
assert_eq!(point.x, 2);
2930
assert_eq!(point.y, 4);

0 commit comments

Comments
 (0)