mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
clippy::complexity fixes
clone_on_copy useless_format bind_instead_of_map filter_map_identity useless_conversion map_flatten unnecessary_unwrap
This commit is contained in:
parent
8bf9c20765
commit
5fc8a8e227
@ -1463,10 +1463,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
if let GenericBound::Trait(ref poly, modify) = *bound {
|
if let GenericBound::Trait(ref poly, modify) = *bound {
|
||||||
match (ctxt, modify) {
|
match (ctxt, modify) {
|
||||||
(BoundKind::SuperTraits, TraitBoundModifier::Maybe) => {
|
(BoundKind::SuperTraits, TraitBoundModifier::Maybe) => {
|
||||||
let mut err = self.err_handler().struct_span_err(
|
let mut err = self
|
||||||
poly.span,
|
.err_handler()
|
||||||
&format!("`?Trait` is not permitted in supertraits"),
|
.struct_span_err(poly.span, "`?Trait` is not permitted in supertraits");
|
||||||
);
|
|
||||||
let path_str = pprust::path_to_string(&poly.trait_ref.path);
|
let path_str = pprust::path_to_string(&poly.trait_ref.path);
|
||||||
err.note(&format!("traits are `?{}` by default", path_str));
|
err.note(&format!("traits are `?{}` by default", path_str));
|
||||||
err.emit();
|
err.emit();
|
||||||
@ -1474,7 +1473,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
(BoundKind::TraitObject, TraitBoundModifier::Maybe) => {
|
(BoundKind::TraitObject, TraitBoundModifier::Maybe) => {
|
||||||
let mut err = self.err_handler().struct_span_err(
|
let mut err = self.err_handler().struct_span_err(
|
||||||
poly.span,
|
poly.span,
|
||||||
&format!("`?Trait` is not permitted in trait object types"),
|
"`?Trait` is not permitted in trait object types",
|
||||||
);
|
);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
@ -450,10 +450,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if defined_hir.is_some() {
|
if let Some(def_hir) = defined_hir {
|
||||||
let upvars_map = self.infcx.tcx.upvars_mentioned(def_id).unwrap();
|
let upvars_map = self.infcx.tcx.upvars_mentioned(def_id).unwrap();
|
||||||
let upvar_def_span = self.infcx.tcx.hir().span(defined_hir.unwrap());
|
let upvar_def_span = self.infcx.tcx.hir().span(def_hir);
|
||||||
let upvar_span = upvars_map.get(&defined_hir.unwrap()).unwrap().span;
|
let upvar_span = upvars_map.get(&def_hir).unwrap().span;
|
||||||
diag.span_label(upvar_def_span, "variable defined here");
|
diag.span_label(upvar_def_span, "variable defined here");
|
||||||
diag.span_label(upvar_span, "variable captured here");
|
diag.span_label(upvar_span, "variable captured here");
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
for elem in place_ref.projection[base..].iter() {
|
for elem in place_ref.projection[base..].iter() {
|
||||||
cg_base = match elem.clone() {
|
cg_base = match *elem {
|
||||||
mir::ProjectionElem::Deref => {
|
mir::ProjectionElem::Deref => {
|
||||||
// a box with a non-zst allocator should not be directly dereferenced
|
// a box with a non-zst allocator should not be directly dereferenced
|
||||||
if cg_base.layout.ty.is_box() && !cg_base.layout.field(cx, 1).is_zst() {
|
if cg_base.layout.ty.is_box() && !cg_base.layout.field(cx, 1).is_zst() {
|
||||||
|
@ -520,13 +520,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
frame
|
frame
|
||||||
.instance
|
.instance
|
||||||
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
|
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
|
||||||
.or_else(|e| {
|
.map_err(|e| {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.delay_span_bug(
|
||||||
self.cur_span(),
|
self.cur_span(),
|
||||||
format!("failed to normalize {}", e.get_type_for_failure()).as_str(),
|
format!("failed to normalize {}", e.get_type_for_failure()).as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Err(InterpError::InvalidProgram(InvalidProgramInfo::TooGeneric))
|
InterpError::InvalidProgram(InvalidProgramInfo::TooGeneric)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,11 +1009,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(
|
write!(fmt, ": {:?}", self.ecx.dump_allocs(allocs.into_iter().flatten().collect()))
|
||||||
fmt,
|
|
||||||
": {:?}",
|
|
||||||
self.ecx.dump_allocs(allocs.into_iter().filter_map(|x| x).collect())
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Place::Ptr(mplace) => match mplace.ptr.provenance.and_then(Provenance::get_alloc_id) {
|
Place::Ptr(mplace) => match mplace.ptr.provenance.and_then(Provenance::get_alloc_id) {
|
||||||
Some(alloc_id) => write!(
|
Some(alloc_id) => write!(
|
||||||
|
@ -69,13 +69,7 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
|
|||||||
|
|
||||||
let verbose_entry_exit = match env::var_os(String::from(env) + "_ENTRY_EXIT") {
|
let verbose_entry_exit = match env::var_os(String::from(env) + "_ENTRY_EXIT") {
|
||||||
None => false,
|
None => false,
|
||||||
Some(v) => {
|
Some(v) => &v != "0",
|
||||||
if &v == "0" {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let layer = tracing_tree::HierarchicalLayer::default()
|
let layer = tracing_tree::HierarchicalLayer::default()
|
||||||
|
@ -167,8 +167,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||||||
if loc.statement_index > body[loc.block].statements.len() {
|
if loc.statement_index > body[loc.block].statements.len() {
|
||||||
let term = body[loc.block].terminator();
|
let term = body[loc.block].terminator();
|
||||||
for i in term.successors() {
|
for i in term.successors() {
|
||||||
stmts_and_targets
|
stmts_and_targets.push((Statement { source_info, kind: stmt.clone() }, i));
|
||||||
.push((Statement { source_info, kind: stmt.clone() }, i.clone()));
|
|
||||||
}
|
}
|
||||||
delta += 1;
|
delta += 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -435,11 +435,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
thir::InlineAsmOperand::SymFn { value, span } => {
|
thir::InlineAsmOperand::SymFn { value, span } => {
|
||||||
mir::InlineAsmOperand::SymFn {
|
mir::InlineAsmOperand::SymFn {
|
||||||
value: Box::new(Constant {
|
value: Box::new(Constant { span, user_ty: None, literal: value }),
|
||||||
span,
|
|
||||||
user_ty: None,
|
|
||||||
literal: value.into(),
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thir::InlineAsmOperand::SymStatic { def_id } => {
|
thir::InlineAsmOperand::SymStatic { def_id } => {
|
||||||
|
@ -264,7 +264,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
);
|
);
|
||||||
} else if let [success, fail] = *make_target_blocks(self) {
|
} else if let [success, fail] = *make_target_blocks(self) {
|
||||||
assert_eq!(value.ty(), ty);
|
assert_eq!(value.ty(), ty);
|
||||||
let expect = self.literal_operand(test.span, value.into());
|
let expect = self.literal_operand(test.span, value);
|
||||||
let val = Operand::Copy(place);
|
let val = Operand::Copy(place);
|
||||||
self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);
|
self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);
|
||||||
} else {
|
} else {
|
||||||
@ -277,8 +277,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let target_blocks = make_target_blocks(self);
|
let target_blocks = make_target_blocks(self);
|
||||||
|
|
||||||
// Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
|
// Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
|
||||||
let lo = self.literal_operand(test.span, lo.into());
|
let lo = self.literal_operand(test.span, lo);
|
||||||
let hi = self.literal_operand(test.span, hi.into());
|
let hi = self.literal_operand(test.span, hi);
|
||||||
let val = Operand::Copy(place);
|
let val = Operand::Copy(place);
|
||||||
|
|
||||||
let [success, fail] = *target_blocks else {
|
let [success, fail] = *target_blocks else {
|
||||||
@ -370,7 +370,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
place: Place<'tcx>,
|
place: Place<'tcx>,
|
||||||
mut ty: Ty<'tcx>,
|
mut ty: Ty<'tcx>,
|
||||||
) {
|
) {
|
||||||
let mut expect = self.literal_operand(source_info.span, value.into());
|
let mut expect = self.literal_operand(source_info.span, value);
|
||||||
let mut val = Operand::Copy(place);
|
let mut val = Operand::Copy(place);
|
||||||
|
|
||||||
// If we're using `b"..."` as a pattern, we need to insert an
|
// If we're using `b"..."` as a pattern, we need to insert an
|
||||||
|
@ -845,7 +845,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let first_provided_ty = if let Some((ty, _)) = final_arg_types[input_idx] {
|
let first_provided_ty = if let Some((ty, _)) = final_arg_types[input_idx] {
|
||||||
format!(",found `{}`", ty)
|
format!(",found `{}`", ty)
|
||||||
} else {
|
} else {
|
||||||
"".into()
|
String::new()
|
||||||
};
|
};
|
||||||
labels.push((
|
labels.push((
|
||||||
first_span,
|
first_span,
|
||||||
@ -857,7 +857,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if let Some((ty, _)) = final_arg_types[other_input_idx] {
|
if let Some((ty, _)) = final_arg_types[other_input_idx] {
|
||||||
format!(",found `{}`", ty)
|
format!(",found `{}`", ty)
|
||||||
} else {
|
} else {
|
||||||
"".into()
|
String::new()
|
||||||
};
|
};
|
||||||
labels.push((
|
labels.push((
|
||||||
second_span,
|
second_span,
|
||||||
@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let provided_ty = if let Some((ty, _)) = final_arg_types[dst_arg] {
|
let provided_ty = if let Some((ty, _)) = final_arg_types[dst_arg] {
|
||||||
format!(",found `{}`", ty)
|
format!(",found `{}`", ty)
|
||||||
} else {
|
} else {
|
||||||
"".into()
|
String::new()
|
||||||
};
|
};
|
||||||
labels.push((
|
labels.push((
|
||||||
provided_args[dst_arg].span,
|
provided_args[dst_arg].span,
|
||||||
@ -1744,8 +1744,7 @@ fn label_fn_like<'tcx>(
|
|||||||
.get_if_local(def_id)
|
.get_if_local(def_id)
|
||||||
.and_then(|node| node.body_id())
|
.and_then(|node| node.body_id())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|id| tcx.hir().body(id).params)
|
.flat_map(|id| tcx.hir().body(id).params);
|
||||||
.flatten();
|
|
||||||
|
|
||||||
for param in params {
|
for param in params {
|
||||||
spans.push_span_label(param.span, String::new());
|
spans.push_span_label(param.span, String::new());
|
||||||
|
@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
Obligation {
|
Obligation {
|
||||||
cause: cause.clone(),
|
cause: cause.clone(),
|
||||||
param_env: self.param_env,
|
param_env: self.param_env,
|
||||||
predicate: predicate.clone(),
|
predicate: *predicate,
|
||||||
recursion_depth: 0,
|
recursion_depth: 0,
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
@ -676,7 +676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let span = self_ty.span.ctxt().outer_expn_data().call_site;
|
let span = self_ty.span.ctxt().outer_expn_data().call_site;
|
||||||
let mut spans: MultiSpan = span.into();
|
let mut spans: MultiSpan = span.into();
|
||||||
spans.push_span_label(span, derive_msg.to_string());
|
spans.push_span_label(span, derive_msg.to_string());
|
||||||
let entry = spanned_predicates.entry(spans.into());
|
let entry = spanned_predicates.entry(spans);
|
||||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +704,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
ident.span.into()
|
ident.span.into()
|
||||||
};
|
};
|
||||||
spans.push_span_label(ident.span, "in this trait".to_string());
|
spans.push_span_label(ident.span, "in this trait".to_string());
|
||||||
let entry = spanned_predicates.entry(spans.into());
|
let entry = spanned_predicates.entry(spans);
|
||||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
spans.push_span_label(self_ty.span, String::new());
|
spans.push_span_label(self_ty.span, String::new());
|
||||||
|
|
||||||
let entry = spanned_predicates.entry(spans.into());
|
let entry = spanned_predicates.entry(spans);
|
||||||
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@ -1460,7 +1460,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
{
|
{
|
||||||
derives.push((
|
derives.push((
|
||||||
self_name.clone(),
|
self_name.clone(),
|
||||||
self_span.clone(),
|
self_span,
|
||||||
parent_diagnostic_name.to_string(),
|
parent_diagnostic_name.to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -705,7 +705,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let predicates = errors
|
let predicates = errors
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|error| {
|
.filter_map(|error| {
|
||||||
error.obligation.predicate.clone().to_opt_poly_trait_pred()
|
error.obligation.predicate.to_opt_poly_trait_pred()
|
||||||
});
|
});
|
||||||
for pred in predicates {
|
for pred in predicates {
|
||||||
self.infcx.suggest_restricting_param_bound(
|
self.infcx.suggest_restricting_param_bound(
|
||||||
|
Loading…
Reference in New Issue
Block a user