Auto merge of #74195 - Manishearth:rollup-h3m0sl8, r=Manishearth

Rollup of 14 pull requests

Successful merges:

 - #73292 (Fixing broken link for the Eq trait)
 - #73791 (Allow for parentheses after macro intra-doc-links)
 - #74070 ( Use for<'tcx> fn pointers in Providers, instead of having Providers<'tcx>.)
 - #74077 (Use relative path for local links to primitives)
 - #74079 (Eliminate confusing "globals" terminology.)
 - #74107 (Hide `&mut self` methods from Deref in sidebar if there are no `DerefMut` impl for the type.)
 - #74136 (Fix broken link in rustdocdoc)
 - #74137 (Update cargo)
 - #74142 (Liballoc use vec instead of vector)
 - #74143 (Try remove unneeded ToString import in liballoc slice)
 - #74146 (update miri)
 - #74150 (Avoid "blacklist")
 - #74184 (Add docs for intra-doc-links)
 - #74188 (Tweak `::` -> `:` typo heuristic and reduce verbosity)

Failed merges:

 - #74122 (Start-up clean-up)
 - #74127 (Avoid "whitelist")

r? @ghost
This commit is contained in:
bors 2020-07-09 21:32:02 +00:00
commit e59b08e62e
184 changed files with 590 additions and 448 deletions

View File

