Skip to content

Commit 49395ef

Browse files
committed
Auto merge of #144044 - fmease:rollup-kg413pt, r=fmease
Rollup of 15 pull requests Successful merges: - rust-lang/rust#142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test) - rust-lang/rust#143388 (Various refactors to the LTO handling code) - rust-lang/rust#143409 (Enable xgot feature for mips64 musl targets) - rust-lang/rust#143592 (UWP: link ntdll functions using raw-dylib) - rust-lang/rust#143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call) - rust-lang/rust#143678 (Added error for invalid char cast) - rust-lang/rust#143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets) - rust-lang/rust#143829 (Trim `BorrowedCursor` API) - rust-lang/rust#143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test) - rust-lang/rust#143856 (Linting public reexport of private dependencies) - rust-lang/rust#143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates) - rust-lang/rust#143922 (Improve path segment joining) - rust-lang/rust#143964 (Fix handling of SCRIPT_ARG in docker images) - rust-lang/rust#144002 (Update poison.rs) - rust-lang/rust#144016 (trait_sel: `MetaSized` always holds temporarily) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3c048b3 + e9817c5 commit 49395ef

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

clippy_lints/src/methods/from_iter_instead_of_collect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
44
use clippy_utils::source::snippet_with_applicability;
55
use clippy_utils::ty::implements_trait;
66
use clippy_utils::{is_path_diagnostic_item, sugg};
7+
use rustc_ast::join_path_idents;
78
use rustc_errors::Applicability;
89
use rustc_hir::def::Res;
910
use rustc_hir::{self as hir, Expr, ExprKind, GenericArg, QPath, TyKind};
@@ -47,7 +48,7 @@ fn build_full_type(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, app: &mut Applica
4748
&& let QPath::Resolved(None, ty_path) = &ty_qpath
4849
&& let Res::Def(_, ty_did) = ty_path.res
4950
{
50-
let mut ty_str = itertools::join(ty_path.segments.iter().map(|s| s.ident), "::");
51+
let mut ty_str = join_path_idents(ty_path.segments.iter().map(|seg| seg.ident));
5152
let mut first = true;
5253
let mut append = |arg: &str| {
5354
write!(&mut ty_str, "{}{arg}", [", ", "<"][usize::from(first)]).unwrap();

clippy_utils/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ use std::sync::{Mutex, MutexGuard, OnceLock};
8989

9090
use itertools::Itertools;
9191
use rustc_abi::Integer;
92+
use rustc_ast::join_path_syms;
9293
use rustc_ast::ast::{self, LitKind, RangeLimits};
9394
use rustc_attr_data_structures::{AttributeKind, find_attr};
9495
use rustc_data_structures::fx::FxHashMap;
@@ -3245,8 +3246,8 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32453246
// a::b::c ::d::sym refers to
32463247
// e::f::sym:: ::
32473248
// result should be super::super::super::super::e::f
3248-
if let DefPathData::TypeNs(s) = l {
3249-
path.push(s.to_string());
3249+
if let DefPathData::TypeNs(sym) = l {
3250+
path.push(sym);
32503251
}
32513252
if let DefPathData::TypeNs(_) = r {
32523253
go_up_by += 1;
@@ -3256,7 +3257,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32563257
// a::b::sym:: :: refers to
32573258
// c::d::e ::f::sym
32583259
// when looking at `f`
3259-
Left(DefPathData::TypeNs(sym)) => path.push(sym.to_string()),
3260+
Left(DefPathData::TypeNs(sym)) => path.push(sym),
32603261
// consider:
32613262
// a::b::c ::d::sym refers to
32623263
// e::f::sym:: ::
@@ -3268,17 +3269,17 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32683269

32693270
if go_up_by > max_super {
32703271
// `super` chain would be too long, just use the absolute path instead
3271-
once(String::from("crate"))
3272-
.chain(to.data.iter().filter_map(|el| {
3272+
join_path_syms(
3273+
once(kw::Crate).chain(to.data.iter().filter_map(|el| {
32733274
if let DefPathData::TypeNs(sym) = el.data {
3274-
Some(sym.to_string())
3275+
Some(sym)
32753276
} else {
32763277
None
32773278
}
32783279
}))
3279-
.join("::")
3280+
)
32803281
} else {
3281-
repeat_n(String::from("super"), go_up_by).chain(path).join("::")
3282+
join_path_syms(repeat_n(kw::Super, go_up_by).chain(path))
32823283
}
32833284
}
32843285

0 commit comments

Comments
 (0)