From 69bc112e723d3117f81552aeee44e9f6beae3584 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 22 Jan 2015 15:21:46 -0500 Subject: [PATCH] Do not propagate the region requirements on the projected type to the input types it is being projected from. Fixes #21520. --- src/librustc_typeck/check/regionmanip.rs | 5 ---- src/test/run-pass/issue-21520.rs | 29 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/test/run-pass/issue-21520.rs diff --git a/src/librustc_typeck/check/regionmanip.rs b/src/librustc_typeck/check/regionmanip.rs index 8730858f66e..a1fc04f605b 100644 --- a/src/librustc_typeck/check/regionmanip.rs +++ b/src/librustc_typeck/check/regionmanip.rs @@ -123,11 +123,6 @@ impl<'a, 'tcx> Wf<'a, 'tcx> { // `>::Name` self.push_projection_constraint_from_top(data); - - // this seems like a minimal requirement: - let trait_def = ty::lookup_trait_def(self.tcx, data.trait_ref.def_id); - self.accumulate_from_adt(ty, data.trait_ref.def_id, - &trait_def.generics, data.trait_ref.substs) } ty::ty_tup(ref tuptys) => { diff --git a/src/test/run-pass/issue-21520.rs b/src/test/run-pass/issue-21520.rs new file mode 100644 index 00000000000..3a813641a3f --- /dev/null +++ b/src/test/run-pass/issue-21520.rs @@ -0,0 +1,29 @@ +// Copyright 2015 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. + +// Test that the requirement (in `Bar`) that `T::Bar : 'static` does +// not wind up propagating to `T`. + +pub trait Foo { + type Bar; + + fn foo(&self) -> Self; +} + +pub struct Static(T); + +struct Bar + where T::Bar : 'static +{ + x: Static> +} + +fn main() { } +