Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
2261154
core: add Peekable::next_if_map
kennytm Jul 10, 2025
bbf08d8
add a test with incorrect `if let`-`super let` drop order
dianne Aug 13, 2025
8fc3938
fix scope of `super let` bindings within `if let`
dianne Aug 13, 2025
52063ae
stabilize path_add_extension
hanna-kruppe Aug 10, 2025
7d09ce8
Bump slab from 0.4.10 to 0.4.11 in /tests/deps
dependabot[bot] Aug 20, 2025
6370c8e
Merge pull request #4533 from rust-lang/dependabot/cargo/tests/deps/s…
RalfJung Aug 20, 2025
07aff76
Prepare for merging from rust-lang/rust
Aug 21, 2025
fc5e20e
Merge ref '125ff8a788c5' from rust-lang/rust
Aug 21, 2025
f702219
update rustc-build-sysroot
RalfJung Aug 21, 2025
802de3d
Merge pull request #4534 from rust-lang/rustup-2025-08-21
RalfJung Aug 21, 2025
5c3f317
CI: also test on powerpc
RalfJung Aug 21, 2025
ad8b241
Merge pull request #4536 from RalfJung/ci
RalfJung Aug 21, 2025
9f15771
Prepare for merging from rust-lang/rust
Aug 22, 2025
4833659
Merge ref '8e3710ef31a0' from rust-lang/rust
Aug 22, 2025
dd91d77
Merge pull request #4537 from rust-lang/rustup-2025-08-22
RalfJung Aug 22, 2025
5068317
add some ZST reborrow tests
RalfJung Aug 22, 2025
069074e
Merge pull request #4538 from RalfJung/zst-rebor
RalfJung Aug 22, 2025
804b41e
Account for time spent tracing, use RDTSC for faster time
Stypox Aug 12, 2025
d70fea9
Merge pull request #4524 from Stypox/tracing-chrome-overhead-rdtsc
RalfJung Aug 23, 2025
c68450a
tree borrows: refactor new-permission logic
RalfJung Aug 23, 2025
416f988
refactor tb_rebor: reduce code duplication
RalfJung Aug 23, 2025
fe7892b
Merge pull request #4540 from RalfJung/tb-refactors
RalfJung Aug 23, 2025
8c2d2c0
Prepare for merging from rust-lang/rust
Aug 24, 2025
005dc5c
Merge ref 'f6d23413c399' from rust-lang/rust
Aug 24, 2025
9e18b7b
fmt
Aug 24, 2025
7f6f741
Merge pull request #4541 from rust-lang/rustup-2025-08-24
saethlin Aug 24, 2025
22ef90c
Prepare for merging from rust-lang/rust
Aug 25, 2025
ca89652
Merge ref 'a1dbb443527b' from rust-lang/rust
Aug 25, 2025
dd80147
Merge pull request #4542 from rust-lang/rustup-2025-08-25
RalfJung Aug 25, 2025
b08ebc5
TB: fix SIFA comment
RalfJung Aug 25, 2025
5ea8c2d
Merge pull request #4543 from RalfJung/tb-sifa
RalfJung Aug 25, 2025
a10bdf9
Prepare for merging from rust-lang/rust
Aug 27, 2025
aa58379
Merge ref '269d5b56bcfd' from rust-lang/rust
Aug 27, 2025
f44d957
Merge pull request #4544 from rust-lang/rustup-2025-08-27
RalfJung Aug 27, 2025
8743a04
Add documentation for tracing
Stypox Aug 22, 2025
4beb15f
Merge pull request #4539 from Stypox/tracing-docs
RalfJung Aug 28, 2025
fc7de99
Ensure we emit an allocator shim when only some crate types need one
bjorn3 Aug 28, 2025
1d30900
Fix typo in comment
bjorn3 Aug 28, 2025
f4888c2
Correctly handle different crate types disagreeing if the allocator s…
bjorn3 Aug 28, 2025
01ed105
unix read/write: fix zero-size handling
RalfJung Aug 28, 2025
74ade5b
Merge pull request #4545 from RalfJung/zst-readwrite
RalfJung Aug 29, 2025
497df60
Add duplicate handle test + make null lpTargetHandle an abort, not an…
CraftSpider Jun 2, 2025
aabfe43
Merge pull request #4371 from CraftSpider/duplicate-handle-test
RalfJung Aug 29, 2025
615450e
Bump tracing-subscriber from 0.3.19 to 0.3.20
dependabot[bot] Aug 29, 2025
b00c449
Merge pull request #4546 from rust-lang/dependabot/cargo/tracing-subs…
saethlin Aug 29, 2025
435de36
Prepare for merging from rust-lang/rust
Aug 30, 2025
d269d23
Merge ref 'e004014d1bf4' from rust-lang/rust
Aug 30, 2025
c8d20ce
Merge pull request #4548 from rust-lang/rustup-2025-08-30
oli-obk Aug 30, 2025
f2ff4c2
native-lib mode: avoid unsoundness due to mrpotect
RalfJung Aug 30, 2025
0308a15
reduce some code duplication and update some comments
RalfJung Aug 30, 2025
1feabac
Merge pull request #4549 from RalfJung/mprotect
RalfJung Aug 30, 2025
a44b180
add `#[must_use]` to `array::repeat`
joboet Aug 31, 2025
fbd8b96
native-lib: more resilient grabbing of instruction bytes
nia-e Aug 31, 2025
4dbadd0
native-lib: pass structs to native code
nia-e Jul 13, 2025
7e0ae3a
Merge pull request #4551 from nia-e/fixup-jump-instr
RalfJung Aug 31, 2025
c1d1677
some refactoring and cleanup
RalfJung Aug 31, 2025
1f0216e
Merge pull request #4466 from nia-e/native-structs
RalfJung Aug 31, 2025
0711bba
Ignore test when dylibs are not supported
bjorn3 Aug 31, 2025
988c077
Prepare for merging from rust-lang/rust
Sep 1, 2025
4cc7cca
Merge ref '828e45ad11ce' from rust-lang/rust
Sep 1, 2025
e8626a3
Merge pull request #4553 from rust-lang/rustup-2025-09-01
RalfJung Sep 1, 2025
20a3256
improve output for 'cargo miri test --help'
RalfJung Sep 1, 2025
8236def
Merge pull request #4554 from RalfJung/help
RalfJung Sep 1, 2025
821a44d
move some configuration enums to a more logical place
RalfJung Sep 1, 2025
5e9b655
Correct typo in `rustc_errors` comment
smoelius Sep 2, 2025
5b43244
Add LSX accelerated implementation for source file analysis
heiher Aug 28, 2025
a354649
add a flag to always apply the maximum float error
RalfJung Sep 2, 2025
d4f861e
account for aarch64 windows oversleeping
RalfJung Sep 2, 2025
a8537ab
Remove special implementation of `PartialEq` for `InvisibleOrigin` ou…
Kobzol Sep 1, 2025
80c3ba8
Merge pull request #4555 from RalfJung/float-err
RalfJung Sep 2, 2025
5d9f8fc
llvm: nvptx: Layout update to match LLVM
maurer Sep 2, 2025
916b55e
Revert "Make `lto` and `linker-plugin-lto` work the same for `compile…
rcvalle Sep 2, 2025
5a9e2e4
docs(std): add missing closing code block fences in doc comments
AudaciousAxiom Sep 2, 2025
af0d6f1
compiletest: cygwin follows windows in using PATH for dynamic libraries
jeremyd2019 Sep 2, 2025
4daea27
add zed editor config
nia-e Sep 2, 2025
ef1dab1
Prepare for merging from rust-lang/rust
Sep 3, 2025
d98a9c6
Merge ref '51ff895062ba' from rust-lang/rust
Sep 3, 2025
5f3197f
Merge pull request #4560 from rust-lang/rustup-2025-09-03
saethlin Sep 3, 2025
d9dc20c
raw_vec.rs: Remove superfluous fn alloc_guard
btj Aug 22, 2025
0fa93a3
Disallow frontmatter in `--cfg` and `--check-cfg` arguments
Urgau Sep 2, 2025
9f0b2a2
fix mangitude of applied float error
RalfJung Sep 2, 2025
3015ce1
Merge pull request #4559 from nia-e/zed-config
RalfJung Sep 3, 2025
df5896a
Rename `ToolRustc` to `ToolRustcPrivate`
Kobzol Sep 2, 2025
1421247
Merge pull request #4558 from RalfJung/float-err-fix
oli-obk Sep 3, 2025
2839853
add flag to not shorten FD reads/writes; don't shorten pipe operations
RalfJung Sep 3, 2025
2c8bd9b
Merge pull request #4561 from RalfJung/short-fd-ops
RalfJung Sep 3, 2025
18683c2
update lockfile
RalfJung Sep 3, 2025
1d7d788
Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhpratt
Zalathar Sep 3, 2025
e7ec9f7
Rollup merge of #145209 - hanna-kruppe:path_add_extension, r=tgross35
Zalathar Sep 3, 2025
e5df312
Rollup merge of #145342 - dianne:if-let-super-let, r=nnethercote
Zalathar Sep 3, 2025
b76fcc1
Rollup merge of #145750 - btj:drop-alloc-guard, r=tgross35
Zalathar Sep 3, 2025
bd15fe5
Rollup merge of #145962 - bjorn3:linkage_fixes, r=WaffleLapkin
Zalathar Sep 3, 2025
2828c5c
Rollup merge of #145963 - heiher:src-analysis-lsx, r=lqd
Zalathar Sep 3, 2025
a595e5c
Rollup merge of #146054 - joboet:array-repeat-must_use, r=ibraheemdev
Zalathar Sep 3, 2025
ad717dd
Rollup merge of #146090 - Kobzol:invisible-origin-eq, r=petrochenkov
Zalathar Sep 3, 2025
f12214f
Rollup merge of #146120 - smoelius:patch-3, r=lqd
Zalathar Sep 3, 2025
cc031f2
Rollup merge of #146127 - Kobzol:rename-tool-rustc, r=jieyouxu
Zalathar Sep 3, 2025
39cd957
Rollup merge of #146133 - rcvalle:rust-cfi-fix-145981, r=bjorn3
Zalathar Sep 3, 2025
643fbf0
Rollup merge of #146134 - maurer:nvptx-sync, r=durin42
Zalathar Sep 3, 2025
ab790b8
Rollup merge of #146136 - AudaciousAxiom:docs/missing-closing-code-bl…
Zalathar Sep 3, 2025
d60a2bf
Rollup merge of #146137 - Urgau:cfg-disallow-frontmatter, r=fmease
Zalathar Sep 3, 2025
6f20c43
Rollup merge of #146140 - jeremyd2019:patch-1, r=jieyouxu
Zalathar Sep 3, 2025
5c0ad20
Rollup merge of #146156 - RalfJung:miri, r=RalfJung
Zalathar Sep 3, 2025
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3204,9 +3204,9 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.5.9"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb13874a0e55baf4ac3d49d38206aecb31a55b75d6c4d04fd850b53942c8cc8"
checksum = "3b881c015c729b43105bbd3702a9bdecee28fafaa21126d1d62e454ec011a4b7"
dependencies = [
"anyhow",
"rustc_version",
Expand Down
20 changes: 3 additions & 17 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ pub enum CommentKind {
Block,
}

// This type must not implement `Hash` due to the unusual `PartialEq` impl below.
#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic)]
#[derive(Copy, Clone, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
pub enum InvisibleOrigin {
// From the expansion of a metavariable in a declarative macro.
MetaVar(MetaVarKind),
Expand All @@ -45,20 +44,6 @@ impl InvisibleOrigin {
}
}

impl PartialEq for InvisibleOrigin {
#[inline]
fn eq(&self, _other: &InvisibleOrigin) -> bool {
// When we had AST-based nonterminals we couldn't compare them, and the
// old `Nonterminal` type had an `eq` that always returned false,
// resulting in this restriction:
// https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment
// This `eq` emulates that behaviour. We could consider lifting this
// restriction now but there are still cases involving invisible
// delimiters that make it harder than it first appears.
false
}
}

/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
pub enum MetaVarKind {
Expand Down Expand Up @@ -142,7 +127,8 @@ impl Delimiter {
}
}

// This exists because `InvisibleOrigin`s should be compared. It is only used for assertions.
// This exists because `InvisibleOrigin`s should not be compared. It is only used for
// assertions.
pub fn eq_ignoring_invisible_origin(&self, other: &Delimiter) -> bool {
match (self, other) {
(Delimiter::Parenthesis, Delimiter::Parenthesis) => true,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ pub(crate) unsafe fn create_module<'ll>(
// LLVM 22.0 updated the default layout on avr: https://github.com/llvm/llvm-project/pull/153010
target_data_layout = target_data_layout.replace("n8:16", "n8")
}
if sess.target.arch == "nvptx64" {
// LLVM 22 updated the NVPTX layout to indicate 256-bit vector load/store: https://github.com/llvm/llvm-project/pull/155198
target_data_layout = target_data_layout.replace("-i256:256", "");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
Expand Down
17 changes: 13 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use super::linker::{self, Linker};
use super::metadata::{MetadataPosition, create_wrapper_file};
use super::rpath::{self, RPathConfig};
use super::{apple, versioned_llvm_target};
use crate::base::needs_allocator_shim_for_linking;
use crate::{
CodegenResults, CompiledModule, CrateInfo, NativeLib, errors, looks_like_rust_object_file,
};
Expand Down Expand Up @@ -2080,9 +2081,17 @@ fn add_local_crate_regular_objects(cmd: &mut dyn Linker, codegen_results: &Codeg
}

/// Add object files for allocator code linked once for the whole crate tree.
fn add_local_crate_allocator_objects(cmd: &mut dyn Linker, codegen_results: &CodegenResults) {
if let Some(obj) = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref()) {
cmd.add_object(obj);
fn add_local_crate_allocator_objects(
cmd: &mut dyn Linker,
codegen_results: &CodegenResults,
crate_type: CrateType,
) {
if needs_allocator_shim_for_linking(&codegen_results.crate_info.dependency_formats, crate_type)
{
if let Some(obj) = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref())
{
cmd.add_object(obj);
}
}
}

Expand Down Expand Up @@ -2281,7 +2290,7 @@ fn linker_with_args(
codegen_results,
metadata,
);
add_local_crate_allocator_objects(cmd, codegen_results);
add_local_crate_allocator_objects(cmd, codegen_results, crate_type);

// Avoid linking to dynamic libraries unless they satisfy some undefined symbols
// at the point at which they are specified on the command line.
Expand Down
17 changes: 14 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use rustc_metadata::{
};
use rustc_middle::bug;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols;
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportKind};
use rustc_middle::middle::exported_symbols::{
self, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
Expand All @@ -22,6 +23,8 @@ use tracing::{debug, warn};

use super::command::Command;
use super::symbol_export;
use crate::back::symbol_export::allocator_shim_symbols;
use crate::base::needs_allocator_shim_for_linking;
use crate::errors;

#[cfg(test)]
Expand Down Expand Up @@ -1827,7 +1830,7 @@ fn exported_symbols_for_non_proc_macro(
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
// from any dylib. The latter doesn't work anyway as we use hidden visibility for
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
symbols.push((
Expand All @@ -1838,6 +1841,14 @@ fn exported_symbols_for_non_proc_macro(
}
});

// Mark allocator shim symbols as exported only if they were generated.
if export_threshold == SymbolExportLevel::Rust
&& needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type)
&& tcx.allocator_kind(()).is_some()
{
symbols.extend(allocator_shim_symbols(tcx));
}

symbols
}

Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::config::{CrateType, Lto};
use tracing::info;

use crate::back::symbol_export::{self, symbol_name_for_instance_in_crate};
use crate::back::symbol_export::{self, allocator_shim_symbols, symbol_name_for_instance_in_crate};
use crate::back::write::CodegenContext;
use crate::base::allocator_kind_for_codegen;
use crate::errors::{DynamicLinkingWithLTO, LtoDisallowed, LtoDylib, LtoProcMacro};
use crate::traits::*;

Expand Down Expand Up @@ -115,6 +116,11 @@ pub(super) fn exported_symbols_for_lto(
}
}

// Mark allocator shim symbols as exported only if they were generated.
if export_threshold == SymbolExportLevel::Rust && allocator_kind_for_codegen(tcx).is_some() {
symbols_below_threshold.extend(allocator_shim_symbols(tcx).map(|(name, _kind)| name));
}

symbols_below_threshold
}

