aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/expr/validation.rs25
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs21
2 files changed, 23 insertions, 23 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs
index 339a7b848..f0da3d169 100644
--- a/crates/ra_hir/src/expr/validation.rs
+++ b/crates/ra_hir/src/expr/validation.rs
@@ -12,7 +12,7 @@ use crate::{
12 name, 12 name,
13 path::{PathKind, PathSegment}, 13 path::{PathKind, PathSegment},
14 ty::{InferenceResult, Ty, TypeCtor}, 14 ty::{InferenceResult, Ty, TypeCtor},
15 Function, HasSource, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution 15 Function, HasSource, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution,
16}; 16};
17use ra_syntax::ast; 17use ra_syntax::ast;
18 18
@@ -116,26 +116,25 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
116 PathSegment { name: name::STD, args_and_bindings: None }, 116 PathSegment { name: name::STD, args_and_bindings: None },
117 PathSegment { name: name::RESULT_MOD, args_and_bindings: None }, 117 PathSegment { name: name::RESULT_MOD, args_and_bindings: None },
118 PathSegment { name: name::RESULT_TYPE, args_and_bindings: None }, 118 PathSegment { name: name::RESULT_TYPE, args_and_bindings: None },
119 ] 119 ],
120 }; 120 };
121 121
122 let resolver = self.func.resolver(db); 122 let resolver = self.func.resolver(db);
123 let std_result_enum = match resolver.resolve_path_segments(db, &std_result_path).into_fully_resolved() { 123 let std_result_enum =
124 PerNs { types: Some(Resolution::Def(ModuleDef::Enum(e))), .. } => e, 124 match resolver.resolve_path_segments(db, &std_result_path).into_fully_resolved() {
125 _ => return, 125 PerNs { types: Some(Resolution::Def(ModuleDef::Enum(e))), .. } => e,
126 }; 126 _ => return,
127 };
127 128
128 let std_result_type = std_result_enum.ty(db); 129 let std_result_type = std_result_enum.ty(db);
129 130
130 fn enum_from_type(ty: &Ty) -> Option<Enum> { 131 fn enum_from_type(ty: &Ty) -> Option<Enum> {
131 match ty { 132 match ty {
132 Ty::Apply(t) => { 133 Ty::Apply(t) => match t.ctor {
133 match t.ctor { 134 TypeCtor::Adt(AdtDef::Enum(e)) => Some(e),
134 TypeCtor::Adt(AdtDef::Enum(e)) => Some(e), 135 _ => None,
135 _ => None, 136 },
136 } 137 _ => None,
137 }
138 _ => None
139 } 138 }
140 } 139 }
141 140
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 9841fbdf3..0b9bb5a66 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -217,7 +217,8 @@ mod tests {
217 } 217 }
218 218
219 fn check_apply_diagnostic_fix_for_target_file(target_file: &str, fixture: &str, after: &str) { 219 fn check_apply_diagnostic_fix_for_target_file(target_file: &str, fixture: &str, after: &str) {
220 let (analysis, file_id, target_file_contents) = fixture_with_target_file(fixture, target_file); 220 let (analysis, file_id, target_file_contents) =
221 fixture_with_target_file(fixture, target_file);
221 let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap(); 222 let diagnostic = analysis.diagnostics(file_id).unwrap().pop().unwrap();
222 let mut fix = diagnostic.fix.unwrap(); 223 let mut fix = diagnostic.fix.unwrap();
223 let edit = fix.source_file_edits.pop().unwrap().edit; 224 let edit = fix.source_file_edits.pop().unwrap().edit;
@@ -267,9 +268,9 @@ mod tests {
267 pub enum Result<T, E> { Ok(T), Err(E) } 268 pub enum Result<T, E> { Ok(T), Err(E) }
268 } 269 }
269 "#; 270 "#;
270// The formatting here is a bit odd due to how the parse_fixture function works in test_utils - 271 // The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
271// it strips empty lines and leading whitespace. The important part of this test is that the final 272 // it strips empty lines and leading whitespace. The important part of this test is that the final
272// `x / y` expr is now wrapped in `Ok(..)` 273 // `x / y` expr is now wrapped in `Ok(..)`
273 let after = r#"use std::{string::String, result::Result::{self, Ok, Err}}; 274 let after = r#"use std::{string::String, result::Result::{self, Ok, Err}};
274fn div(x: i32, y: i32) -> Result<i32, String> { 275fn div(x: i32, y: i32) -> Result<i32, String> {
275 if y == 0 { 276 if y == 0 {
@@ -299,9 +300,9 @@ fn div(x: i32, y: i32) -> Result<i32, String> {
299 pub enum Result<T, E> { Ok(T), Err(E) } 300 pub enum Result<T, E> { Ok(T), Err(E) }
300 } 301 }
301 "#; 302 "#;
302// The formatting here is a bit odd due to how the parse_fixture function works in test_utils - 303 // The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
303// it strips empty lines and leading whitespace. The important part of this test is that the final 304 // it strips empty lines and leading whitespace. The important part of this test is that the final
304// expr is now wrapped in `Ok(..)` 305 // expr is now wrapped in `Ok(..)`
305 let after = r#"use std::result::Result::{self, Ok, Err}; 306 let after = r#"use std::result::Result::{self, Ok, Err};
306fn div<T>(x: T) -> Result<T, i32> { 307fn div<T>(x: T) -> Result<T, i32> {
307 if x == 0 { 308 if x == 0 {
@@ -336,9 +337,9 @@ fn div<T>(x: T) -> Result<T, i32> {
336 pub enum Result<T, E> { Ok(T), Err(E) } 337 pub enum Result<T, E> { Ok(T), Err(E) }
337 } 338 }
338 "#; 339 "#;
339// The formatting here is a bit odd due to how the parse_fixture function works in test_utils - 340 // The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
340// it strips empty lines and leading whitespace. The important part of this test is that the final 341 // it strips empty lines and leading whitespace. The important part of this test is that the final
341// `x / y` expr is now wrapped in `Ok(..)` 342 // `x / y` expr is now wrapped in `Ok(..)`
342 let after = r#"use std::{string::String, result::Result::{self, Ok, Err}}; 343 let after = r#"use std::{string::String, result::Result::{self, Ok, Err}};
343type MyResult<T> = Result<T, String>; 344type MyResult<T> = Result<T, String>;
344fn div(x: i32, y: i32) -> MyResult<i32> { 345fn div(x: i32, y: i32) -> MyResult<i32> {