@ -38,50 +38,62 @@ future.
Attempting to use these error numbers on stable will result in the code sample being interpreted as
plain text.
### Linking to items by type
### Linking to items by name
As designed in [RFC 1946], Rustdoc can parse paths to items when you use them as links. To resolve
these type names, it uses the items currently in-scope, either by declaration or by `use` statement.
For modules, the "active scope" depends on whether the documentation is written outside the module
(as `///` comments on the `mod` statement) or inside the module (at `//!` comments inside the file
or block). For all other items, it uses the enclosing module's scope.
Rustdoc is capable of directly linking to other rustdoc pages in Markdown documentation using the path of item as a link.
[RFC 1946]: https://github.com/rust-lang/rfcs/pull/1946
For example, in the following code:
For example, in the following code all of the links will link to the rustdoc page for `Bar`:
```rust
/// Does the thing.
pub fn do_the_thing(_: SomeType) {
println!("Let's do the thing!");
}
/// This struct is not [Bar]
pub struct Foo1;
/// Token you use to [`do_the_thing`].
pub struct SomeType;
```
/// This struct is also not [bar](Bar)
pub struct Foo2;
The link to ``[`do_the_thing`]`` in `SomeType`'s docs will properly link to the page for `fn
do_the_thing`. Note that here, rustdoc will insert the link target for you, but manually writing the
target out also works:
```rust
pub mod some_module {
/// Token you use to do the thing.
pub struct SomeStruct;
}
/// Does the thing. Requires one [`SomeStruct`] for the thing to work.
/// This struct is also not [bar][b]
///
/// [`SomeStruct`]: some_module::SomeStruct
pub fn do_the_thing(_: some_module::SomeStruct) {
println!("Let's do the thing!");
/// [b]: Bar
pub struct Foo3;
/// This struct is also not [`Bar`]
pub struct Foo4;
pub struct Bar;
```
You can refer to anything in scope, and use paths, including `Self`. You may also use `foo()` and `foo!()` to refer to methods/functions and macros respectively.
```rust,edition2018
use std::sync::mpsc::Receiver;
/// This is an version of [`Receiver`], with support for [`std::future`].
///
/// You can obtain a [`std::future::Future`] by calling [`Self::recv()`].
pub struct AsyncReceiver<T> {
sender: Receiver<T>
}
impl<T> AsyncReceiver<T> {
pub async fn recv() -> T {
unimplemented!()
}
}
```
For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43466] for more
information about what parts of the feature are available.
Paths in Rust have three namespaces: type, value, and macro. Items from these namespaces are allowed to overlap. In case of ambiguity, rustdoc will warn about the ambiguity and ask you to disambiguate, which can be done by using a prefix like `struct@`, `enum@`, `type@`, `trait@`, `union@`, `const@`, `static@`, `value@`, `function@`, `mod@`, `fn@`, `module@`, `method@` , `macro@`, or `derive@`:
[43466]: https://github.com/rust-lang/rust/issues/43466
```rust
/// See also: [`Foo`](struct@Foo)
struct Bar;
/// This is different from [`Foo`](fn@Foo)
struct Foo {}
fn Foo() {}
```
Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc links of a `macro_rules` macro will be resolved relative to the crate root, as opposed to the module it is defined in.
## Extensions to the `#[doc]` attribute
@ -321,7 +333,7 @@ library, as an equivalent command-line argument is provided to `rustc` when buil
### `--index-page`: provide a top-level landing page for docs
This feature allows you to generate an index-page with a given markdown file. A good example of it
is the [rust documentation index](https://doc.rust-lang.org/index.html).
is the [rust documentation index](https://doc.rust-lang.org/nightly/index.html).
With this, you'll have a page which you can custom as much as you want at the top of your crates.

View File

@ -136,8 +136,6 @@ pub use hack::to_vec;
// `test_permutations` test
mod hack {
use crate::boxed::Box;
#[cfg(test)]
use crate::string::ToString;
use crate::vec::Vec;
// We shouldn't add inline attribute to this since this is used in
@ -156,9 +154,9 @@ mod hack {
where
T: Clone,
{
let mut vector = Vec::with_capacity(s.len());
vector.extend_from_slice(s);
vector
let mut vec = Vec::with_capacity(s.len());
vec.extend_from_slice(s);
vec
}
}

View File

@ -35,7 +35,7 @@ use self::Ordering::*;
///
/// This trait allows for partial equality, for types that do not have a full
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
/// so floating point types implement `PartialEq` but not [`Eq`].
/// so floating point types implement `PartialEq` but not [`Eq`](Eq).
///
/// Formally, the equality must be (for all `a`, `b` and `c`):
///
@ -191,7 +191,6 @@ use self::Ordering::*;
/// assert_eq!(x.eq(&y), false);
/// ```
///
/// [`Eq`]: Eq
/// [`eq`]: PartialEq::eq
/// [`ne`]: PartialEq::ne
#[lang = "eq"]

View File

@ -21,55 +21,61 @@ use log::debug;
use std::iter;
use std::ops::DerefMut;
pub struct Globals {
// Per-session global variables: this struct is stored in thread-local storage
// in such a way that it is accessible without any kind of handle to all
// threads within the compilation session, but is not accessible outside the
// session.
pub struct SessionGlobals {
used_attrs: Lock<GrowableBitSet<AttrId>>,
known_attrs: Lock<GrowableBitSet<AttrId>>,
rustc_span_globals: rustc_span::Globals,
span_session_globals: rustc_span::SessionGlobals,
}
impl Globals {
fn new(edition: Edition) -> Globals {
Globals {
impl SessionGlobals {
fn new(edition: Edition) -> SessionGlobals {
SessionGlobals {
// We have no idea how many attributes there will be, so just
// initiate the vectors with 0 bits. We'll grow them as necessary.
used_attrs: Lock::new(GrowableBitSet::new_empty()),
known_attrs: Lock::new(GrowableBitSet::new_empty()),
rustc_span_globals: rustc_span::Globals::new(edition),
span_session_globals: rustc_span::SessionGlobals::new(edition),
}
}
}
pub fn with_globals<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
let globals = Globals::new(edition);
GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f))
pub fn with_session_globals<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
let ast_session_globals = SessionGlobals::new(edition);
SESSION_GLOBALS.set(&ast_session_globals, || {
rustc_span::SESSION_GLOBALS.set(&ast_session_globals.span_session_globals, f)
})
}
pub fn with_default_globals<R>(f: impl FnOnce() -> R) -> R {
with_globals(DEFAULT_EDITION, f)
pub fn with_default_session_globals<R>(f: impl FnOnce() -> R) -> R {
with_session_globals(DEFAULT_EDITION, f)
}
scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals);
pub fn mark_used(attr: &Attribute) {
debug!("marking {:?} as used", attr);
GLOBALS.with(|globals| {
globals.used_attrs.lock().insert(attr.id);
SESSION_GLOBALS.with(|session_globals| {
session_globals.used_attrs.lock().insert(attr.id);
});
}
pub fn is_used(attr: &Attribute) -> bool {
GLOBALS.with(|globals| globals.used_attrs.lock().contains(attr.id))
SESSION_GLOBALS.with(|session_globals| session_globals.used_attrs.lock().contains(attr.id))
}
pub fn mark_known(attr: &Attribute) {
debug!("marking {:?} as known", attr);
GLOBALS.with(|globals| {
globals.known_attrs.lock().insert(attr.id);
SESSION_GLOBALS.with(|session_globals| {
session_globals.known_attrs.lock().insert(attr.id);
});
}
pub fn is_known(attr: &Attribute) -> bool {
GLOBALS.with(|globals| globals.known_attrs.lock().contains(attr.id))
SESSION_GLOBALS.with(|session_globals| session_globals.known_attrs.lock().contains(attr.id))
}
pub fn is_known_lint_tool(m_item: Ident) -> bool {

View File

@ -43,7 +43,7 @@ pub mod util {
pub mod ast;
pub mod attr;
pub use attr::{with_default_globals, with_globals, GLOBALS};
pub use attr::{with_default_session_globals, with_session_globals, SESSION_GLOBALS};
pub mod crate_disambiguator;
pub mod entry;
pub mod expand;

View File

@ -21,8 +21,8 @@ fn test_lev_distance() {
#[test]
fn test_find_best_match_for_name() {
use crate::with_default_globals;
with_default_globals(|| {
use crate::with_default_session_globals;
with_default_session_globals(|| {
let input = vec![Symbol::intern("aaab"), Symbol::intern("aaabc")];
assert_eq!(
find_best_match_for_name(input.iter(), "aaaa", None),

View File

@ -1,7 +1,7 @@
use super::*;
use rustc_ast::ast;
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_span::source_map::respan;
use rustc_span::symbol::Ident;
@ -25,7 +25,7 @@ fn variant_to_string(var: &ast::Variant) -> String {
#[test]
fn test_fun_to_string() {
with_default_globals(|| {
with_default_session_globals(|| {
let abba_ident = Ident::from_str("abba");
let decl =
@ -40,7 +40,7 @@ fn test_fun_to_string() {
#[test]
fn test_variant_to_string() {
with_default_globals(|| {
with_default_session_globals(|| {
let ident = Ident::from_str("principal_skinner");
let var = ast::Variant {

View File

@ -342,7 +342,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.target_features_whitelist = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc {
@ -360,7 +360,7 @@ pub fn provide(providers: &mut Providers<'_>) {
provide_extern(providers);
}
pub fn provide_extern(providers: &mut Providers<'_>) {
pub fn provide_extern(providers: &mut Providers) {
providers.wasm_import_module_map = |tcx, cnum| {
// Build up a map from DefId to a `NativeLib` structure, where
// `NativeLib` internally contains information about

View File

@ -241,11 +241,11 @@ impl CodegenBackend for LlvmCodegenBackend {
Box::new(metadata::LlvmMetadataLoader)
}
fn provide(&self, providers: &mut ty::query::Providers<'_>) {
fn provide(&self, providers: &mut ty::query::Providers) {
attributes::provide(providers);
}
fn provide_extern(&self, providers: &mut ty::query::Providers<'_>) {
fn provide_extern(&self, providers: &mut ty::query::Providers) {
attributes::provide_extern(providers);
}

View File

@ -161,9 +161,9 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
}
fn exported_symbols_provider_local(
tcx: TyCtxt<'_>,
tcx: TyCtxt<'tcx>,
cnum: CrateNum,
) -> &'tcx [(ExportedSymbol<'_>, SymbolExportLevel)] {
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
@ -366,7 +366,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> b
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.reachable_non_generics = reachable_non_generics_provider;
providers.is_reachable_non_generic = is_reachable_non_generic_provider_local;
providers.exported_symbols = exported_symbols_provider_local;
@ -375,7 +375,7 @@ pub fn provide(providers: &mut Providers<'_>) {
providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
}
pub fn provide_extern(providers: &mut Providers<'_>) {
pub fn provide_extern(providers: &mut Providers) {
providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider;
}

View File

@ -853,7 +853,7 @@ impl CrateInfo {
}
}
pub fn provide_both(providers: &mut Providers<'_>) {
pub fn provide_both(providers: &mut Providers) {
providers.backend_optimization_level = |tcx, cratenum| {
let for_speed = match tcx.sess.opts.optimize {
// If globally no optimisation is done, #[optimize] has no effect.

View File

@ -138,12 +138,12 @@ pub struct CodegenResults {
pub crate_info: CrateInfo,
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
crate::back::symbol_export::provide(providers);
crate::base::provide_both(providers);
}
pub fn provide_extern(providers: &mut Providers<'_>) {
pub fn provide_extern(providers: &mut Providers) {
crate::back::symbol_export::provide_extern(providers);
crate::base::provide_both(providers);
}

View File

@ -55,8 +55,8 @@ pub trait CodegenBackend {
fn print_version(&self) {}
fn metadata_loader(&self) -> Box<MetadataLoaderDyn>;
fn provide(&self, _providers: &mut Providers<'_>);
fn provide_extern(&self, _providers: &mut Providers<'_>);
fn provide(&self, _providers: &mut Providers);
fn provide_extern(&self, _providers: &mut Providers);
fn codegen_crate<'tcx>(
&self,
tcx: TyCtxt<'tcx>,

View File

@ -1,6 +1,6 @@
The requested ABI is unsupported by the current target.
The rust compiler maintains for each target a blacklist of ABIs unsupported on
The rust compiler maintains for each target a list of unsupported ABIs on
that target. If an ABI is present in such a list this usually means that the
target / ABI combination is currently unsupported by llvm.

View File

@ -39,16 +39,16 @@ impl<T: Write> Write for Shared<T> {
}
}
fn with_default_globals(f: impl FnOnce()) {
let globals = rustc_span::Globals::new(rustc_span::edition::DEFAULT_EDITION);
rustc_span::GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals, f))
fn with_default_session_globals(f: impl FnOnce()) {
let session_globals = rustc_span::SessionGlobals::new(rustc_span::edition::DEFAULT_EDITION);
rustc_span::SESSION_GLOBALS.set(&session_globals, f);
}
/// Test the span yields correct positions in JSON.
fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
let expected_output = TestData { spans: vec![expected_output] };
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned());

View File

@ -2,7 +2,7 @@ use crate::tests::{matches_codepattern, string_to_crate};
use rustc_ast::ast;
use rustc_ast::mut_visit::{self, MutVisitor};
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_ast_pretty::pprust;
use rustc_span::symbol::Ident;
@ -38,7 +38,7 @@ macro_rules! assert_pred {
// Make sure idents get transformed everywhere.
#[test]
fn ident_transformation() {
with_default_globals(|| {
with_default_session_globals(|| {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate =
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
@ -55,7 +55,7 @@ fn ident_transformation() {
// Make sure idents get transformed even inside macro defs.
#[test]
fn ident_transformation_in_defs() {
with_default_globals(|| {
with_default_session_globals(|| {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate = string_to_crate(
"macro_rules! a {(b $c:expr $(d $e:token)f+ => \

View File

@ -1,6 +1,6 @@
use rustc_ast::token::{self, Token, TokenKind};
use rustc_ast::util::comments::is_doc_comment;
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{emitter::EmitterWriter, Handler};
use rustc_parse::lexer::StringReader;
@ -33,7 +33,7 @@ fn setup<'a>(sm: &SourceMap, sess: &'a ParseSess, teststr: String) -> StringRead
#[test]
fn t1() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut string_reader = setup(
@ -79,7 +79,7 @@ fn mk_lit(kind: token::LitKind, symbol: &str, suffix: Option<&str>) -> TokenKind
#[test]
fn doublecolon_parsing() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(
@ -91,7 +91,7 @@ fn doublecolon_parsing() {
#[test]
fn doublecolon_parsing_2() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(
@ -103,7 +103,7 @@ fn doublecolon_parsing_2() {
#[test]
fn doublecolon_parsing_3() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(
@ -115,7 +115,7 @@ fn doublecolon_parsing_3() {
#[test]
fn doublecolon_parsing_4() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
check_tokenization(
@ -127,7 +127,7 @@ fn doublecolon_parsing_4() {
#[test]
fn character_a() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(), mk_lit(token::Char, "a", None),);
@ -136,7 +136,7 @@ fn character_a() {
#[test]
fn character_space() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(), mk_lit(token::Char, " ", None),);
@ -145,7 +145,7 @@ fn character_space() {
#[test]
fn character_escaped() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(
@ -157,7 +157,7 @@ fn character_escaped() {
#[test]
fn lifetime_name() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(
@ -169,7 +169,7 @@ fn lifetime_name() {
#[test]
fn raw_string() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
assert_eq!(
@ -181,7 +181,7 @@ fn raw_string() {
#[test]
fn literal_suffixes() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
macro_rules! test {
@ -232,7 +232,7 @@ fn line_doc_comments() {
#[test]
fn nested_block_comments() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string());
@ -243,7 +243,7 @@ fn nested_block_comments() {
#[test]
fn crlf_comments() {
with_default_globals(|| {
with_default_session_globals(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let sh = mk_sess(sm.clone());
let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string());

View File

@ -5,7 +5,7 @@ use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
use rustc_ast::visit;
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_ast_pretty::pprust::item_to_string;
use rustc_errors::PResult;
use rustc_parse::new_parser_from_source_str;
@ -50,7 +50,7 @@ fn string_to_item(source_str: String) -> Option<P<ast::Item>> {
#[should_panic]
#[test]
fn bad_path_expr_1() {
with_default_globals(|| {
with_default_session_globals(|| {
string_to_expr("::abc::def::return".to_string());
})
}
@ -58,7 +58,7 @@ fn bad_path_expr_1() {
// Checks the token-tree-ization of macros.
#[test]
fn string_to_tts_macro() {
with_default_globals(|| {
with_default_session_globals(|| {
let tts: Vec<_> =
string_to_stream("macro_rules! zip (($a)=>($a))".to_string()).trees().collect();
let tts: &[TokenTree] = &tts[..];
@ -95,7 +95,7 @@ fn string_to_tts_macro() {
#[test]
fn string_to_tts_1() {
with_default_globals(|| {
with_default_session_globals(|| {
let tts = string_to_stream("fn a (b : i32) { b; }".to_string());
let expected = TokenStream::new(vec![
@ -130,7 +130,7 @@ fn string_to_tts_1() {
#[test]
fn parse_use() {
with_default_globals(|| {
with_default_session_globals(|| {
let use_s = "use foo::bar::baz;";
let vitem = string_to_item(use_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
@ -145,7 +145,7 @@ fn parse_use() {
#[test]
fn parse_extern_crate() {
with_default_globals(|| {
with_default_session_globals(|| {
let ex_s = "extern crate foo;";
let vitem = string_to_item(ex_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
@ -183,7 +183,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec<Span> {
#[test]
fn span_of_self_arg_pat_idents_are_correct() {
with_default_globals(|| {
with_default_session_globals(|| {
let srcs = [
"impl z { fn a (&self, &myarg: i32) {} }",
"impl z { fn a (&mut self, &myarg: i32) {} }",
@ -207,7 +207,7 @@ fn span_of_self_arg_pat_idents_are_correct() {
#[test]
fn parse_exprs() {
with_default_globals(|| {
with_default_session_globals(|| {
// just make sure that they parse....
string_to_expr("3 + 4".to_string());
string_to_expr("a::z.froob(b,&(987+3))".to_string());
@ -216,7 +216,7 @@ fn parse_exprs() {
#[test]
fn attrs_fix_bug() {
with_default_globals(|| {
with_default_session_globals(|| {
string_to_item(
"pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
-> Result<Box<Writer>, String> {
@ -237,7 +237,7 @@ let mut fflags: c_int = wb();
#[test]
fn crlf_doc_comments() {
with_default_globals(|| {
with_default_session_globals(|| {
let sess = sess();
let name_1 = FileName::Custom("crlf_source_1".to_string());
@ -271,7 +271,7 @@ fn ttdelim_span() {
new_parser_from_source_str(sess, name, source).parse_expr()
}
with_default_globals(|| {
with_default_session_globals(|| {
let sess = sess();
let expr = parse_expr_from_source_str(
PathBuf::from("foo").into(),
@ -299,7 +299,7 @@ fn ttdelim_span() {
// See `recurse_into_file_modules` in the parser.
#[test]
fn out_of_line_mod() {
with_default_globals(|| {
with_default_session_globals(|| {
let item = parse_item_from_source_str(
PathBuf::from("foo").into(),
"mod foo { struct S; mod this_does_not_exist; }".to_owned(),

View File

@ -1,6 +1,6 @@
use rustc_ast::ast;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FilePathMapping, SourceMap};
@ -124,7 +124,7 @@ impl<T: Write> Write for Shared<T> {
}
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
with_default_globals(|| {
with_default_session_globals(|| {
let output = Arc::new(Mutex::new(Vec::new()));
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));

View File

@ -2,7 +2,7 @@ use crate::tests::string_to_stream;
use rustc_ast::token;
use rustc_ast::tokenstream::{TokenStream, TokenStreamBuilder, TokenTree};
use rustc_ast::with_default_globals;
use rustc_ast::with_default_session_globals;
use rustc_span::{BytePos, Span, Symbol};
use smallvec::smallvec;
@ -16,7 +16,7 @@ fn sp(a: u32, b: u32) -> Span {
#[test]
fn test_concat() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("foo::bar::baz");
let test_fst = string_to_ts("foo::bar");
let test_snd = string_to_ts("::baz");
@ -29,7 +29,7 @@ fn test_concat() {
#[test]
fn test_to_from_bijection() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_start = string_to_ts("foo::bar(baz)");
let test_end = test_start.trees().collect();
assert_eq!(test_start, test_end)
@ -38,7 +38,7 @@ fn test_to_from_bijection() {
#[test]
fn test_eq_0() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("foo");
let test_eqs = string_to_ts("foo");
assert_eq!(test_res, test_eqs)
@ -47,7 +47,7 @@ fn test_eq_0() {
#[test]
fn test_eq_1() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("::bar::baz");
let test_eqs = string_to_ts("::bar::baz");
assert_eq!(test_res, test_eqs)
@ -56,7 +56,7 @@ fn test_eq_1() {
#[test]
fn test_eq_3() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("");
let test_eqs = string_to_ts("");
assert_eq!(test_res, test_eqs)
@ -65,7 +65,7 @@ fn test_eq_3() {
#[test]
fn test_diseq_0() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("::bar::baz");
let test_eqs = string_to_ts("bar::baz");
assert_eq!(test_res == test_eqs, false)
@ -74,7 +74,7 @@ fn test_diseq_0() {
#[test]
fn test_diseq_1() {
with_default_globals(|| {
with_default_session_globals(|| {
let test_res = string_to_ts("(bar,baz)");
let test_eqs = string_to_ts("bar,baz");
assert_eq!(test_res == test_eqs, false)
@ -83,7 +83,7 @@ fn test_diseq_1() {
#[test]
fn test_is_empty() {
with_default_globals(|| {
with_default_session_globals(|| {
let test0: TokenStream = Vec::<TokenTree>::new().into_iter().collect();
let test1: TokenStream =
TokenTree::token(token::Ident(Symbol::intern("a"), false), sp(0, 1)).into();
@ -97,7 +97,7 @@ fn test_is_empty() {
#[test]
fn test_dotdotdot() {
with_default_globals(|| {
with_default_session_globals(|| {
let mut builder = TokenStreamBuilder::new();
builder.push(TokenTree::token(token::Dot, sp(0, 1)).joint());
builder.push(TokenTree::token(token::Dot, sp(1, 2)).joint());

View File

@ -38,7 +38,7 @@ pub struct Compiler {
pub(crate) crate_name: Option<String>,
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
pub(crate) override_queries:
Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>,
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
}
impl Compiler {
@ -74,7 +74,7 @@ impl Compiler {
/// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String>)> {
rustc_ast::with_default_globals(move || {
rustc_ast::with_default_session_globals(move || {
let cfg = cfgspecs
.into_iter()
.map(|s| {
@ -153,7 +153,7 @@ pub struct Config {
///
/// The second parameter is local providers and the third parameter is external providers.
pub override_queries:
Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>,
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
/// Registry of diagnostics codes.
pub registry: Registry,

View File

@ -719,7 +719,7 @@ pub fn prepare_outputs(
Ok(outputs)
}
pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
pub fn default_provide(providers: &mut ty::query::Providers) {
providers.analysis = analysis;
proc_macro_decls::provide(providers);
plugin::build::provide(providers);
@ -740,7 +740,7 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
rustc_codegen_ssa::provide(providers);
}
pub fn default_provide_extern(providers: &mut ty::query::Providers<'_>) {
pub fn default_provide_extern(providers: &mut ty::query::Providers) {
rustc_metadata::provide_extern(providers);
rustc_codegen_ssa::provide_extern(providers);
}

View File

@ -35,6 +35,6 @@ impl<'v> ItemLikeVisitor<'v> for Finder {
fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) {}
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { proc_macro_decls_static, ..*providers };
}

View File

@ -73,7 +73,7 @@ fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
// When the user supplies --test we should implicitly supply --cfg test
#[test]
fn test_switch_implies_cfg_test() {
rustc_ast::with_default_globals(|| {
rustc_ast::with_default_session_globals(|| {
let matches = optgroups().parse(&["--test".to_string()]).unwrap();
let (sess, cfg) = mk_session(matches);
let cfg = build_configuration(&sess, to_crate_config(cfg));
@ -84,7 +84,7 @@ fn test_switch_implies_cfg_test() {
// When the user supplies --test and --cfg test, don't implicitly add another --cfg test
#[test]
fn test_switch_implies_cfg_test_unless_cfg_test() {
rustc_ast::with_default_globals(|| {
rustc_ast::with_default_session_globals(|| {
let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
let (sess, cfg) = mk_session(matches);
let cfg = build_configuration(&sess, to_crate_config(cfg));
@ -96,20 +96,20 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
#[test]
fn test_can_print_warnings() {
rustc_ast::with_default_globals(|| {
rustc_ast::with_default_session_globals(|| {
let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
let (sess, _) = mk_session(matches);
assert!(!sess.diagnostic().can_emit_warnings());
});
rustc_ast::with_default_globals(|| {
rustc_ast::with_default_session_globals(|| {
let matches =
optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
let (sess, _) = mk_session(matches);
assert!(sess.diagnostic().can_emit_warnings());
});
rustc_ast::with_default_globals(|| {
rustc_ast::with_default_session_globals(|| {
let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
let (sess, _) = mk_session(matches);
assert!(sess.diagnostic().can_emit_warnings());

View File

@ -141,7 +141,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
crate::callbacks::setup_callbacks();
scoped_thread(cfg, || {
rustc_ast::with_globals(edition, || {
rustc_ast::with_session_globals(edition, || {
ty::tls::GCX_PTR.set(&Lock::new(0), || {
if let Some(stderr) = stderr {
io::set_panic(Some(box Sink(stderr.clone())));
@ -177,16 +177,17 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
let with_pool = move |pool: &ThreadPool| pool.install(move || f());
rustc_ast::with_globals(edition, || {
rustc_ast::GLOBALS.with(|syntax_globals| {
rustc_span::GLOBALS.with(|rustc_span_globals| {
// The main handler runs for each Rayon worker thread and sets up
// the thread local rustc uses. syntax_globals and rustc_span_globals are
// captured and set on the new threads. ty::tls::with_thread_locals sets up
// thread local callbacks from librustc_ast
rustc_ast::with_session_globals(edition, || {
rustc_ast::SESSION_GLOBALS.with(|ast_session_globals| {
rustc_span::SESSION_GLOBALS.with(|span_session_globals| {
// The main handler runs for each Rayon worker thread and sets
// up the thread local rustc uses. ast_session_globals and
// span_session_globals are captured and set on the new
// threads. ty::tls::with_thread_locals sets up thread local
// callbacks from librustc_ast.
let main_handler = move |thread: ThreadBuilder| {
rustc_ast::GLOBALS.set(syntax_globals, || {
rustc_span::GLOBALS.set(rustc_span_globals, || {
rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || {
rustc_span::SESSION_GLOBALS.set(span_session_globals, || {
if let Some(stderr) = stderr {
io::set_panic(Some(box Sink(stderr.clone())));
}

View File

@ -571,6 +571,6 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.lint_levels = lint_levels;
}

View File

@ -88,7 +88,7 @@ pub use rustc_session::lint::Level::{self, *};
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
pub use rustc_session::lint::{LintArray, LintPass};
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
levels::provide(providers);
*providers = Providers { lint_mod, ..*providers };
}

View File

@ -17,7 +17,6 @@ use rustc_middle::middle::cstore::{CrateSource, CrateStore, EncodedMetadata};
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::middle::stability::DeprecationEntry;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::query::QueryConfig;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::utils::NativeLibKind;
use rustc_session::{CrateDisambiguator, Session};
@ -31,13 +30,11 @@ use std::any::Any;
macro_rules! provide {
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
$($name:ident => $compute:block)*) => {
pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) {
// HACK(eddyb) `$lt: $lt` forces `$lt` to be early-bound, which
// allows the associated type in the return type to be normalized.
$(fn $name<$lt: $lt, T: IntoArgs>(
pub fn provide_extern(providers: &mut Providers) {
$(fn $name<$lt>(
$tcx: TyCtxt<$lt>,
def_id_arg: T,
) -> <ty::queries::$name<$lt> as QueryConfig<TyCtxt<$lt>>>::Value {
def_id_arg: ty::query::query_keys::$name<$lt>,
) -> ty::query::query_values::$name<$lt> {
let _prof_timer =
$tcx.prof.generic_activity("metadata_decode_entry");
@ -243,7 +240,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
crate_extern_paths => { cdata.source().paths().cloned().collect() }
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
// FIXME(#44234) - almost all of these queries have no sub-queries and
// therefore no actual inputs, they're just reading tables calculated in
// resolve! Does this work? Unsure! That's what the issue is about

View File

@ -1067,6 +1067,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.def_kind = |tcx, def_id| tcx.hir().def_kind(def_id.expect_local());
}

View File

@ -62,7 +62,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.parent_module_from_def_id = |tcx, id| {
let hir = tcx.hir();
hir.local_def_id(hir.get_module_parent_node(hir.as_local_hir_id(id)))

View File

@ -1060,8 +1060,8 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn create_global_ctxt(
s: &'tcx Session,
lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
local_providers: ty::query::Providers<'tcx>,
extern_providers: ty::query::Providers<'tcx>,
local_providers: ty::query::Providers,
extern_providers: ty::query::Providers,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
resolutions: ty::ResolverOutputs,
krate: &'tcx hir::Crate<'tcx>,
@ -2699,7 +2699,7 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
t as *const () == u as *const ()
}
pub fn provide(providers: &mut ty::query::Providers<'_>) {
pub fn provide(providers: &mut ty::query::Providers) {
providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id);
providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).map(|v| &v[..]);
providers.crate_name = |tcx, id| {

View File

@ -1,7 +1,7 @@
use crate::ty::fold::{TypeFoldable, TypeFolder};
use crate::ty::{self, Ty, TyCtxt, TypeFlags};
pub(super) fn provide(providers: &mut ty::query::Providers<'_>) {
pub(super) fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers { erase_regions_ty, ..*providers };
}

View File

@ -210,7 +210,7 @@ fn layout_raw<'tcx>(
})
}
pub fn provide(providers: &mut ty::query::Providers<'_>) {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers { layout_raw, ..*providers };
}

View File

@ -2966,7 +2966,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
None
}
pub fn provide(providers: &mut ty::query::Providers<'_>) {
pub fn provide(providers: &mut ty::query::Providers) {
context::provide(providers);
erase_regions::provide(providers);
layout::provide(providers);

View File

@ -13,16 +13,15 @@ pub unsafe fn handle_deadlock() {
let gcx_ptr = tls::GCX_PTR.with(|gcx_ptr| gcx_ptr as *const _);
let gcx_ptr = &*gcx_ptr;
let rustc_span_globals =
rustc_span::GLOBALS.with(|rustc_span_globals| rustc_span_globals as *const _);
let rustc_span_globals = &*rustc_span_globals;
let syntax_globals = rustc_ast::attr::GLOBALS.with(|syntax_globals| syntax_globals as *const _);
let syntax_globals = &*syntax_globals;
let span_session_globals = rustc_span::SESSION_GLOBALS.with(|ssg| ssg as *const _);
let span_session_globals = &*span_session_globals;
let ast_session_globals = rustc_ast::attr::SESSION_GLOBALS.with(|asg| asg as *const _);
let ast_session_globals = &*ast_session_globals;
thread::spawn(move || {
tls::GCX_PTR.set(gcx_ptr, || {
rustc_ast::attr::GLOBALS.set(syntax_globals, || {
rustc_span::GLOBALS
.set(rustc_span_globals, || tls::with_global(|tcx| deadlock(tcx, &registry)))
rustc_ast::attr::SESSION_GLOBALS.set(ast_session_globals, || {
rustc_span::SESSION_GLOBALS
.set(span_session_globals, || tls::with_global(|tcx| deadlock(tcx, &registry)))
});
})
});

View File

@ -318,15 +318,34 @@ macro_rules! define_queries_inner {
}
}
#[allow(nonstandard_style)]
pub mod queries {
use std::marker::PhantomData;
$(#[allow(nonstandard_style)]
pub struct $name<$tcx> {
$(pub struct $name<$tcx> {
data: PhantomData<&$tcx ()>
})*
}
// HACK(eddyb) this is like the `impl QueryConfig for queries::$name`
// below, but using type aliases instead of associated types, to bypass
// the limitations around normalizing under HRTB - for example, this:
// `for<'tcx> fn(...) -> <queries::$name<'tcx> as QueryConfig<TyCtxt<'tcx>>>::Value`
// doesn't currently normalize to `for<'tcx> fn(...) -> query_values::$name<'tcx>`.
// This is primarily used by the `provide!` macro in `rustc_metadata`.
#[allow(nonstandard_style, unused_lifetimes)]
pub mod query_keys {
use super::*;
$(pub type $name<$tcx> = $($K)*;)*
}
#[allow(nonstandard_style, unused_lifetimes)]
pub mod query_values {
use super::*;
$(pub type $name<$tcx> = $V;)*
}
$(impl<$tcx> QueryConfig<TyCtxt<$tcx>> for queries::$name<$tcx> {
type Key = $($K)*;
type Value = $V;
@ -478,13 +497,16 @@ macro_rules! define_queries_inner {
input: ($(([$($modifiers)*] [$name] [$($K)*] [$V]))*)
}
impl<$tcx> Copy for Providers<$tcx> {}
impl<$tcx> Clone for Providers<$tcx> {
impl Copy for Providers {}
impl Clone for Providers {
fn clone(&self) -> Self { *self }
}
}
}
// FIXME(eddyb) this macro (and others?) use `$tcx` and `'tcx` interchangeably.
// We should either not take `$tcx` at all and use `'tcx` everywhere, or use
// `$tcx` everywhere (even if that isn't necessary due to lack of hygiene).
macro_rules! define_queries_struct {
(tcx: $tcx:tt,
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
@ -494,8 +516,8 @@ macro_rules! define_queries_struct {
/// `DepGraph::try_mark_green()` and the query infrastructure.
pub(crate) on_disk_cache: OnDiskCache<'tcx>,
providers: IndexVec<CrateNum, Providers<$tcx>>,
fallback_extern_providers: Box<Providers<$tcx>>,
providers: IndexVec<CrateNum, Providers>,
fallback_extern_providers: Box<Providers>,
$($(#[$attr])* $name: QueryState<
TyCtxt<$tcx>,
@ -505,8 +527,8 @@ macro_rules! define_queries_struct {
impl<$tcx> Queries<$tcx> {
pub(crate) fn new(
providers: IndexVec<CrateNum, Providers<$tcx>>,
fallback_extern_providers: Providers<$tcx>,
providers: IndexVec<CrateNum, Providers>,
fallback_extern_providers: Providers,
on_disk_cache: OnDiskCache<'tcx>,
) -> Self {
Queries {
@ -539,11 +561,11 @@ macro_rules! define_queries_struct {
macro_rules! define_provider_struct {
(tcx: $tcx:tt,
input: ($(([$($modifiers:tt)*] [$name:ident] [$K:ty] [$R:ty]))*)) => {
pub struct Providers<$tcx> {
$(pub $name: fn(TyCtxt<$tcx>, $K) -> $R,)*
pub struct Providers {
$(pub $name: for<$tcx> fn(TyCtxt<$tcx>, $K) -> $R,)*
}
impl<$tcx> Default for Providers<$tcx> {
impl Default for Providers {
fn default() -> Self {
$(fn $name<$tcx>(_: TyCtxt<$tcx>, key: $K) -> $R {
bug!("`tcx.{}({:?})` unsupported by its crate",

View File

@ -47,6 +47,6 @@ pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
);
}
pub fn provide(providers: &mut crate::ty::query::Providers<'_>) {
pub fn provide(providers: &mut crate::ty::query::Providers) {
*providers = crate::ty::query::Providers { trigger_delay_span_bug, ..*providers };
}

View File

@ -86,7 +86,7 @@ crate struct Upvar {
const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref];
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { mir_borrowck, ..*providers };
}

View File

@ -156,7 +156,7 @@ fn const_fn_is_allowed_fn_ptr(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
&& tcx.lookup_const_stability(def_id).map(|stab| stab.allow_const_fn_ptr).unwrap_or(false)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers {
is_const_fn_raw,
is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()),

View File

@ -47,7 +47,7 @@ pub mod util;
use rustc_middle::ty::query::Providers;
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
borrow_check::provide(providers);
const_eval::provide(providers);
shim::provide(providers);

View File

@ -880,9 +880,9 @@ where
}
fn collect_and_partition_mono_items(
tcx: TyCtxt<'_>,
tcx: TyCtxt<'tcx>,
cnum: CrateNum,
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'_>]) {
) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
assert_eq!(cnum, LOCAL_CRATE);
let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items {
@ -994,7 +994,7 @@ fn collect_and_partition_mono_items(
(tcx.arena.alloc(mono_items), codegen_units)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
providers.is_codegened_item = |tcx, def_id| {

View File

@ -23,7 +23,7 @@ use crate::util::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle
use crate::util::expand_aggregate;
use crate::util::patch::MirPatch;
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.mir_shims = make_shim;
}

View File

@ -488,7 +488,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
}
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { unsafety_check_result, unsafe_derive_on_repr_packed, ..*providers };
}

View File

@ -25,7 +25,7 @@ pub struct InstrumentCoverage;
/// The `query` provider for `CoverageInfo`, requested by `codegen_intrinsic_call()` when
/// constructing the arguments for `llvm.instrprof.increment`.
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
providers.coverageinfo = |tcx, def_id| coverageinfo_from_mir(tcx, def_id);
}

View File

@ -43,7 +43,7 @@ pub mod uninhabited_enum_branching;
pub mod unreachable_prop;
pub mod validate;
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
self::check_unsafety::provide(providers);
*providers = Providers {
mir_keys,

View File

@ -23,7 +23,7 @@ mod lints;
use rustc_middle::ty::query::Providers;
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.check_match = hair::pattern::check_match;
providers.lit_to_const = hair::constant::lit_to_const;
providers.mir_built = build::mir_built;

View File

@ -346,13 +346,16 @@ impl<'a> Parser<'a> {
if allow_unstable {
// Give extra information about type ascription only if it's a nightly compiler.
err.note(
"`#![feature(type_ascription)]` lets you annotate an expression with a \
type: `<expr>: <type>`",
);
err.note(
"see issue #23416 <https://github.com/rust-lang/rust/issues/23416> \
for more information",
"`#![feature(type_ascription)]` lets you annotate an expression with a type: \
`<expr>: <type>`",
);
if !likely_path {
// Avoid giving too much info when it was likely an unrelated typo.
err.note(
"see issue #23416 <https://github.com/rust-lang/rust/issues/23416> \
for more information",
);
}
}
}
}
@ -1161,8 +1164,10 @@ impl<'a> Parser<'a> {
} &&
!self.token.is_reserved_ident() && // v `foo:bar(baz)`
self.look_ahead(1, |t| t == &token::OpenDelim(token::Paren))
|| self.look_ahead(1, |t| t == &token::Lt) && // `foo:bar<baz`
self.look_ahead(2, |t| t.is_ident())
|| self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace)) // `foo:bar {`
|| self.look_ahead(1, |t| t == &token::Colon) && // `foo:bar::<baz`
self.look_ahead(2, |t| t == &token::Lt) &&
self.look_ahead(3, |t| t.is_ident())
|| self.look_ahead(1, |t| t == &token::Colon) && // `foo:bar:baz`
self.look_ahead(2, |t| t.is_ident())
|| self.look_ahead(1, |t| t == &token::ModSep)

View File

@ -144,8 +144,8 @@ fn format_align_fill() {
}
#[test]
fn format_counts() {
use rustc_span::{edition, Globals, GLOBALS};
GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || {
use rustc_span::{edition, SessionGlobals, SESSION_GLOBALS};
SESSION_GLOBALS.set(&SessionGlobals::new(edition::DEFAULT_EDITION), || {
same(
"{:10x}",
&[NextArgument(Argument {

View File

@ -469,6 +469,6 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
.visit_item_likes_in_module(module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor());
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_attrs, ..*providers };
}

View File

@ -62,7 +62,7 @@ fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis.as_deep_visitor());
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_const_bodies, ..*providers };
}

View File

@ -118,7 +118,7 @@ fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
collector
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.diagnostic_items = |tcx, id| {
assert_eq!(id, LOCAL_CRATE);
collect(tcx)

View File

@ -217,6 +217,6 @@ pub fn find_entry_point(tcx: TyCtxt<'_>) -> Option<(LocalDefId, EntryFnType)> {
tcx.entry_fn(LOCAL_CRATE)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { entry_fn, ..*providers };
}

View File

@ -18,7 +18,7 @@ fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut ItemVisitor { tcx }.as_deep_visitor());
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_intrinsics, ..*providers };
}

View File

@ -205,7 +205,7 @@ fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
items
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.get_lang_items = |tcx, id| {
assert_eq!(id, LOCAL_CRATE);
collect(tcx)

View File

@ -37,7 +37,7 @@ pub mod stability;
mod upvars;
mod weak_lang_items;
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
check_attr::provide(providers);
check_const::provide(providers);
diagnostic_items::provide(providers);

View File

@ -135,7 +135,7 @@ fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
collector.lib_features
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.get_lib_features = |tcx, id| {
assert_eq!(id, LOCAL_CRATE);
collect(tcx)

View File

@ -179,7 +179,7 @@ fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
);
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_liveness, ..*providers };
}

View File

@ -36,7 +36,7 @@ fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
);
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_loops, ..*providers };
}

View File

@ -425,6 +425,6 @@ fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet
tcx.arena.alloc(reachable_context.reachable_symbols)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { reachable_set, ..*providers };
}

View File

@ -842,6 +842,6 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
tcx.arena.alloc(scope_tree)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { region_scope_tree, ..*providers };
}

View File

@ -476,7 +476,7 @@ fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor());
}
pub(crate) fn provide(providers: &mut Providers<'_>) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_unstable_api_usage, ..*providers };
providers.stability_index = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);

View File

@ -9,7 +9,7 @@ use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_span::Span;
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
providers.upvars_mentioned = |tcx, def_id| {
if !tcx.is_closure(def_id) {
return None;

View File

@ -57,6 +57,6 @@ fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { plugin_registrar_fn, ..*providers };
}

View File

@ -2029,7 +2029,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers {
privacy_access_levels,
check_private_in_public,

View File

@ -898,44 +898,42 @@ impl<'a> Resolver<'a> {
suggestion: Option<TypoSuggestion>,
span: Span,
) -> bool {
if let Some(suggestion) = suggestion {
let suggestion = match suggestion {
None => return false,
// We shouldn't suggest underscore.
if suggestion.candidate == kw::Underscore {
return false;
}
let msg = format!(
"{} {} with a similar name exists",
suggestion.res.article(),
suggestion.res.descr()
);
err.span_suggestion(
span,
&msg,
suggestion.candidate.to_string(),
Applicability::MaybeIncorrect,
);
let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate {
LOCAL_CRATE => self.opt_span(def_id),
_ => Some(
self.session
.source_map()
.guess_head_span(self.cstore().get_span_untracked(def_id, self.session)),
Some(suggestion) if suggestion.candidate == kw::Underscore => return false,
Some(suggestion) => suggestion,
};
let msg = format!(
"{} {} with a similar name exists",
suggestion.res.article(),
suggestion.res.descr()
);
err.span_suggestion(
span,
&msg,
suggestion.candidate.to_string(),
Applicability::MaybeIncorrect,
);
let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate {
LOCAL_CRATE => self.opt_span(def_id),
_ => Some(
self.session
.source_map()
.guess_head_span(self.cstore().get_span_untracked(def_id, self.session)),
),
});
if let Some(span) = def_span {
err.span_label(
self.session.source_map().guess_head_span(span),
&format!(
"similarly named {} `{}` defined here",
suggestion.res.descr(),
suggestion.candidate.as_str(),
),
});
if let Some(span) = def_span {
err.span_label(
self.session.source_map().guess_head_span(span),
&format!(
"similarly named {} `{}` defined here",
suggestion.res.descr(),
suggestion.candidate.as_str(),
),
);
}
return true;
);
}
false
true
}
fn binding_description(&self, b: &NameBinding<'_>, ident: Ident, from_prelude: bool) -> String {

View File

@ -262,8 +262,8 @@ impl<'a> Resolver<'a> {
}
let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| {
if let Some(blacklisted_binding) = this.blacklisted_binding {
if ptr::eq(binding, blacklisted_binding) {
if let Some(unusable_binding) = this.unusable_binding {
if ptr::eq(binding, unusable_binding) {
return Err((Determined, Weak::No));
}
}
@ -278,12 +278,12 @@ impl<'a> Resolver<'a> {
return resolution
.binding
.and_then(|binding| {
// If the primary binding is blacklisted, search further and return the shadowed
// glob binding if it exists. What we really want here is having two separate
// scopes in a module - one for non-globs and one for globs, but until that's done
// use this hack to avoid inconsistent resolution ICEs during import validation.
if let Some(blacklisted_binding) = self.blacklisted_binding {
if ptr::eq(binding, blacklisted_binding) {
// If the primary binding is unusable, search further and return the shadowed glob
// binding if it exists. What we really want here is having two separate scopes in
// a module - one for non-globs and one for globs, but until that's done use this
// hack to avoid inconsistent resolution ICEs during import validation.
if let Some(unusable_binding) = self.unusable_binding {
if ptr::eq(binding, unusable_binding) {
return resolution.shadowed_glob;
}
}
@ -875,9 +875,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
/// consolidate multiple unresolved import errors into a single diagnostic.
fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImportError> {
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
let orig_blacklisted_binding = match &import.kind {
let orig_unusable_binding = match &import.kind {
ImportKind::Single { target_bindings, .. } => {
Some(mem::replace(&mut self.r.blacklisted_binding, target_bindings[TypeNS].get()))
Some(mem::replace(&mut self.r.unusable_binding, target_bindings[TypeNS].get()))
}
_ => None,
};
@ -891,8 +891,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
import.crate_lint(),
);
let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
if let Some(orig_blacklisted_binding) = orig_blacklisted_binding {
self.r.blacklisted_binding = orig_blacklisted_binding;
if let Some(orig_unusable_binding) = orig_unusable_binding {
self.r.unusable_binding = orig_unusable_binding;
}
import.vis.set(orig_vis);
if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
@ -1013,8 +1013,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
self.r.per_ns(|this, ns| {
if !type_ns_only || ns == TypeNS {
let orig_vis = import.vis.replace(ty::Visibility::Invisible);
let orig_blacklisted_binding =
mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get());
let orig_unusable_binding =
mem::replace(&mut this.unusable_binding, target_bindings[ns].get());
let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true);
let binding = this.resolve_ident_in_module(
module,
@ -1025,7 +1025,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
import.span,
);
this.last_import_segment = orig_last_import_segment;
this.blacklisted_binding = orig_blacklisted_binding;
this.unusable_binding = orig_unusable_binding;
import.vis.set(orig_vis);
match binding {
@ -1291,8 +1291,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
return;
}
let orig_blacklisted_binding =
mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get());
let orig_unusable_binding =
mem::replace(&mut this.unusable_binding, target_bindings[ns].get());
match this.early_resolve_ident_in_lexical_scope(
target,
@ -1311,7 +1311,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
Err(_) => is_redundant[ns] = Some(false),
}
this.blacklisted_binding = orig_blacklisted_binding;
this.unusable_binding = orig_unusable_binding;
}
});

View File

@ -842,14 +842,14 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
report_error(self, ns);
}
Some(LexicalScopeBinding::Item(binding)) => {
let orig_blacklisted_binding =
replace(&mut self.r.blacklisted_binding, Some(binding));
let orig_unusable_binding =
replace(&mut self.r.unusable_binding, Some(binding));
if let Some(LexicalScopeBinding::Res(..)) = self
.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span)
{
report_error(self, ns);
}
self.r.blacklisted_binding = orig_blacklisted_binding;
self.r.unusable_binding = orig_unusable_binding;
}
None => {}
}

View File

@ -278,7 +278,7 @@ type ScopeRef<'a> = &'a Scope<'a>;
const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
pub fn provide(providers: &mut ty::query::Providers<'_>) {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
resolve_lifetimes,

View File

@ -867,7 +867,7 @@ pub struct Resolver<'a> {
last_import_segment: bool,
/// This binding should be ignored during in-module resolution, so that we don't get
/// "self-confirming" import resolutions during import validation.
blacklisted_binding: Option<&'a NameBinding<'a>>,
unusable_binding: Option<&'a NameBinding<'a>>,
/// The idents for the primitive types.
primitive_type_table: PrimitiveTypeTable,
@ -1266,7 +1266,7 @@ impl<'a> Resolver<'a> {
indeterminate_imports: Vec::new(),
last_import_segment: false,
blacklisted_binding: None,
unusable_binding: None,
primitive_type_table: PrimitiveTypeTable::new(),
@ -3102,6 +3102,6 @@ impl CrateLint {
}
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
late::lifetimes::provide(providers);
}

View File

@ -27,7 +27,7 @@
use crate::def_id::{DefId, CRATE_DEF_INDEX};
use crate::edition::Edition;
use crate::symbol::{kw, sym, Symbol};
use crate::GLOBALS;
use crate::SESSION_GLOBALS;
use crate::{Span, DUMMY_SP};
use rustc_data_structures::fx::FxHashMap;
@ -174,7 +174,7 @@ impl HygieneData {
}
fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
GLOBALS.with(|globals| f(&mut *globals.hygiene_data.borrow_mut()))
SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.hygiene_data.borrow_mut()))
}
fn fresh_expn(&mut self, expn_data: Option<ExpnData>) -> ExpnId {

View File

@ -65,16 +65,20 @@ use sha1::Sha1;
#[cfg(test)]
mod tests;
pub struct Globals {
// Per-session global variables: this struct is stored in thread-local storage
// in such a way that it is accessible without any kind of handle to all
// threads within the compilation session, but is not accessible outside the
// session.
pub struct SessionGlobals {
symbol_interner: Lock<symbol::Interner>,
span_interner: Lock<span_encoding::SpanInterner>,
hygiene_data: Lock<hygiene::HygieneData>,
source_map: Lock<Option<Lrc<SourceMap>>>,
}
impl Globals {
pub fn new(edition: Edition) -> Globals {
Globals {
impl SessionGlobals {
pub fn new(edition: Edition) -> SessionGlobals {
SessionGlobals {
symbol_interner: Lock::new(symbol::Interner::fresh()),
span_interner: Lock::new(span_encoding::SpanInterner::default()),
hygiene_data: Lock::new(hygiene::HygieneData::new(edition)),
@ -83,7 +87,7 @@ impl Globals {
}
}
scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals);
// FIXME: Perhaps this should not implement Rustc{Decodable, Encodable}
//
@ -713,14 +717,14 @@ impl rustc_serialize::UseSpecializedDecodable for Span {
/// the `SourceMap` provided to this function. If that is not available,
/// we fall back to printing the raw `Span` field values
pub fn with_source_map<T, F: FnOnce() -> T>(source_map: Lrc<SourceMap>, f: F) -> T {
GLOBALS.with(|globals| {
*globals.source_map.borrow_mut() = Some(source_map);
SESSION_GLOBALS.with(|session_globals| {
*session_globals.source_map.borrow_mut() = Some(source_map);
});
struct ClearSourceMap;
impl Drop for ClearSourceMap {
fn drop(&mut self) {
GLOBALS.with(|globals| {
globals.source_map.borrow_mut().take();
SESSION_GLOBALS.with(|session_globals| {
session_globals.source_map.borrow_mut().take();
});
}
}
@ -738,8 +742,8 @@ pub fn debug_with_source_map(
}
pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
GLOBALS.with(|globals| {
if let Some(source_map) = &*globals.source_map.borrow() {
SESSION_GLOBALS.with(|session_globals| {
if let Some(source_map) = &*session_globals.source_map.borrow() {
debug_with_source_map(span, f, source_map)
} else {
f.debug_struct("Span")

View File

@ -5,7 +5,7 @@
// See https://internals.rust-lang.org/t/rfc-compiler-refactoring-spans/1357/28
use crate::hygiene::SyntaxContext;
use crate::GLOBALS;
use crate::SESSION_GLOBALS;
use crate::{BytePos, SpanData};
use rustc_data_structures::fx::FxHashMap;
@ -136,5 +136,5 @@ impl SpanInterner {
// If an interner exists, return it. Otherwise, prepare a fresh one.
#[inline]
fn with_span_interner<T, F: FnOnce(&mut SpanInterner) -> T>(f: F) -> T {
GLOBALS.with(|globals| f(&mut *globals.span_interner.lock()))
SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.span_interner.lock()))
}

View File

@ -14,7 +14,7 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use std::str;
use crate::{Span, DUMMY_SP, GLOBALS};
use crate::{Span, DUMMY_SP, SESSION_GLOBALS};
#[cfg(test)]
mod tests;
@ -1387,7 +1387,7 @@ impl Ident {
#[inline]
fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
GLOBALS.with(|globals| f(&mut *globals.symbol_interner.lock()))
SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.symbol_interner.lock()))
}
/// An alternative to `Symbol`, useful when the chars within the symbol need to

View File

@ -1,6 +1,6 @@
use super::*;
use crate::{edition, Globals};
use crate::{edition, SessionGlobals};
#[test]
fn interner_tests() {
@ -18,7 +18,7 @@ fn interner_tests() {
#[test]
fn without_first_quote_test() {
GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || {
SESSION_GLOBALS.set(&SessionGlobals::new(edition::DEFAULT_EDITION), || {
let i = Ident::from_str("'break");
assert_eq!(i.without_first_quote().name, kw::Break);
});

View File

@ -126,7 +126,7 @@ pub fn symbol_name_for_instance_in_crate(
compute_symbol_name(tcx, instance, || instantiating_crate)
}
pub fn provide(providers: &mut Providers<'_>) {
pub fn provide(providers: &mut Providers) {
*providers = Providers { symbol_name: symbol_name_provider, ..*providers };
}

View File

@ -18,7 +18,7 @@ pub fn target() -> TargetResult {
features: "+neon,+fp-armv8,+apple-a7".to_string(),
eliminate_frame_pointer: false,
max_atomic_width: Some(128),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
forces_embed_bitcode: true,
// Taken from a clang build on Xcode 11.4.1.
// These arguments are not actually invoked - they just have

View File

@ -18,7 +18,7 @@ pub fn target() -> TargetResult {
features: "+neon,+fp-armv8,+apple-a7".to_string(),
eliminate_frame_pointer: false,
max_atomic_width: Some(128),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
forces_embed_bitcode: true,
..base
},

View File

@ -15,6 +15,6 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base },
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}

View File

@ -20,6 +20,6 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base },
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}

View File

@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::cloudabi_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
base.unsupported_abis = super::arm_base::unsupported_abis();
base.linker = Some("aarch64-unknown-cloudabi-cc".to_string());
Ok(Target {

View File

@ -15,6 +15,6 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base },
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}

View File

@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::hermit_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
base.unsupported_abis = super::arm_base::unsupported_abis();
base.linker = Some("aarch64-hermit-gcc".to_string());
Ok(Target {

View File

@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}_mcount".to_string(),
..base
},

View File

@ -16,7 +16,7 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}_mcount".to_string(),
..base
},

View File

@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
base.unsupported_abis = super::arm_base::unsupported_abis();
Ok(Target {
llvm_target: "aarch64-unknown-netbsd".to_string(),

View File

@ -18,7 +18,7 @@ pub fn target() -> Result<Target, String> {
linker_is_gnu: true,
max_atomic_width: Some(128),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
..Default::default()
};
Ok(Target {

View File

@ -18,7 +18,7 @@ pub fn target() -> Result<Target, String> {
linker_is_gnu: true,
max_atomic_width: Some(128),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
..Default::default()
};
Ok(Target {

View File

@ -3,7 +3,7 @@ use crate::spec::{LinkerFlavor, Target, TargetResult};
pub fn target() -> TargetResult {
let mut base = super::openbsd_base::opts();
base.max_atomic_width = Some(128);
base.abi_blacklist = super::arm_base::abi_blacklist();
base.unsupported_abis = super::arm_base::unsupported_abis();
Ok(Target {
llvm_target: "aarch64-unknown-openbsd".to_string(),

View File

@ -15,6 +15,6 @@ pub fn target() -> TargetResult {
target_env: "gnu".to_string(),
target_vendor: "wrs".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base },
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}

View File

@ -1,6 +1,6 @@
use crate::spec::abi::Abi;
// All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm
pub fn abi_blacklist() -> Vec<Abi> {
pub fn unsupported_abis() -> Vec<Abi> {
vec![Abi::Stdcall, Abi::Fastcall, Abi::Vectorcall, Abi::Thiscall, Abi::Win64, Abi::SysV64]
}

View File

@ -17,6 +17,6 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { abi_blacklist: super::arm_base::abi_blacklist(), ..base },
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}

View File

@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+strict-align,+v6".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},

View File

@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+strict-align,+v6,+vfp2,-d32".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},

View File

@ -22,7 +22,7 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
..base
},

View File

@ -22,7 +22,7 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
..base
},

View File

@ -22,7 +22,7 @@ pub fn target() -> TargetResult {
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
emit_debug_gdb_scripts: false,
..Default::default()
},

View File

@ -23,7 +23,7 @@ pub fn target() -> TargetResult {
panic_strategy: PanicStrategy::Abort,
features: "+vfp3,-d32,-fp16".to_string(),
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
emit_debug_gdb_scripts: false,
..Default::default()
},

View File

@ -18,7 +18,7 @@ pub fn target() -> TargetResult {
features: "+soft-float,+strict-align".to_string(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},

View File

@ -18,7 +18,7 @@ pub fn target() -> TargetResult {
features: "+soft-float,+strict-align".to_string(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}__gnu_mcount_nc".to_string(),
..base
},

View File

@ -21,7 +21,7 @@ pub fn target() -> TargetResult {
features: "+soft-float,+strict-align".to_string(),
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
unsupported_abis: super::arm_base::unsupported_abis(),
target_mcount: "\u{1}mcount".to_string(),
..base
},

Some files were not shown because too many files have changed in this diff Show More