about summary refs log tree commit diff
path: root/library/proc_macro/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-01-26Auto merge of #107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #97373 (impl DispatchFromDyn for Cell and UnsafeCell) - #106625 (Remove backwards compat for LLVM 12 coverage format) - #106779 (Avoid __cxa_thread_atexit_impl on Emscripten) - #106811 (Append .dwp to the binary filename instead of replacing the existing extension.) - #106836 (Remove optimistic spinning from `mpsc::SyncSender`) - #106946 (implement Hash for proc_macro::LineColumn) - #107074 (remove unnecessary check for opaque types) - #107287 (Improve fn pointer notes) - #107304 (Use `can_eq` to compare types for default assoc type error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-16implement Hash for proc_macro::LineColumnDavid Tolnay-1/+1
2023-01-12Improve proc macro attribute diagnosticsmejrs-0/+1
2022-12-12Add a "the" to proc_macro documentationest31-1/+1
2022-11-06Bump version placeholders to releaseMark Rousskov-1/+1
2022-10-18Stabilize proc_macro::Span::source_textest31-1/+1
Splits proc_macro::Span::source_text into a new feature gate and stabilizes it.
2022-09-17Fix typo in proc_macro Span::eqjam1garner-1/+1
2022-08-19use <[u8]>::escape_ascii instead of core::ascii::escape_defaultKaDiWa-6/+1
2022-07-24Expose size_hint() for TokenStream's iteratorDavid Tolnay-0/+8
2022-07-20Rollup merge of #99516 - m-ou-se:proc-macro-tracked-tracking-issue, ↵Matthias Krüger-4/+4
r=Mark-Simulacrum Use new tracking issue for proc_macro::tracked_*.
2022-07-20Use new tracking issue for proc_macro::tracked_*.Mara Bos-4/+4
2022-07-18proc_macro: Move subspan to be a method on Span in the bridgeNika Layzell-6/+1
This method is still only used for Literal::subspan, however the implementation only depends on the Span component, so it is simpler and more efficient for now to pass down only the information that is needed. In the future, if more information about the Literal is required in the implementation (e.g. to validate that spans line up as expected with source text), that extra information can be added back with extra arguments.
2022-07-18proc_macro: stop using a remote object handle for LiteralNika Layzell-28/+110
This builds on the symbol infrastructure built for `Ident` to replicate the `LitKind` and `Lit` structures in rustc within the `proc_macro` client, allowing literals to be fully created and interacted with from the client thread. Only parsing and subspan operations still require sync RPC.
2022-07-18proc_macro: stop using a remote object handle for IdentNika Layzell-16/+31
Doing this for all unicode identifiers would require a dependency on `unicode-normalization` and `rustc_lexer`, which is currently not possible for `proc_macro` due to it being built concurrently with `std` and `core`. Instead, ASCII identifiers are validated locally, and an RPC message is used to validate unicode identifiers when needed. String values are interned on the both the server and client when deserializing, to avoid unnecessary copies and keep Ident cheap to copy and move. This appears to be important for performance. The client-side interner is based roughly on the one from rustc_span, and uses an arena inspired by rustc_arena. RPC messages passing symbols always include the full value. This could potentially be optimized in the future if it is revealed to be a performance bottleneck. Despite now having a relevant implementaion of Display for Ident, ToString is still specialized, as it is a hot-path for this object. The symbol infrastructure will also be used for literals in the next part.
2022-07-18proc_macro: Specialize Punct::to_stringNika Layzell-0/+7
This was removed in a previous part, however it should be specialized for to_string performance and consistency.
2022-06-28review changesNika Layzell-2/+6
longer names for RPC generics and reduced dependency on macros in the server.
2022-06-26proc_macro: stop using a remote object handle for GroupNika Layzell-11/+15
This greatly reduces round-trips to fetch relevant extra information about the token in proc macro code, and avoids RPC messages to create Group tokens.
2022-06-26proc_macro: stop using a remote object handle for PunctNika Layzell-19/+17
This greatly reduces round-trips to fetch relevant extra information about the token in proc macro code, and avoids RPC messages to create Punct tokens.
2022-06-25proc_macro: cache static spans in client's thread-local stateNika Layzell-1/+1
This greatly improves the performance of the very frequently called `call_site()` macro when running in a cross-thread configuration.
2022-06-17review fixupsNika Layzell-15/+15
2022-06-17Try to reduce codegen complexity of TokenStream's FromIterator and Extend implsNika Layzell-16/+92
This is an experimental patch to try to reduce the codegen complexity of TokenStream's FromIterator and Extend implementations for downstream crates, by moving the core logic into a helper type. This might help improve build performance of crates which depend on proc_macro as iterators are used less, and the compiler may take less time to do things like attempt specializations or other iterator optimizations. The change intentionally sacrifices some optimization opportunities, such as using the specializations for collecting iterators derived from Vec::into_iter() into Vec. This is one of the simpler potential approaches to reducing the amount of code generated in crates depending on proc_macro, so it seems worth trying before other more-involved changes.
2022-06-17proc_macro: reduce the number of messages required to create, extend, and ↵Nika Layzell-24/+54
iterate TokenStreams This significantly reduces the cost of common interactions with TokenStream when running with the CrossThread execution strategy, by reducing the number of RPC calls required.
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-06-02Revert #96682.Nicholas Nethercote-3/+2
The change was "Show invisible delimiters (within comments) when pretty printing". It's useful to show these delimiters, but is a breaking change for some proc macros. Fixes #97608.
2022-05-04Show invisible delimeters (within comments) when pretty printing.Nicholas Nethercote-2/+3
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-2/+2
2022-04-09Rollup merge of #95308 - bjorn3:more_stable_proc_macro, r=Mark-SimulacrumDylan DPC-3/+3
Reduce the amount of unstable features used in libproc_macro This makes it easier to adapt the source for stable when copying it into rust-analyzer to load rustc compiled proc macros.
2022-04-05trivial cfg(bootstrap) changesPietro Albini-2/+0
2022-03-25Add note about feature gatesbjorn3-0/+3
2022-03-25Remove usage of extern_types feature gatebjorn3-1/+0
2022-03-25Remove usage of panic_update_hook feature gatebjorn3-1/+0
2022-03-25Remove unused auto_traits feature gatebjorn3-1/+0
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-4/+4
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-2/+2
2022-01-07Implement panic::update_hookBadel2-0/+1
2021-12-14made compiler happyAnuvrat-1/+0
2021-11-12proc_macro: Add an expand_expr method to TokenStreamNika Layzell-7/+41
This feature is aimed at giving proc macros access to powers similar to those used by builtin macros such as `format_args!` or `concat!`. These macros are able to accept macros in place of string literal parameters, such as the format string, as they perform recursive macro expansion while being expanded. This can be especially useful in many cases thanks to helper macros like `concat!`, `stringify!` and `include_str!` which are often used to construct string literals at compile-time in user code. For now, this method only allows expanding macros which produce literals, although more expresisons will be supported before the method is stabilized.
2021-10-25Append .0 to unsuffixed float if it would otherwise become int tokenDavid Tolnay-2/+10
2021-10-10Stabilize proc_macro::is_availablebjorn3-1/+1
2021-09-10Rollup merge of #86165 - m-ou-se:proc-macro-span-shrink, r=dtolnayManish Goregaokar-0/+12
Add proc_macro::Span::{before, after}. This adds `proc_macro::Span::before()` and `proc_macro::Span::after()` to get a zero width span at the start or end of the span. These are equivalent to rustc's `Span::shrink_to_lo()` and `Span::shrink_to_hi()` but with a less cryptic name. They are useful when generating diagnostlics like "missing \<thing\> after \<thing\>". E.g. ```rust syn::Error::new(ident.span().after(), "missing `:` after field name").into_compile_error() ```
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-04Auto merge of #87712 - est31:line-column-1-based, r=petrochenkovbors-4/+10
Proc macro spans: make columns 1 based This makes proc macro spans consistent with the `column!()` macro as well as `std::panic::Location`, as both are 1-based. https://github.com/rust-lang/rust/issues/54725#issuecomment-497246753
2021-08-03Remove space after negative sign in Literal to_stringDavid Tolnay-1/+1
2021-08-03Make the UTF-8 statement more explicit and explicitly test for itest31-2/+2
2021-08-03Make columns 1 basedest31-3/+9
2021-07-29Fix may not to appropriate might not or must notAli Malik-9/+9
2021-07-28Add tracking issue number to proc_macro_span_shrink.Mara Bos-2/+2
2021-07-03Rollup merge of #84029 - drahnr:master, r=petrochenkovYuki Okushi-0/+14
add `track_path::path` fn for usage in `proc_macro`s Adds a way to declare a dependency on external files without including them, to either re-trigger the build of a file as well as covering the use case of including dependencies within the `rustc` invocation, such that tools like `sccache`/`cachepot` are able to handle references to external files which are not included. Ref #73921
2021-07-02add track_path::path fn for proc-macro usageBernhard Schuster-0/+14
Ref #73921
2021-07-01Stabilize `Bound::cloned()`Aris Merchant-1/+0