aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs31
-rw-r--r--crates/ra_db/src/input.rs3
-rw-r--r--crates/ra_hir/src/code_model.rs32
-rw-r--r--crates/ra_hir/src/ty/infer.rs2
-rw-r--r--crates/ra_syntax/src/validation/unescape.rs2
5 files changed, 34 insertions, 36 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs
index d51010b84..deef166b5 100644
--- a/crates/ra_assists/src/fill_match_arms.rs
+++ b/crates/ra_assists/src/fill_match_arms.rs
@@ -23,27 +23,24 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As
23 // We already have some match arms, so we don't provide any assists. 23 // We already have some match arms, so we don't provide any assists.
24 // Unless if there is only one trivial match arm possibly created 24 // Unless if there is only one trivial match arm possibly created
25 // by match postfix complete. Trivial match arm is the catch all arm. 25 // by match postfix complete. Trivial match arm is the catch all arm.
26 match match_expr.match_arm_list() { 26 if let Some(arm_list) = match_expr.match_arm_list() {
27 Some(arm_list) => { 27 let mut arm_iter = arm_list.arms();
28 let mut arm_iter = arm_list.arms(); 28 let first = arm_iter.next();
29 let first = arm_iter.next(); 29
30 30 match first {
31 match first { 31 // If there arm list is empty or there is only one trivial arm, then proceed.
32 // If there arm list is empty or there is only one trivial arm, then proceed. 32 Some(arm) if is_trivial_arm(arm) => {
33 Some(arm) if is_trivial_arm(arm) => { 33 if arm_iter.next() != None {
34 if arm_iter.next() != None {
35 return None;
36 }
37 }
38 None => {}
39
40 _ => {
41 return None; 34 return None;
42 } 35 }
43 } 36 }
37 None => {}
38
39 _ => {
40 return None;
41 }
44 } 42 }
45 _ => {} 43 };
46 }
47 44
48 let expr = match_expr.expr()?; 45 let expr = match_expr.expr()?;
49 let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None); 46 let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None);
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 2d563bd01..ad8e10c52 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -131,7 +131,8 @@ impl CrateGraph {
131 if self.dfs_find(from, to, &mut FxHashSet::default()) { 131 if self.dfs_find(from, to, &mut FxHashSet::default()) {
132 return Err(CyclicDependencies); 132 return Err(CyclicDependencies);
133 } 133 }
134 Ok(self.arena.get_mut(&from).unwrap().add_dep(name, to)) 134 self.arena.get_mut(&from).unwrap().add_dep(name, to);
135 Ok(())
135 } 136 }
136 137
137 pub fn is_empty(&self) -> bool { 138 pub fn is_empty(&self) -> bool {
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 7d5d9b995..b2fb5a563 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -240,10 +240,10 @@ impl Module {
240 } 240 }
241 241
242 pub fn path_to_root(self, db: &impl HirDatabase) -> Vec<Module> { 242 pub fn path_to_root(self, db: &impl HirDatabase) -> Vec<Module> {
243 let mut res = vec![self.clone()]; 243 let mut res = vec![self];
244 let mut curr = self.clone(); 244 let mut curr = self;
245 while let Some(next) = curr.parent(db) { 245 while let Some(next) = curr.parent(db) {
246 res.push(next.clone()); 246 res.push(next);
247 curr = next 247 curr = next
248 } 248 }
249 res 249 res
@@ -299,7 +299,7 @@ impl Module {
299 .collect() 299 .collect()
300 } 300 }
301 301
302 fn with_module_id(&self, module_id: CrateModuleId) -> Module { 302 fn with_module_id(self, module_id: CrateModuleId) -> Module {
303 Module { module_id, krate: self.krate } 303 Module { module_id, krate: self.krate }
304 } 304 }
305} 305}
@@ -463,33 +463,33 @@ pub struct EnumVariant {
463} 463}
464 464
465impl EnumVariant { 465impl EnumVariant {
466 pub fn module(&self, db: &impl HirDatabase) -> Module { 466 pub fn module(self, db: &impl HirDatabase) -> Module {
467 self.parent.module(db) 467 self.parent.module(db)
468 } 468 }
469 pub fn parent_enum(&self, _db: &impl DefDatabase) -> Enum { 469 pub fn parent_enum(self, _db: &impl DefDatabase) -> Enum {
470 self.parent 470 self.parent
471 } 471 }
472 472
473 pub fn name(&self, db: &impl DefDatabase) -> Option<Name> { 473 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
474 db.enum_data(self.parent).variants[self.id].name.clone() 474 db.enum_data(self.parent).variants[self.id].name.clone()
475 } 475 }
476 476
477 pub fn fields(&self, db: &impl HirDatabase) -> Vec<StructField> { 477 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
478 self.variant_data(db) 478 self.variant_data(db)
479 .fields() 479 .fields()
480 .into_iter() 480 .into_iter()
481 .flat_map(|it| it.iter()) 481 .flat_map(|it| it.iter())
482 .map(|(id, _)| StructField { parent: (*self).into(), id }) 482 .map(|(id, _)| StructField { parent: self.into(), id })
483 .collect() 483 .collect()
484 } 484 }
485 485
486 pub fn field(&self, db: &impl HirDatabase, name: &Name) -> Option<StructField> { 486 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
487 self.variant_data(db) 487 self.variant_data(db)
488 .fields() 488 .fields()
489 .into_iter() 489 .into_iter()
490 .flat_map(|it| it.iter()) 490 .flat_map(|it| it.iter())
491 .find(|(_id, data)| data.name == *name) 491 .find(|(_id, data)| data.name == *name)
492 .map(|(id, _)| StructField { parent: (*self).into(), id }) 492 .map(|(id, _)| StructField { parent: self.into(), id })
493 } 493 }
494} 494}
495 495
@@ -517,11 +517,11 @@ impl DefWithBody {
517 } 517 }
518 518
519 /// Builds a resolver for code inside this item. 519 /// Builds a resolver for code inside this item.
520 pub(crate) fn resolver(&self, db: &impl HirDatabase) -> Resolver { 520 pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
521 match *self { 521 match self {
522 DefWithBody::Const(ref c) => c.resolver(db), 522 DefWithBody::Const(c) => c.resolver(db),
523 DefWithBody::Function(ref f) => f.resolver(db), 523 DefWithBody::Function(f) => f.resolver(db),
524 DefWithBody::Static(ref s) => s.resolver(db), 524 DefWithBody::Static(s) => s.resolver(db),
525 } 525 }
526 } 526 }
527} 527}
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index f47f4c5de..8322de0a8 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -529,7 +529,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
529 match matching_def { 529 match matching_def {
530 Some(_) => { 530 Some(_) => {
531 self.write_assoc_resolution(id, item); 531 self.write_assoc_resolution(id, item);
532 return matching_def; 532 matching_def
533 } 533 }
534 None => None, 534 None => None,
535 } 535 }
diff --git a/crates/ra_syntax/src/validation/unescape.rs b/crates/ra_syntax/src/validation/unescape.rs
index 1cb2433f3..7eed6c663 100644
--- a/crates/ra_syntax/src/validation/unescape.rs
+++ b/crates/ra_syntax/src/validation/unescape.rs
@@ -262,7 +262,7 @@ where
262 262
263fn byte_from_char(c: char) -> u8 { 263fn byte_from_char(c: char) -> u8 {
264 let res = c as u32; 264 let res = c as u32;
265 assert!(res <= u8::max_value() as u32, "guaranteed because of Mode::Byte"); 265 assert!(res <= u32::from(u8::max_value()), "guaranteed because of Mode::Byte");
266 res as u8 266 res as u8
267} 267}
268 268