Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d32d1c1
Size optimize int formatting
diondokter May 27, 2024
cdccf52
Clarify our tier 1 Windows Server support
ChrisDenton Jun 5, 2024
3f892f8
Clarify an `x fmt` error.
nnethercote Jun 5, 2024
8781074
Raise `DEFAULT_MIN_STACK_SIZE` to at least 64KiB
workingjubilee Jun 6, 2024
5772181
Migrate `run-make/symlinked-rlib` to `rmake.rs`
GuillaumeGomez Jun 5, 2024
7ad5ebc
Migrate `run-make/manual-crate-name` to `rmake.rs`
GuillaumeGomez Jun 6, 2024
c7ced1b
Make the panic info more useful
oli-obk Sep 6, 2023
0a4176a
Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"
lqd Jun 6, 2024
9ddf572
add non-regression run-make test for issues 125474, 125484, and 125646
lqd May 29, 2024
dc91ad0
Port `tests/run-make-fulldeps/obtain-borrowck` to ui-fulldeps
Zalathar Jun 5, 2024
b09f5a1
Rollup merge of #125606 - diondokter:opt-size-int-fmt, r=cuviper
GuillaumeGomez Jun 6, 2024
8ff5334
Rollup merge of #126015 - GuillaumeGomez:migrate-run-make-symlinked-r…
GuillaumeGomez Jun 6, 2024
805d6a5
Rollup merge of #126034 - ChrisDenton:winsupport, r=ehuss
GuillaumeGomez Jun 6, 2024
b00aa85
Rollup merge of #126035 - oli-obk:query_macro_errors, r=fmease
GuillaumeGomez Jun 6, 2024
8f55122
Rollup merge of #126051 - nnethercote:clarify-x-fmt-error, r=Nilstrieb
GuillaumeGomez Jun 6, 2024
5ef362f
Rollup merge of #126059 - workingjubilee:stack-nothing-higher, r=Chri…
GuillaumeGomez Jun 6, 2024
4e79737
Rollup merge of #126064 - GuillaumeGomez:migrate-run-make-manual-crat…
GuillaumeGomez Jun 6, 2024
bb2d768
Rollup merge of #126068 - lqd:revert-124976, r=petrochenkov
GuillaumeGomez Jun 6, 2024
c824159
Rollup merge of #126073 - Zalathar:fulldeps-borrowck, r=jieyouxu
GuillaumeGomez Jun 6, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ fn upstream_monomorphizations_provider(
tcx: TyCtxt<'_>,
(): (),
) -> DefIdMap<UnordMap<GenericArgsRef<'_>, CrateNum>> {
let cnums = tcx.used_crates(());
let cnums = tcx.crates(());

