Skip to content

Commit 2acc3e7

Browse files
committed
add regression test for rust-lang#48071
Fixes rust-lang#48071
1 parent d9afd2b commit 2acc3e7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Regression test for #48071. This test used to ICE because -- in
12+
// the leak-check -- it would pass since we knew that the return type
13+
// was `'static`, and hence `'static: 'a` was legal even for a
14+
// placeholder region, but in NLL land it would fail because we had
15+
// rewritten `'static` to a region variable.
16+
//
17+
// compile-pass
18+
19+
#![allow(warnings)]
20+
#![feature(dyn_trait)]
21+
#![feature(nll)]
22+
23+
trait Foo {
24+
fn foo(&self) { }
25+
}
26+
27+
impl Foo for () {
28+
}
29+
30+
type MakeFooFn = for<'a> fn(&'a u8) -> Box<dyn Foo + 'a>;
31+
32+
fn make_foo(x: &u8) -> Box<dyn Foo + 'static> {
33+
Box::new(())
34+
}
35+
36+
fn main() {
37+
let x: MakeFooFn = make_foo as MakeFooFn;
38+
}

0 commit comments

Comments
 (0)