Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #137176

Merged
merged 121 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
ee6b5cf
Make Pat::Range's start and end Option<ExprId>
alibektas Jan 7, 2025
31a5685
Make higher levels adapt Bodys exprs having ExprOrPatId values
alibektas Jan 7, 2025
8a18dce
Add a test to monitor whats going on
alibektas Jan 7, 2025
d694b20
Make `rust-analyzer.files.excludeDirs` work, actually
ChayimFriedman2 Jan 22, 2025
cee2df2
Refactor `TyLoweringContext::substs_from_args_and_bindings()` to alwa…
ChayimFriedman2 Feb 4, 2025
54ad31b
Fix incorrect terminology
ChayimFriedman2 Feb 4, 2025
66599f1
Remove a no-longer-correct FIXME
ChayimFriedman2 Feb 4, 2025
c7e331b
Do not include excluded files even when the client opens them
ChayimFriedman2 Feb 4, 2025
7201010
fix: Apply adjustments to proper expr when invoking `CoerceMany`
ShoyuVanilla Feb 7, 2025
01794a4
simplify panic_context
eagr Feb 7, 2025
050c63a
Lower ast::Ident to hir::Path when lowering RangePats
alibektas Jan 19, 2025
e402c8c
make SourceAnalyzer::pat_id return ExprOrPatId
alibektas Jan 21, 2025
3e9633b
resolve_bind_pat_to_const does not early return if expr
alibektas Jan 21, 2025
0d544cf
Remove dbg lines
alibektas Jan 21, 2025
fcc7968
Remove fixme and add a missing test attribute
alibektas Jan 21, 2025
bf2f2c4
Fix clippy errors
alibektas Jan 21, 2025
bc5f61c
Check if PatPtr resolves to ExprId
alibektas Feb 3, 2025
9bd9bcf
fix off-by-one error
jyn514 Feb 9, 2025
d2459e5
fix target dir test
jyn514 Feb 9, 2025
b5ad702
Censor cfg_attr for attribute macros
ChayimFriedman2 Feb 9, 2025
ef8574a
Shadowing BuiltinType by Module
Hmikihiro Feb 10, 2025
340e9a3
Merge pull request #19088 from Hmikihiro/all_remove_duplicate_module_adt
ChayimFriedman2 Feb 10, 2025
8f8e1c6
pass struct fields to chalk
Austaras Feb 9, 2025
724b85e
Fix postfix completions inside macros
ChayimFriedman2 Feb 10, 2025
5373014
Merge pull request #19124 from jyn514/range-fmt-off-by-one
Veykril Feb 10, 2025
0dd7aad
add xtask codegen command as well
joshrotenberg Feb 10, 2025
7c68345
fix mdbook paths
joshrotenberg Feb 10, 2025
b4014de
Bump esbuild from 0.18.12 to 0.25.0 in /editors/code
dependabot[bot] Feb 11, 2025
11c49a6
Fix highlighting for extern crate in doc comments
asuto15 Feb 11, 2025
6e6bdc3
don't emit implicit drop inlay hints for macro
gohome001 Feb 11, 2025
4036a7a
add test case for ignoring inlay hint for macro call
gohome001 Feb 11, 2025
4883966
Merge pull request #18998 from ChayimFriedman2/exclude
Veykril Feb 11, 2025
da4c099
Merge pull request #19117 from gohome001/implicit-drop-inlay-hints-bug
ChayimFriedman2 Feb 11, 2025
d695e33
manual: Fix URLs to rustdoc pages
Wilfred Feb 11, 2025
8453e14
Merge pull request #19133 from joshrotenberg/fix-manual-github-paths
ChayimFriedman2 Feb 11, 2025
3a7a47b
remove unused plugin config
joshrotenberg Feb 11, 2025
98096fe
Merge pull request #19139 from Wilfred/fix_assists_urls
Veykril Feb 12, 2025
8ddf82b
Merge pull request #19140 from joshrotenberg/remove-mdbook-toc-config
Veykril Feb 12, 2025
3a041fc
Propogate error types in mir type projections
Veykril Feb 12, 2025
4aa318c
Merge pull request #19143 from Veykril/push-mkokotluzskw
Veykril Feb 12, 2025
c12a2e7
minor: don't show drop hints for other pattern
gohome001 Feb 12, 2025
7abfbee
Merge pull request #19144 from gohome001/follow_up_implicit_drop
Veykril Feb 12, 2025
9a257e9
Merge pull request #19136 from rust-lang/dependabot/npm_and_yarn/edit…
Veykril Feb 12, 2025
f504084
Merge pull request #19132 from joshrotenberg/book-readme-run-codegen
Veykril Feb 12, 2025
ad8c6c6
Merge pull request #19129 from ChayimFriedman2/snippet-macro
Veykril Feb 12, 2025
444c2f9
Merge pull request #18995 from alibektas/12210
Veykril Feb 12, 2025
8159195
Merge pull request #19125 from ChayimFriedman2/cfg-attr-fast
Veykril Feb 12, 2025
53e6870
Merge pull request #19110 from eagr/panic-context
Veykril Feb 12, 2025
4a15593
Merge pull request #19111 from ShoyuVanilla/issue-19021
Veykril Feb 12, 2025
a09ece2
fix: Do not show safety hints for extern items lacking semantics
Veykril Feb 7, 2025
0d8015c
fix: handle character boundary in search mode
roife Jan 12, 2025
2de7529
Merge pull request #19109 from Veykril/push-nzpuuqommpnq
Veykril Feb 12, 2025
537f4b2
Merge pull request #18928 from roife/fix-18918
Veykril Feb 12, 2025
f26f1dd
Spawn toolchain querying processes in parallel
Veykril Feb 12, 2025
d9256ab
Improve error recovery when method-calling a field
Veykril Feb 12, 2025
caa651a
Merge pull request #19148 from Veykril/push-ptnykrwnwwlu
Veykril Feb 12, 2025
875f3e2
Rename sysroot src/lib related things
Veykril Feb 12, 2025
2190e7b
Merge pull request #19142 from Veykril/push-upwqztrsuwpz
Veykril Feb 12, 2025
7ef1fcf
manual: Separate out installation and configuration pages
Wilfred Feb 11, 2025
d72b2df
Add modifiers to highlighting for extern crate
asuto15 Feb 12, 2025
21b0c22
Delete useless comma
asuto15 Feb 12, 2025
b3ef716
Apply cfg.setTest to json projects
darichey Feb 12, 2025
5023945
Merge pull request #19150 from darichey/set-test-json-project
Veykril Feb 13, 2025
1951cf5
Merge pull request #19141 from Wilfred/split_editors
Veykril Feb 13, 2025
7c61ec7
internal: Remove mutable syntax tree usages from `add_missing_match_a…
ShoyuVanilla Feb 13, 2025
bad69a3
add cargo's git checkouts to the list of paths to mark as read-only i…
programmerjake Feb 14, 2025
7f87814
Merge pull request #19156 from programmerjake/patch-1
Veykril Feb 14, 2025
36c314c
generate-copyright: pass the source root from bootstrap
pietroalbini Feb 14, 2025
08b4f6d
generate-copyright: pass the list of manifests from bootstrap
pietroalbini Feb 14, 2025
84485a8
Delete library modifier to highlighting for extern crate
asuto15 Feb 15, 2025
eaf22bc
fix: remove unnecessary conversion
asuto15 Feb 15, 2025
ea10f8e
boostrap: skip no_std targets in Std doc step
niklaskorz Feb 15, 2025
6e7838d
Factor out business logic of expand_glob_import
PoignardAzur Feb 15, 2025
1253006
Implement expand_glob_reexport assist
PoignardAzur Feb 15, 2025
4c7b609
Temporarily ignore tests with comments
ShoyuVanilla Feb 13, 2025
824b182
Re-generate doctests
PoignardAzur Feb 15, 2025
af804d2
Set `RUSTUP_TOOLCHAIN` when loading sysroot workspace
Veykril Feb 16, 2025
0a01cab
Merge pull request #19159 from Veykril/push-kwtzytsyktpv
Veykril Feb 16, 2025
930918d
Improve error recovery when method-calling an assoc function
Veykril Feb 16, 2025
b54269c
fix: Stabilize sort order of runnables
Veykril Feb 16, 2025
e6eadd3
Merge pull request #19160 from Veykril/push-f3601671f6a468a8cc0774253…
Veykril Feb 16, 2025
9e507b2
Merge pull request #19161 from Veykril/push-prmuyxlnxzxo
Veykril Feb 16, 2025
c5f49cf
fix: Stabilize sort order of `related_tests`
Veykril Feb 16, 2025
ac2ffdb
Merge pull request #19163 from Veykril/push-owykwupqnzpq
Veykril Feb 16, 2025
c8a5743
Merge pull request #19155 from ShoyuVanilla/migrate-missing-match-arms
Veykril Feb 16, 2025
4273bec
Merge pull request #19137 from asuto15/highlight-extern-crate
Veykril Feb 16, 2025
2e7158b
Refactor path lowering
ChayimFriedman2 Feb 10, 2025
1300310
Refactor `apply_effects_in_block`.
nnethercote Feb 11, 2025
23dbff8
Add a useful comment.
nnethercote Feb 12, 2025
8403d39
Add `SwitchTargetValue`.
nnethercote Feb 13, 2025
db1ca60
Update and clarify the comment on `SwitchTargets`.
nnethercote Feb 13, 2025
3b81d9d
Remove `SwitchIntTarget`.
nnethercote Feb 14, 2025
04ab837
Fix sorting of runnables
ChayimFriedman2 Feb 17, 2025
6b46937
Merge pull request #19166 from ChayimFriedman2/runnables-order
lnicola Feb 17, 2025
123f17c
Merge pull request #19127 from ChayimFriedman2/different-generic-args
Veykril Feb 17, 2025
9cbc310
Update default loongarch code model in docs
nikic Feb 17, 2025
6fa3ad1
correct comment
klensy Feb 17, 2025
d7fb8f1
Merge pull request #19122 from Austaras/master
Veykril Feb 17, 2025
f46c765
CI: rfl: move job forward to Linux v6.14-rc3
ojeda Feb 17, 2025
c7a2986
Merge pull request #19158 from PoignardAzur/expaned_pub_glob_imports
Veykril Feb 17, 2025
b7a9a32
Fix detection of ref patterns for path patterns
ChayimFriedman2 Feb 17, 2025
33e7f9b
generate-copyright: pass the vendored sources from bootstrap
pietroalbini Feb 17, 2025
a71de77
allow configuring jemalloc per target
pietroalbini Feb 17, 2025
19fa3de
Preparing for merge from rust-lang/rust
lnicola Feb 17, 2025
b571e8a
Merge from rust-lang/rust
lnicola Feb 17, 2025
2a0d16f
Merge pull request #19167 from ChayimFriedman2/fix-ref-pat
Veykril Feb 17, 2025
952bfae
Bump rustc crates
lnicola Feb 17, 2025
0c9c489
Merge pull request #19169 from lnicola/sync-from-rust
lnicola Feb 17, 2025
bce3d0f
Update lockfile
lnicola Feb 17, 2025
e08736d
Merge pull request #19170 from lnicola/update-lockfile
lnicola Feb 17, 2025
7112474
Use tell for <File as Seek>::stream_position
thaliaarchi Feb 17, 2025
92f31b9
use the shared vendor impl for plan source tarballs
pietroalbini Feb 17, 2025
005de38
Rollup merge of #136959 - nnethercote:simplify-SwitchSources, r=tmiasko
matthiaskrgr Feb 17, 2025
48543dd
Rollup merge of #137020 - ferrocene:pa-vendor-sources, r=Kobzol
matthiaskrgr Feb 17, 2025
97962d7
Rollup merge of #137073 - niklaskorz:bootstrap-doc-fix-empty-no-std, …
matthiaskrgr Feb 17, 2025
10018d8
Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDenton
matthiaskrgr Feb 17, 2025
652c8b6
Rollup merge of #137166 - nikic:loongarch-code-model, r=workingjubilee
matthiaskrgr Feb 17, 2025
7808784
Rollup merge of #137168 - klensy:rc--, r=lcnr
matthiaskrgr Feb 17, 2025
8d72b7c
Rollup merge of #137169 - ojeda:rfl, r=lqd
matthiaskrgr Feb 17, 2025
10cc816
Rollup merge of #137170 - ferrocene:pa-target-jemalloc, r=Kobzol
matthiaskrgr Feb 17, 2025
fc82903
Rollup merge of #137173 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Feb 17, 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
31 changes: 26 additions & 5 deletions compiler/rustc_middle/src/mir/basic_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,22 @@ pub struct BasicBlocks<'tcx> {
// Typically 95%+ of basic blocks have 4 or fewer predecessors.
type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;

type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
/// Each `(target, switch)` entry in the map contains a list of switch values
/// that lead to a `target` block from a `switch` block.
///
/// Note: this type is currently never instantiated, because it's only used for
/// `BasicBlocks::switch_sources`, which is only called by backwards analyses
/// that do `SwitchInt` handling, and we don't have any of those, not even in
/// tests. See #95120 and #94576.
type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[SwitchTargetValue; 1]>>;

#[derive(Debug, Clone, Copy)]
pub enum SwitchTargetValue {
// A normal switch value.
Normal(u128),
// The final "otherwise" fallback value.
Otherwise,
}

#[derive(Clone, Default, Debug)]
struct Cache {
Expand Down Expand Up @@ -70,8 +85,8 @@ impl<'tcx> BasicBlocks<'tcx> {
})
}

/// `switch_sources()[&(target, switch)]` returns a list of switch
/// values that lead to a `target` block from a `switch` block.
/// Returns info about switch values that lead from one block to another
/// block. See `SwitchSources`.
#[inline]
pub fn switch_sources(&self) -> &SwitchSources {
self.cache.switch_sources.get_or_init(|| {
Expand All @@ -82,9 +97,15 @@ impl<'tcx> BasicBlocks<'tcx> {
}) = &data.terminator
{
for (value, target) in targets.iter() {
switch_sources.entry((target, bb)).or_default().push(Some(value));
switch_sources
.entry((target, bb))
.or_default()
.push(SwitchTargetValue::Normal(value));
}
switch_sources.entry((targets.otherwise(), bb)).or_default().push(None);
switch_sources
.entry((targets.otherwise(), bb))
.or_default()
.push(SwitchTargetValue::Otherwise);
}
}
switch_sources
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::fmt::{self, Debug, Formatter};
use std::ops::{Index, IndexMut};
use std::{iter, mem};

pub use basic_blocks::BasicBlocks;
pub use basic_blocks::{BasicBlocks, SwitchTargetValue};
use either::Either;
use polonius_engine::Atom;
use rustc_abi::{FieldIdx, VariantIdx};
Expand Down
30 changes: 19 additions & 11 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,22 +1015,30 @@ impl TerminatorKind<'_> {

#[derive(Debug, Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
pub struct SwitchTargets {
/// Possible values. The locations to branch to in each case
/// are found in the corresponding indices from the `targets` vector.
/// Possible values. For each value, the location to branch to is found in
/// the corresponding element in the `targets` vector.
pub(super) values: SmallVec<[Pu128; 1]>,

/// Possible branch sites. The last element of this vector is used
/// for the otherwise branch, so targets.len() == values.len() + 1
/// should hold.
/// Possible branch targets. The last element of this vector is used for
/// the "otherwise" branch, so `targets.len() == values.len() + 1` always
/// holds.
//
// This invariant is quite non-obvious and also could be improved.
// One way to make this invariant is to have something like this instead:
// Note: This invariant is non-obvious and easy to violate. This would be a
// more rigorous representation:
//
// branches: Vec<(ConstInt, BasicBlock)>,
// otherwise: Option<BasicBlock> // exhaustive if None
// normal: SmallVec<[(Pu128, BasicBlock); 1]>,
// otherwise: BasicBlock,
//
// However we’ve decided to keep this as-is until we figure a case
// where some other approach seems to be strictly better than other.
// But it's important to have the targets in a sliceable type, because
// target slices show up elsewhere. E.g. `TerminatorKind::InlineAsm` has a
// boxed slice, and `TerminatorKind::FalseEdge` has a single target that
// can be converted to a slice with `slice::from_ref`.
//
// Why does this matter? In functions like `TerminatorKind::successors` we
// return `impl Iterator` and a non-slice-of-targets representation here
// causes problems because multiple different concrete iterator types would
// be involved and we would need a boxed trait object, which requires an
// allocation, which is expensive if done frequently.
pub(super) targets: SmallVec<[BasicBlock; 2]>,
}

Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/ty/typeck_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ pub struct TypeckResults<'tcx> {
coercion_casts: ItemLocalSet,

/// Set of trait imports actually used in the method resolution.
/// This is used for warning unused imports. During type
/// checking, this `Arc` should not be cloned: it must have a ref-count
/// of 1 so that we can insert things into the set mutably.
/// This is used for warning unused imports.
pub used_trait_imports: UnordSet<LocalDefId>,

/// If any errors occurred while type-checking this body,
Expand Down
27 changes: 11 additions & 16 deletions compiler/rustc_mir_dataflow/src/framework/direction.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::ops::RangeInclusive;

use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges};
use rustc_middle::mir::{
self, BasicBlock, CallReturnPlaces, Location, SwitchTargetValue, TerminatorEdges,
};

use super::visitor::ResultsVisitor;
use super::{Analysis, Effect, EffectIndex, Results, SwitchIntTarget};
use super::{Analysis, Effect, EffectIndex, Results};

pub trait Direction {
const IS_FORWARD: bool;
Expand Down Expand Up @@ -112,14 +114,10 @@ impl Direction for Backward {

mir::TerminatorKind::SwitchInt { targets: _, ref discr } => {
if let Some(mut data) = analysis.get_switch_int_data(block, discr) {
let values = &body.basic_blocks.switch_sources()[&(block, pred)];
let targets =
values.iter().map(|&value| SwitchIntTarget { value, target: block });

let mut tmp = analysis.bottom_value(body);
for target in targets {
tmp.clone_from(&exit_state);
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, target);
for &value in &body.basic_blocks.switch_sources()[&(block, pred)] {
tmp.clone_from(exit_state);
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, value);
propagate(pred, &tmp);
}
} else {
Expand Down Expand Up @@ -292,12 +290,9 @@ impl Direction for Forward {
if let Some(mut data) = analysis.get_switch_int_data(block, discr) {
let mut tmp = analysis.bottom_value(body);
for (value, target) in targets.iter() {
tmp.clone_from(&exit_state);
analysis.apply_switch_int_edge_effect(
&mut data,
&mut tmp,
SwitchIntTarget { value: Some(value), target },
);
tmp.clone_from(exit_state);
let value = SwitchTargetValue::Normal(value);
analysis.apply_switch_int_edge_effect(&mut data, &mut tmp, value);
propagate(target, &tmp);
}

Expand All @@ -308,7 +303,7 @@ impl Direction for Forward {
analysis.apply_switch_int_edge_effect(
&mut data,
exit_state,
SwitchIntTarget { value: None, target: otherwise },
SwitchTargetValue::Otherwise,
);
propagate(otherwise, exit_state);
} else {
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_mir_dataflow/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ use rustc_data_structures::work_queue::WorkQueue;
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
use rustc_index::{Idx, IndexVec};
use rustc_middle::bug;
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges, traversal};
use rustc_middle::mir::{
self, BasicBlock, CallReturnPlaces, Location, SwitchTargetValue, TerminatorEdges, traversal,
};
use rustc_middle::ty::TyCtxt;
use tracing::error;

Expand Down Expand Up @@ -220,7 +222,7 @@ pub trait Analysis<'tcx> {
&mut self,
_data: &mut Self::SwitchIntData,
_state: &mut Self::Domain,
_edge: SwitchIntTarget,
_value: SwitchTargetValue,
) {
unreachable!();
}
Expand Down Expand Up @@ -430,10 +432,5 @@ impl EffectIndex {
}
}

pub struct SwitchIntTarget {
pub value: Option<u128>,
pub target: BasicBlock,
}

#[cfg(test)]
mod tests;
13 changes: 7 additions & 6 deletions compiler/rustc_mir_dataflow/src/impls/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use rustc_abi::VariantIdx;
use rustc_index::Idx;
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
use rustc_middle::bug;
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
use rustc_middle::mir::{
self, Body, CallReturnPlaces, Location, SwitchTargetValue, TerminatorEdges,
};
use rustc_middle::ty::util::Discr;
use rustc_middle::ty::{self, TyCtxt};
use tracing::{debug, instrument};

use crate::drop_flag_effects::DropFlagState;
use crate::framework::SwitchIntTarget;
use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
use crate::{
Analysis, GenKill, MaybeReachable, drop_flag_effects, drop_flag_effects_for_function_entry,
Expand Down Expand Up @@ -422,9 +423,9 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
&mut self,
data: &mut Self::SwitchIntData,
state: &mut Self::Domain,
edge: SwitchIntTarget,
value: SwitchTargetValue,
) {
if let Some(value) = edge.value {
if let SwitchTargetValue::Normal(value) = value {
// Kill all move paths that correspond to variants we know to be inactive along this
// particular outgoing edge of a `SwitchInt`.
drop_flag_effects::on_all_inactive_variants(
Expand Down Expand Up @@ -535,9 +536,9 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
&mut self,
data: &mut Self::SwitchIntData,
state: &mut Self::Domain,
edge: SwitchIntTarget,
value: SwitchTargetValue,
) {
if let Some(value) = edge.value {
if let SwitchTargetValue::Normal(value) = value {
// Mark all move paths that correspond to variants other than this one as maybe
// uninitialized (in reality, they are *definitely* uninitialized).
drop_flag_effects::on_all_inactive_variants(
Expand Down
7 changes: 6 additions & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@
#remap-debuginfo = false

# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
# This option is only tested on Linux and OSX.
# This option is only tested on Linux and OSX. It can also be configured per-target in the
# [target.<tuple>] section.
#jemalloc = false

# Run tests in various test suites with the "nll compare mode" in addition to
Expand Down Expand Up @@ -927,6 +928,10 @@
# order to run `x check`.
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool)

# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
# This overrides the global `rust.jemalloc` option. See that option for more info.
#jemalloc = rust.jemalloc (bool)

# =============================================================================
# Distribution options
#
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,9 @@ impl Seek for &File {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
self.inner.seek(pos)
}
fn stream_position(&mut self) -> io::Result<u64> {
self.inner.tell()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1275,6 +1278,9 @@ impl Seek for File {
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
(&*self).seek(pos)
}
fn stream_position(&mut self) -> io::Result<u64> {
(&*self).stream_position()
}
}

#[stable(feature = "io_traits_arc", since = "1.73.0")]
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/hermit/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ impl File {
Err(Error::from_raw_os_error(22))
}

pub fn tell(&self) -> io::Result<u64> {
self.seek(SeekFrom::Current(0))
}

pub fn duplicate(&self) -> io::Result<File> {
Err(Error::from_raw_os_error(22))
}
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/pal/solid/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,11 @@ impl File {
abi::SOLID_FS_Lseek(self.fd.raw(), pos, whence)
})
.map_err(|e| e.as_io_error())?;

// Get the new offset
self.tell()
}

pub fn tell(&self) -> io::Result<u64> {
unsafe {
let mut out_offset = MaybeUninit::uninit();
error::SolidError::err_if_negative(abi::SOLID_FS_Ftell(
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/uefi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ impl File {
self.0
}

pub fn tell(&self) -> io::Result<u64> {
self.0
}

pub fn duplicate(&self) -> io::Result<File> {
self.0
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,10 @@ impl File {
Ok(n as u64)
}

pub fn tell(&self) -> io::Result<u64> {
self.seek(SeekFrom::Current(0))
}

pub fn duplicate(&self) -> io::Result<File> {
self.0.duplicate().map(File)
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/unsupported/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ impl File {
self.0
}

pub fn tell(&self) -> io::Result<u64> {
self.0
}

pub fn duplicate(&self) -> io::Result<File> {
self.0
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ impl File {
self.fd.seek(pos)
}

pub fn tell(&self) -> io::Result<u64> {
self.fd.tell()
}

pub fn duplicate(&self) -> io::Result<File> {
// https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-rationale.md#why-no-dup
unsupported()
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/windows/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ impl File {
Ok(newpos as u64)
}

pub fn tell(&self) -> io::Result<u64> {
self.seek(SeekFrom::Current(0))
}

pub fn duplicate(&self) -> io::Result<File> {
Ok(Self { handle: self.handle.try_clone()? })
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ pub fn rustc_cargo_env(

// Build jemalloc on AArch64 with support for page sizes up to 64K
// See: https://github.com/rust-lang/rust/pull/135081
if builder.config.jemalloc
if builder.config.jemalloc(target)
&& target.starts_with("aarch64")
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
{
Expand Down
Loading
Loading