about summary refs log tree commit diff
path: root/compiler/rustc_metadata
AgeCommit message (Collapse)AuthorLines
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap to 1.60 This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25Rollup merge of #94252 - lcnr:def_kind-encoding, r=cjgillotMatthias Krüger-7/+2
don't special case `DefKind::Ctor` in encoding considering that we still use `DefKind::Ctor` for these in `Res`, this seems weird and definitely felt like a bug when encountering it while working on #89862. r? `@cjgillot`
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-1/+3
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24resolve/metadata: Stop encoding macros as reexportsVadim Petrochenkov-8/+23
2022-02-24metadata: Tweak the way in which declarative macros are encodedVadim Petrochenkov-5/+8
To make the `macro_rules` flag more readily available without decoding everything else
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-1/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24don't special case `DefKind::Ctor` in encodinglcnr-7/+2
2022-02-24Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkovbors-450/+321
Back more metadata using per-query tables r? `@ghost`
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-1/+3
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-1/+1
2022-02-19Adopt let else in more placesest31-37/+23
2022-02-19Add generator_kind table.Camille GILLOT-10/+5
2022-02-19Add fn_arg_names table.Camille GILLOT-29/+14
2022-02-19Add asyncness table.Camille GILLOT-19/+7
2022-02-19Add rendered_const table.Camille GILLOT-35/+19
2022-02-19Add mir_const_qualifs table.Camille GILLOT-28/+15
2022-02-19Drop ImplData.Camille GILLOT-76/+31
2022-02-19Do not decode span when we only need the name.Camille GILLOT-17/+19
2022-02-19Encode metadata using queries.Camille GILLOT-243/+222
2022-02-19Stop interning stability.Camille GILLOT-7/+3
2022-02-18rustdoc: Collect traits in scope for lang itemsVadim Petrochenkov-8/+11
2022-02-17Rollup merge of #94011 - est31:let_else, r=lcnrMatthias Krüger-1/+1
Even more let_else adoptions Continuation of #89933, #91018, #91481, #93046, #93590.
2022-02-16Adopt let_else in even more placesest31-1/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-1/+1
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-14fast_reject: remove `StripReferences`lcnr-2/+1
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-17/+12
2022-02-08Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisabors-3/+5
Add more *-unwind ABI variants The following *-unwind ABIs are now supported: - "C-unwind" - "cdecl-unwind" - "stdcall-unwind" - "fastcall-unwind" - "vectorcall-unwind" - "thiscall-unwind" - "aapcs-unwind" - "win64-unwind" - "sysv64-unwind" - "system-unwind" cc `@rust-lang/wg-ffi-unwind`
2022-02-05Auto merge of #93539 - petrochenkov:doclink, r=camelid,michaelwoeristerbors-0/+27
rustdoc: Collect traits in scope for foreign inherent impls Inherent impls can be inlined for variety of reasons (impls of reexported types, impls available through `Deref`, impls inlined for unclear reasons like in https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480). If an impl is inlined, then doc links in its comments are resolved and we may need the set of traits that are in scope at that impl's definition point. So in this PR we simply collect traits in scope for *all* inherent impls from other crates if their `Self` type is public, which is very similar for the strategy for trait impls previously used in https://github.com/rust-lang/rust/pull/88679. Fixes https://github.com/rust-lang/rust/issues/93476 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1026520300 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480
2022-02-04rustdoc: Collect traits in scope for foreign inherent implsVadim Petrochenkov-0/+27
2022-02-04Add a comment about possible mismatches.Nicholas Nethercote-0/+7
2022-02-04Remove `staticlibs` local variable.Nicholas Nethercote-4/+1
2022-02-04Clean up `find_library_crate`.Nicholas Nethercote-21/+19
By introducing prefix and suffix variables for all file types, and renaming some variables.
2022-02-02Add more *-unwind ABI variantsAmanieu d'Antras-3/+5
The following *-unwind ABIs are now supported: - "C-unwind" - "cdecl-unwind" - "stdcall-unwind" - "fastcall-unwind" - "vectorcall-unwind" - "thiscall-unwind" - "aapcs-unwind" - "win64-unwind" - "sysv64-unwind" - "system-unwind"
2022-02-02Make `SearchPathFile::file_name_str` non-optional.Nicholas Nethercote-4/+1
Currently, it can be `None` if the conversion from `OsString` fails, in which case all searches will skip over the `SearchPathFile`. The commit changes things so that the `SearchPathFile` just doesn't get created in the first place. Same behaviour, but slightly simpler code.
2022-02-02Inline and remove `FileSearch::search`.Nicholas Nethercote-35/+46
It has only a single callsite, and having all the code in one place will make it possible to optimize the search.
2022-02-02Remove `FileMatch`.Nicholas Nethercote-5/+4
It's returned from `FileSearch::search` but it's only used to print some debug info.
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-26Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomezbors-6/+10
rustdoc: Pre-calculate traits that are in scope for doc links This eliminates one more late use of resolver (part of #83761). At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by `collect-intra-doc-links` pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes. r? `@jyn514`
2022-01-25Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillotbors-2/+2
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-25rustdoc: Pre-calculate traits that are in scope for doc linksVadim Petrochenkov-6/+10
This eliminates one more late use of resolver
2022-01-24Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiserbors-3/+1
Use `indexmap` to avoid sorting `LocalDefId`s See discussion in https://github.com/rust-lang/rust/pull/90408#discussion_r745935459. Related to work on https://github.com/rust-lang/rust/issues/90317.
2022-01-22Use an `indexmap` to avoid sorting `LocalDefId`spierwill-3/+1
Update `indexmap` to 1.8.0. Bless test
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-53/+48
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-19Store a `Symbol` instead of an `Ident` in `AssocItem`Aaron Hill-2/+2
This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-18Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoeristerMatthias Krüger-5/+0
Implement raw-dylib support for windows-gnu Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets. Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801. (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.) In support of #58713.
2022-01-17Rollup merge of #92164 - WaffleLapkin:rustc_must_implement_one_of_attr, ↵Matthias Krüger-0/+4
r=Aaron1011 Implement `#[rustc_must_implement_one_of]` attribute This PR adds a new attribute — `#[rustc_must_implement_one_of]` that allows changing the "minimal complete definition" of a trait. It's similar to GHC's minimal `{-# MINIMAL #-}` pragma, though `#[rustc_must_implement_one_of]` is weaker atm. Such attribute was long wanted. It can be, for example, used in `Read` trait to make transitions to recently added `read_buf` easier: ```rust #[rustc_must_implement_one_of(read, read_buf)] pub trait Read { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { let mut buf = ReadBuf::new(buf); self.read_buf(&mut buf)?; Ok(buf.filled_len()) } fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { default_read_buf(|b| self.read(b), buf) } } impl Read for Ty0 {} //^ This will fail to compile even though all `Read` methods have default implementations // Both of these will compile just fine impl Read for Ty1 { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { /* ... */ } } impl Read for Ty2 { fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { /* ... */ } } ``` For now, this is implemented as an internal attribute to start experimenting on the design of this feature. In the future we may want to extend it: - Allow arbitrary requirements like `a | (b & c)` - Allow multiple requirements like - ```rust #[rustc_must_implement_one_of(a, b)] #[rustc_must_implement_one_of(c, d)] ``` - Make it appear in rustdoc documentation - Change the syntax? - Etc Eventually, we should make an RFC and make this (or rather similar) attribute public. --- I'm fairly new to compiler development and not at all sure if the implementation makes sense, but at least it passes tests :)
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-5/+5
2022-01-16rustc_metadata: Switch all decoder methods from vectors to iteratorsVadim Petrochenkov-77/+56
Also remove unnecessary `is_proc_macro_crate` checks from decoder
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-8/+6