@@ -1807,41 +1807,40 @@ 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 if path_res. base_def == Def :: Err {
1814- Err ( true )
1815- } else {
1816- let mut err =
1817- resolve_struct_error ( self ,
1818- trait_path. span ,
1819- ResolutionError :: IsNotATrait ( & path_names_to_string ( trait_path,
1820- path_depth) ) ) ;
1821-
1822- // If it's a typedef, give a note
1823- if let Def :: TyAlias ( ..) = path_res. base_def {
1824- let trait_name = trait_path. segments . last ( ) . unwrap ( ) . identifier . name ;
1825- err. span_label ( trait_path. span ,
1826- & format ! ( "`{}` is not a trait" , trait_name) ) ;
1827-
1828- let definition_site = {
1829- let segments = & trait_path. segments ;
1830- if trait_path. global {
1831- self . resolve_crate_relative_path ( trait_path. span , segments, TypeNS )
1832- } else {
1833- self . resolve_module_relative_path ( trait_path. span , segments, TypeNS )
1834- } . map ( |binding| binding. span ) . unwrap_or ( syntax_pos:: DUMMY_SP )
1835- } ;
1810+ match path_res. base_def {
1811+ Def :: Trait ( _) => {
1812+ debug ! ( "(resolving trait) found trait def: {:?}" , path_res) ;
1813+ return Ok ( path_res) ;
1814+ }
1815+ Def :: Err => return Err ( true ) ,
1816+ _ => { }
1817+ }
18361818
1837- if definition_site != syntax_pos:: DUMMY_SP {
1838- err. span_label ( definition_site,
1839- & format ! ( "type aliases cannot be used for traits" ) ) ;
1840- }
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+ let trait_name = trait_path. segments . last ( ) . unwrap ( ) . identifier . name ;
1826+ err. span_label ( trait_path. span , & format ! ( "`{}` is not a trait" , trait_name) ) ;
1827+
1828+ let definition_site = {
1829+ let segments = & trait_path. segments ;
1830+ if trait_path. global {
1831+ self . resolve_crate_relative_path ( trait_path. span , segments, TypeNS )
1832+ } else {
1833+ self . resolve_module_relative_path ( trait_path. span , segments, TypeNS )
1834+ } . map ( |binding| binding. span ) . unwrap_or ( syntax_pos:: DUMMY_SP )
1835+ } ;
1836+
1837+ if definition_site != syntax_pos:: DUMMY_SP {
1838+ err. span_label ( definition_site,
1839+ & format ! ( "type aliases cannot be used for traits" ) ) ;
18411840 }
1842- err. emit ( ) ;
1843- Err ( true )
18441841 }
1842+ err. emit ( ) ;
1843+ Err ( true )
18451844 } ) . map_err ( |error_reported| {
18461845 if error_reported { return }
18471846
0 commit comments