Auto merge of #78066 - bugadani:wat, r=jonas-schievink
Clean up small, surprising bits of code This PR clean up a small number of unrelated, small things I found while browsing the code base.
This commit is contained in:
commit
834821e3b6
6 changed files with 49 additions and 54 deletions
|
@ -54,7 +54,7 @@ where
|
||||||
T: Iterator<Item = &'a Symbol>,
|
T: Iterator<Item = &'a Symbol>,
|
||||||
{
|
{
|
||||||
let lookup = &lookup.as_str();
|
let lookup = &lookup.as_str();
|
||||||
let max_dist = dist.map_or_else(|| cmp::max(lookup.len(), 3) / 3, |d| d);
|
let max_dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3);
|
||||||
let name_vec: Vec<&Symbol> = iter_names.collect();
|
let name_vec: Vec<&Symbol> = iter_names.collect();
|
||||||
|
|
||||||
let (case_insensitive_match, levenshtein_match) = name_vec
|
let (case_insensitive_match, levenshtein_match) = name_vec
|
||||||
|
|
|
@ -1190,7 +1190,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
input| {
|
input| {
|
||||||
match used_regs.entry(r) {
|
match used_regs.entry(r) {
|
||||||
Entry::Occupied(o) => {
|
Entry::Occupied(o) => {
|
||||||
if !skip {
|
if skip {
|
||||||
|
return;
|
||||||
|
}
|
||||||
skip = true;
|
skip = true;
|
||||||
|
|
||||||
let idx2 = *o.get();
|
let idx2 = *o.get();
|
||||||
|
@ -1207,14 +1209,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
reg2.name()
|
reg2.name()
|
||||||
);
|
);
|
||||||
let mut err = sess.struct_span_err(op_sp, &msg);
|
let mut err = sess.struct_span_err(op_sp, &msg);
|
||||||
err.span_label(
|
err.span_label(op_sp, &format!("register `{}`", reg.name()));
|
||||||
op_sp,
|
err.span_label(op_sp2, &format!("register `{}`", reg2.name()));
|
||||||
&format!("register `{}`", reg.name()),
|
|
||||||
);
|
|
||||||
err.span_label(
|
|
||||||
op_sp2,
|
|
||||||
&format!("register `{}`", reg2.name()),
|
|
||||||
);
|
|
||||||
|
|
||||||
match (op, op2) {
|
match (op, op2) {
|
||||||
(
|
(
|
||||||
|
@ -1236,7 +1232,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
v.insert(idx);
|
v.insert(idx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -968,7 +968,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
|
||||||
while let Some(attr) = attrs.next() {
|
while let Some(attr) = attrs.next() {
|
||||||
if attr.is_doc_comment() {
|
if attr.is_doc_comment() {
|
||||||
sugared_span =
|
sugared_span =
|
||||||
Some(sugared_span.map_or_else(|| attr.span, |span| span.with_hi(attr.span.hi())));
|
Some(sugared_span.map_or(attr.span, |span| span.with_hi(attr.span.hi())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrs.peek().map(|next_attr| next_attr.is_doc_comment()).unwrap_or_default() {
|
if attrs.peek().map(|next_attr| next_attr.is_doc_comment()).unwrap_or_default() {
|
||||||
|
|
|
@ -103,7 +103,7 @@ impl<'tcx> Place<'tcx> {
|
||||||
|
|
||||||
/// Returns the type of this `Place` after all projections have been applied.
|
/// Returns the type of this `Place` after all projections have been applied.
|
||||||
pub fn ty(&self) -> Ty<'tcx> {
|
pub fn ty(&self) -> Ty<'tcx> {
|
||||||
self.projections.last().map_or_else(|| self.base_ty, |proj| proj.ty)
|
self.projections.last().map_or(self.base_ty, |proj| proj.ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the type of this `Place` immediately before `projection_index`th projection
|
/// Returns the type of this `Place` immediately before `projection_index`th projection
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Equate expected input tys with those in the MIR.
|
// Equate expected input tys with those in the MIR.
|
||||||
for (&normalized_input_ty, argument_index) in normalized_input_tys.iter().zip(0..) {
|
for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
|
||||||
// In MIR, argument N is stored in local N+1.
|
// In MIR, argument N is stored in local N+1.
|
||||||
let local = Local::new(argument_index + 1);
|
let local = Local::new(argument_index + 1);
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(user_provided_sig) = user_provided_sig {
|
if let Some(user_provided_sig) = user_provided_sig {
|
||||||
for (&user_provided_input_ty, argument_index) in
|
for (argument_index, &user_provided_input_ty) in
|
||||||
user_provided_sig.inputs().iter().zip(0..)
|
user_provided_sig.inputs().iter().enumerate()
|
||||||
{
|
{
|
||||||
// In MIR, closures begin an implicit `self`, so
|
// In MIR, closures begin an implicit `self`, so
|
||||||
// argument N is stored in local N+2.
|
// argument N is stored in local N+2.
|
||||||
|
|
|
@ -458,8 +458,8 @@ fn create_and_seed_worklist<'tcx>(
|
||||||
.map
|
.map
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(
|
.filter_map(
|
||||||
|(&id, level)| {
|
|(&id, &level)| {
|
||||||
if level >= &privacy::AccessLevel::Reachable { Some(id) } else { None }
|
if level >= privacy::AccessLevel::Reachable { Some(id) } else { None }
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.chain(
|
.chain(
|
||||||
|
@ -547,7 +547,7 @@ impl DeadVisitor<'tcx> {
|
||||||
let def_id = self.tcx.hir().local_def_id(id);
|
let def_id = self.tcx.hir().local_def_id(id);
|
||||||
let inherent_impls = self.tcx.inherent_impls(def_id);
|
let inherent_impls = self.tcx.inherent_impls(def_id);
|
||||||
for &impl_did in inherent_impls.iter() {
|
for &impl_did in inherent_impls.iter() {
|
||||||
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
|
for item_did in self.tcx.associated_item_def_ids(impl_did) {
|
||||||
if let Some(did) = item_did.as_local() {
|
if let Some(did) = item_did.as_local() {
|
||||||
let item_hir_id = self.tcx.hir().local_def_id_to_hir_id(did);
|
let item_hir_id = self.tcx.hir().local_def_id_to_hir_id(did);
|
||||||
if self.live_symbols.contains(&item_hir_id) {
|
if self.live_symbols.contains(&item_hir_id) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue