Change:
The code <pretrait T {} impl&lt;U: T&gt; Vec&lt;U&gt; {} fn main() { let r = Vec::fromslice(&[1u]); } </prefails with 4:36 error: unresolved name . fn main() { let r = Vec::from_slice(&[1u]); } </preRemoving the <codeimpl</codeline causes the code to compile fine. Thx Ms2ger for finding such a small example case.
I think this is related to anonymous modules appearing, resolves to a module due to the impl. If you change to this you get another interesting error:
Note that a workaround is to wrap in parens, as Then you get the correct error message about trying to on a type outside of its crate.
I've spent some time investigating this bug and I think that the cleanest thing to do is to (closed B-RFC right now, does anyone have a link to a relevant RFC?) and require to occur only in the same module as, and after, the definition of . This check would be done before creating the anonymous trait module with name . Otherwise in the case of where a definition of is not visible, is not resolved until typeck (at which point the compiler will complain if is defined outside the current crate, or not at all), but if there are resolve errors like the current bug, these will be exposed to the user first and halt compilation. The current behaviour upon encountering where has not been defined in the current module is to create a module (which shadows any other modules exposed by statements) and try to resolve any symbols into this module. This means that the current support for outside of the module is defined in is <ialready</ibroken. Consider for example will error out with "unresolved name ". I'm sure I could come up with other examples of currently broken behaviour like this.
the closing of that bug predates our RFC process, so there would not be a link to an RFC.
Interestingly, this breaks in the opposite direction if you qualify the :
My suggestion is that should be disallowed. I will submit an RFC with these changes.

Discussion:
match *name_bindings.type_def.borrow() { None => {} Some(ref ty) => { <del> let msg = format!("import `{}` conflicts with type in  this module", token::get_name(name).get()); self.session.span_err(import_span, msg.as_slice()); match ty.type_span { None => {} Some(span) => { self.session .span_note(span, "conflicting type here") </del> <ins> match ty.module_def { None => { let msg = format!("import `{}` conflicts with type in  this module", token::get_name(name).get()); self.session.span_err(import_span, msg.as_slice()); match ty.type_span { None => {} Some(span) => { self.session .span_note(span, "note conflicting type here") } } } Some(ref module_def) => { match module_def.kind.get() { ImplModuleKind => { match ty.type_span { None => { /* this can't ever happen */ } Some(span) => { let msg = format!("inherent implementations  are only allowed on types  defined in the current module"); self.session .span_err(span, msg.as_slice()); self.session .span_note(import_span, "import from other module here") } } } _ => { let msg = format!("import `{}` conflicts with existing  submodule", token::get_name(name).get()); self.session.span_err(import_span, msg.as_slice()); match ty.type_span { None => {} Some(span) => { self.session .span_note(span, "note conflicting module here") } } } } </ins> } } }

}); }); }); <ins> // Check that the current type is indeed a type, if we have an anonymous impl if opt_trait_reference.is_none() { match self_type.node { // TyPath is the only thing that we handled in `build_reduced_graph_for_item`, // where we created a module with the name of the type in order to implement // an anonymous trait. In the case that the path does not resolve to an actual // type, the result will be that the type name resolves to a module but not // a type (shadowing any imported modules or types with this name), leading // to weird user-visible bugs. So we ward this off here. See #15060. TyPath(ref path, _, path_id) => { match self.def_map.borrow().find(&path_id) { // FIXME: should we catch other options and give more precise errors? Some(&DefMod(_)) => { self.resolve_error(path.span, "inherent implementations are not  allowed for types not defined in  the current module."); } _ => {} } } _ => { } } } </ins> } fn check_trait_item(&self, ident: Ident, span: Span) {

<ins> // Copyright 2012 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. // ignore-tidy-linelength pub struct Foo; mod bar { use Foo; impl Foo { //~ERROR inherent implementations are only allowed on types defined in the current module fn baz(&self) {} } } fn main() {} </ins>

<ins> // Copyright 2012 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. // ignore-tidy-linelength struct Foo { x: int } impl Fo { //~ERROR inherent implementations are not allowed for types not defined in the current module. fn foo() {} } fn main() {} </ins>

<ins> // Copyright 2012 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. // ignore-tidy-linelength pub mod a { pub struct Foo { a: uint } } pub mod b { use a::Foo; impl Foo { //~ERROR inherent implementations are only allowed on types defined in the current module fn bar(&self) { } } } pub fn main() { } </ins>

<ins> // Copyright 2012 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. // ignore-tidy-linelength impl B { //~ERROR inherent implementations are not allowed for types not defined in the current module. } fn main() { } </ins>

// option. This file may not be copied, modified, or distributed // except according to those terms. <del> // FIXME(#8767) bad error message; Option is not a module impl<T> Option<T> { //~ERROR found module name used as a type </del> <ins> // ignore-tidy-linelength impl<T> Option<T> { //~ERROR inherent implementations are not allowed for types not defined in the current module. </ins> pub fn foo(&self) { } }