more clippy fixes
This commit is contained in:
parent
88b4ea8fb6
commit
5c454551da
27 changed files with 140 additions and 184 deletions
|
@ -446,7 +446,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
(&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
|
||||
if let hir::ExprKind::Lit(_) = expr.kind {
|
||||
if let Ok(src) = sm.span_to_snippet(sp) {
|
||||
if let Some(_) = replace_prefix(&src, "b\"", "\"") {
|
||||
if replace_prefix(&src, "b\"", "\"").is_some() {
|
||||
let pos = sp.lo() + BytePos(1);
|
||||
return Some((
|
||||
sp.with_hi(pos),
|
||||
|
@ -462,7 +462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
(&ty::Array(arr, _) | &ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => {
|
||||
if let hir::ExprKind::Lit(_) = expr.kind {
|
||||
if let Ok(src) = sm.span_to_snippet(sp) {
|
||||
if let Some(_) = replace_prefix(&src, "\"", "b\"") {
|
||||
if replace_prefix(&src, "\"", "b\"").is_some() {
|
||||
return Some((
|
||||
sp.shrink_to_lo(),
|
||||
"consider adding a leading `b`",
|
||||
|
|
|
@ -2058,8 +2058,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
) -> Option<(&Vec<ty::FieldDef>, SubstsRef<'tcx>)> {
|
||||
debug!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_t);
|
||||
|
||||
let mut autoderef = self.autoderef(span, base_t);
|
||||
while let Some((base_t, _)) = autoderef.next() {
|
||||
for (base_t, _) in self.autoderef(span, base_t) {
|
||||
match base_t.kind() {
|
||||
ty::Adt(base_def, substs) if !base_def.is_enum() => {
|
||||
let fields = &base_def.non_enum_variant().fields;
|
||||
|
|
|
@ -176,7 +176,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
|||
.type_var_origin(ty)
|
||||
.map(|origin| origin.span)
|
||||
.unwrap_or(rustc_span::DUMMY_SP);
|
||||
let oty = self.inner.borrow().opaque_types_vars.get(ty).map(|v| *v);
|
||||
let oty = self.inner.borrow().opaque_types_vars.get(ty).copied();
|
||||
if let Some(opaque_ty) = oty {
|
||||
debug!(
|
||||
"fallback_opaque_type_vars(ty={:?}): falling back to opaque type {:?}",
|
||||
|
|
|
@ -1045,34 +1045,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
call_expr: &'tcx hir::Expr<'tcx>,
|
||||
) {
|
||||
if let hir::ExprKind::Call(path, _) = &call_expr.kind {
|
||||
if let hir::ExprKind::Path(qpath) = &path.kind {
|
||||
if let hir::QPath::Resolved(_, path) = &qpath {
|
||||
for error in errors {
|
||||
if let ty::PredicateKind::Trait(predicate) =
|
||||
error.obligation.predicate.kind().skip_binder()
|
||||
if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &path.kind {
|
||||
for error in errors {
|
||||
if let ty::PredicateKind::Trait(predicate) =
|
||||
error.obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
// If any of the type arguments in this path segment caused the
|
||||
// `FulfillmentError`, point at its span (#61860).
|
||||
for arg in path
|
||||
.segments
|
||||
.iter()
|
||||
.filter_map(|seg| seg.args.as_ref())
|
||||
.flat_map(|a| a.args.iter())
|
||||
{
|
||||
// If any of the type arguments in this path segment caused the
|
||||
// `FulfillmentError`, point at its span (#61860).
|
||||
for arg in path
|
||||
.segments
|
||||
.iter()
|
||||
.filter_map(|seg| seg.args.as_ref())
|
||||
.flat_map(|a| a.args.iter())
|
||||
{
|
||||
if let hir::GenericArg::Type(hir_ty) = &arg {
|
||||
if let hir::TyKind::Path(hir::QPath::TypeRelative(..)) =
|
||||
&hir_ty.kind
|
||||
{
|
||||
// Avoid ICE with associated types. As this is best
|
||||
// effort only, it's ok to ignore the case. It
|
||||
// would trigger in `is_send::<T::AssocType>();`
|
||||
// from `typeck-default-trait-impl-assoc-type.rs`.
|
||||
} else {
|
||||
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, hir_ty);
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
if ty == predicate.self_ty() {
|
||||
error.obligation.cause.make_mut().span = hir_ty.span;
|
||||
}
|
||||
if let hir::GenericArg::Type(hir_ty) = &arg {
|
||||
if let hir::TyKind::Path(hir::QPath::TypeRelative(..)) =
|
||||
&hir_ty.kind
|
||||
{
|
||||
// Avoid ICE with associated types. As this is best
|
||||
// effort only, it's ok to ignore the case. It
|
||||
// would trigger in `is_send::<T::AssocType>();`
|
||||
// from `typeck-default-trait-impl-assoc-type.rs`.
|
||||
} else {
|
||||
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, hir_ty);
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
if ty == predicate.self_ty() {
|
||||
error.obligation.cause.make_mut().span = hir_ty.span;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1208,7 +1208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let edition_fix = candidates
|
||||
.iter()
|
||||
.find(|did| self.tcx.is_diagnostic_item(sym::TryInto, **did))
|
||||
.map(|&d| d);
|
||||
.copied();
|
||||
|
||||
err.help("items from traits can only be used if the trait is in scope");
|
||||
let msg = format!(
|
||||
|
|
|
@ -399,12 +399,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
if let Ref(_, rty, _) = lhs_ty.kind() {
|
||||
if {
|
||||
self.infcx.type_is_copy_modulo_regions(self.param_env, rty, lhs_expr.span)
|
||||
&& self
|
||||
.lookup_op_method(rty, &[rhs_ty], Op::Binary(op, is_assign))
|
||||
.is_ok()
|
||||
} {
|
||||
if self.infcx.type_is_copy_modulo_regions(self.param_env, rty, lhs_expr.span)
|
||||
&& self.lookup_op_method(rty, &[rhs_ty], Op::Binary(op, is_assign)).is_ok()
|
||||
{
|
||||
if let Ok(lstring) = source_map.span_to_snippet(lhs_expr.span) {
|
||||
let msg = &format!(
|
||||
"`{}{}` can be used on `{}`, you can dereference `{}`",
|
||||
|
|
|
@ -435,9 +435,7 @@ fn check_gat_where_clauses(
|
|||
let written_predicates: ty::GenericPredicates<'_> =
|
||||
tcx.explicit_predicates_of(trait_item.def_id);
|
||||
let mut clauses: Vec<_> = clauses
|
||||
.drain_filter(|clause| {
|
||||
written_predicates.predicates.iter().find(|p| &p.0 == clause).is_none()
|
||||
})
|
||||
.drain_filter(|clause| !written_predicates.predicates.iter().any(|p| &p.0 == clause))
|
||||
.map(|clause| format!("{}", clause))
|
||||
.collect();
|
||||
// We sort so that order is predictable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue