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 13 pull requests #122131

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
14be58a
compiler: allow transmute of ZST arrays with generics
dvdhrm Jul 24, 2023
547f3ce
fixing error std::fs::read_to_string example documentation
haydonryan Dec 11, 2023
6e9ca48
Updating fs::read example to remove SocketAddress
haydonryan Dec 11, 2023
a03d19e
Allow targets to override default codegen backend
WaffleLapkin Feb 14, 2024
5441523
Refactor out a repeating pattern with `get_or_default_sysroot`
WaffleLapkin Feb 15, 2024
9539feb
Update library/std/src/fs.rs
haydonryan Feb 15, 2024
b5e1ca3
Update library/std/src/fs.rs
haydonryan Feb 15, 2024
6d115f5
Refactor out another repeating pattern
WaffleLapkin Feb 18, 2024
f27a22c
try_with_capacity for RawVec
kornelski Jan 30, 2024
78fb977
try_with_capacity for Vec, VecDeque, String
kornelski Jan 30, 2024
784e6a1
Move capacity_overflow function to make ui tests change less
kornelski Jan 31, 2024
2149c45
Bubble up the TyCtxtFeed
oli-obk Feb 14, 2024
31d0a64
Keep `TyCtxtFeed` around longer in the resolver
oli-obk Feb 14, 2024
3b9dfd3
Preserve the `Feed` in local tables
oli-obk Feb 14, 2024
30f2ec2
Eliminate all non-CRATE_DEF_ID uses of `feed_def_id`
oli-obk Feb 14, 2024
5a0c46a
Get rid of `feed_local_def_id`
oli-obk Feb 14, 2024
890dd58
Prevent leaking `Feed`s into query results
oli-obk Feb 19, 2024
3845be6
Prevent feeding `CRATE_DEF_ID` queries outside the resolver
oli-obk Feb 19, 2024
c696d4c
Remove a use of feed_local_crate and make it fail if used within queries
oli-obk Feb 19, 2024
ef00fae
Avoid using feed_unit_query from within queries
oli-obk Feb 19, 2024
0a00749
Implement MaybeUninit::fill{,_with,_from}
ajwock Feb 18, 2024
b69607c
Add missing background color for top-level rust documentation page an…
GuillaumeGomez Mar 6, 2024
9da004e
Dynamically size sigaltstk in std
workingjubilee Jul 10, 2023
8e45d0f
Cancel parsing ever made during recovery
clubby789 Mar 6, 2024
ee1c691
Make `x t miri` respect `MIRI_TEMP`
WaffleLapkin Mar 6, 2024
9891d6a
Add advice for failing `shims/fs.rs` miri test
WaffleLapkin Mar 6, 2024
52bc7ce
Make not finding core a fatal error
saethlin Mar 6, 2024
bf9782d
Fix tidy --bless on Windows
workingjubilee Mar 7, 2024
1a2bc11
Rust is a proper name: rust → Rust
RalfJung Mar 6, 2024
07afa65
Rollup merge of #113525 - workingjubilee:handle-dynamic-minsigstksz, …
workingjubilee Mar 7, 2024
0cd0ad6
Rollup merge of #114009 - dvdhrm:pr/transmzst, r=pnkfelix
workingjubilee Mar 7, 2024
9ed2a53
Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cj…
workingjubilee Mar 7, 2024
06f20f6
Rollup merge of #118623 - haydonryan:master, r=workingjubilee
workingjubilee Mar 7, 2024
8d31644
Rollup merge of #120504 - kornelski:try_with_capacity, r=Amanieu
workingjubilee Mar 7, 2024
5171011
Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkov
workingjubilee Mar 7, 2024
ef8b1df
Rollup merge of #121280 - ajwock:maybeuninit_fill, r=Amanieu
workingjubilee Mar 7, 2024
3e865a9
Rollup merge of #122087 - GuillaumeGomez:fix-rust-index-page, r=notri…
workingjubilee Mar 7, 2024
440c35a
Rollup merge of #122104 - RalfJung:rust, r=ChrisDenton
workingjubilee Mar 7, 2024
c6dfdc7
Rollup merge of #122110 - WaffleLapkin:miri-temp, r=RalfJung
workingjubilee Mar 7, 2024
a88c35d
Rollup merge of #122114 - saethlin:cant-find-crate-spam, r=WaffleLapkin
workingjubilee Mar 7, 2024
3a4b2c1
Rollup merge of #122115 - clubby789:cancel-recoverr, r=compiler-errors
workingjubilee Mar 7, 2024
c22cf59
Rollup merge of #122126 - workingjubilee:every-os-in-the-world-belong…
workingjubilee Mar 7, 2024
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
Prev Previous commit
Next Next commit
Avoid using feed_unit_query from within queries
  • Loading branch information
