mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
stop cross-crate associated types from being imported
Fixes #22968 Probably fixes #27602
This commit is contained in:
parent
2b45a0d908
commit
1dd0c058cf
@ -785,6 +785,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
|||||||
debug!("(building reduced graph for external \
|
debug!("(building reduced graph for external \
|
||||||
crate) building type {}", final_ident);
|
crate) building type {}", final_ident);
|
||||||
|
|
||||||
|
let modifiers = match new_parent.kind.get() {
|
||||||
|
NormalModuleKind => modifiers,
|
||||||
|
_ => modifiers & !DefModifiers::IMPORTABLE
|
||||||
|
};
|
||||||
|
|
||||||
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
|
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
|
||||||
}
|
}
|
||||||
DefStruct(def_id) => {
|
DefStruct(def_id) => {
|
||||||
|
@ -8,16 +8,22 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(associated_consts)]
|
||||||
|
|
||||||
pub use self::sub::{Bar, Baz};
|
pub use self::sub::{Bar, Baz};
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
fn foo(&self);
|
fn foo(&self);
|
||||||
|
type Assoc;
|
||||||
|
const CONST: u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
pub fn new() {}
|
pub fn new() {}
|
||||||
|
|
||||||
|
pub const C: u32 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod sub {
|
mod sub {
|
||||||
|
@ -15,9 +15,18 @@ extern crate use_from_trait_xc;
|
|||||||
use use_from_trait_xc::Trait::foo;
|
use use_from_trait_xc::Trait::foo;
|
||||||
//~^ ERROR `foo` is not directly importable
|
//~^ ERROR `foo` is not directly importable
|
||||||
|
|
||||||
|
use use_from_trait_xc::Trait::Assoc;
|
||||||
|
//~^ ERROR `Assoc` is not directly importable
|
||||||
|
|
||||||
|
use use_from_trait_xc::Trait::CONST;
|
||||||
|
//~^ ERROR `CONST` is not directly importable
|
||||||
|
|
||||||
use use_from_trait_xc::Foo::new;
|
use use_from_trait_xc::Foo::new;
|
||||||
//~^ ERROR `new` is not directly importable
|
//~^ ERROR `new` is not directly importable
|
||||||
|
|
||||||
|
use use_from_trait_xc::Foo::C;
|
||||||
|
//~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
|
||||||
|
|
||||||
use use_from_trait_xc::Bar::new as bnew;
|
use use_from_trait_xc::Bar::new as bnew;
|
||||||
//~^ ERROR `bnew` is not directly importable
|
//~^ ERROR `bnew` is not directly importable
|
||||||
|
|
||||||
|
@ -8,19 +8,32 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(associated_consts)]
|
||||||
|
|
||||||
use Trait::foo;
|
use Trait::foo;
|
||||||
//~^ ERROR `foo` is not directly importable
|
//~^ ERROR `foo` is not directly importable
|
||||||
|
use Trait::Assoc;
|
||||||
|
//~^ ERROR `Assoc` is not directly importable
|
||||||
|
use Trait::C;
|
||||||
|
//~^ ERROR `C` is not directly importable
|
||||||
|
|
||||||
use Foo::new;
|
use Foo::new;
|
||||||
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
|
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
|
||||||
|
|
||||||
|
use Foo::C2;
|
||||||
|
//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo`
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
fn foo();
|
fn foo();
|
||||||
|
type Assoc;
|
||||||
|
const C: u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn new() {}
|
fn new() {}
|
||||||
|
const C2: u32 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user