Skip to content

Commit

Permalink
Fallout to compile-fail tests.
Browse files Browse the repository at this point in the history
This change is worrisome to me, both because:

1. I thought the rules in RFC 599 imply that the `Box<Trait>` without `'static`
   in the first case would expand to the second case, but their behaviors
   here differ.  And,

2. The explicit handling of `'static` should mean `dropck` has no application
   here and thus we should have seen no change to the expected error messages.
   Nonetheless, the error messages changed.
  • Loading branch information
pnkfelix committed May 8, 2015
1 parent d8d4bb4 commit 0fa1c16
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/test/compile-fail/unboxed-closures-failed-recursive-fn-1.rs
Expand Up @@ -22,12 +22,24 @@ fn a() {
let mut factorial: Option<Box<Fn(u32) -> u32>> = None;

let f = |x: u32| -> u32 {
//~^ ERROR `factorial` does not live long enough
let g = factorial.as_ref().unwrap();
if x == 0 {1} else {x * g(x-1)}
};

factorial = Some(Box::new(f));
}

fn b() {
let mut factorial: Option<Box<Fn(u32) -> u32 + 'static>> = None;

let f = |x: u32| -> u32 {
//~^ ERROR closure may outlive the current function, but it borrows `factorial`
let g = factorial.as_ref().unwrap();
if x == 0 {1} else {x * g(x-1)}
};

factorial = Some(Box::new(f));
//~^ ERROR cannot assign to `factorial` because it is borrowed
}

fn main() { }

0 comments on commit 0fa1c16

Please sign in to comment.