Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
20cb59b
bootstrap: respect modern jobserver
haampie Feb 3, 2026
5c64b89
DOC: do not link to "nightly" in Iterator::by_ref() docstring
mgeier Feb 18, 2026
a9e6a89
bootstrap: add snapshot tests for {`install`, `install src`}
jieyouxu Feb 19, 2026
f99f249
Remove -Zemit-thin-lto flag
bjorn3 Feb 12, 2026
fa7f138
Deduplicate some code in LLVMRustOptimize
bjorn3 Feb 12, 2026
6dab8fa
Clarify comment
bjorn3 Feb 17, 2026
ede7279
Clarify some variable names in the query proc-macro
Zalathar Feb 18, 2026
27c0476
Fix typo in doc for core::mem::type_info::Struct
apasel422 Feb 19, 2026
aebafba
resolve: do not suggest `_` for unresolved imports
ozankenangungor Feb 19, 2026
4ab6d1f
std::ops::ControlFlow - use "a" before `Result`
DanielEScherzer Feb 19, 2026
a0fb142
Rollup merge of #152057 - haampie:hs/fix/bootstrap-respect-jobserver-…
jhpratt Feb 20, 2026
5174132
Rollup merge of #152527 - bjorn3:remove_z_emit_thin_lto, r=cuviper
jhpratt Feb 20, 2026
eb37a6c
Rollup merge of #152818 - mgeier:doc-by_ref-link, r=scottmcm
jhpratt Feb 20, 2026
cef021a
Rollup merge of #152840 - jieyouxu:bootstrap-install-src-no-docs, r=c…
jhpratt Feb 20, 2026
a4ac5d2
Rollup merge of #152846 - Zalathar:query-proc-macro, r=nnethercote
jhpratt Feb 20, 2026
85f2191
Rollup merge of #152858 - apasel422:patch-1, r=oli-obk
jhpratt Feb 20, 2026
d6e0701
Rollup merge of #152861 - ozankenangungor:fix-underscore-import-sugge…
jhpratt Feb 20, 2026
891edff
Rollup merge of #152873 - DanielEScherzer:patch-2, r=jhpratt
jhpratt Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,6 @@ pub(crate) unsafe fn llvm_optimize(
config.verify_llvm_ir,
config.lint_llvm_ir,
thin_lto_buffer,
config.emit_thin_lto,
config.emit_thin_lto_summary,
merge_functions,
unroll_loops,
Expand Down Expand Up @@ -1033,7 +1032,7 @@ pub(crate) fn codegen(
"LLVM_module_codegen_make_bitcode",
&*module.name,
);
ThinBuffer::new(llmod, config.emit_thin_lto)
ThinBuffer::new(llmod, cgcx.lto != Lto::Fat)
};
let data = thin.data();
let _timer = prof
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,6 @@ unsafe extern "C" {
VerifyIR: bool,
LintIR: bool,
ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>,
EmitThinLTO: bool,
EmitThinLTOSummary: bool,
MergeFunctions: bool,
UnrollLoops: bool,
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ pub struct ModuleConfig {
pub emit_ir: bool,
pub emit_asm: bool,
pub emit_obj: EmitObj,
pub emit_thin_lto: bool,
pub emit_thin_lto_summary: bool,

// Miscellaneous flags. These are mostly copied from command-line
Expand Down Expand Up @@ -212,9 +211,6 @@ impl ModuleConfig {
false
),
emit_obj,
// thin lto summaries prevent fat lto, so do not emit them if fat
// lto is requested. See PR #136840 for background information.
emit_thin_lto: sess.opts.unstable_opts.emit_thin_lto && sess.lto() != Lto::Fat,
emit_thin_lto_summary: if_regular!(
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
false
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(dwarf_version, Some(5));
tracked!(embed_metadata, false);
tracked!(embed_source, true);
tracked!(emit_thin_lto, false);
tracked!(emscripten_wasm_eh, false);
tracked!(export_executable_symbols, true);
tracked!(fewer_names, Some(true));
Expand Down
34 changes: 14 additions & 20 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef,
LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage,
bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR,
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTO,
bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef,
bool EmitThinLTOSummary, bool MergeFunctions, bool UnrollLoops,
bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls,
bool EmitLifetimeMarkers, registerEnzymeAndPassPipelineFn EnzymePtr,
Expand Down Expand Up @@ -808,44 +808,35 @@ extern "C" LLVMRustResult LLVMRustOptimize(
}

ModulePassManager MPM;
bool NeedThinLTOBufferPasses = EmitThinLTO;
bool NeedThinLTOBufferPasses = true;
auto ThinLTOBuffer = std::make_unique<LLVMRustThinLTOBuffer>();
raw_string_ostream ThinLTODataOS(ThinLTOBuffer->data);
raw_string_ostream ThinLinkDataOS(ThinLTOBuffer->thin_link_data);
bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO ||
OptStage == LLVMRustOptStage::FatLTO;
if (!NoPrepopulatePasses) {
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);

// The pre-link pipelines don't support O0 and require using
// buildO0DefaultPipeline() instead. At the same time, the LTO pipelines do
// support O0 and using them is required.
if (OptLevel == OptimizationLevel::O0 && !IsLTO) {
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);

// We manually schedule ThinLTOBufferPasses below, so don't pass the value
// to enable it here.
MPM = PB.buildO0DefaultPipeline(OptLevel);
} else {
for (const auto &C : PipelineStartEPCallbacks)
PB.registerPipelineStartEPCallback(C);
for (const auto &C : OptimizerLastEPCallbacks)
PB.registerOptimizerLastEPCallback(C);

switch (OptStage) {
case LLVMRustOptStage::PreLinkNoLTO:
if (ThinLTOBufferRef) {
// This is similar to LLVM's `buildFatLTODefaultPipeline`, where the
// bitcode for embedding is obtained after performing
// `ThinLTOPreLinkDefaultPipeline`.
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(OptLevel));
if (EmitThinLTO) {
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
} else {
MPM.addPass(BitcodeWriterPass(ThinLTODataOS));
}
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
*ThinLTOBufferRef = ThinLTOBuffer.release();
MPM.addPass(PB.buildModuleOptimizationPipeline(
OptLevel, ThinOrFullLTOPhase::None));
Expand All @@ -870,6 +861,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
break;
case LLVMRustOptStage::FatLTO:
MPM = PB.buildLTODefaultPipeline(OptLevel, nullptr);
NeedThinLTOBufferPasses = false;
break;
}
}
Expand All @@ -895,9 +887,11 @@ extern "C" LLVMRustResult LLVMRustOptimize(
MPM.addPass(CanonicalizeAliasesPass());
MPM.addPass(NameAnonGlobalPass());
}
// For `-Copt-level=0`, ThinLTO, or LTO.
// For `-Copt-level=0`, and the pre-link fat/thin LTO stages.
if (ThinLTOBufferRef && *ThinLTOBufferRef == nullptr) {
if (EmitThinLTO) {
// thin lto summaries prevent fat lto, so do not emit them if fat
// lto is requested. See PR #136840 for background information.
if (OptStage != LLVMRustOptStage::PreLinkFatLTO) {
MPM.addPass(ThinLTOBitcodeWriterPass(
ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr));
} else {
Expand Down
85 changes: 53 additions & 32 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,28 @@ fn check_attributes(attrs: Vec<Attribute>) -> Result<Vec<Attribute>> {
attrs.into_iter().map(inner).collect()
}

/// A compiler query. `query ... { ... }`
/// Declaration of a compiler query.
///
/// ```ignore (illustrative)
/// /// Doc comment for `my_query`.
/// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doc_comments
/// query my_query(key: DefId) -> Value { anon }
/// // ^^^^^^^^ name
/// // ^^^ key_pat
/// // ^^^^^ key_ty
/// // ^^^^^^^^ return_ty
/// // ^^^^ modifiers
/// ```
struct Query {
doc_comments: Vec<Attribute>,
modifiers: QueryModifiers,
name: Ident,
key: Pat,
arg: Type,
result: ReturnType,

/// Parameter name for the key, or an arbitrary irrefutable pattern (e.g. `_`).
key_pat: Pat,
key_ty: Type,
return_ty: ReturnType,

modifiers: QueryModifiers,
}

impl Parse for Query {
Expand All @@ -47,26 +61,30 @@ impl Parse for Query {
// Parse the query declaration. Like `query type_of(key: DefId) -> Ty<'tcx>`
input.parse::<kw::query>()?;
let name: Ident = input.parse()?;
let arg_content;
parenthesized!(arg_content in input);
let key = Pat::parse_single(&arg_content)?;
arg_content.parse::<Token![:]>()?;
let arg = arg_content.parse()?;
let _ = arg_content.parse::<Option<Token![,]>>()?;
let result = input.parse()?;

// `(key: DefId)`
let parens_content;
parenthesized!(parens_content in input);
let key_pat = Pat::parse_single(&parens_content)?;
parens_content.parse::<Token![:]>()?;
let key_ty = parens_content.parse::<Type>()?;
let _trailing_comma = parens_content.parse::<Option<Token![,]>>()?;

// `-> Value`
let return_ty = input.parse::<ReturnType>()?;

// Parse the query modifiers
let content;
braced!(content in input);
let modifiers = parse_query_modifiers(&content)?;
let braces_content;
braced!(braces_content in input);
let modifiers = parse_query_modifiers(&braces_content)?;

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

Ok(Query { doc_comments, modifiers, name, key, arg, result })
Ok(Query { doc_comments, modifiers, name, key_pat, key_ty, return_ty })
}
}

Expand Down Expand Up @@ -288,7 +306,7 @@ struct HelperTokenStreams {
}

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

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

let desc = quote! {
#[allow(unused_variables)]
pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, key: #arg) -> String {
let (#tcx, #key) = (tcx, key);
pub fn #erased_name<'tcx>(tcx: TyCtxt<'tcx>, key: #key_ty) -> String {
let (#tcx, #key_pat) = (tcx, key);
format!(#expr_list)
}
};
Expand Down Expand Up @@ -373,7 +391,7 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
let mut erased_name = name.clone();
erased_name.set_span(Span::call_site());

let result = &query.result;
let result = &query.return_ty;

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

for query in queries.0 {
let Query { name, arg, modifiers, .. } = &query;
let result_full = &query.result;
let result = match query.result {
let Query { doc_comments, name, key_ty, return_ty, modifiers, .. } = &query;

// Normalize an absent return type into `-> ()` to make macro-rules parsing easier.
let return_ty = match return_ty {
ReturnType::Default => quote! { -> () },
_ => quote! { #result_full },
ReturnType::Type(..) => quote! { #return_ty },
};

let mut attributes = Vec::new();
let mut modifiers_out = vec![];

macro_rules! passthrough {
( $( $modifier:ident ),+ $(,)? ) => {
$( if let Some($modifier) = &modifiers.$modifier {
attributes.push(quote! { (#$modifier) });
modifiers_out.push(quote! { (#$modifier) });
}; )+
}
}
Expand All @@ -452,7 +471,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
// on a synthetic `(cache_on_disk)` modifier that can be inspected by
// macro-rules macros.
if modifiers.cache_on_disk_if.is_some() {
attributes.push(quote! { (cache_on_disk) });
modifiers_out.push(quote! { (cache_on_disk) });
}

// This uses the span of the query definition for the commas,
Expand All @@ -462,12 +481,13 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
// at the entire `rustc_queries!` invocation, which wouldn't
// be very useful.
let span = name.span();
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
let doc_comments = &query.doc_comments;
let modifiers_stream = quote_spanned! { span => #(#modifiers_out),* };

// Add the query to the group
query_stream.extend(quote! {
#(#doc_comments)*
[#attribute_stream] fn #name(#arg) #result,
[#modifiers_stream]
fn #name(#key_ty) #return_ty,
});

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

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if i.name == ident.name {
return None;
} // Never suggest the same name
if i.name == kw::Underscore {
return None;
} // `use _` is never valid

let resolution = resolution.borrow();
if let Some(name_binding) = resolution.best_decl() {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2335,8 +2335,6 @@ options! {
"embed source text in DWARF debug sections (default: no)"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
"emit a section containing stack size metadata (default: no)"),
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
"emit the bc module with thin LTO info (default: yes)"),
emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED],
"Use WebAssembly error handling for wasm32-unknown-emscripten"),
enforce_type_length_limit: bool = (false, parse_bool, [TRACKED],
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ pub const trait Iterator {
/// without giving up ownership of the original iterator,
/// so you can use the original iterator afterwards.
///
/// 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).
/// Uses [`impl<I: Iterator + ?Sized> Iterator for &mut I { type Item = I::Item; ...}`](Iterator#impl-Iterator-for-%26mut+I).
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct Trait {
pub is_auto: bool,
}

/// Compile-time type information about arrays.
/// Compile-time type information about structs.
#[derive(Debug)]
#[non_exhaustive]
#[unstable(feature = "type_info", issue = "146922")]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<B, C> ControlFlow<B, C> {
}
}

/// Converts the `ControlFlow` into an `Result` which is `Ok` if the
/// Converts the `ControlFlow` into a `Result` which is `Ok` if the
/// `ControlFlow` was `Break` and `Err` if otherwise.
///
/// # Examples
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<B, C> ControlFlow<B, C> {
}
}

/// Converts the `ControlFlow` into an `Result` which is `Ok` if the
/// Converts the `ControlFlow` into a `Result` which is `Ok` if the
/// `ControlFlow` was `Continue` and `Err` if otherwise.
///
/// # Examples
Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,15 @@ fn configure_cmake(
.define("CMAKE_CXX_COMPILER", sanitize_cc(&cxx))
.define("CMAKE_ASM_COMPILER", sanitize_cc(&cc));

cfg.build_arg("-j").build_arg(builder.jobs().to_string());
// If we are running under a FIFO jobserver, we should not pass -j to CMake; otherwise it
// overrides the jobserver settings and can lead to oversubscription.
let has_modern_jobserver = env::var("MAKEFLAGS")
.map(|flags| flags.contains("--jobserver-auth=fifo:"))
.unwrap_or(false);

if !has_modern_jobserver {
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
}
let mut cflags = ccflags.cflags.clone();
// FIXME(madsmtm): Allow `cmake-rs` to select flags by itself by passing
// our flags via `.cflag`/`.cxxflag` instead.
Expand Down
Loading
Loading