Skip to content

Commit 82169af

Browse files
committed
Auto merge of #27698 - arielb1:foreign-type-import, r=alexcrichton
Fixes #22968 Probably fixes #27602 (the issue needs a reproduction) r? @alexcrichton
2 parents 6a5c4e7 + 1dd0c05 commit 82169af

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/librustc_resolve/build_reduced_graph.rs

+5
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
785785
debug!("(building reduced graph for external \
786786
crate) building type {}", final_ident);
787787

788+
let modifiers = match new_parent.kind.get() {
789+
NormalModuleKind => modifiers,
790+
_ => modifiers & !DefModifiers::IMPORTABLE
791+
};
792+
788793
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
789794
}
790795
DefStruct(def_id) => {

src/test/auxiliary/use_from_trait_xc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(associated_consts)]
12+
1113
pub use self::sub::{Bar, Baz};
1214

1315
pub trait Trait {
1416
fn foo(&self);
17+
type Assoc;
18+
const CONST: u32;
1519
}
1620

1721
struct Foo;
1822

1923
impl Foo {
2024
pub fn new() {}
25+
26+
pub const C: u32 = 0;
2127
}
2228

2329
mod sub {

src/test/compile-fail/use-from-trait-xc.rs

+9
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ extern crate use_from_trait_xc;
1515
use use_from_trait_xc::Trait::foo;
1616
//~^ ERROR `foo` is not directly importable
1717

18+
use use_from_trait_xc::Trait::Assoc;
19+
//~^ ERROR `Assoc` is not directly importable
20+
21+
use use_from_trait_xc::Trait::CONST;
22+
//~^ ERROR `CONST` is not directly importable
23+
1824
use use_from_trait_xc::Foo::new;
1925
//~^ ERROR `new` is not directly importable
2026

27+
use use_from_trait_xc::Foo::C;
28+
//~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
29+
2130
use use_from_trait_xc::Bar::new as bnew;
2231
//~^ ERROR `bnew` is not directly importable
2332

src/test/compile-fail/use-from-trait.rs

+13
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,32 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(associated_consts)]
12+
1113
use Trait::foo;
1214
//~^ ERROR `foo` is not directly importable
15+
use Trait::Assoc;
16+
//~^ ERROR `Assoc` is not directly importable
17+
use Trait::C;
18+
//~^ ERROR `C` is not directly importable
19+
1320
use Foo::new;
1421
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
1522

23+
use Foo::C2;
24+
//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo`
25+
1626
pub trait Trait {
1727
fn foo();
28+
type Assoc;
29+
const C: u32;
1830
}
1931

2032
struct Foo;
2133

2234
impl Foo {
2335
fn new() {}
36+
const C2: u32 = 0;
2437
}
2538

2639
fn main() {}

0 commit comments

Comments
 (0)