about summary refs log tree commit diff
path: root/compiler/rustc_span/src/hygiene.rs
AgeCommit message (Collapse)AuthorLines
2021-10-02Add desugaring mark to while loopCameron Steffen-0/+2
2021-10-02rustc_span: Make hygiene debug printing reproducibleVadim Petrochenkov-1/+4
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-3/+1
2021-08-30Lower let-else to HIRCameron Steffen-0/+2
2021-07-19Auto merge of #87225 - estebank:cleanup, r=oli-obkbors-2/+2
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-2/+2
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-17Simplify Expn creation.Camille GILLOT-27/+25
2021-07-17Rename expn_info -> expn_data.Camille GILLOT-8/+8
2021-07-17Pass ExpnData by reference.Camille GILLOT-3/+3
2021-07-17Drop ExpnData::krate.Camille GILLOT-19/+10
2021-07-17Drop orig_id.Camille GILLOT-33/+9
2021-07-17Encode ExpnId using ExpnHash for incr. comp.Camille GILLOT-65/+56
2021-07-17Choose encoding format in caller code.Camille GILLOT-72/+26
2021-07-17Use LocalExpnId where possible.Camille GILLOT-14/+1
2021-07-17Make the CrateNum part of the ExpnId.Camille GILLOT-95/+250
2021-07-15Simplify metadata decoding.Camille GILLOT-30/+8
2021-07-15Separate encoding paths.Camille GILLOT-52/+87
The two paths will be modified independently in the next few commits.
2021-07-14Auto merge of #87106 - Mark-Simulacrum:edition-no-clone, r=petrochenkovbors-1/+1
Avoid cloning ExpnData to access Span edition ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost. r? `@ghost` -- opening for a perf run to start with
2021-07-13Cache expansion hash.Camille GILLOT-163/+120
2021-07-13Move HashStable implementations.Camille GILLOT-1/+59
2021-07-13Avoid cloning ExpnData to access Span editionMark Rousskov-1/+1
ExpnData is a fairly hefty structure to clone; cloning it may not be cheap. In some cases this may get optimized out, but it's not clear that will always be the case. Try to avoid that cost.
2021-07-11rustc_span: Reorder some `ExpnData` fields in accordance with commentsVadim Petrochenkov-26/+25
A drive-by change.
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-12/+3
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-4/+5
2021-07-06Store macro parent module in ExpnData.Camille GILLOT-2/+10
2021-06-11Make DummyHashStableContext dummier.Camille GILLOT-5/+5
2021-06-11Hash DefId in rustc_span.Camille GILLOT-7/+7
2021-05-12Implement span quoting for proc-macrosAaron Hill-3/+12
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-05-02Use new thread-local const-initMark Rousskov-1/+1
Let's see if this gives us any speedup - some of the TLS state modified in this commit *is* pretty heavily accessed, so we can hope!
2021-04-19fix few typosklensy-1/+1
2021-03-27Remove (lots of) dead codeJoshua Nelson-24/+2
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-26Use iter::zip in compiler/Josh Stone-1/+1
2021-03-18Remove unwrap_none/expect_none from compiler/.Mara Bos-5/+9
2021-03-11Remove useless method.Camille GILLOT-6/+0
2021-02-13Use debug log level for developer oriented logsTomasz Miąsko-2/+2
The information logged here is of limited general interest, while at the same times makes it impractical to simply enable logging and share the resulting logs due to the amount of the output produced. Reduce log level from info to debug for developer oriented information. For example, when building cargo, this reduces the amount of logs generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB. Continuation of changes from 81350.
2021-01-23Add disambiugator to ExpnDataAaron Hill-5/+152
Due to macro expansion, its possible to end up with two distinct `ExpnId`s that have the same `ExpnData` contents. This violates the contract of `HashStable`, since two unequal `ExpnId`s will end up with equal `Fingerprint`s. This commit adds a `disambiguator` field to `ExpnData`, which is used to force two otherwise-equivalent `ExpnData`s to be distinct.
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-0/+4
2021-01-03Make `ExpnData` fields `krate` and `orig_id` privateAaron Hill-2/+42
These fields are only used by hygiene serialized, and should not be accessed by anything outside of `rustc_span`.
2020-12-30Rename kw::Invalid -> kw::EmptyJoshua Nelson-2/+2
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context.
2020-10-27Show the inline stack of MIR lints that only occur after inliningOliver Scherer-0/+3
2020-10-14Remove unused code from rustc_spanest31-8/+0
2020-09-27Rollup merge of #77263 - bugadani:cleanup, r=lcnrJonas Schievink-1/+1
Clean up trivial if let
2020-09-27Clean up trivial if letDániel Buga-1/+1
2020-09-27Fix typo in ExpnData documentationJoshua Nelson-1/+1
This mis-highlighted the entire documentation as code.
2020-08-30mv compiler to compiler/mark-0/+1239