Expand Down
52 changes: 26 additions & 26 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::TlsModel;
use tracing::debug;

use crate::base::allocator_kind_for_codegen;
use crate::back::symbol_export;

fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
crates_export_threshold(tcx.crate_types())
Expand Down Expand Up @@ -217,31 +217,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
));
}

// Mark allocator shim symbols as exported only if they were generated.
if allocator_kind_for_codegen(tcx).is_some() {
for symbol_name in ALLOCATOR_METHODS
.iter()
.map(|method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
.chain([
mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
])
{
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

symbols.push((
exported_symbol,
SymbolExportInfo {
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: true,
},
));
}
}

// Sort so we get a stable incr. comp. hash.
symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx));

Expand Down Expand Up @@ -516,6 +491,31 @@ pub(crate) fn provide(providers: &mut Providers) {
upstream_monomorphizations_for_provider;
}

pub(crate) fn allocator_shim_symbols(
tcx: TyCtxt<'_>,
) -> impl Iterator<Item = (String, SymbolExportKind)> {
ALLOCATOR_METHODS
.iter()
.map(move |method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
.chain([
mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
])
.map(move |symbol_name| {
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

(
symbol_export::exporting_symbol_name_for_instance_in_crate(
tcx,
exported_symbol,
LOCAL_CRATE,
),
SymbolExportKind::Text,
)
})
}

fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel {
// We export anything that's not mangled at the "C" layer as it probably has
// to do with ABI concerns. We do not, however, apply such treatment to
Expand Down
13 changes: 12 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,23 @@ impl ModuleConfig {

let emit_obj = if !should_emit_obj {
EmitObj::None
} else if sess.target.obj_is_bitcode || sess.opts.cg.linker_plugin_lto.enabled() {
} else if sess.target.obj_is_bitcode
|| (sess.opts.cg.linker_plugin_lto.enabled() && !no_builtins)
{
// This case is selected if the target uses objects as bitcode, or
// if linker plugin LTO is enabled. In the linker plugin LTO case
// the assumption is that the final link-step will read the bitcode
// and convert it to object code. This may be done by either the
// native linker or rustc itself.
//
// Note, however, that the linker-plugin-lto requested here is
// explicitly ignored for `#![no_builtins]` crates. These crates are
// specifically ignored by rustc's LTO passes and wouldn't work if
// loaded into the linker. These crates define symbols that LLVM
// lowers intrinsics to, and these symbol dependencies aren't known
// until after codegen. As a result any crate marked
// `#![no_builtins]` is assumed to not participate in LTO and
// instead goes on to generate object code.
EmitObj::Bitcode
} else if need_bitcode_in_object(tcx) {
EmitObj::ObjectCode(BitcodeSection::Full)
Expand Down
27 changes: 22 additions & 5 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_hir::lang_items::LangItem;
use rustc_hir::{ItemId, Target};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType};
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::middle::exported_symbols::{self, SymbolExportKind};
use rustc_middle::middle::lang_items;
use rustc_middle::mir::BinOp;
Expand Down Expand Up @@ -630,14 +631,30 @@ pub fn allocator_kind_for_codegen(tcx: TyCtxt<'_>) -> Option<AllocatorKind> {
// If the crate doesn't have an `allocator_kind` set then there's definitely
// no shim to generate. Otherwise we also check our dependency graph for all
// our output crate types. If anything there looks like its a `Dynamic`
// linkage, then it's already got an allocator shim and we'll be using that
// one instead. If nothing exists then it's our job to generate the
// allocator!
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
// linkage for all crate types we may link as, then it's already got an
// allocator shim and we'll be using that one instead. If nothing exists
// then it's our job to generate the allocator! If crate types disagree
// about whether an allocator shim is necessary or not, we generate one
// and let needs_allocator_shim_for_linking decide at link time whether or
// not to use it for any particular linker invocation.
let all_crate_types_any_dynamic_crate = tcx.dependency_formats(()).iter().all(|(_, list)| {
use rustc_middle::middle::dependency_format::Linkage;
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
});
if any_dynamic_crate { None } else { tcx.allocator_kind(()) }
if all_crate_types_any_dynamic_crate { None } else { tcx.allocator_kind(()) }
}

/// Decide if this particular crate type needs an allocator shim linked in.
/// This may return true even when allocator_kind_for_codegen returns false. In
/// this case no allocator shim shall be linked.
pub(crate) fn needs_allocator_shim_for_linking(
dependency_formats: &Dependencies,
crate_type: CrateType,
) -> bool {
use rustc_middle::middle::dependency_format::Linkage;
let any_dynamic_crate =
dependency_formats[&crate_type].iter().any(|&linkage| linkage == Linkage::Dynamic);
!any_dynamic_crate
}

pub fn codegen_crate<B: ExtraBackendMethods>(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ impl<'a> DiagCtxtHandle<'a> {
// - It's only produce with JSON output.
// - It's not emitted the usual way, via `emit_diagnostic`.
// - The `$message_type` field is "unused_externs" rather than the usual
// "diagnosic".
// "diagnostic".
//
// We count it as a lint error because it has a lint level. The value
// of `loud` (which comes from "unused-externs" or
Expand Down
20 changes: 18 additions & 2 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use std::rc::Rc;

pub(crate) use NamedMatch::*;
pub(crate) use ParseResult::*;
use rustc_ast::token::{self, DocComment, NonterminalKind, Token};
use rustc_ast::token::{self, DocComment, NonterminalKind, Token, TokenKind};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_lint_defs::pluralize;
Expand Down Expand Up @@ -397,7 +397,23 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool {
{
ident1.name == ident2.name && is_raw1 == is_raw2
} else {
t1.kind == t2.kind
// Note: we SHOULD NOT use `t1.kind == t2.kind` here, and we should instead compare the
// tokens using the special comparison logic below.
// It makes sure that variants containing `InvisibleOrigin` will
// never compare equal to one another.
//
// When we had AST-based nonterminals we couldn't compare them, and the
// old `Nonterminal` type had an `eq` that always returned false,
// resulting in this restriction:
// <https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment>
// This comparison logic emulates that behaviour. We could consider lifting this
// restriction now but there are still cases involving invisible
// delimiters that make it harder than it first appears.
match (t1.kind, t2.kind) {
(TokenKind::OpenInvisible(_) | TokenKind::CloseInvisible(_), _)
| (_, TokenKind::OpenInvisible(_) | TokenKind::CloseInvisible(_)) => false,
(a, b) => a == b,
}
}
}

Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,8 @@ fn resolve_local<'tcx>(
//
// Iterate up to the enclosing destruction scope to find the same scope that will also
// be used for the result of the block itself.
while let Some(s) = visitor.cx.var_parent {
let parent = visitor.scope_tree.parent_map.get(&s).cloned();
if let Some(Scope { data: ScopeData::Destruction, .. }) = parent {
break;
}
visitor.cx.var_parent = parent;
if let Some(inner_scope) = visitor.cx.var_parent {
(visitor.cx.var_parent, _) = visitor.scope_tree.default_temporary_scope(inner_scope)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_lint::LintStore;
use rustc_middle::ty;
use rustc_middle::ty::CurrentGcx;
use rustc_middle::util::Providers;
use rustc_parse::new_parser_from_source_str;
use rustc_parse::new_parser_from_simple_source_str;
use rustc_parse::parser::attr::AllowLeadingUnsafe;
use rustc_query_impl::QueryCtxt;
use rustc_query_system::query::print_query_stack;
Expand Down Expand Up @@ -68,7 +68,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
};
}

match new_parser_from_source_str(&psess, filename, s.to_string()) {
match new_parser_from_simple_source_str(&psess, filename, s.to_string()) {
Ok(mut parser) => match parser.parse_meta_item(AllowLeadingUnsafe::No) {
Ok(meta_item) if parser.token == token::Eof => {
if meta_item.path.segments.len() != 1 {
Expand Down Expand Up @@ -166,7 +166,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
error!("expected `cfg(name, values(\"value1\", \"value2\", ... \"valueN\"))`")
};

let mut parser = match new_parser_from_source_str(&psess, filename, s.to_string()) {
let mut parser = match new_parser_from_simple_source_str(&psess, filename, s.to_string()) {
Ok(parser) => parser,
Err(errs) => {
errs.into_iter().for_each(|err| err.cancel());
Expand Down
Loading
Loading