don't use .into() to convert types to identical types (clippy::useless_conversion)

Example:
let _x: String = String::from("hello world").into();
This commit is contained in:
Matthias Krüger 2021-08-03 07:24:31 +02:00
parent e91405b9d5
commit 02b7754f9e
11 changed files with 21 additions and 22 deletions

View File

@ -585,7 +585,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let ptr = self.global_base_pointer(Pointer::new(id, offset))?; let ptr = self.global_base_pointer(Pointer::new(id, offset))?;
Operand::Indirect(MemPlace::from_ptr(ptr.into(), layout.align.abi)) Operand::Indirect(MemPlace::from_ptr(ptr.into(), layout.align.abi))
} }
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x.into())?.into()), ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x)?.into()),
ConstValue::Slice { data, start, end } => { ConstValue::Slice { data, start, end } => {
// We rely on mutability being set correctly in `data` to prevent writes // We rely on mutability being set correctly in `data` to prevent writes
// where none should happen. // where none should happen.

View File

@ -73,7 +73,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ty::FnPtr(sig) => { ty::FnPtr(sig) => {
let caller_abi = sig.abi(); let caller_abi = sig.abi();
let fn_ptr = self.read_pointer(&func)?; let fn_ptr = self.read_pointer(&func)?;
let fn_val = self.memory.get_fn(fn_ptr.into())?; let fn_val = self.memory.get_fn(fn_ptr)?;
( (
fn_val, fn_val,
caller_abi, caller_abi,

View File

@ -211,7 +211,7 @@ fn find_branch_value_info<'tcx>(
return None; return None;
}; };
let branch_value_scalar = branch_value.literal.try_to_scalar()?; let branch_value_scalar = branch_value.literal.try_to_scalar()?;
Some((branch_value_scalar.into(), branch_value_ty, *to_switch_on)) Some((branch_value_scalar, branch_value_ty, *to_switch_on))
} }
_ => None, _ => None,
} }

View File

@ -675,11 +675,10 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
if let Some(((_, trait_did, name), rhs)) = if let Some(((_, trait_did, name), rhs)) =
proj.as_ref().and_then(|(lhs, rhs)| Some((lhs.projection()?, rhs))) proj.as_ref().and_then(|(lhs, rhs)| Some((lhs.projection()?, rhs)))
{ {
impl_trait_proj.entry(param_idx).or_default().push(( impl_trait_proj
trait_did.into(), .entry(param_idx)
name, .or_default()
rhs, .push((trait_did, name, rhs));
));
} }
return None; return None;

View File

