Skip to content

Commit

Permalink
rustc: Fix reachability with cross-crate generators
Browse files Browse the repository at this point in the history
Same solution as in f2df185

Closes #44181
  • Loading branch information
alexcrichton committed Aug 31, 2017
1 parent 51a54b6 commit 41d3e83
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
24 changes: 24 additions & 0 deletions src/test/run-pass/generator/auxiliary/xcrate-reachable.rs
Original file line number Diff line number Diff line change
@@ -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();
}
}
21 changes: 21 additions & 0 deletions src/test/run-pass/generator/xcrate-reachable.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 41d3e83

Please sign in to comment.