@@ -1633,19 +1633,17 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
16331633 * def = module. def ( ) . unwrap ( ) ,
16341634 PathResult :: NonModule ( path_res) if path_res. unresolved_segments ( ) == 0 =>
16351635 * def = path_res. base_def ( ) ,
1636- PathResult :: NonModule ( ..) => match self . resolve_path (
1637- None ,
1638- & path ,
1639- None ,
1640- true ,
1641- span ,
1642- CrateLint :: No ,
1643- ) {
1644- PathResult :: Failed ( span , msg , _ ) => {
1636+ PathResult :: NonModule ( ..) =>
1637+ if let PathResult :: Failed ( span , msg , _ ) = self . resolve_path (
1638+ None ,
1639+ & path ,
1640+ None ,
1641+ true ,
1642+ span ,
1643+ CrateLint :: No ,
1644+ ) {
16451645 error_callback ( self , span, ResolutionError :: FailedToResolve ( & msg) ) ;
1646- }
1647- _ => { }
1648- } ,
1646+ } ,
16491647 PathResult :: Module ( ModuleOrUniformRoot :: UniformRoot ( _) ) |
16501648 PathResult :: Indeterminate => unreachable ! ( ) ,
16511649 PathResult :: Failed ( span, msg, _) => {
@@ -2357,7 +2355,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
23572355 span : prefix. span . to ( use_tree. prefix . span ) ,
23582356 } ;
23592357
2360- if items. len ( ) == 0 {
2358+ if items. is_empty ( ) {
23612359 // Resolve prefix of an import with empty braces (issue #28388).
23622360 self . smart_resolve_path_with_crate_lint (
23632361 id,
@@ -2696,7 +2694,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
26962694
26972695 let map_j = self . binding_mode_map ( & q) ;
26982696 for ( & key, & binding_i) in & map_i {
2699- if map_j. len ( ) == 0 { // Account for missing bindings when
2697+ if map_j. is_empty ( ) { // Account for missing bindings when
27002698 let binding_error = missing_vars // map_j has none.
27012699 . entry ( key. name )
27022700 . or_insert ( BindingError {
@@ -2757,9 +2755,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
27572755 // This has to happen *after* we determine which pat_idents are variants
27582756 self . check_consistent_bindings ( & arm. pats ) ;
27592757
2760- match arm. guard {
2761- Some ( ast:: Guard :: If ( ref expr) ) => self . visit_expr ( expr) ,
2762- _ => { }
2758+ if let Some ( ast:: Guard :: If ( ref expr) ) = arm. guard {
2759+ self . visit_expr ( expr)
27632760 }
27642761 self . visit_expr ( & arm. body ) ;
27652762
@@ -3000,14 +2997,14 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30002997 // Make the base error.
30012998 let expected = source. descr_expected ( ) ;
30022999 let path_str = names_to_string ( path) ;
3003- let item_str = path[ path . len ( ) - 1 ] ;
3000+ let item_str = path. last ( ) . unwrap ( ) ;
30043001 let code = source. error_code ( def. is_some ( ) ) ;
30053002 let ( base_msg, fallback_label, base_span) = if let Some ( def) = def {
30063003 ( format ! ( "expected {}, found {} `{}`" , expected, def. kind_name( ) , path_str) ,
30073004 format ! ( "not a {}" , expected) ,
30083005 span)
30093006 } else {
3010- let item_span = path[ path . len ( ) - 1 ] . span ;
3007+ let item_span = path. last ( ) . unwrap ( ) . span ;
30113008 let ( mod_prefix, mod_str) = if path. len ( ) == 1 {
30123009 ( String :: new ( ) , "this scope" . to_string ( ) )
30133010 } else if path. len ( ) == 2 && path[ 0 ] . name == keywords:: CrateRoot . name ( ) {
@@ -3030,10 +3027,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
30303027 let mut err = this. session . struct_span_err_with_code ( base_span, & base_msg, code) ;
30313028
30323029 // Emit help message for fake-self from other languages like `this`(javascript)
3033- let fake_self: Vec < Ident > = [ "this" , "my" ] . iter ( ) . map (
3034- |s| Ident :: from_str ( * s)
3035- ) . collect ( ) ;
3036- if fake_self. contains ( & item_str)
3030+ if [ "this" , "my" ] . contains ( & & * item_str. as_str ( ) )
30373031 && this. self_value_is_available ( path[ 0 ] . span , span) {
30383032 err. span_suggestion_with_applicability (
30393033 span,
@@ -3374,7 +3368,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
33743368 ) ;
33753369 }
33763370 break ;
3377- } else if snippet. trim ( ) . len ( ) != 0 {
3371+ } else if ! snippet. trim ( ) . is_empty ( ) {
33783372 debug ! ( "tried to find type ascription `:` token, couldn't find it" ) ;
33793373 break ;
33803374 }
@@ -3936,7 +3930,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
39363930 }
39373931 _ => { }
39383932 }
3939- return def;
3933+ def
39403934 }
39413935
39423936 fn lookup_assoc_candidate < FilterFn > ( & mut self ,
@@ -4386,10 +4380,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
43864380 where FilterFn : Fn ( Def ) -> bool
43874381 {
43884382 let mut candidates = Vec :: new ( ) ;
4389- let mut worklist = Vec :: new ( ) ;
43904383 let mut seen_modules = FxHashSet ( ) ;
43914384 let not_local_module = crate_name != keywords:: Crate . ident ( ) ;
4392- worklist. push ( ( start_module, Vec :: < ast:: PathSegment > :: new ( ) , not_local_module) ) ;
4385+ let mut worklist = vec ! [ ( start_module, Vec :: <ast:: PathSegment >:: new( ) , not_local_module) ] ;
43934386
43944387 while let Some ( ( in_module,
43954388 path_segments,
@@ -4476,33 +4469,24 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
44764469 -> Vec < ImportSuggestion >
44774470 where FilterFn : Fn ( Def ) -> bool
44784471 {
4479- let mut suggestions = vec ! [ ] ;
4480-
4481- suggestions. extend (
4482- self . lookup_import_candidates_from_module (
4483- lookup_name, namespace, self . graph_root , keywords:: Crate . ident ( ) , & filter_fn
4484- )
4485- ) ;
4472+ let mut suggestions = self . lookup_import_candidates_from_module (
4473+ lookup_name, namespace, self . graph_root , keywords:: Crate . ident ( ) , & filter_fn) ;
44864474
44874475 if self . session . rust_2018 ( ) {
44884476 let extern_prelude_names = self . extern_prelude . clone ( ) ;
44894477 for & name in extern_prelude_names. iter ( ) {
44904478 let ident = Ident :: with_empty_ctxt ( name) ;
4491- match self . crate_loader . maybe_process_path_extern ( name, ident. span ) {
4492- Some ( crate_id) => {
4493- let crate_root = self . get_module ( DefId {
4494- krate : crate_id,
4495- index : CRATE_DEF_INDEX ,
4496- } ) ;
4497- self . populate_module_if_necessary ( & crate_root) ;
4479+ if let Some ( crate_id) = self . crate_loader . maybe_process_path_extern ( name,
4480+ ident. span )
4481+ {
4482+ let crate_root = self . get_module ( DefId {
4483+ krate : crate_id,
4484+ index : CRATE_DEF_INDEX ,
4485+ } ) ;
4486+ self . populate_module_if_necessary ( & crate_root) ;
44984487
4499- suggestions. extend (
4500- self . lookup_import_candidates_from_module (
4501- lookup_name, namespace, crate_root, ident, & filter_fn
4502- )
4503- ) ;
4504- }
4505- None => { }
4488+ suggestions. extend ( self . lookup_import_candidates_from_module (
4489+ lookup_name, namespace, crate_root, ident, & filter_fn) ) ;
45064490 }
45074491 }
45084492 }
@@ -4515,9 +4499,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
45154499 -> Option < ( Module < ' a > , ImportSuggestion ) >
45164500 {
45174501 let mut result = None ;
4518- let mut worklist = Vec :: new ( ) ;
45194502 let mut seen_modules = FxHashSet ( ) ;
4520- worklist. push ( ( self . graph_root , Vec :: new ( ) ) ) ;
4503+ let mut worklist = vec ! [ ( self . graph_root, Vec :: new( ) ) ] ;
45214504
45224505 while let Some ( ( in_module, path_segments) ) = worklist. pop ( ) {
45234506 // abort if the module is already found
0 commit comments