Skip to content

Commit

Permalink
fixes for new rules for lifetimes and destructors.
Browse files Browse the repository at this point in the history
note that some of these cases may actually be fixes to latent bugs, in
some sense (depending on what our guarantees are about e.g. what a
hashmap should be allowed to access in its own destructor).
  • Loading branch information
pnkfelix committed Jan 12, 2015
1 parent c5dde23 commit 56c39ae
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/libregex/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ impl<'r, 't> Nfa<'r, 't> {
};
let mut matched = false;
let ninsts = self.prog.insts.len();
let mut clist = &mut Threads::new(self.which, ninsts, ncaps);
let mut nlist = &mut Threads::new(self.which, ninsts, ncaps);
let mut cthread = Threads::new(self.which, ninsts, ncaps);
let mut nthread = Threads::new(self.which, ninsts, ncaps);
let mut clist = &mut cthread;
let mut nlist = &mut nthread;

let mut groups: Vec<_> = repeat(None).take(ncaps * 2).collect();

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();

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Jan 13, 2015

oh dear me what a chain!

let data = req["METHOD".to_string()].clone();
let _x = data.borrow().clone()[0].clone();
}
5 changes: 3 additions & 2 deletions 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 io::stdin().lock().lines() {
let mut stdin = io::stdin();
for line in stdin.lock().lines() {
println!("{}", line.unwrap());
}
};

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Jan 13, 2015

This semicolon is needed so that the for loop is not the tail expression? Man, it's really unfortunate, though of course I see why.

This comment has been minimized.

Copy link
@pnkfelix

pnkfelix Jan 13, 2015

Author Owner

yeah, that's an example of a problem that I was debating about trying to investigate before putting this up for review. But right now I think we'd be better off trying to land this with this wart, and filing a bug to look into "fixing" this (or establishing that it actually makes sense at some fundamental level, which seems unlikely at least in this context).

This comment has been minimized.

Copy link
@pnkfelix

pnkfelix Feb 2, 2015

Author Owner

(for-loops are now implemented via a rewrite to more primitive expressions; it is actually easier to put in the fix for this now than it was before. This will be tracked on rust-lang#21114)

}
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() {
io::stdout().write_line("foo").unwrap();
io::stderr().write_line("bar").unwrap();
assert_eq!(io::stdin().lock().read_line().err().unwrap().kind, io::EndOfFile);
let mut stdin = io::stdin();
assert_eq!(stdin.lock().read_line().err().unwrap().kind, io::EndOfFile);
}

fn test() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/issue-3026.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern crate collections;
use std::collections::HashMap;

pub fn main() {
let mut buggy_map: HashMap<uint, &uint> = HashMap::new();
let x = box 1;
let mut buggy_map: HashMap<uint, &uint> = HashMap::new();
buggy_map.insert(42, &*x);
}
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();
}

1 comment on commit 56c39ae

@nikomatsakis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. hmm, not bad, all things considered. The need to occasionally throw in a semicolon is prob ok but I woner how obvious it is from the error messages?

Please sign in to comment.