Skip to content

Commit 60279ab

Browse files
committed
Auto merge of #152886 - jhpratt:rollup-rFaLot4, r=jhpratt
Rollup of 8 pull requests Successful merges: - #152057 (bootstrap: respect POSIX jobserver) - #152527 (Remove -Zemit-thin-lto flag) - #152818 (DOC: do not link to "nightly" in Iterator::by_ref() docstring) - #152840 (Add bootstrap snapshot tests for {`install`, `install src`}) - #152846 (Clarify some variable names in the query proc-macro) - #152858 (Fix typo in doc for core::mem::type_info::Struct) - #152861 (resolve: do not suggest `_` for unresolved imports) - #152873 (std::ops::ControlFlow - use "a" before `Result`)
2 parents 59fd4ef + 891edff commit 60279ab

16 files changed

Lines changed: 252 additions & 85 deletions

File tree

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,6 @@ pub(crate) unsafe fn llvm_optimize(
786786
config.verify_llvm_ir,
787787
config.lint_llvm_ir,
788788
thin_lto_buffer,
789-
config.emit_thin_lto,
790789
config.emit_thin_lto_summary,
791790
merge_functions,
792791
unroll_loops,
@@ -1033,7 +1032,7 @@ pub(crate) fn codegen(
10331032
"LLVM_module_codegen_make_bitcode",
10341033
&*module.name,
10351034
);
1036-
ThinBuffer::new(llmod, config.emit_thin_lto)
1035+
ThinBuffer::new(llmod, cgcx.lto != Lto::Fat)
10371036
};
10381037
let data = thin.data();
10391038
let _timer = prof

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,6 @@ unsafe extern "C" {
23762376
VerifyIR: bool,
23772377
LintIR: bool,
23782378
ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>,
2379-
EmitThinLTO: bool,
23802379
EmitThinLTOSummary: bool,
23812380
MergeFunctions: bool,
23822381
UnrollLoops: bool,

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ pub struct ModuleConfig {
101101
pub emit_ir: bool,
102102
pub emit_asm: bool,
103103
pub emit_obj: EmitObj,
104-
pub emit_thin_lto: bool,
105104
pub emit_thin_lto_summary: bool,
106105

107106
// Miscellaneous flags. These are mostly copied from command-line
@@ -212,9 +211,6 @@ impl ModuleConfig {
212211
false
213212
),
214213
emit_obj,
215-
// thin lto summaries prevent fat lto, so do not emit them if fat
216-
// lto is requested. See PR #136840 for background information.
217-
emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto && sess.lto() != Lto::Fat,
218214
emit_thin_lto_summary: if_regular!(
219215
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
220216
false

compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ fn test_unstable_options_tracking_hash() {
796796
tracked!(dwarf_version, Some(5));
797797
tracked!(embed_metadata, false);
798798
tracked!(embed_source, true);
799-
tracked!(emit_thin_lto, false);
800799
tracked!(emscripten_wasm_eh, false);
801800
tracked!(export_executable_symbols, true);
802801
tracked!(fewer_names, Some(true));

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
566566
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
567567
LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
568568
bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
569-
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTO,
569+
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef,
570570
bool EmitThinLTOSummary, bool MergeFunctions, bool UnrollLoops,
571571
bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
572572
bool EmitLifetimeMarkers, registerEnzymeAndPassPipelineFn EnzymePtr,
@@ -808,44 +808,35 @@ extern "C" LLVMRustResult LLVMRustOptimize(
808808
}
809809

810810
ModulePassManager MPM;
811-
bool NeedThinLTOBufferPasses = EmitThinLTO;
811+
bool NeedThinLTOBufferPasses = true;
812812
auto ThinLTOBuffer = std::make_unique<LLVMRustThinLTOBuffer>();
813813
raw_string_ostream ThinLTODataOS(ThinLTOBuffer->data);
814814
raw_string_ostream ThinLinkDataOS(ThinLTOBuffer->thin_link_data);
815815
bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO ||
816816
OptStage == LLVMRustOptStage::FatLTO;
817817
if (!NoPrepopulatePasses) {
818+
for (const auto &C : PipelineStartEPCallbacks)
819+
PB.registerPipelineStartEPCallback(C);
820+
for (const auto &C : OptimizerLastEPCallbacks)
821+
PB.registerOptimizerLastEPCallback(C);
822+
818823
// The pre-link pipelines don't support O0 and require using
819824
// buildO0DefaultPipeline() instead. At the same time, the LTO pipelines do
820825
// support O0 and using them is required.
821826
if (OptLevel == OptimizationLevel::O0 && !IsLTO) {
822-
for (const auto &C : PipelineStartEPCallbacks)
823-
PB.registerPipelineStartEPCallback(C);
824-
for (const auto &C : OptimizerLastEPCallbacks)
825-
PB.registerOptimizerLastEPCallback(C);
826-
827827
// We manually schedule ThinLTOBufferPasses below, so don't pass the value
828828
// to enable it here.
829829
MPM = PB.buildO0DefaultPipeline(OptLevel);
830830
} else {
831-
for (const auto &C : PipelineStartEPCallbacks)
832-
PB.registerPipelineStartEPCallback(C);
833-
for (const auto &C : OptimizerLastEPCallbacks)
834-
PB.registerOptimizerLastEPCallback(C);
835-
836831
switch (OptStage) {
837832
case LLVMRustOptStage::PreLinkNoLTO:
838833
if (ThinLTOBufferRef) {
839834
// This is similar to LLVM's `buildFatLTODefaultPipeline`, where the
840835
// bitcode for embedding is obtained after performing
841836
// `ThinLTOPreLinkDefaultPipeline`.
842837
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(OptLevel));
843-
if (EmitThinLTO) {
844-
MPM.addPass(ThinLTOBitcodeWriterPass(
845-
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
846-
} else {
847-
MPM.addPass(BitcodeWriterPass(ThinLTODataOS));
848-
}
838+
MPM.addPass(ThinLTOBitcodeWriterPass(
839+
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
849840
*ThinLTOBufferRef = ThinLTOBuffer.release();
850841
MPM.addPass(PB.buildModuleOptimizationPipeline(
851842
OptLevel, ThinOrFullLTOPhase::None));
@@ -870,6 +861,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
870861
break;
871862
case LLVMRustOptStage::FatLTO:
872863
MPM = PB.buildLTODefaultPipeline(OptLevel, nullptr);
864+
NeedThinLTOBufferPasses = false;
873865
break;
874866
}
875867
}
@@ -895,9 +887,11 @@ extern "C" LLVMRustResult LLVMRustOptimize(
895887
MPM.addPass(CanonicalizeAliasesPass());
896888
MPM.addPass(NameAnonGlobalPass());
897889
}
898-
// For `-Copt-level=0`, ThinLTO, or LTO.
890+
// For `-Copt-level=0`, and the pre-link fat/thin LTO stages.
899891
if (ThinLTOBufferRef && *ThinLTOBufferRef == nullptr) {
900-
if (EmitThinLTO) {
892+
// thin lto summaries prevent fat lto, so do not emit them if fat
893+
// lto is requested. See PR #136840 for background information.
894+
if (OptStage != LLVMRustOptStage::PreLinkFatLTO) {
901895
MPM.addPass(ThinLTOBitcodeWriterPass(
902896
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
903897
} else {

compiler/rustc_macros/src/query.rs

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,28 @@ fn check_attributes(attrs: Vec<Attribute>) -> Result<Vec<Attribute>> {
3030
attrs.into_iter().map(inner).collect()
3131
}
3232

33-
/// A compiler query. `query ... { ... }`
33+
/// Declaration of a compiler query.
34+
///
35+
/// ```ignore (illustrative)
36+
/// /// Doc comment for `my_query`.
37+
/// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doc_comments
38+
/// query my_query(key: DefId) -> Value { anon }
39+
/// // ^^^^^^^^ name
40+
/// // ^^^ key_pat
41+
/// // ^^^^^ key_ty
42+
/// // ^^^^^^^^ return_ty
43+
/// // ^^^^ modifiers
44+
/// ```
3445
struct Query {
3546
doc_comments: Vec<Attribute>,
36-
modifiers: QueryModifiers,
3747
name: Ident,
38-
key: Pat,
39-
arg: Type,
40-
result: ReturnType,
48+
49+
/// Parameter name for the key, or an arbitrary irrefutable pattern (e.g. `_`).
50+
key_pat: Pat,
51+
key_ty: Type,
52+
return_ty: ReturnType,
53+
54+
modifiers: QueryModifiers,
4155
}
4256

4357
impl Parse for Query {
@@ -47,26 +61,30 @@ impl Parse for Query {
4761
// Parse the query declaration. Like `query type_of(key: DefId) -> Ty<'tcx>`
4862
input.parse::<kw::query>()?;
4963
let name: Ident = input.parse()?;
50-
let arg_content;
51-
parenthesized!(arg_content in input);
52-
let key = Pat::parse_single(&arg_content)?;
53-
arg_content.parse::<Token![:]>()?;
54-
let arg = arg_content.parse()?;
55-
let _ = arg_content.parse::<Option<Token![,]>>()?;
56-
let result = input.parse()?;
64+
65+
// `(key: DefId)`
66+
let parens_content;
67+
parenthesized!(parens_content in input);
68+
let key_pat = Pat::parse_single(&parens_content)?;
69+
parens_content.parse::<Token![:]>()?;
70+
let key_ty = parens_content.parse::<Type>()?;
71+
let _trailing_comma = parens_content.parse::<Option<Token![,]>>()?;
72+
73+
// `-> Value`
74+
let return_ty = input.parse::<ReturnType>()?;
5775

5876
// Parse the query modifiers
59-
let content;
60-
braced!(content in input);
61-
let modifiers = parse_query_modifiers(&content)?;
77+
let braces_content;
78+
braced!(braces_content in input);
79+
let modifiers = parse_query_modifiers(&braces_content)?;
6280

6381
// If there are no doc-comments, give at least some idea of what
6482
// it does by showing the query description.
6583
if doc_comments.is_empty() {
6684
doc_comments.push(doc_comment_from_desc(&modifiers.desc.expr_list)?);
6785
}
6886

69-
Ok(Query { doc_comments, modifiers, name, key, arg, result })
87+
Ok(Query { doc_comments, modifiers, name, key_pat, key_ty, return_ty })
7088
}
7189
}
7290

@@ -288,7 +306,7 @@ struct HelperTokenStreams {
288306
}
289307

290308
fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
291-
let Query { name, key, modifiers, arg, .. } = &query;
309+
let Query { name, key_pat, key_ty, modifiers, .. } = &query;
292310

293311
// Replace span for `name` to make rust-analyzer ignore it.
294312
let mut erased_name = name.clone();
@@ -301,7 +319,7 @@ fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
301319
streams.cache_on_disk_if_fns_stream.extend(quote! {
302320
#[allow(unused_variables, rustc::pass_by_value)]
303321
#[inline]
304-
pub fn #erased_name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::queries::#name::Key<'tcx>) -> bool
322+
pub fn #erased_name<'tcx>(#tcx: TyCtxt<'tcx>, #key_pat: &crate::queries::#name::Key<'tcx>) -> bool
305323
#block
306324
});
307325
}
@@ -311,8 +329,8 @@ fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
311329

312330
let desc = quote! {
313331
#[allow(unused_variables)]
314-
pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, key: #arg) -> String {
315-
let (#tcx, #key) = (tcx, key);
332+
pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, key: #key_ty) -> String {
333+
let (#tcx, #key_pat) = (tcx, key);
316334
format!(#expr_list)
317335
}
318336
};
@@ -373,7 +391,7 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
373391
let mut erased_name = name.clone();
374392
erased_name.set_span(Span::call_site());
375393

376-
let result = &query.result;
394+
let result = &query.return_ty;
377395

378396
// This dead code exists to instruct rust-analyzer about the link between the `rustc_queries`
379397
// query names and the corresponding produced provider. The issue is that by nature of this
@@ -417,19 +435,20 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
417435
}
418436

419437
for query in queries.0 {
420-
let Query { name, arg, modifiers, .. } = &query;
421-
let result_full = &query.result;
422-
let result = match query.result {
438+
let Query { doc_comments, name, key_ty, return_ty, modifiers, .. } = &query;
439+
440+
// Normalize an absent return type into `-> ()` to make macro-rules parsing easier.
441+
let return_ty = match return_ty {
423442
ReturnType::Default => quote! { -> () },
424-
_ => quote! { #result_full },
443+
ReturnType::Type(..) => quote! { #return_ty },
425444
};
426445

427-
let mut attributes = Vec::new();
446+
let mut modifiers_out = vec![];
428447

429448
macro_rules! passthrough {
430449
( $( $modifier:ident ),+ $(,)? ) => {
431450
$( if let Some($modifier) = &modifiers.$modifier {
432-
attributes.push(quote! { (#$modifier) });
451+
modifiers_out.push(quote! { (#$modifier) });
433452
}; )+
434453
}
435454
}
@@ -452,7 +471,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
452471
// on a synthetic `(cache_on_disk)` modifier that can be inspected by
453472
// macro-rules macros.
454473
if modifiers.cache_on_disk_if.is_some() {
455-
attributes.push(quote! { (cache_on_disk) });
474+
modifiers_out.push(quote! { (cache_on_disk) });
456475
}
457476

458477
// This uses the span of the query definition for the commas,
@@ -462,12 +481,13 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
462481
// at the entire `rustc_queries!` invocation, which wouldn't
463482
// be very useful.
464483
let span = name.span();
465-
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
466-
let doc_comments = &query.doc_comments;
484+
let modifiers_stream = quote_spanned! { span => #(#modifiers_out),* };
485+
467486
// Add the query to the group
468487
query_stream.extend(quote! {
469488
#(#doc_comments)*
470-
[#attribute_stream] fn #name(#arg) #result,
489+
[#modifiers_stream]
490+
fn #name(#key_ty) #return_ty,
471491
});
472492

473493
if let Some(feedable) = &modifiers.feedable {
@@ -482,7 +502,8 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
482502
"Query {name} cannot be both `feedable` and `eval_always`."
483503
);
484504
feedable_queries.extend(quote! {
485-
[#attribute_stream] fn #name(#arg) #result,
505+
[#modifiers_stream]
506+
fn #name(#key_ty) #return_ty,
486507
});
487508
}
488509

compiler/rustc_resolve/src/imports.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12821282
if i.name == ident.name {
12831283
return None;
12841284
} // Never suggest the same name
1285+
if i.name == kw::Underscore {
1286+
return None;
1287+
} // `use _` is never valid
12851288

12861289
let resolution = resolution.borrow();
12871290
if let Some(name_binding) = resolution.best_decl() {

compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,8 +2335,6 @@ options! {
23352335
"embed source text in DWARF debug sections (default: no)"),
23362336
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
23372337
"emit a section containing stack size metadata (default: no)"),
2338-
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
2339-
"emit the bc module with thin LTO info (default: yes)"),
23402338
emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED],
23412339
"Use WebAssembly error handling for wasm32-unknown-emscripten"),
23422340
enforce_type_length_limit: bool = (false, parse_bool, [TRACKED],

library/core/src/iter/traits/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ pub const trait Iterator {
19081908
/// without giving up ownership of the original iterator,
19091909
/// so you can use the original iterator afterwards.
19101910
///
1911-
/// Uses [`impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#impl-Iterator-for-%26mut+I).
1911+
/// Uses [`impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}`](Iterator#impl-Iterator-for-%26mut+I).
19121912
///
19131913
/// # Examples
19141914
///

library/core/src/mem/type_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub struct Trait {
153153
pub is_auto: bool,
154154
}
155155

156-
/// Compile-time type information about arrays.
156+
/// Compile-time type information about structs.
157157
#[derive(Debug)]
158158
#[non_exhaustive]
159159
#[unstable(feature = "type_info", issue = "146922")]

0 commit comments

Comments
 (0)