Skip to content

Commit

Permalink
rustc: T: 'empty always holds forall T.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 6, 2017
1 parent c94a9ac commit ec7195f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc/infer/region_inference/mod.rs
Expand Up @@ -1200,6 +1200,13 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
for verify in self.verifys.borrow().iter() {
debug!("collect_errors: verify={:?}", verify);
let sub = normalize(self.tcx, var_data, verify.region);

// This was an inference variable which didn't get
// constrained, therefore it can be assume to hold.
if let ty::ReEmpty = *sub {
continue;
}

if verify.bound.is_met(region_rels, var_data, sub) {
continue;
}
Expand Down
32 changes: 32 additions & 0 deletions src/test/run-pass/issue-42467.rs
@@ -0,0 +1,32 @@
// Copyright 2017 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Foo<T>(T);

struct IntoIter<T>(T);

impl<'a, T: 'a> Iterator for IntoIter<T> {
type Item = ();

fn next(&mut self) -> Option<()> {
None
}
}

impl<T> IntoIterator for Foo<T> {
type Item = ();
type IntoIter = IntoIter<T>;

fn into_iter(self) -> IntoIter<T> {
IntoIter(self.0)
}
}

fn main() {}

0 comments on commit ec7195f

Please sign in to comment.