Skip to content

Commit 917c047

Browse files
authored
Rollup merge of #87720 - matthiaskrgr:clippy_into, r=jyn514
don't use .into() to convert types to identical types (clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2 parents 75e1487 + 02b7754 commit 917c047

File tree

11 files changed

+21
-22
lines changed

11 files changed

+21
-22
lines changed

compiler/rustc_mir/src/interpret/operand.rs

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

compiler/rustc_mir/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
7373
ty::FnPtr(sig) => {
7474
let caller_abi = sig.abi();
7575
let fn_ptr = self.read_pointer(&func)?;
76-
let fn_val = self.memory.get_fn(fn_ptr.into())?;
76+
let fn_val = self.memory.get_fn(fn_ptr)?;
7777
(
7878
fn_val,
7979
caller_abi,

compiler/rustc_mir/src/transform/simplify_comparison_integral.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn find_branch_value_info<'tcx>(
211211
return None;
212212
};
213213
let branch_value_scalar = branch_value.literal.try_to_scalar()?;
214-
Some((branch_value_scalar.into(), branch_value_ty, *to_switch_on))
214+
Some((branch_value_scalar, branch_value_ty, *to_switch_on))
215215
}
216216
_ => None,
217217
}

src/librustdoc/clean/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,10 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
675675
if let Some(((_, trait_did, name), rhs)) =
676676
proj.as_ref().and_then(|(lhs, rhs)| Some((lhs.projection()?, rhs)))
677677
{
678-
impl_trait_proj.entry(param_idx).or_default().push((
679-
trait_did.into(),
680-
name,
681-
rhs,
682-
));
678+
impl_trait_proj
679+
.entry(param_idx)
680+
.or_default()
681+
.push((trait_did, name, rhs));
683682
}
684683

685684
return None;

src/librustdoc/clean/types.rs

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

src/librustdoc/formats/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
228228
if i.blanket_impl.is_none() {
229229
self.cache
230230
.implementors
231-
.entry(did.into())
231+
.entry(did)
232232
.or_default()
233233
.push(Impl { impl_item: item.clone() });
234234
}

src/librustdoc/html/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ crate fn anchor<'a, 'cx: 'a>(
688688
text: &'a str,
689689
cx: &'cx Context<'_>,
690690
) -> impl fmt::Display + 'a {
691-
let parts = href(did.into(), cx);
691+
let parts = href(did, cx);
692692
display_fn(move |f| {
693693
if let Ok((url, short_ty, fqp)) = parts {
694694
write!(
@@ -921,7 +921,7 @@ fn fmt_type<'cx>(
921921
// everything comes in as a fully resolved QPath (hard to
922922
// look at).
923923
box clean::ResolvedPath { did, .. } => {
924-
match href(did.into(), cx) {
924+
match href(did, cx) {
925925
Ok((ref url, _, ref path)) if !f.alternate() => {
926926
write!(
927927
f,

src/librustdoc/html/render/cache.rs

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

src/librustdoc/passes/collect_intra_doc_links.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
293293
) -> Result<(Res, Option<String>), ErrorKind<'path>> {
294294
let tcx = self.cx.tcx;
295295
let no_res = || ResolutionFailure::NotResolved {
296-
module_id: module_id.into(),
296+
module_id: module_id,
297297
partial_res: None,
298298
unresolved: path_str.into(),
299299
};
@@ -521,7 +521,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
521521
// but the disambiguator logic expects the associated item.
522522
// Store the kind in a side channel so that only the disambiguator logic looks at it.
523523
if let Some((kind, id)) = side_channel {
524-
self.kind_side_channel.set(Some((kind, id.into())));
524+
self.kind_side_channel.set(Some((kind, id)));
525525
}
526526
Ok((res, Some(fragment)))
527527
};
@@ -1268,7 +1268,7 @@ impl LinkCollector<'_, '_> {
12681268
// doesn't allow statements like `use str::trim;`, making this a (hopefully)
12691269
// valid omission. See https://github.com/rust-lang/rust/pull/80660#discussion_r551585677
12701270
// for discussion on the matter.
1271-
verify(kind, id.into())?;
1271+
verify(kind, id)?;
12721272

12731273
// FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether.
12741274
// However I'm not sure how to check that across crates.
@@ -1306,9 +1306,9 @@ impl LinkCollector<'_, '_> {
13061306
Some(ItemLink { link: ori_link.link, link_text, did: None, fragment })
13071307
}
13081308
Res::Def(kind, id) => {
1309-
verify(kind, id.into())?;
1309+
verify(kind, id)?;
13101310
let id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id));
1311-
Some(ItemLink { link: ori_link.link, link_text, did: Some(id.into()), fragment })
1311+
Some(ItemLink { link: ori_link.link, link_text, did: Some(id), fragment })
13121312
}
13131313
}
13141314
}
@@ -1886,7 +1886,7 @@ fn resolution_failure(
18861886
name = start;
18871887
for ns in [TypeNS, ValueNS, MacroNS] {
18881888
if let Some(res) =
1889-
collector.check_full_res(ns, &start, module_id.into(), &None)
1889+
collector.check_full_res(ns, &start, module_id, &None)
18901890
{
18911891
debug!("found partial_res={:?}", res);
18921892
*partial_res = Some(res);

src/librustdoc/passes/collect_trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
4545

4646
// FIXME(eddyb) is this `doc(hidden)` check needed?
4747
if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) {
48-
let impls = get_auto_trait_and_blanket_impls(cx, def_id.into());
48+
let impls = get_auto_trait_and_blanket_impls(cx, def_id);
4949
new_items.extend(impls.filter(|i| cx.inlined.insert(i.def_id)));
5050
}
5151
});

src/librustdoc/visit_ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
192192
} else {
193193
// All items need to be handled here in case someone wishes to link
194194
// to them with intra-doc links
195-
self.cx.cache.access_levels.map.insert(did.into(), AccessLevel::Public);
195+
self.cx.cache.access_levels.map.insert(did, AccessLevel::Public);
196196
}
197197
}
198198
}
@@ -204,7 +204,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
204204
None => return false,
205205
};
206206

207-
let is_private = !self.cx.cache.access_levels.is_public(res_did.into());
207+
let is_private = !self.cx.cache.access_levels.is_public(res_did);
208208
let is_hidden = inherits_doc_hidden(self.cx.tcx, res_hir_id);
209209

210210
// Only inline if requested or if the item would otherwise be stripped.

0 commit comments

Comments
 (0)