Skip to content

Commit 2dece5b

Browse files
committed
Auto merge of rust-lang#132317 - workingjubilee:rollup-x21ncea, r=workingjubilee
Rollup of 12 pull requests Successful merges: - rust-lang#131375 (compiler: apply clippy::clone_on_ref_ptr for CI) - rust-lang#131520 (Mark `str::is_char_boundary` and `str::split_at*` unstably `const`.) - rust-lang#132119 (Hack out effects support for old solver) - rust-lang#132194 (Collect item bounds for RPITITs from trait where clauses just like associated types) - rust-lang#132216 (correct LLVMRustCreateThinLTOData arg types) - rust-lang#132233 (Split `boxed.rs` into a few modules) - rust-lang#132266 (riscv-soft-abi-with-float-features.rs: adapt for LLVM 20) - rust-lang#132270 (clarified doc for `std::fs::OpenOptions.truncate()`) - rust-lang#132284 (Remove my ping for rustdoc/clean/types.rs) - rust-lang#132293 (Remove myself from mentions inside `tests/ui/check-cfg` directory) - rust-lang#132312 (Delete `tests/crashes/23707.rs` because it's flaky) - rust-lang#132313 (compiletest: Rename `command-list.rs` to `directive-list.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c8a8c82 + 6c5641c commit 2dece5b

File tree

90 files changed