oli-obk committed Mar 5, 2024
commit ef00fae46d6bf05b1ea7c5447410f0cdf8dc2267
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> {
tcx.ensure_with_value().early_lint_checks(());
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
tcx.ensure_with_value().get_lang_items(());
let (mut resolver, krate) = tcx.resolver_for_lowering(()).steal();
let (mut resolver, krate) = tcx.resolver_for_lowering().steal();

let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
let mut owners = IndexVec::from_fn_n(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ fn run_compiler(
}

// Make sure name resolution and macro expansion is run.
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering(()));
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering());

if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
return early_exit();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_driver_impl/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
{
match self {
PrintExtra::AfterParsing { krate, .. } => f(krate),
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).borrow().1),
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering().borrow().1),
}
}

Expand Down Expand Up @@ -281,7 +281,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
}
AstTreeExpanded => {
debug!("pretty-printing expanded AST");
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1)
format!("{:#?}", ex.tcx().resolver_for_lowering().borrow().1)
}
Hir(s) => {
debug!("pretty printing HIR {:?}", s);
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ fn configure_and_expand(

fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
let sess = tcx.sess;
let (resolver, krate) = &*tcx.resolver_for_lowering(()).borrow();
let (resolver, krate) = &*tcx.resolver_for_lowering().borrow();
let mut lint_buffer = resolver.lint_buffer.steal();

if sess.opts.unstable_opts.input_stats {
Expand Down Expand Up @@ -531,10 +531,10 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
}
}

fn resolver_for_lowering<'tcx>(
fn resolver_for_lowering_raw<'tcx>(
tcx: TyCtxt<'tcx>,
(): (),
) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
let arenas = Resolver::arenas();
let _ = tcx.registered_tools(()); // Uses `crate_for_resolver`.
let (krate, pre_configured_attrs) = tcx.crate_for_resolver(()).steal();
Expand All @@ -549,16 +549,15 @@ fn resolver_for_lowering<'tcx>(
ast_lowering: untracked_resolver_for_lowering,
} = resolver.into_outputs();

let feed = tcx.feed_unit_query();
feed.resolutions(tcx.arena.alloc(untracked_resolutions));
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
let resolutions = tcx.arena.alloc(untracked_resolutions);
(tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate)))), resolutions)
}

pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) {
// Make sure name resolution and macro expansion is run for
// the side-effect of providing a complete set of all
// accessed files and env vars.
let _ = tcx.resolver_for_lowering(());
let _ = tcx.resolver_for_lowering();

let sess = tcx.sess;
let _timer = sess.timer("write_dep_info");
Expand Down Expand Up @@ -607,9 +606,10 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
let providers = &mut Providers::default();
providers.analysis = analysis;
providers.hir_crate = rustc_ast_lowering::lower_to_hir;
providers.resolver_for_lowering = resolver_for_lowering;
providers.resolver_for_lowering_raw = resolver_for_lowering_raw;
providers.stripped_cfg_items =
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
providers.early_lint_checks = early_lint_checks;
proc_macro_decls::provide(providers);
rustc_const_eval::provide(providers);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ rustc_queries! {
}

query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
feedable
no_hash
desc { "getting the resolver outputs" }
}

query resolver_for_lowering(_: ()) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
query resolver_for_lowering_raw(_: ()) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
eval_always
no_hash
desc { "getting the resolver for lowering" }
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal};
use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal};
#[cfg(parallel_compiler)]
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordSet;
Expand Down Expand Up @@ -553,6 +553,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Can only be fed before queries are run, and is thus exempt from any
/// incremental issues. Do not use except for the initial query feeding.
pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()> {
self.dep_graph.assert_ignored();
TyCtxtFeed { tcx: self, key: () }
}

Expand Down Expand Up @@ -2383,6 +2384,10 @@ impl<'tcx> TyCtxt<'tcx> {
self.resolutions(()).module_children.get(&def_id).map_or(&[], |v| &v[..])
}

pub fn resolver_for_lowering(self) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
self.resolver_for_lowering_raw(()).0
}

/// Given an `impl_id`, return the trait it implements.
/// Return `None` if this is an inherent impl.
pub fn impl_trait_ref(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/debugger_visualizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'ast> rustc_ast::visit::Visitor<'ast> for DebuggerVisualizerCollector<'_> {

/// Traverses and collects the debugger visualizers for a specific crate.
fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualizerFile> {
let resolver_and_krate = tcx.resolver_for_lowering(()).borrow();
let resolver_and_krate = tcx.resolver_for_lowering().borrow();
let krate = &*resolver_and_krate.1;

let mut visitor = DebuggerVisualizerCollector { sess: tcx.sess, visualizers: Vec::new() };
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {

/// Traverses and collects all the lang items in all crates.
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
let resolver = tcx.resolver_for_lowering(()).borrow();
let resolver = tcx.resolver_for_lowering().borrow();
let (resolver, krate) = &*resolver;

// Initialize the collector.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/panics/default-backtrace-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ error: the compiler unexpectedly panicked. this is a bug.


query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
Loading