@ -1614,7 +1614,7 @@ impl Type {
impl Type { impl Type {
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> { fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
let t: PrimitiveType = match *self { let t: PrimitiveType = match *self {
ResolvedPath { did, .. } => return Some(did.into()), ResolvedPath { did, .. } => return Some(did),
DynTrait(ref bounds, _) => return bounds[0].trait_.inner_def_id(cache), DynTrait(ref bounds, _) => return bounds[0].trait_.inner_def_id(cache),
Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()), Primitive(p) => return cache.and_then(|c| c.primitive_locations.get(&p).cloned()),
BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference, BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference,

View File

@ -228,7 +228,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
if i.blanket_impl.is_none() { if i.blanket_impl.is_none() {
self.cache self.cache
.implementors .implementors
.entry(did.into()) .entry(did)
.or_default() .or_default()
.push(Impl { impl_item: item.clone() }); .push(Impl { impl_item: item.clone() });
} }

View File

@ -688,7 +688,7 @@ crate fn anchor<'a, 'cx: 'a>(
text: &'a str, text: &'a str,
cx: &'cx Context<'_>, cx: &'cx Context<'_>,
) -> impl fmt::Display + 'a { ) -> impl fmt::Display + 'a {
let parts = href(did.into(), cx); let parts = href(did, cx);
display_fn(move |f| { display_fn(move |f| {
if let Ok((url, short_ty, fqp)) = parts { if let Ok((url, short_ty, fqp)) = parts {
write!( write!(
@ -921,7 +921,7 @@ fn fmt_type<'cx>(
// everything comes in as a fully resolved QPath (hard to // everything comes in as a fully resolved QPath (hard to
// look at). // look at).
box clean::ResolvedPath { did, .. } => { box clean::ResolvedPath { did, .. } => {
match href(did.into(), cx) { match href(did, cx) {
Ok((ref url, _, ref path)) if !f.alternate() => { Ok((ref url, _, ref path)) if !f.alternate() => {
write!( write!(
f, f,

View File

@ -42,7 +42,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
name: item.name.unwrap().to_string(), name: item.name.unwrap().to_string(),
path: fqp[..fqp.len() - 1].join("::"), path: fqp[..fqp.len() - 1].join("::"),
desc, desc,
parent: Some(did.into()), parent: Some(did),
parent_idx: None, parent_idx: None,
search_type: get_index_search_type(&item, tcx), search_type: get_index_search_type(&item, tcx),
aliases: item.attrs.get_doc_aliases(), aliases: item.attrs.get_doc_aliases(),

View File

@ -293,7 +293,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
) -> Result<(Res, Option<String>), ErrorKind<'path>> { ) -> Result<(Res, Option<String>), ErrorKind<'path>> {
let tcx = self.cx.tcx; let tcx = self.cx.tcx;
let no_res = || ResolutionFailure::NotResolved { let no_res = || ResolutionFailure::NotResolved {
module_id: module_id.into(), module_id: module_id,
partial_res: None, partial_res: None,
unresolved: path_str.into(), unresolved: path_str.into(),
}; };
@ -521,7 +521,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
// but the disambiguator logic expects the associated item. // but the disambiguator logic expects the associated item.
// Store the kind in a side channel so that only the disambiguator logic looks at it. // Store the kind in a side channel so that only the disambiguator logic looks at it.
if let Some((kind, id)) = side_channel { if let Some((kind, id)) = side_channel {
self.kind_side_channel.set(Some((kind, id.into()))); self.kind_side_channel.set(Some((kind, id)));
} }
Ok((res, Some(fragment))) Ok((res, Some(fragment)))
}; };
@ -1268,7 +1268,7 @@ impl LinkCollector<'_, '_> {
// doesn't allow statements like `use str::trim;`, making this a (hopefully) // doesn't allow statements like `use str::trim;`, making this a (hopefully)
// valid omission. See https://github.com/rust-lang/rust/pull/80660#discussion_r551585677 // valid omission. See https://github.com/rust-lang/rust/pull/80660#discussion_r551585677
// for discussion on the matter. // for discussion on the matter.
verify(kind, id.into())?; verify(kind, id)?;
// FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether. // FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether.
// However I'm not sure how to check that across crates. // However I'm not sure how to check that across crates.
@ -1306,9 +1306,9 @@ impl LinkCollector<'_, '_> {
Some(ItemLink { link: ori_link.link, link_text, did: None, fragment }) Some(ItemLink { link: ori_link.link, link_text, did: None, fragment })
} }
Res::Def(kind, id) => { Res::Def(kind, id) => {
verify(kind, id.into())?; verify(kind, id)?;
let id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id)); let id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id));
Some(ItemLink { link: ori_link.link, link_text, did: Some(id.into()), fragment }) Some(ItemLink { link: ori_link.link, link_text, did: Some(id), fragment })
} }
} }
} }
@ -1886,7 +1886,7 @@ fn resolution_failure(
name = start; name = start;
for ns in [TypeNS, ValueNS, MacroNS] { for ns in [TypeNS, ValueNS, MacroNS] {
if let Some(res) = if let Some(res) =
collector.check_full_res(ns, &start, module_id.into(), &None) collector.check_full_res(ns, &start, module_id, &None)
{ {
debug!("found partial_res={:?}", res); debug!("found partial_res={:?}", res);
*partial_res = Some(res); *partial_res = Some(res);

View File

@ -45,7 +45,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
// FIXME(eddyb) is this `doc(hidden)` check needed? // FIXME(eddyb) is this `doc(hidden)` check needed?
if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) { if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) {
let impls = get_auto_trait_and_blanket_impls(cx, def_id.into()); let impls = get_auto_trait_and_blanket_impls(cx, def_id);
new_items.extend(impls.filter(|i| cx.inlined.insert(i.def_id))); new_items.extend(impls.filter(|i| cx.inlined.insert(i.def_id)));
} }
}); });

View File

@ -192,7 +192,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
} else { } else {
// All items need to be handled here in case someone wishes to link // All items need to be handled here in case someone wishes to link
// to them with intra-doc links // to them with intra-doc links
self.cx.cache.access_levels.map.insert(did.into(), AccessLevel::Public); self.cx.cache.access_levels.map.insert(did, AccessLevel::Public);
} }
} }
} }
@ -204,7 +204,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
None => return false, None => return false,
}; };
let is_private = !self.cx.cache.access_levels.is_public(res_did.into()); let is_private = !self.cx.cache.access_levels.is_public(res_did);
let is_hidden = inherits_doc_hidden(self.cx.tcx, res_hir_id); let is_hidden = inherits_doc_hidden(self.cx.tcx, res_hir_id);
// Only inline if requested or if the item would otherwise be stripped. // Only inline if requested or if the item would otherwise be stripped.