aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorAramis Razzaghipour <[email protected]>2021-05-24 05:53:15 +0100
committerAramis Razzaghipour <[email protected]>2021-05-24 05:54:48 +0100
commiteca4b764e4d8653f3862129586f47cb60be4bf3f (patch)
treefc6b872409d3c4484a8f386c9d815b76dec087b9 /crates/ide/src/syntax_highlighting
parente51188cd09d0a78de20d1fdde866fa5a4a31e938 (diff)
Remove superfluous early-returns
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs40
1 files changed, 22 insertions, 18 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index f070601fd..14d68d3f3 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -291,7 +291,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
291 h |= HlMod::Library; 291 h |= HlMod::Library;
292 } 292 }
293 293
294 return h; 294 h
295 } 295 }
296 Definition::Field(field) => { 296 Definition::Field(field) => {
297 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Field)); 297 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Field));
@@ -300,7 +300,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
300 h |= HlMod::Library; 300 h |= HlMod::Library;
301 } 301 }
302 302
303 return h; 303 h
304 } 304 }
305 Definition::ModuleDef(def) => match def { 305 Definition::ModuleDef(def) => match def {
306 hir::ModuleDef::Module(module) => { 306 hir::ModuleDef::Module(module) => {
@@ -310,7 +310,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
310 h |= HlMod::Library; 310 h |= HlMod::Library;
311 } 311 }
312 312
313 return h; 313 h
314 } 314 }
315 hir::ModuleDef::Function(func) => { 315 hir::ModuleDef::Function(func) => {
316 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Function)); 316 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Function));
@@ -346,7 +346,8 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
346 if Some(func.module(db).krate()) != krate { 346 if Some(func.module(db).krate()) != krate {
347 h |= HlMod::Library; 347 h |= HlMod::Library;
348 } 348 }
349 return h; 349
350 h
350 } 351 }
351 hir::ModuleDef::Adt(adt) => { 352 hir::ModuleDef::Adt(adt) => {
352 let h = match adt { 353 let h = match adt {
@@ -360,7 +361,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
360 h |= HlMod::Library; 361 h |= HlMod::Library;
361 } 362 }
362 363
363 return h; 364 h
364 } 365 }
365 hir::ModuleDef::Variant(variant) => { 366 hir::ModuleDef::Variant(variant) => {
366 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Variant)); 367 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Variant));
@@ -369,7 +370,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
369 h |= HlMod::Library; 370 h |= HlMod::Library;
370 } 371 }
371 372
372 return h; 373 h
373 } 374 }
374 hir::ModuleDef::Const(konst) => { 375 hir::ModuleDef::Const(konst) => {
375 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Const)); 376 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Const));
@@ -392,7 +393,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
392 h |= HlMod::Library; 393 h |= HlMod::Library;
393 } 394 }
394 395
395 return h; 396 h
396 } 397 }
397 hir::ModuleDef::Trait(trait_) => { 398 hir::ModuleDef::Trait(trait_) => {
398 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Trait)); 399 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Trait));
@@ -405,7 +406,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
405 h |= HlMod::Library; 406 h |= HlMod::Library;
406 } 407 }
407 408
408 return h; 409 h
409 } 410 }
410 hir::ModuleDef::TypeAlias(type_) => { 411 hir::ModuleDef::TypeAlias(type_) => {
411 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::TypeAlias)); 412 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::TypeAlias));
@@ -428,9 +429,9 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
428 h |= HlMod::Library; 429 h |= HlMod::Library;
429 } 430 }
430 431
431 return h; 432 h
432 } 433 }
433 hir::ModuleDef::BuiltinType(_) => HlTag::BuiltinType, 434 hir::ModuleDef::BuiltinType(_) => Highlight::new(HlTag::BuiltinType),
434 hir::ModuleDef::Static(s) => { 435 hir::ModuleDef::Static(s) => {
435 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Static)); 436 let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Static));
436 437
@@ -443,14 +444,18 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
443 h |= HlMod::Library; 444 h |= HlMod::Library;
444 } 445 }
445 446
446 return h; 447 h
447 } 448 }
448 }, 449 },
449 Definition::SelfType(_) => HlTag::Symbol(SymbolKind::Impl), 450 Definition::SelfType(_) => Highlight::new(HlTag::Symbol(SymbolKind::Impl)),
450 Definition::GenericParam(it) => match it { 451 Definition::GenericParam(it) => match it {
451 hir::GenericParam::TypeParam(_) => HlTag::Symbol(SymbolKind::TypeParam), 452 hir::GenericParam::TypeParam(_) => Highlight::new(HlTag::Symbol(SymbolKind::TypeParam)),
452 hir::GenericParam::ConstParam(_) => HlTag::Symbol(SymbolKind::ConstParam), 453 hir::GenericParam::ConstParam(_) => {
453 hir::GenericParam::LifetimeParam(_) => HlTag::Symbol(SymbolKind::LifetimeParam), 454 Highlight::new(HlTag::Symbol(SymbolKind::ConstParam))
455 }
456 hir::GenericParam::LifetimeParam(_) => {
457 Highlight::new(HlTag::Symbol(SymbolKind::LifetimeParam))
458 }
454 }, 459 },
455 Definition::Local(local) => { 460 Definition::Local(local) => {
456 let tag = if local.is_self(db) { 461 let tag = if local.is_self(db) {
@@ -468,11 +473,10 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
468 if ty.as_callable(db).is_some() || ty.impls_fnonce(db) { 473 if ty.as_callable(db).is_some() || ty.impls_fnonce(db) {
469 h |= HlMod::Callable; 474 h |= HlMod::Callable;
470 } 475 }
471 return h; 476 h
472 } 477 }
473 Definition::Label(_) => HlTag::Symbol(SymbolKind::Label), 478 Definition::Label(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)),
474 } 479 }
475 .into()
476} 480}
477 481
478fn highlight_func_by_name_ref( 482fn highlight_func_by_name_ref(