@@ -1807,39 +1807,25 @@ impl<'a> Resolver<'a> {
18071807 path_depth : usize )
18081808 -> Result < PathResolution , ( ) > {
18091809 self . resolve_path ( id, trait_path, path_depth, TypeNS ) . and_then ( |path_res| {
1810- if let Def :: Trait ( _) = path_res. base_def {
1811- debug ! ( "(resolving trait) found trait def: {:?}" , path_res) ;
1812- Ok ( path_res)
1813- } else {
1814- let mut err =
1815- resolve_struct_error ( self ,
1816- trait_path. span ,
1817- ResolutionError :: IsNotATrait ( & path_names_to_string ( trait_path,
1818- path_depth) ) ) ;
1819-
1820- // If it's a typedef, give a note
1821- if let Def :: TyAlias ( ..) = path_res. base_def {
1822- let trait_name = trait_path. segments . last ( ) . unwrap ( ) . identifier . name ;
1823- err. span_label ( trait_path. span ,
1824- & format ! ( "`{}` is not a trait" , trait_name) ) ;
1825-
1826- let definition_site = {
1827- let segments = & trait_path. segments ;
1828- if trait_path. global {
1829- self . resolve_crate_relative_path ( trait_path. span , segments, TypeNS )
1830- } else {
1831- self . resolve_module_relative_path ( trait_path. span , segments, TypeNS )
1832- } . map ( |binding| binding. span ) . unwrap_or ( syntax_pos:: DUMMY_SP )
1833- } ;
1834-
1835- if definition_site != syntax_pos:: DUMMY_SP {
1836- err. span_label ( definition_site,
1837- & format ! ( "type aliases cannot be used for traits" ) ) ;
1838- }
1810+ match path_res. base_def {
1811+ Def :: Trait ( _) => {
1812+ debug ! ( "(resolving trait) found trait def: {:?}" , path_res) ;
1813+ return Ok ( path_res) ;
18391814 }
1840- err. emit ( ) ;
1841- Err ( true )
1815+ Def :: Err => return Err ( true ) ,
1816+ _ => { }
1817+ }
1818+
1819+ let mut err = resolve_struct_error ( self , trait_path. span , {
1820+ ResolutionError :: IsNotATrait ( & path_names_to_string ( trait_path, path_depth) )
1821+ } ) ;
1822+
1823+ // If it's a typedef, give a note
1824+ if let Def :: TyAlias ( ..) = path_res. base_def {
1825+ err. note ( & format ! ( "type aliases cannot be used for traits" ) ) ;
18421826 }
1827+ err. emit ( ) ;
1828+ Err ( true )
18431829 } ) . map_err ( |error_reported| {
18441830 if error_reported { return }
18451831
0 commit comments