Fallout to compile-fail tests.

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.
This commit is contained in:
Felix S. Klock II 2015-05-08 16:08:59 +02:00
parent d8d4bb4ce3
commit 0fa1c1662f

View file

@ -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() { }