mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
Two minor changes for readability and efficiency
This commit is contained in:
parent
4efa4a5273
commit
7b301985fa
@ -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,
|
||||
|
@ -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 }
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user