+1580
-1504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1580
-1504
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3301,6 +3301,7 @@ version = "0.0.0"
33013301
dependencies = [
33023302
"itertools",
33033303
"rustc_ast",
3304+
"rustc_data_structures",
33043305
"rustc_lexer",
33053306
"rustc_span",
33063307
"thin-vec",

compiler/rustc_ast/src/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl Clone for TokenKind {
368368
// a copy. This is faster than the `derive(Clone)` version which has a
369369
// separate path for every variant.
370370
match self {
371-
Interpolated(nt) => Interpolated(nt.clone()),
371+
Interpolated(nt) => Interpolated(Lrc::clone(nt)),
372372
_ => unsafe { std::ptr::read(self) },
373373
}
374374
}

compiler/rustc_ast_lowering/src/expr.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::assert_matches::assert_matches;
33
use rustc_ast::ptr::P as AstP;
44
use rustc_ast::*;
55
use rustc_data_structures::stack::ensure_sufficient_stack;
6+
use rustc_data_structures::sync::Lrc;
67
use rustc_hir as hir;
78
use rustc_hir::HirId;
89
use rustc_hir::def::{DefKind, Res};
@@ -143,7 +144,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
143144
ExprKind::IncludedBytes(bytes) => {
144145
let lit = self.arena.alloc(respan(
145146
self.lower_span(e.span),
146-
LitKind::ByteStr(bytes.clone(), StrStyle::Cooked),
147+
LitKind::ByteStr(Lrc::clone(bytes), StrStyle::Cooked),
147148
));
148149
hir::ExprKind::Lit(lit)
149150
}
@@ -536,15 +537,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
536537
this.mark_span_with_reason(
537538
DesugaringKind::TryBlock,
538539
expr.span,
539-
Some(this.allow_try_trait.clone()),
540+
Some(Lrc::clone(&this.allow_try_trait)),
540541
),
541542
expr,
542543
)
543544
} else {
544545
let try_span = this.mark_span_with_reason(
545546
DesugaringKind::TryBlock,
546547
this.tcx.sess.source_map().end_point(body.span),
547-
Some(this.allow_try_trait.clone()),
548+
Some(Lrc::clone(&this.allow_try_trait)),
548549
);
549550

550551
(try_span, this.expr_unit(try_span))
@@ -653,7 +654,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
653654
let unstable_span = self.mark_span_with_reason(
654655
DesugaringKind::Async,
655656
self.lower_span(span),
656-
Some(self.allow_gen_future.clone()),
657+
Some(Lrc::clone(&self.allow_gen_future)),
657658
);
658659
let resume_ty =
659660
self.make_lang_item_qpath(hir::LangItem::ResumeTy, unstable_span, None);
@@ -739,7 +740,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
739740
let unstable_span = self.mark_span_with_reason(
740741
DesugaringKind::Async,
741742
span,
742-
Some(self.allow_gen_future.clone()),
743+
Some(Lrc::clone(&self.allow_gen_future)),
743744
);
744745
self.lower_attrs(inner_hir_id, &[Attribute {
745746
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
@@ -815,13 +816,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
815816

816817
let features = match await_kind {
817818
FutureKind::Future => None,
818-
FutureKind::AsyncIterator => Some(self.allow_for_await.clone()),
819+
FutureKind::AsyncIterator => Some(Lrc::clone(&self.allow_for_await)),
819820
};
820821
let span = self.mark_span_with_reason(DesugaringKind::Await, await_kw_span, features);
821822
let gen_future_span = self.mark_span_with_reason(
822823
DesugaringKind::Await,
823824
full_span,
824-
Some(self.allow_gen_future.clone()),
825+
Some(Lrc::clone(&self.allow_gen_future)),
825826
);
826827
let expr_hir_id = expr.hir_id;
827828

@@ -1841,13 +1842,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
18411842
let unstable_span = self.mark_span_with_reason(
18421843
DesugaringKind::QuestionMark,
18431844
span,
1844-
Some(self.allow_try_trait.clone()),
1845+
Some(Lrc::clone(&self.allow_try_trait)),
18451846
);
18461847
let try_span = self.tcx.sess.source_map().end_point(span);
18471848
let try_span = self.mark_span_with_reason(
18481849
DesugaringKind::QuestionMark,
18491850
try_span,
1850-
Some(self.allow_try_trait.clone()),
1851+
Some(Lrc::clone(&self.allow_try_trait)),
18511852
);
18521853

18531854
// `Try::branch(<expr>)`
@@ -1941,7 +1942,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19411942
let unstable_span = self.mark_span_with_reason(
19421943
DesugaringKind::YeetExpr,
19431944
span,
1944-
Some(self.allow_try_trait.clone()),
1945+
Some(Lrc::clone(&self.allow_try_trait)),
19451946
);
19461947

19471948
let from_yeet_expr = self.wrap_in_try_constructor(

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18781878
CoroutineKind::Async { return_impl_trait_id, .. } => (return_impl_trait_id, None),
18791879
CoroutineKind::Gen { return_impl_trait_id, .. } => (return_impl_trait_id, None),
18801880
CoroutineKind::AsyncGen { return_impl_trait_id, .. } => {
1881-
(return_impl_trait_id, Some(self.allow_async_iterator.clone()))
1881+
(return_impl_trait_id, Some(Lrc::clone(&self.allow_async_iterator)))
18821882
}
18831883
};
18841884

compiler/rustc_ast_lowering/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
7373
let bound_modifier_allowed_features = if let Res::Def(DefKind::Trait, async_def_id) = res
7474
&& self.tcx.async_fn_trait_kind_from_def_id(async_def_id).is_some()
7575
{
76-
Some(self.allow_async_fn_traits.clone())
76+
Some(Lrc::clone(&self.allow_async_fn_traits))
7777
} else {
7878
None
7979
};

compiler/rustc_ast_pretty/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77
# tidy-alphabetical-start
88
itertools = "0.12"
99
rustc_ast = { path = "../rustc_ast" }
10+
rustc_data_structures = { path = "../rustc_data_structures" }
1011
rustc_lexer = { path = "../rustc_lexer" }
1112
rustc_span = { path = "../rustc_span" }
1213
thin-vec = "0.2.12"

compiler/rustc_ast_pretty/src/pprust/state.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rustc_ast::{
2121
GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass,
2222
InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
2323
};
24+
use rustc_data_structures::sync::Lrc;
2425
use rustc_span::edition::Edition;
2526
use rustc_span::source_map::{SourceMap, Spanned};
2627
use rustc_span::symbol::{Ident, IdentPrinter, Symbol, kw, sym};
@@ -105,7 +106,7 @@ fn split_block_comment_into_lines(text: &str, col: CharPos) -> Vec<String> {
105106
fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comment> {
106107
let sm = SourceMap::new(sm.path_mapping().clone());
107108
let source_file = sm.new_source_file(path, src);
108-
let text = (*source_file.src.as_ref().unwrap()).clone();
109+
let text = Lrc::clone(&(*source_file.src.as_ref().unwrap()));
109110

110111
let text: &str = text.as_str();
111112
let start_bpos = source_file.start_pos;

compiler/rustc_borrowck/src/nll.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ pub(crate) fn compute_regions<'a, 'tcx>(
107107
param_env,
108108
body,
109109
promoted,
110-
universal_regions.clone(),
110+
Rc::clone(&universal_regions),
111111
location_table,
112112
borrow_set,
113113
&mut all_facts,
114114
flow_inits,
115115
move_data,
116-
elements.clone(),
116+
Rc::clone(&elements),
117117
upvars,
118118
);
119119

compiler/rustc_borrowck/src/region_infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
733733
}
734734

735735
// Now take member constraints into account.
736-
let member_constraints = self.member_constraints.clone();
736+
let member_constraints = Rc::clone(&self.member_constraints);
737737
for m_c_i in member_constraints.indices(scc_a) {
738738
self.apply_member_constraint(scc_a, m_c_i, member_constraints.choice_regions(m_c_i));
739739
}
@@ -1679,7 +1679,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
16791679
infcx: &InferCtxt<'tcx>,
16801680
errors_buffer: &mut RegionErrors<'tcx>,
16811681
) {
1682-
let member_constraints = self.member_constraints.clone();
1682+
let member_constraints = Rc::clone(&self.member_constraints);
16831683
for m_c_i in member_constraints.all_indices() {
16841684
debug!(?m_c_i);
16851685
let m_c = &member_constraints[m_c_i];

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub(crate) fn type_check<'a, 'tcx>(
134134
let mut constraints = MirTypeckRegionConstraints {
135135
placeholder_indices: PlaceholderIndices::default(),
136136
placeholder_index_to_region: IndexVec::default(),
137-
liveness_constraints: LivenessValues::with_specific_points(elements.clone()),
137+
liveness_constraints: LivenessValues::with_specific_points(Rc::clone(&elements)),
138138
outlives_constraints: OutlivesConstraintSet::default(),
139139
member_constraints: MemberConstraintSet::default(),
140140
type_tests: Vec::default(),
@@ -150,7 +150,7 @@ pub(crate) fn type_check<'a, 'tcx>(
150150
infcx,
151151
param_env,
152152
implicit_region_bound,
153-
universal_regions.clone(),
153+
Rc::clone(&universal_regions),
154154
&mut constraints,
155155
);
156156

compiler/rustc_codegen_llvm/src/back/lto.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ fn thin_lto(
503503
// upstream...
504504
let data = llvm::LLVMRustCreateThinLTOData(
505505
thin_modules.as_ptr(),
506-
thin_modules.len() as u32,
506+
thin_modules.len(),
507507
symbols_below_threshold.as_ptr(),
508-
symbols_below_threshold.len() as u32,
508+
symbols_below_threshold.len(),
509509
)
510510
.ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?;
511511

@@ -570,7 +570,7 @@ fn thin_lto(
570570

571571
info!(" - {}: re-compiled", module_name);
572572
opt_jobs.push(LtoModuleCodegen::Thin(ThinModule {
573-
shared: shared.clone(),
573+
shared: Arc::clone(&shared),
574574
idx: module_index,
575575
}));
576576
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2385,9 +2385,9 @@ unsafe extern "C" {
23852385
pub fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t;
23862386
pub fn LLVMRustCreateThinLTOData(
23872387
Modules: *const ThinLTOModule,
2388-
NumModules: c_uint,
2388+
NumModules: size_t,
23892389
PreservedSymbols: *const *const c_char,
2390-
PreservedSymbolsLen: c_uint,
2390+
PreservedSymbolsLen: size_t,
23912391
) -> Option<&'static mut ThinLTOData>;
23922392
pub fn LLVMRustPrepareThinLTORename(
23932393
Data: &ThinLTOData,

compiler/rustc_codegen_ssa/src/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
514514
future: Some(coordinator_thread),
515515
phantom: PhantomData,
516516
},
517-
output_filenames: tcx.output_filenames(()).clone(),
517+
output_filenames: Arc::clone(tcx.output_filenames(())),
518518
}
519519
}
520520

@@ -1203,7 +1203,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
12031203
coordinator_send,
12041204
expanded_args: tcx.sess.expanded_args.clone(),
12051205
diag_emitter: shared_emitter.clone(),
1206-
output_filenames: tcx.output_filenames(()).clone(),
1206+
output_filenames: Arc::clone(tcx.output_filenames(())),
12071207
regular_module_config: regular_config,
12081208
metadata_module_config: metadata_config,
12091209
allocator_module_config: allocator_config,

compiler/rustc_codegen_ssa/src/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, AllocatorKind, global_fn_n
77
use rustc_attr as attr;
88
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
99
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
10-
use rustc_data_structures::sync::par_map;
10+
use rustc_data_structures::sync::{Lrc, par_map};
1111
use rustc_data_structures::unord::UnordMap;
1212
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1313
use rustc_hir::lang_items::LangItem;
@@ -923,7 +923,7 @@ impl CrateInfo {
923923
crate_name: UnordMap::with_capacity(n_crates),
924924
used_crates,
925925
used_crate_source: UnordMap::with_capacity(n_crates),
926-
dependency_formats: tcx.dependency_formats(()).clone(),
926+
dependency_formats: Lrc::clone(tcx.dependency_formats(())),
927927
windows_subsystem,
928928
natvis_debugger_visualizers: Default::default(),
929929
};
@@ -936,7 +936,7 @@ impl CrateInfo {
936936
info.crate_name.insert(cnum, tcx.crate_name(cnum));
937937

938938
let used_crate_source = tcx.used_crate_source(cnum);
939-
info.used_crate_source.insert(cnum, used_crate_source.clone());
939+
info.used_crate_source.insert(cnum, Lrc::clone(used_crate_source));
940940
if tcx.is_profiler_runtime(cnum) {
941941
info.profiler_runtime = Some(cnum);
942942
}

compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ pub fn install_ice_hook(
13951395
}
13961396

13971397
let using_internal_features = Arc::new(std::sync::atomic::AtomicBool::default());
1398-
let using_internal_features_hook = using_internal_features.clone();
1398+
let using_internal_features_hook = Arc::clone(&using_internal_features);
13991399
panic::update_hook(Box::new(
14001400
move |default_hook: &(dyn Fn(&PanicHookInfo<'_>) + Send + Sync + 'static),
14011401
info: &PanicHookInfo<'_>| {

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl AnnotateSnippetEmitter {
173173
source_map.ensure_source_file_source_present(&file);
174174
(
175175
format!("{}", source_map.filename_for_diagnostics(&file.name)),
176-
source_string(file.clone(), &line),
176+
source_string(Lrc::clone(&file), &line),
177177
line.line_index,
178178
line.annotations,
179179
)

compiler/rustc_errors/src/emitter.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ impl HumanEmitter {
15551555
// Get the left-side margin to remove it
15561556
let mut whitespace_margin = usize::MAX;
15571557
for line_idx in 0..annotated_file.lines.len() {
1558-
let file = annotated_file.file.clone();
1558+
let file = Lrc::clone(&annotated_file.file);
15591559
let line = &annotated_file.lines[line_idx];
15601560
if let Some(source_string) =
15611561
line.line_index.checked_sub(1).and_then(|l| file.get_line(l))
@@ -1646,7 +1646,7 @@ impl HumanEmitter {
16461646

16471647
let depths = self.render_source_line(
16481648
&mut buffer,
1649-
annotated_file.file.clone(),
1649+
Lrc::clone(&annotated_file.file),
16501650
&annotated_file.lines[line_idx],
16511651
width_offset,
16521652
code_offset,
@@ -2529,7 +2529,12 @@ impl FileWithAnnotatedLines {
25292529
// | | |
25302530
// | |______foo
25312531
// | baz
2532-
add_annotation_to_file(&mut output, file.clone(), ann.line_start, ann.as_start());
2532+
add_annotation_to_file(
2533+
&mut output,
2534+
Lrc::clone(&file),
2535+
ann.line_start,
2536+
ann.as_start(),
2537+
);
25332538
// 4 is the minimum vertical length of a multiline span when presented: two lines
25342539
// of code and two lines of underline. This is not true for the special case where
25352540
// the beginning doesn't have an underline, but the current logic seems to be
@@ -2545,11 +2550,11 @@ impl FileWithAnnotatedLines {
25452550
.unwrap_or(ann.line_start);
25462551
for line in ann.line_start + 1..until {
25472552
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
2548-
add_annotation_to_file(&mut output, file.clone(), line, ann.as_line());
2553+
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
25492554
}
25502555
let line_end = ann.line_end - 1;
25512556
if middle < line_end {
2552-
add_annotation_to_file(&mut output, file.clone(), line_end, ann.as_line());
2557+
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
25532558
}
25542559
} else {
25552560
end_ann.annotation_type = AnnotationType::Singleline;

compiler/rustc_errors/src/json.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ impl Diagnostic {
367367
ColorConfig::Always | ColorConfig::Auto => dst = Box::new(termcolor::Ansi::new(dst)),
368368
ColorConfig::Never => {}
369369
}
370-
HumanEmitter::new(dst, je.fallback_bundle.clone())
370+
HumanEmitter::new(dst, Lrc::clone(&je.fallback_bundle))
371371
.short_message(short)
372-
.sm(Some(je.sm.clone()))
372+
.sm(Some(Lrc::clone(&je.sm)))
373373
.fluent_bundle(je.fluent_bundle.clone())
374374
.diagnostic_width(je.diagnostic_width)
375375
.macro_backtrace(je.macro_backtrace)

compiler/rustc_expand/src/mbe/macro_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl TtParser {
622622
// possible next positions into `next_mps`. After some post-processing, the contents of
623623
// `next_mps` replenish `cur_mps` and we start over again.
624624
self.cur_mps.clear();
625-
self.cur_mps.push(MatcherPos { idx: 0, matches: self.empty_matches.clone() });
625+
self.cur_mps.push(MatcherPos { idx: 0, matches: Rc::clone(&self.empty_matches) });
626626

627627
loop {
628628
self.next_mps.clear();

compiler/rustc_expand/src/mbe/transcribe.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc_ast::mut_visit::{self, MutVisitor};
55
use rustc_ast::token::{self, Delimiter, IdentIsRaw, Lit, LitKind, Nonterminal, Token, TokenKind};
66
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
77
use rustc_data_structures::fx::FxHashMap;
8+
use rustc_data_structures::sync::Lrc;
89
use rustc_errors::{Diag, DiagCtxtHandle, PResult, pluralize};
910
use rustc_parse::lexer::nfc_normalize;
1011
use rustc_parse::parser::ParseNtResult;
@@ -293,7 +294,7 @@ pub(super) fn transcribe<'a>(
293294
// `Delimiter::Invisible` to maintain parsing priorities.
294295
// `Interpolated` is currently used for such groups in rustc parser.
295296
marker.visit_span(&mut sp);
296-
TokenTree::token_alone(token::Interpolated(nt.clone()), sp)
297+
TokenTree::token_alone(token::Interpolated(Lrc::clone(nt)), sp)
297298
}
298299
MatchedSeq(..) => {
299300
// We were unable to descend far enough. This is an error.

compiler/rustc_hir_analysis/messages.ftl

-4
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ hir_analysis_drop_impl_reservation = reservation `Drop` impls are not supported
149149
hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twice
150150
.label = parameter captured again here
151151
152-
hir_analysis_effects_without_next_solver = using `#![feature(effects)]` without enabling next trait solver globally
153-
.note = the next trait solver must be enabled globally for the effects feature to work correctly
154-
.help = use `-Znext-solver` to enable
155-
156152
hir_analysis_empty_specialization = specialization impl does not specialize any associated items
157153
.note = impl is a specialization of this impl
158154

0 commit comments

Comments
 (0)