rustc: Fix reachability with cross-crate generators

Same solution as in f2df1857

Closes #44181
This commit is contained in:
Alex Crichton 2017-08-30 17:32:21 -07:00
parent 51a54b6dc0
commit 41d3e83183
3 changed files with 46 additions and 0 deletions

View File

@ -446,6 +446,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
ty::TyProjection(ref proj) => Some(proj.item_def_id),
ty::TyFnDef(def_id, ..) |
ty::TyClosure(def_id, ..) |
ty::TyGenerator(def_id, ..) |
ty::TyAnon(def_id, _) => Some(def_id),
_ => None
};

View File

@ -0,0 +1,24 @@
// 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.
#![feature(conservative_impl_trait, generators, generator_trait)]
use std::ops::Generator;
fn msg() -> u32 {
0
}
pub fn foo() -> impl Generator<Yield=(), Return=u32> {
|| {
yield;
return msg();
}
}

View File

@ -0,0 +1,21 @@
// 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.
// aux-build:xcrate-reachable.rs
#![feature(conservative_impl_trait, generator_trait)]
extern crate xcrate_reachable as foo;
use std::ops::Generator;
fn main() {
foo::foo().resume();
}