Skip to content

Commit

Permalink
Two minor changes for readability and efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianWolff committed May 17, 2021
1 parent 4efa4a5 commit 7b30198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_passes/src/lang_items.rs
Expand Up @@ -100,12 +100,11 @@ impl LanguageItemCollector<'tcx> {
}

fn collect_item(&mut self, item_index: usize, item_def_id: DefId) {
let lang_item = LangItem::from_u32(item_index as u32).unwrap();
let name = lang_item.name();

// Check for duplicates.
if let Some(original_def_id) = self.items.items[item_index] {
if original_def_id != item_def_id {
let lang_item = LangItem::from_u32(item_index as u32).unwrap();
let name = lang_item.name();
let mut err = match self.tcx.hir().span_if_local(item_def_id) {
Some(span) => struct_span_err!(
self.tcx.sess,
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_typeck/src/check/mod.rs
Expand Up @@ -1194,13 +1194,10 @@ fn potentially_plural_count(count: usize, word: &str) -> String {
fn has_expected_num_generic_args<'tcx>(
tcx: TyCtxt<'tcx>,
trait_did: Option<DefId>,
mut expected: usize,
expected: usize,
) -> bool {
trait_did.map_or(true, |trait_did| {
let generics = tcx.generics_of(trait_did);
if generics.has_self {
expected += 1;
}
generics.count() == expected
generics.count() == expected + if generics.has_self { 1 } else { 0 }
})
}

0 comments on commit 7b30198

Please sign in to comment.