66
77mod unresolved_module;
88mod unresolved_extern_crate;
9+ mod unresolved_import;
910mod missing_fields;
1011
1112mod fixes;
@@ -43,17 +44,39 @@ pub struct Diagnostic {
4344 pub fixes : Option < Vec < Assist > > ,
4445 pub unused : bool ,
4546 pub code : Option < DiagnosticCode > ,
47+ pub experimental : bool ,
4648}
4749
4850impl Diagnostic {
4951 fn new ( code : & ' static str , message : impl Into < String > , range : TextRange ) -> Diagnostic {
5052 let message = message. into ( ) ;
5153 let code = Some ( DiagnosticCode ( code) ) ;
52- Self { message, range, severity : Severity :: Error , fixes : None , unused : false , code }
54+ Self {
55+ message,
56+ range,
57+ severity : Severity :: Error ,
58+ fixes : None ,
59+ unused : false ,
60+ code,
61+ experimental : false ,
62+ }
63+ }
64+
65+ fn experimental ( mut self ) -> Diagnostic {
66+ self . experimental = true ;
67+ self
5368 }
5469
5570 fn error ( range : TextRange , message : String ) -> Self {
56- Self { message, range, severity : Severity :: Error , fixes : None , unused : false , code : None }
71+ Self {
72+ message,
73+ range,
74+ severity : Severity :: Error ,
75+ fixes : None ,
76+ unused : false ,
77+ code : None ,
78+ experimental : false ,
79+ }
5780 }
5881
5982 fn hint ( range : TextRange , message : String ) -> Self {
@@ -64,6 +87,7 @@ impl Diagnostic {
6487 fixes : None ,
6588 unused : false ,
6689 code : None ,
90+ experimental : false ,
6791 }
6892 }
6993
@@ -234,13 +258,17 @@ pub(crate) fn diagnostics(
234258 let d = match diag {
235259 AnyDiagnostic :: UnresolvedModule ( d) => unresolved_module:: unresolved_module ( & ctx, & d) ,
236260 AnyDiagnostic :: UnresolvedExternCrate ( d) => unresolved_extern_crate:: unresolved_extern_crate ( & ctx, & d) ,
261+ AnyDiagnostic :: UnresolvedImport ( d) => unresolved_import:: unresolved_import ( & ctx, & d) ,
237262 AnyDiagnostic :: MissingFields ( d) => missing_fields:: missing_fields ( & ctx, & d) ,
238263 } ;
239264 if let Some ( code) = d. code {
240265 if ctx. config . disabled . contains ( code. as_str ( ) ) {
241266 continue ;
242267 }
243268 }
269+ if ctx. config . disable_experimental && d. experimental {
270+ continue ;
271+ }
244272 res. push ( d)
245273 }
246274
@@ -462,33 +490,6 @@ foo::bar!(92);
462490 ) ;
463491 }
464492
465- #[ test]
466- fn unresolved_import_in_use_tree ( ) {
467- // Only the relevant part of a nested `use` item should be highlighted.
468- check_diagnostics (
469- r#"
470- use does_exist::{Exists, DoesntExist};
471- //^^^^^^^^^^^ unresolved import
472-
473- use {does_not_exist::*, does_exist};
474- //^^^^^^^^^^^^^^^^^ unresolved import
475-
476- use does_not_exist::{
477- a,
478- //^ unresolved import
479- b,
480- //^ unresolved import
481- c,
482- //^ unresolved import
483- };
484-
485- mod does_exist {
486- pub struct Exists;
487- }
488- "# ,
489- ) ;
490- }
491-
492493 #[ test]
493494 fn range_mapping_out_of_macros ( ) {
494495 // FIXME: this is very wrong, but somewhat tricky to fix.
0 commit comments