From 2acc3e7ce10012cb1ad41f139c1a58b2e97cbe7f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 25 Jul 2018 00:27:01 +0300 Subject: [PATCH] add regression test for #48071 Fixes #48071 --- src/test/ui/nll/relate_tys/issue-48071.rs | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/ui/nll/relate_tys/issue-48071.rs diff --git a/src/test/ui/nll/relate_tys/issue-48071.rs b/src/test/ui/nll/relate_tys/issue-48071.rs new file mode 100644 index 00000000000..c2498cbe50f --- /dev/null +++ b/src/test/ui/nll/relate_tys/issue-48071.rs @@ -0,0 +1,38 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #48071. This test used to ICE because -- in +// the leak-check -- it would pass since we knew that the return type +// was `'static`, and hence `'static: 'a` was legal even for a +// placeholder region, but in NLL land it would fail because we had +// rewritten `'static` to a region variable. +// +// compile-pass + +#![allow(warnings)] +#![feature(dyn_trait)] +#![feature(nll)] + +trait Foo { + fn foo(&self) { } +} + +impl Foo for () { +} + +type MakeFooFn = for<'a> fn(&'a u8) -> Box; + +fn make_foo(x: &u8) -> Box { + Box::new(()) +} + +fn main() { + let x: MakeFooFn = make_foo as MakeFooFn; +}