let mut instances: DefIdMap<UnordMap<_, _>> = Default::default();

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ pub fn collect_debugger_visualizers_transitive(
tcx.debugger_visualizers(LOCAL_CRATE)
.iter()
.chain(
tcx.used_crates(())
tcx.crates(())
.iter()
.filter(|&cnum| {
let used_crate_source = tcx.used_crate_source(*cnum);
Expand Down Expand Up @@ -851,7 +851,7 @@ impl CrateInfo {
// `compiler_builtins` are always placed last to ensure that they're linked correctly.
used_crates.extend(compiler_builtins);

let crates = tcx.used_crates(());
let crates = tcx.crates(());
let n_crates = crates.len();
let mut info = CrateInfo {
target_cpu,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}

for &cnum in tcx.crates_including_speculative(()) {
for &cnum in tcx.crates(()) {
let source = tcx.used_crate_source(cnum);
if let Some((path, _)) = &source.dylib {
files.push(escape_dep_filename(&path.display().to_string()));
Expand Down
21 changes: 19 additions & 2 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut query_description_stream = quote! {};
let mut query_cached_stream = quote! {};
let mut feedable_queries = quote! {};
let mut errors = quote! {};

macro_rules! assert {
( $cond:expr, $span:expr, $( $tt:tt )+ ) => {
if !$cond {
errors.extend(
Error::new($span, format!($($tt)+)).into_compile_error(),
);
}
}
}

for query in queries.0 {
let Query { name, arg, modifiers, .. } = &query;
Expand Down Expand Up @@ -369,10 +380,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
[#attribute_stream] fn #name(#arg) #result,
});

if modifiers.feedable.is_some() {
assert!(modifiers.anon.is_none(), "Query {name} cannot be both `feedable` and `anon`.");
if let Some(feedable) = &modifiers.feedable {
assert!(
modifiers.anon.is_none(),
feedable.span(),
"Query {name} cannot be both `feedable` and `anon`."
);
assert!(
modifiers.eval_always.is_none(),
feedable.span(),
"Query {name} cannot be both `feedable` and `eval_always`."
);
feedable_queries.extend(quote! {
Expand Down Expand Up @@ -407,5 +423,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
use super::*;
#query_cached_stream
}
#errors
})
}
12 changes: 6 additions & 6 deletions compiler/rustc_metadata/src/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
&& sess.crt_static(Some(ty))
&& !sess.target.crt_static_allows_dylibs)
{
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() {
continue;
}
Expand All @@ -165,7 +165,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
// Sweep all crates for found dylibs. Add all dylibs, as well as their
// dependencies, ensuring there are no conflicts. The only valid case for a
// dependency to be relied upon twice is for both cases to rely on a dylib.
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() {
continue;
}
Expand All @@ -183,7 +183,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
}

// Collect what we've got so far in the return vector.
let last_crate = tcx.used_crates(()).len();
let last_crate = tcx.crates(()).len();
let mut ret = (1..last_crate + 1)
.map(|cnum| match formats.get(&CrateNum::new(cnum)) {
Some(&RequireDynamic) => Linkage::Dynamic,
Expand All @@ -197,7 +197,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
//
// If the crate hasn't been included yet and it's not actually required
// (e.g., it's an allocator) then we skip it here as well.
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
let src = tcx.used_crate_source(cnum);
if src.dylib.is_none()
&& !formats.contains_key(&cnum)
Expand Down Expand Up @@ -285,7 +285,7 @@ fn add_library(

fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<DependencyList> {
let all_crates_available_as_rlib = tcx
.used_crates(())
.crates(())
.iter()
.copied()
.filter_map(|cnum| {
Expand All @@ -306,7 +306,7 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<De
// All crates are available in an rlib format, so we're just going to link
// everything in explicitly so long as it's actually required.
let mut ret = tcx
.used_crates(())
.crates(())
.iter()
.map(|&cnum| match tcx.dep_kind(cnum) {
CrateDepKind::Explicit => Linkage::Static,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
// traversal, but not globally minimal across all crates.
let bfs_queue = &mut VecDeque::new();

for &cnum in tcx.crates_including_speculative(()) {
for &cnum in tcx.crates(()) {
// Ignore crates without a corresponding local `extern crate` item.
if tcx.missing_extern_crate_item(cnum) {
continue;
Expand Down Expand Up @@ -509,7 +509,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
tcx.arena
.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE))
},
crates_including_speculative: |tcx, ()| {
crates: |tcx, ()| {
// The list of loaded crates is now frozen in query cache,
// so make sure cstore is not mutably accessed from here on.
tcx.untracked().cstore.freeze();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {

let deps = self
.tcx
.crates_including_speculative(())
.crates(())
.iter()
.map(|&cnum| {
let dep = CrateDep {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
let krate = tcx.hir_crate(());
let hir_body_hash = krate.opt_hir_hash.expect("HIR hash missing while computing crate hash");

let upstream_crates = upstream_crates_for_hashing(tcx);
let upstream_crates = upstream_crates(tcx);

let resolutions = tcx.resolutions(());

Expand Down Expand Up @@ -1111,9 +1111,9 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
Svh::new(crate_hash)
}

fn upstream_crates_for_hashing(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
let mut upstream_crates: Vec<_> = tcx
.crates_including_speculative(())
.crates(())
.iter()
.map(|&cnum| {
let stable_crate_id = tcx.stable_crate_id(cnum);
Expand Down
17 changes: 4 additions & 13 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,22 +1861,13 @@ rustc_queries! {
eval_always
desc { "calculating the stability index for the local crate" }
}
/// All loaded crates, including those loaded purely for doc links or diagnostics.
/// (Diagnostics include lints, so speculatively loaded crates may occur in successful
/// compilation even without doc links.)
/// Should be used when encoding crate metadata (and therefore when generating crate hash,
/// depinfo and similar things), to avoid dangling crate references in other encoded data,
/// like source maps.
/// May also be used for diagnostics - if we are loading a crate anyway we can suggest some
/// items from it as well.
/// But otherwise, `used_crates` should generally be used.
query crates_including_speculative(_: ()) -> &'tcx [CrateNum] {
query crates(_: ()) -> &'tcx [CrateNum] {
eval_always
desc { "fetching all foreign CrateNum instances" }
}
/// Crates that are loaded non-speculatively (not for diagnostics or doc links).
/// Should be used to maintain observable language behavior, for example when collecting lang
/// items or impls from all crates, or collecting libraries to link.
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
// FIXME: This is currently only used for collecting lang items, but should be used instead of
// `crates` in most other cases too.
query used_crates(_: ()) -> &'tcx [CrateNum] {
eval_always
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ impl<'tcx> TyCtxt<'tcx> {

pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx {
iter::once(LOCAL_CRATE)
.chain(self.used_crates(()).iter().copied())
.chain(self.crates(()).iter().copied())
.flat_map(move |cnum| self.traits(cnum).iter().copied())
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3232,7 +3232,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
let queue = &mut Vec::new();
let mut seen_defs: DefIdSet = Default::default();

for &cnum in tcx.crates_including_speculative(()).iter() {
for &cnum in tcx.crates(()).iter() {
let def_id = cnum.as_def_id();

// Ignore crates that are not direct dependencies.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/trait_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> Trait
// Traits defined in the current crate can't have impls in upstream
// crates, so we don't bother querying the cstore.
if !trait_id.is_local() {
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
for &(impl_def_id, simplified_self_ty) in
tcx.implementations_of_trait((cnum, trait_id)).iter()
{
Expand Down Expand Up @@ -248,7 +248,7 @@ pub(super) fn incoherent_impls_provider(
let mut impls = Vec::new();

let mut res = Ok(());
for cnum in iter::once(LOCAL_CRATE).chain(tcx.used_crates(()).iter().copied()) {
for cnum in iter::once(LOCAL_CRATE).chain(tcx.crates(()).iter().copied()) {
let incoherent_impls = match tcx.crate_incoherent_impls((cnum, simp)) {
Ok(impls) => impls,
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
let mut items = DiagnosticItems::default();

// Collect diagnostic items in other crates.
for &cnum in tcx.crates_including_speculative(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id {
collect_item(tcx, &mut items, name, def_id);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
// stabilization diagnostic, but it can be avoided when there are no
// `remaining_lib_features`.
let mut all_implications = remaining_implications.clone();
for &cnum in tcx.used_crates(()) {
for &cnum in tcx.crates(()) {
all_implications
.extend_unord(tcx.stability_implications(cnum).items().map(|(k, v)| (*k, *v)));
}
Expand All @@ -1033,7 +1033,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
&all_implications,
);

for &cnum in tcx.used_crates(()) {
for &cnum in tcx.crates(()) {
if remaining_lib_features.is_empty() && remaining_implications.is_empty() {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn verify(tcx: TyCtxt<'_>, items: &lang_items::LanguageItems) {
}

let mut missing = FxHashSet::default();
for &cnum in tcx.used_crates(()).iter() {
for &cnum in tcx.crates(()).iter() {
for &item in tcx.missing_lang_items(cnum).iter() {
missing.insert(item);
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_query_system/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ pub struct MarkFrame<'a> {
parent: Option<&'a MarkFrame<'a>>,
}

#[derive(PartialEq)]
enum DepNodeColor {
Red,
Green(DepNodeIndex),
Expand Down Expand Up @@ -925,7 +924,7 @@ impl<D: Deps> DepGraph<D> {
/// Returns true if the given node has been marked as red during the
/// current compilation session. Used in various assertions
pub fn is_red(&self, dep_node: &DepNode) -> bool {
self.node_color(dep_node) == Some(DepNodeColor::Red)
matches!(self.node_color(dep_node), Some(DepNodeColor::Red))
}

/// Returns true if the given node has been marked as green during the
Expand Down
11 changes: 3 additions & 8 deletions compiler/rustc_smir/src/rustc_smir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
let mut tables = self.0.borrow_mut();
let tcx = tables.tcx;
iter::once(LOCAL_CRATE)
.chain(tables.tcx.used_crates(()).iter().copied())
.chain(tables.tcx.crates(()).iter().copied())
.flat_map(|cnum| tcx.trait_impls_in_crate(cnum).iter())
.map(|impl_def_id| tables.impl_def(*impl_def_id))
.collect()
Expand Down Expand Up @@ -201,19 +201,14 @@ impl<'tcx> Context for TablesWrapper<'tcx> {

fn external_crates(&self) -> Vec<stable_mir::Crate> {
let tables = self.0.borrow();
tables
.tcx
.used_crates(())
.iter()
.map(|crate_num| smir_crate(tables.tcx, *crate_num))
.collect()
tables.tcx.crates(()).iter().map(|crate_num| smir_crate(tables.tcx, *crate_num)).collect()
}

fn find_crates(&self, name: &str) -> Vec<stable_mir::Crate> {
let tables = self.0.borrow();
let crates: Vec<stable_mir::Crate> = [LOCAL_CRATE]
.iter()
.chain(tables.tcx.used_crates(()).iter())
.chain(tables.tcx.crates(()).iter())
.filter_map(|crate_num| {
let crate_name = tables.tcx.crate_name(*crate_num).to_string();
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
Expand Down
33 changes: 33 additions & 0 deletions library/core/src/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ static DEC_DIGITS_LUT: &[u8; 200] = b"0001020304050607080910111213141516171819\

macro_rules! impl_Display {
($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => {
#[cfg(not(feature = "optimize_for_size"))]
fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// 2^128 is about 3*10^38, so 39 gives an extra byte of space
let mut buf = [MaybeUninit::<u8>::uninit(); 39];
Expand Down Expand Up @@ -277,6 +278,38 @@ macro_rules! impl_Display {
f.pad_integral(is_nonnegative, "", buf_slice)
}

#[cfg(feature = "optimize_for_size")]
fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// 2^128 is about 3*10^38, so 39 gives an extra byte of space
let mut buf = [MaybeUninit::<u8>::uninit(); 39];
let mut curr = buf.len();
let buf_ptr = MaybeUninit::slice_as_mut_ptr(&mut buf);

// SAFETY: To show that it's OK to copy into `buf_ptr`, notice that at the beginning
// `curr == buf.len() == 39 > log(n)` since `n < 2^128 < 10^39`, and at
// each step this is kept the same as `n` is divided. Since `n` is always
// non-negative, this means that `curr > 0` so `buf_ptr[curr..curr + 1]`
// is safe to access.
unsafe {
loop {
curr -= 1;
buf_ptr.add(curr).write((n % 10) as u8 + b'0');
n /= 10;

if n == 0 {
break;
}
}
}

// SAFETY: `curr` > 0 (since we made `buf` large enough), and all the chars are valid UTF-8
let buf_slice = unsafe {
str::from_utf8_unchecked(
slice::from_raw_parts(buf_ptr.add(curr), buf.len() - curr))
};
f.pad_integral(is_nonnegative, "", buf_slice)
}

$(#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for $t {
#[allow(unused_comparisons)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/uefi/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::time::Duration;

pub struct Thread(!);

pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
pub const DEFAULT_MIN_STACK_SIZE: usize = 64 * 1024;

impl Thread {
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unsupported/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::time::Duration;

pub struct Thread(!);

pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
pub const DEFAULT_MIN_STACK_SIZE: usize = 64 * 1024;

impl Thread {
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
Expand Down
Loading