-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Compute default query providers at compile-time #87040
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -45,7 +45,6 @@ use std::any::Any; | |||||
use std::cell::RefCell; | ||||||
use std::ffi::OsString; | ||||||
use std::io::{self, BufWriter, Write}; | ||||||
use std::lazy::SyncLazy; | ||||||
use std::marker::PhantomPinned; | ||||||
use std::path::PathBuf; | ||||||
use std::pin::Pin; | ||||||
|
@@ -737,35 +736,35 @@ pub fn prepare_outputs( | |||||
Ok(outputs) | ||||||
} | ||||||
|
||||||
pub static DEFAULT_QUERY_PROVIDERS: SyncLazy<Providers> = SyncLazy::new(|| { | ||||||
let providers = &mut Providers::default(); | ||||||
pub const DEFAULT_QUERY_PROVIDERS: Providers = { | ||||||
let mut providers = Providers::default(); | ||||||
providers.analysis = analysis; | ||||||
proc_macro_decls::provide(providers); | ||||||
plugin::build::provide(providers); | ||||||
rustc_middle::hir::provide(providers); | ||||||
mir::provide(providers); | ||||||
mir_build::provide(providers); | ||||||
rustc_privacy::provide(providers); | ||||||
typeck::provide(providers); | ||||||
ty::provide(providers); | ||||||
traits::provide(providers); | ||||||
rustc_passes::provide(providers); | ||||||
rustc_resolve::provide(providers); | ||||||
rustc_traits::provide(providers); | ||||||
rustc_ty_utils::provide(providers); | ||||||
rustc_metadata::provide(providers); | ||||||
rustc_lint::provide(providers); | ||||||
rustc_symbol_mangling::provide(providers); | ||||||
rustc_codegen_ssa::provide(providers); | ||||||
*providers | ||||||
}); | ||||||
|
||||||
pub static DEFAULT_EXTERN_QUERY_PROVIDERS: SyncLazy<Providers> = SyncLazy::new(|| { | ||||||
let mut extern_providers = *DEFAULT_QUERY_PROVIDERS; | ||||||
proc_macro_decls::provide(&mut providers); | ||||||
plugin::build::provide(&mut providers); | ||||||
rustc_middle::hir::provide(&mut providers); | ||||||
mir::provide(&mut providers); | ||||||
mir_build::provide(&mut providers); | ||||||
rustc_privacy::provide(&mut providers); | ||||||
typeck::provide(&mut providers); | ||||||
ty::provide(&mut providers); | ||||||
traits::provide(&mut providers); | ||||||
rustc_passes::provide(&mut providers); | ||||||
rustc_resolve::provide(&mut providers); | ||||||
rustc_traits::provide(&mut providers); | ||||||
rustc_ty_utils::provide(&mut providers); | ||||||
rustc_metadata::provide(&mut providers); | ||||||
rustc_lint::provide(&mut providers); | ||||||
rustc_symbol_mangling::provide(&mut providers); | ||||||
rustc_codegen_ssa::provide(&mut providers); | ||||||
providers | ||||||
}; | ||||||
|
||||||
pub const DEFAULT_EXTERN_QUERY_PROVIDERS: Providers = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let mut extern_providers = DEFAULT_QUERY_PROVIDERS; | ||||||
rustc_metadata::provide_extern(&mut extern_providers); | ||||||
rustc_codegen_ssa::provide_extern(&mut extern_providers); | ||||||
extern_providers | ||||||
}); | ||||||
}; | ||||||
|
||||||
pub struct QueryContext<'tcx> { | ||||||
gcx: &'tcx GlobalCtxt<'tcx>, | ||||||
|
@@ -808,10 +807,10 @@ pub fn create_global_ctxt<'tcx>( | |||||
let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess); | ||||||
|
||||||
let codegen_backend = compiler.codegen_backend(); | ||||||
let mut local_providers = *DEFAULT_QUERY_PROVIDERS; | ||||||
let mut local_providers = DEFAULT_QUERY_PROVIDERS; | ||||||
codegen_backend.provide(&mut local_providers); | ||||||
|
||||||
let mut extern_providers = *DEFAULT_EXTERN_QUERY_PROVIDERS; | ||||||
let mut extern_providers = DEFAULT_EXTERN_QUERY_PROVIDERS; | ||||||
codegen_backend.provide(&mut extern_providers); | ||||||
codegen_backend.provide_extern(&mut extern_providers); | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the same semantics as before, it will make a copy of the Providers struct everywhere it's used (which defeats the whole point of having this in rustc proper, originally in #73566 I just use a thread_local in rustdoc and @eddyb asked me not to for performance reasons).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already copy
DEFAULT_QUERY_PROVIDERS
in both places where it's used, so making this astatic
will just result in an unnecessary static allocation in the final library.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not copied in rustdoc:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I'm not completely opposed to changing it, but I don't think it belongs here. AIUI the point of this is to compute the providers at compiletime, which you can do without changing these to consts.