Skip to content

Commit f3b7197

Browse files
Rollup merge of rust-lang#44202 - alexcrichton:xcrate-generators, r=arielb1
rustc: Fix reachability with cross-crate generators Same solution as in f2df185 Closes rust-lang#44181
2 parents 5f00b10 + 41d3e83 commit f3b7197

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
447447
ty::TyProjection(ref proj) => Some(proj.item_def_id),
448448
ty::TyFnDef(def_id, ..) |
449449
ty::TyClosure(def_id, ..) |
450+
ty::TyGenerator(def_id, ..) |
450451
ty::TyAnon(def_id, _) => Some(def_id),
451452
_ => None
452453
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 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+
#![feature(conservative_impl_trait, generators, generator_trait)]
12+
13+
use std::ops::Generator;
14+
15+
fn msg() -> u32 {
16+
0
17+
}
18+
19+
pub fn foo() -> impl Generator<Yield=(), Return=u32> {
20+
|| {
21+
yield;
22+
return msg();
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2017 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+
// aux-build:xcrate-reachable.rs
12+
13+
#![feature(conservative_impl_trait, generator_trait)]
14+
15+
extern crate xcrate_reachable as foo;
16+
17+
use std::ops::Generator;
18+
19+
fn main() {
20+
foo::foo().resume();
21+
}

0 commit comments

Comments
 (0)