File tree Expand file tree Collapse file tree 3 files changed +17
-29
lines changed Expand file tree Collapse file tree 3 files changed +17
-29
lines changed Original file line number Diff line number Diff line change @@ -51,28 +51,26 @@ impl DiagnosticCode {
5151
5252#[ derive( Debug ) ]
5353pub struct Diagnostic {
54- // pub name: Option<String> ,
54+ pub code : DiagnosticCode ,
5555 pub message : String ,
5656 pub range : TextRange ,
5757 pub severity : Severity ,
58- pub fixes : Option < Vec < Assist > > ,
5958 pub unused : bool ,
60- pub code : Option < DiagnosticCode > ,
6159 pub experimental : bool ,
60+ pub fixes : Option < Vec < Assist > > ,
6261}
6362
6463impl Diagnostic {
6564 fn new ( code : & ' static str , message : impl Into < String > , range : TextRange ) -> Diagnostic {
6665 let message = message. into ( ) ;
67- let code = Some ( DiagnosticCode ( code ) ) ;
68- Self {
66+ Diagnostic {
67+ code : DiagnosticCode ( code ) ,
6968 message,
7069 range,
7170 severity : Severity :: Error ,
72- fixes : None ,
7371 unused : false ,
74- code,
7572 experimental : false ,
73+ fixes : None ,
7674 }
7775 }
7876
@@ -181,15 +179,8 @@ pub(crate) fn diagnostics(
181179 }
182180
183181 res. retain ( |d| {
184- if let Some ( code) = d. code {
185- if ctx. config . disabled . contains ( code. as_str ( ) ) {
186- return false ;
187- }
188- }
189- if ctx. config . disable_experimental && d. experimental {
190- return false ;
191- }
192- true
182+ !ctx. config . disabled . contains ( d. code . as_str ( ) )
183+ && !( ctx. config . disable_experimental && d. experimental )
193184 } ) ;
194185
195186 res
Original file line number Diff line number Diff line change @@ -65,9 +65,14 @@ mod baz {}
6565 expect ! [ [ r#"
6666 [
6767 Diagnostic {
68+ code: DiagnosticCode(
69+ "unresolved-module",
70+ ),
6871 message: "unresolved module",
6972 range: 0..8,
7073 severity: Error,
74+ unused: false,
75+ experimental: false,
7176 fixes: Some(
7277 [
7378 Assist {
@@ -98,13 +103,6 @@ mod baz {}
98103 },
99104 ],
100105 ),
101- unused: false,
102- code: Some(
103- DiagnosticCode(
104- "unresolved-module",
105- ),
106- ),
107- experimental: false,
108106 },
109107 ]
110108 "# ] ] ,
Original file line number Diff line number Diff line change @@ -1229,14 +1229,13 @@ pub(crate) fn publish_diagnostics(
12291229 . map ( |d| Diagnostic {
12301230 range : to_proto:: range ( & line_index, d. range ) ,
12311231 severity : Some ( to_proto:: diagnostic_severity ( d. severity ) ) ,
1232- code : d. code . map ( |d| d . as_str ( ) . to_owned ( ) ) . map ( NumberOrString :: String ) ,
1233- code_description : d . code . and_then ( |code| {
1234- lsp_types:: Url :: parse ( & format ! (
1232+ code : Some ( NumberOrString :: String ( d. code . as_str ( ) . to_string ( ) ) ) ,
1233+ code_description : Some ( lsp_types :: CodeDescription {
1234+ href : lsp_types:: Url :: parse ( & format ! (
12351235 "https://rust-analyzer.github.io/manual.html#{}" ,
1236- code. as_str( )
1236+ d . code. as_str( )
12371237 ) )
1238- . ok ( )
1239- . map ( |href| lsp_types:: CodeDescription { href } )
1238+ . unwrap ( ) ,
12401239 } ) ,
12411240 source : Some ( "rust-analyzer" . to_string ( ) ) ,
12421241 message : d. message ,
You can’t perform that action at this time.
0 commit comments