Change:
This code is wrong because ToStr does not define . But what's odd is that the compiler error does not happen in the block but in the : Error message: The expected error message would point to the block that needs to be split into two (one with ToStr and one without a trait).
Reproduced as of
Repro'd with -- but not critical for 0.6, de-milestoning
Appears to be fixed, as per this updated test case: fails with . Closing.
We've regressed: there's a test case (), but it's been xfailed since it was . With I see:
Aaaand, we've un-regressed! Removing all tags except for neesdtest.
Whoops, had the wrong code example, regression still here.

Discussion:
self.resolve_error(trait_reference.path.span, msg.as_slice()); } Some(def) => { <del> debug!("(resolving trait) found trait def: {:?}", def); self.record_def(trait_reference.ref_id, def); </del> <ins> match def { (DefTrait(_), _) => { debug!("(resolving trait) found trait def: {:?}", def); self.record_def(trait_reference.ref_id, def); } (def, _) => { self.resolve_error(trait_reference.path.span, format!("`{}` is not a trait", self.path_idents_to_str( &trait_reference.path))); // If it's a typedef, give a note match def { DefTy(_) => { self.session.span_note( trait_reference.path.span, format!("`type` aliases cannot  be used for traits") .as_slice()); } _ => {} } } } </ins> } } }

this.with_current_self_type(self_type, |this| { for method in methods.iter() { <ins> // If this is a trait impl, ensure the method exists in trait this.check_trait_method(&**method); </ins> // We also need a new scope for the method-specific type parameters. this.resolve_method(MethodRibKind(id, Provided(method.id)), &**method);

}); } <ins> fn check_trait_method(&self, method: &Method) { // If there is a TraitRef in scope for an impl, then the method must be in the trait. for &(did, ref trait_ref) in self.current_trait_ref.iter() { let method_name = method.ident.name; if self.method_map.borrow().find(&(method_name, did)).is_none() { let path_str = self.path_idents_to_str(&trait_ref.path); self.resolve_error(method.span, format!("method `{}` is not a member of trait `{}`", token::get_name(method_name), path_str).as_slice()); } } } </ins> fn resolve_module(&mut self, module: &Mod, _span: Span, _name: Ident, id: NodeId) { // Write the implementations in scope into the module metadata.

&impl_trait_ref.substs); } None => { <del> tcx.sess.span_err( </del> <ins> // This is span_bug as it should have already been caught in resolve. tcx.sess.span_bug( </ins> impl_method.span, format!( "method `{}` is not a member of trait `{}`",

<ins> // Copyright 2013-2014 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:issue_3907.rs extern crate issue_3907; type Foo = issue_3907::Foo; //~ ERROR: reference to trait struct S { name: int } fn main() {} </ins>

<del> // Copyright 2013 The Rust Project Developers. See the COPYRIGHT </del> <ins> // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT </ins> // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //

// aux-build:issue_3907.rs extern crate issue_3907; <del> type Foo = issue_3907::Foo; //~ ERROR: reference to trait </del> <ins> type Foo = issue_3907::Foo; </ins> struct S { name: int } impl Foo for S { //~ ERROR: `Foo` is not a trait <ins> //~^ NOTE: `type` aliases cannot be used for traits </ins> fn bar() { } }

// option. This file may not be copied, modified, or distributed // except according to those terms. <del> // ignore-test use std::io; </del> struct Point { x: f64, y: f64, } <del> impl ToStr for Point { //~ ERROR implements a method not defined in the trait </del> <ins> trait NewTrait { fn a(&self) -> String; } impl NewTrait for Point { </ins> fn new(x: f64, y: f64) -> Point { <ins> //~^ ERROR method `new` is not a member of trait `NewTrait` </ins> Point { x: x, y: y } } <del> fn to_str(&self) -> String { </del> <ins> fn a(&self) -> String { </ins> format!("({}, {})", self.x, self.y) } } fn main() { let p = Point::new(0.0, 0.0); <del> println!("{}", p.to_str()); </del> <ins> //~^ ERROR unresolved name `Point::new` //~^^ ERROR failed to resolve. Use of undeclared module `Point` println!("{}", p.a()); </ins> }

<ins> // Copyright 2013-2014 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. trait I {} type K = I; //~ ERROR: reference to trait fn main() {} </ins>

// except according to those terms. trait I {} <del> type K = I; //~ ERROR: reference to trait </del> <ins> type K = I; </ins> impl K for int {} //~ ERROR: `K` is not a trait <ins> //~^ NOTE: `type` aliases cannot be used for traits </ins> fn main() {}