Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't convert types to the same type with try_into (clippy::useless_conversion) #76757

Merged
merged 2 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
continue;
}

let span = sugared_span.take().unwrap_or_else(|| attr.span);
let span = sugared_span.take().unwrap_or(attr.span);

if attr.is_doc_comment() || cx.sess().check_name(attr, sym::doc) {
cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl Collector<'tcx> {
feature_err(
&self.tcx.sess.parse_sess,
sym::static_nobundle,
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
span.unwrap_or(rustc_span::DUMMY_SP),
"kind=\"static-nobundle\" is unstable",
)
.emit();
Expand All @@ -179,7 +179,7 @@ impl Collector<'tcx> {
feature_err(
&self.tcx.sess.parse_sess,
sym::raw_dylib,
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
span.unwrap_or(rustc_span::DUMMY_SP),
"kind=\"raw-dylib\" is unstable",
)
.emit();
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_mir/src/dataflow/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rustc_middle::mir::*;
use rustc_middle::ty::{self, TyCtxt};
use smallvec::{smallvec, SmallVec};

use std::convert::TryInto;
use std::mem;

use super::abs_domain::Lift;
Expand Down Expand Up @@ -481,12 +480,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
};
let base_ty = base_place.ty(self.builder.body, self.builder.tcx).ty;
let len: u64 = match base_ty.kind() {
ty::Array(_, size) => {
let length = size.eval_usize(self.builder.tcx, self.builder.param_env);
length
.try_into()
.expect("slice pattern of array with more than u32::MAX elements")
}
ty::Array(_, size) => size.eval_usize(self.builder.tcx, self.builder.param_env),
_ => bug!("from_end: false slice pattern of non-array type"),
};
for offset in from..to {
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ where
let n = base.len(self)?;
if n < min_length {
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
throw_ub!(BoundsCheckFailed { len: min_length, index: n });
}

let index = if from_end {
Expand All @@ -565,9 +565,7 @@ where
self.mplace_index(base, index)?
}

Subslice { from, to, from_end } => {
self.mplace_subslice(base, u64::from(from), u64::from(to), from_end)?
}
Subslice { from, to, from_end } => self.mplace_subslice(base, from, to, from_end)?,
})
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/matches/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let tcx = self.hir.tcx();
let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.kind() {
ty::Array(_, length) => {
(length.eval_usize(tcx, self.hir.param_env).try_into().unwrap(), true)
(length.eval_usize(tcx, self.hir.param_env), true)
}
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
};
Expand Down