Skip to content

Commit

Permalink
shift bindings to accommodate new lifetime/dtor rules.
Browse files Browse the repository at this point in the history
(My fix to for-loops (21984) did not deal with similar problems in
if-let expressions, so those binding shifts stay.)
  • Loading branch information
pnkfelix committed Feb 11, 2015
1 parent 5936278 commit bdb9f3e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {

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

// Finally, search through external children.
if namespace == TypeNS {
if let Some(module) = module_.external_module_children.borrow().get(&name).cloned() {
// FIXME (21114): In principle unclear `child` *has* to be lifted.
let child = module_.external_module_children.borrow().get(&name).cloned();
if let Some(module) = child {
let name_bindings =
Rc::new(Resolver::create_name_bindings_from_module(module));
return Success((Target::new(module_,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
trait_def_id);

let trait_impls = self.tcx().trait_impls.borrow();
let impl_def_ids = match trait_impls.get(&trait_def_id) {
let impl_def_ids = trait_impls.get(&trait_def_id);
let impl_def_ids = match impl_def_ids {
None => { return; }
Some(impls) => impls,
};
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/old_io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
//! ```rust
//! use std::old_io as io;
//!
//! for line in io::stdin().lock().lines() {
//! let mut stdin = io::stdin();
//! for line in stdin.lock().lines() {
//! print!("{}", line.unwrap());
//! }
//! ```
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/old_io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ impl StdinReader {
/// ```rust
/// use std::old_io;
///
/// for line in old_io::stdin().lock().lines() {
/// let mut stdin = old_io::stdin();
/// for line in stdin.lock().lines() {
/// println!("{}", line.unwrap());
/// }
/// ```
Expand Down
3 changes: 2 additions & 1 deletion src/test/auxiliary/issue-2631-a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ pub type header_map = HashMap<String, Rc<RefCell<Vec<Rc<String>>>>>;

// the unused ty param is necessary so this gets monomorphized
pub fn request<T>(req: &header_map) {
let _x = req["METHOD".to_string()].clone().borrow().clone()[0].clone();
let data = req["METHOD".to_string()].clone();
let _x = data.borrow().clone()[0].clone();
}
4 changes: 3 additions & 1 deletion src/test/bench/shootout-k-nucleotide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ fn main() {
let fd = std::old_io::File::open(&Path::new("shootout-k-nucleotide.data"));
get_sequence(&mut std::old_io::BufferedReader::new(fd), ">THREE")
} else {
get_sequence(&mut *std::old_io::stdin().lock(), ">THREE")
let mut stdin = std::old_io::stdin();
let mut stdin = stdin.lock();
get_sequence(&mut *stdin, ">THREE")
};
let input = Arc::new(input);

Expand Down
4 changes: 3 additions & 1 deletion src/test/bench/sudoku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ fn main() {
let mut sudoku = if use_default {
Sudoku::from_vec(&DEFAULT_SUDOKU)
} else {
Sudoku::read(&mut *old_io::stdin().lock())
let mut stdin = old_io::stdin();
let mut stdin = stdin.lock();
Sudoku::read(&mut *stdin)
};
sudoku.solve();
sudoku.write(&mut old_io::stdout());
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-pass/issue-13304.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ fn parent() {
}

fn child() {
for line in old_io::stdin().lock().lines() {
let mut stdin = old_io::stdin();
for line in stdin.lock().lines() {
println!("{}", line.unwrap());
}
}
3 changes: 2 additions & 1 deletion src/test/run-pass/issue-14456.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ fn main() {
fn child() {
old_io::stdout().write_line("foo").unwrap();
old_io::stderr().write_line("bar").unwrap();
assert_eq!(old_io::stdin().lock().read_line().err().unwrap().kind, old_io::EndOfFile);
let mut stdin = old_io::stdin();
assert_eq!(stdin.lock().read_line().err().unwrap().kind, old_io::EndOfFile);
}

fn test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ impl Bar {

fn main() {
let b = RefCell::new(Bar);
b.borrow().foo()
b.borrow().foo();
}
3 changes: 2 additions & 1 deletion src/test/run-pass/overloaded-autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ struct Point {
}

pub fn main() {
let box_5 = box 5u;
assert_eq!(Rc::new(5u).to_uint(), Some(5));
assert_eq!((box &box &Rc::new(box box &box 5u)).to_uint(), Some(5));
assert_eq!((box &box &Rc::new(box box &box_5)).to_uint(), Some(5));
let point = Rc::new(Point {x: 2, y: 4});
assert_eq!(point.x, 2);
assert_eq!(point.y, 4);
Expand Down

0 comments on commit bdb9f3e

Please sign in to comment.