1818use la_arena:: Arena ;
1919use smallvec:: SmallVec ;
2020use smol_str:: SmolStr ;
21- use syntax:: SyntaxTree ;
21+ use syntax:: { SyntaxKind , SyntaxTree } ;
2222use triomphe:: Arc ;
2323use utils:: {
2424 get:: GetRef ,
2525 text_edit:: { TextRange , TextSize } ,
2626} ;
2727
28- use syntax:: SyntaxKind ;
29-
3028use crate :: {
31- ast_id_map:: SyntaxFileId , body:: BodyItem , db:: HirDefDb , has_source:: HasSource , owner:: OwnerId ,
32- proc:: Proc , source_map:: { LoweringDiagnostic , LoweringDiagnosticKind } ,
33- source_projection:: SourceProjection , symbol:: NameContext ,
29+ ast_id_map:: SyntaxFileId ,
30+ body:: BodyItem ,
31+ db:: HirDefDb ,
32+ has_source:: HasSource ,
33+ owner:: OwnerId ,
34+ proc:: Proc ,
35+ source_map:: { LoweringDiagnostic , LoweringDiagnosticKind } ,
36+ source_projection:: SourceProjection ,
37+ symbol:: NameContext ,
3438} ;
3539
3640#[ salsa:: tracked( returns( clone) ) ]
@@ -141,9 +145,9 @@ fn collect_import_conflicts(
141145 }
142146 reported. push ( name. clone ( ) ) ;
143147 let declared = scope. lookup ( NameContext :: Listing , & name) . unique ( ) . is_some ( ) ;
144- let other_package = named. iter ( ) . any ( |other| {
145- other . name . as_ref ( ) == Some ( & name ) && other . package != import . package
146- } ) ;
148+ let other_package = named
149+ . iter ( )
150+ . any ( |other| other . name . as_ref ( ) == Some ( & name ) && other . package != import . package ) ;
147151 let message = if declared {
148152 Some ( format ! (
149153 "explicit import of '{name}' conflicts with a declaration in the same scope"
@@ -160,7 +164,9 @@ fn collect_import_conflicts(
160164 let origin = projection. origin ( source) ;
161165 diagnostics. push ( LoweringDiagnostic {
162166 kind : LoweringDiagnosticKind :: InvalidSyntax ,
163- syntax_kind : origin. and_then ( |origin| origin. kind ( ) ) . unwrap_or ( SyntaxKind :: PACKAGE_IMPORT_DECLARATION ) ,
167+ syntax_kind : origin
168+ . and_then ( |origin| origin. kind ( ) )
169+ . unwrap_or ( SyntaxKind :: PACKAGE_IMPORT_DECLARATION ) ,
164170 source : Some ( source) ,
165171 range : origin. and_then ( |origin| origin. full_range ( ) ) ,
166172 message : message. into ( ) ,
@@ -442,9 +448,7 @@ endmodule
442448 let db = db_with_files ( text, None ) ;
443449 let diagnostics = db. file_lowering_diagnostics ( HirFileId :: File ( TOP ) ) ;
444450 assert ! (
445- diagnostics
446- . iter( )
447- . any( |diag| diag. message. contains( "another explicit import" ) ) ,
451+ diagnostics. iter( ) . any( |diag| diag. message. contains( "another explicit import" ) ) ,
448452 "explicit imports of one name from two packages must be diagnosed: {diagnostics:?}"
449453 ) ;
450454 }
@@ -466,12 +470,11 @@ endmodule
466470 let db = db_with_files ( text, None ) ;
467471
468472 let diagnostics = db. file_lowering_diagnostics ( HirFileId :: File ( TOP ) ) ;
469- let unsupported =
470- diagnostics. iter ( ) . filter ( |diag| diag. message == "unsupported statement" ) . collect :: < Vec < _ > > ( ) ;
471- assert ! (
472- !unsupported. is_empty( ) ,
473- "foreach statement must be diagnosed: {diagnostics:?}"
474- ) ;
473+ let unsupported = diagnostics
474+ . iter ( )
475+ . filter ( |diag| diag. message == "unsupported statement" )
476+ . collect :: < Vec < _ > > ( ) ;
477+ assert ! ( !unsupported. is_empty( ) , "foreach statement must be diagnosed: {diagnostics:?}" ) ;
475478 assert ! (
476479 unsupported. iter( ) . all( |diag| diag. source. is_some( ) ) ,
477480 "unsupported statement diagnostics must retain a source identity"
0 commit comments