Skip to content

Commit 41d3e83

Browse files
committed
rustc: Fix reachability with cross-crate generators
Same solution as in f2df185 Closes #44181
1 parent 51a54b6 commit 41d3e83

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/librustc_privacy/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
446446
ty::TyProjection(ref proj) => Some(proj.item_def_id),
447447
ty::TyFnDef(def_id, ..) |
448448
ty::TyClosure(def_id, ..) |
449+
ty::TyGenerator(def_id, ..) |
449450
ty::TyAnon(def_id, _) => Some(def_id),
450451
_ => None
451452
};
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+
}
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)