about summary refs log tree commit diff
path: root/library/proc_macro
AgeCommit message (Collapse)AuthorLines
2025-01-20proc_macro: add `#![warn(unreachable_pub)]`Urgau-7/+8
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-1/+1
2025-01-10Rollup merge of #134693 - SpriteOvO:proc-macro-use-to-tokens-in-quote, ↵Jacob Pratt-64/+87
r=tgross35 proc_macro: Use `ToTokens` trait in `quote` macro Tracking issues: #130977, #54722 This PR changed `proc_macro::quote!` to use `ToTokens` trait instead of `TokenStream::from`, and migrated test cases from `quote` crate. r? `@dtolnay` CC `@tgross35`
2025-01-09Fix `proc_macro::quote!` for raw identAsuna-2/+8
2025-01-09Append `TokenTree` with `ToTokens` in `proc_macro::quote!`Asuna-47/+64
2025-01-01Rename the internal simpler `quote` macro to `minimal_quote`Asuna-24/+24
2024-12-23Use `#[derive(Default)]` instead of manually implementing itEsteban Küber-7/+1
2024-12-13Remove support for specializing ToString outside the standard librarybjorn3-72/+11
This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-11-30rustc_allow_const_fn_unstable is not used in proc_macroRalf Jung-1/+0
2024-10-27Add a new trait `proc_macro::ToTokens`Asuna-0/+314
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-1/+1
2024-10-21move strict provenance lints to new feature gate, remove old feature gatesRalf Jung-1/+0
2024-10-17Remove TODO in proc_macro now `const_refs_to_static` is stableGnomedDev-20/+11
2024-10-02update `Literal`'s introSlanterns-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-18Revert "Add a hack to prevent proc_macro misopt in CI"Josh Stone-3/+1
This reverts commit da8ac73d910a446e796f511c0dda97e49d14f044.
2024-08-27library: Stabilize new_uninit for Box, Rc, and ArcJubilee Young-1/+0
A partial stabilization that only affects: - AllocType<T>::new_uninit - AllocType<T>::assume_init - AllocType<[T]>::new_uninit_slice - AllocType<[T]>::assume_init where "AllocType" is Box, Rc, or Arc
2024-07-29Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomezMatthias Krüger-0/+1
Clean and enable `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro` I am not sure if the lint is supposed to be "ready enough" (since it is `allow` by default), but it does catch a couple issues in `core` (`alloc`, `std`, `test` and `proc_macro` are already clean), so I propose making it `warn` in all the crates rendered in the website. Cc: `@GuillaumeGomez`
2024-07-29Warn on `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro`Miguel Ojeda-0/+1
They are all clean now, so enable the lint to keep them clean going forward. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29Reformat `use` declarations.Nicholas Nethercote-23/+17
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-4/+4
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-24Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=AmanieuMatthias Krüger-9/+6
Replace some `mem::forget`'s with `ManuallyDrop` > but I would like to see a larger effort to replace all uses of `mem::forget`. _Originally posted by `@saethlin` in https://github.com/rust-lang/rust/issues/127584#issuecomment-2226087767_ So, r? `@saethlin` Sorry, I have finished writing all of this before I got your response.
2024-07-19Avoid ref when using format! for perfYuri Astrakhan-2/+2
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
2024-07-15lib: replace some `mem::forget`'s with `ManuallyDrop`Pavel Grigorenko-9/+6
2024-06-19Add a hack to prevent proc_macro misopt in CIGary Guo-1/+3
2024-06-13Remove superfluous escaping from byte, byte str, and c str literalsDavid Tolnay-14/+94
2024-06-05Rollup merge of #123168 - joshtriplett:size-of-prelude, r=AmanieuJubilee-1/+0
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude (Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.) Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it.
2024-05-30Apply x clippy --fix and x fmtr0cky-4/+4
2024-05-23Rollup merge of #124389 - CensoredUsername:master, r=petrochenkovLeón Orell Valerian Liehr-0/+12
Add a warning to proc_macro::Delimiter::None that rustc currently does not respect it. It does not provide the behaviour it is indicated to provide when used in a proc_macro context. This seems to be a bug, (https://github.com/rust-lang/rust/issues/67062), but it is a long standing one, and hard to discover. This pull request adds a warning to inform users of this issue, with a link to the relevant issue, and a version number of the last known affected rustc version.
2024-05-18Add a warning to Delimiter::None that rustc currently does not respect it.CensoredUsername-0/+12
It does not provide the behaviour it is indicated to provide when used in a proc_macro context.
2024-05-13Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the preludeJosh Triplett-1/+0
Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it. Add `size_of_val`, `align_of`, and `align_of_val` as well, with similar justification: widely useful, self-explanatory, unmistakeable for anything else, won't produce conflicts.
2024-05-01Replace version placeholders for 1.79Mark Rousskov-2/+2
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-16Fix empty-set symbol in commentsDavid Tolnay-1/+1
2024-04-11Call the panic hook for non-unwind panics in proc-macrosBen Kimock-1/+6
2024-04-04Stabilize `Literal::c_string`Slanterns-1/+1
2024-04-04Stabilize `Literal::byte_character`Slanterns-1/+1
2024-03-23proc_macro: simplify bridge statejoboet-135/+61
2024-03-19SeqCst->Relaxed for proc_macro bridge counter.Mara Bos-2/+2
Relaxed is enough here.
2024-03-12Fix typo in lib.rs of proc_macroJonathan Jensen-1/+1
2024-03-04Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnrMatthias Krüger-2/+2
constify a couple thread_local statics
2024-03-01Move `HandleStore` into `server.rs`.Nicholas Nethercote-86/+99
This just moves the server-relevant parts of handles into `server.rs`. It introduces a new higher-order macro `with_api_handle_types` to avoid some duplication. This fixes two `FIXME` comments, and makes things clearer, by not having server code in `client.rs`.
2024-02-24Forbid use of `extern "C-unwind"` inside standard libraryGary Guo-0/+1
Those libraries are build with `-C panic=unwind` and is expected to be linkable to `-C panic=abort` library. To ensure unsoundness compiler needs to prevent a `C-unwind` call to exist, as doing so may leak foreign exceptions into `-C panic=abort`.
2024-02-23Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnaybors-1/+1
Use generic `NonZero` everywhere in `library`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 Use generic `NonZero` everywhere (except stable examples). r? `@dtolnay`
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-0/+1
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2024-02-22Use generic `NonZero` everywhere else.Markus Reiter-1/+1
2024-02-19Remove `RefMutL` hack in `proc_macro::bridge`Pavel Grigorenko-26/+3
2024-02-16Auto merge of #116385 - kornelski:maybe-rename, r=Amanieubors-1/+1
Rename MaybeUninit::write_slice A step to push #79995 forward. https://github.com/rust-lang/libs-team/issues/122 also suggested to make them inherent methods, but they can't be — they'd conflict with slice's regular methods.
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-10/+11
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-1/+1