Commit Graph

260 Commits

Author SHA1 Message Date
Matthias Krüger 679ab9e061 Rollup merge of #149400 - Skgland:tracked_mod, r=Amanieu
unstable proc_macro tracked::* rename/restructure

Picking up what should be the uncontroversial part of rust-lang/rust#87173 (closed due to inactivity over two years ago).

Part of rust-lang/rust#99515.

- move `proc_macro::tracked_env::var` to `proc_macro::tracked::env_var`
- move `proc_macro::tracked_path::path` to `proc_macro::tracked::path`
- change the argument of `proc_macro::tracked::path` from `AsRef<str>` to `AsRef<Path>`.
2025-12-09 17:36:48 +01:00
Stuart Cook a32d3103d5 Rollup merge of #148048 - thaliaarchi:stabilize-maybeuninit-write-slice, r=Mark-Simulacrum
Stabilize `maybe_uninit_write_slice`

Stabilize feature `maybe_uninit_write_slice` (closes https://github.com/rust-lang/rust/issues/79995).

Note that this also const-stabilizes `<[MaybeUninit<_>]>::write_copy_of_slice`. That method depends on `<[_]>::copy_from_slice`, which is already const-stable, and `<[MaybeUninit<_>]>::assume_init_mut` which is now also stable.
2025-11-27 12:36:48 +11:00
Skgland 8d8d7021c6 change proc_macro::tracked::path to take an AsRef<Path> instead of an AsRef<str> 2025-11-26 22:44:30 +01:00
Skgland 72076c6b54 move and rename proc_macro::tracked_{env::var,path::path} 2025-11-26 22:44:25 +01:00
Josh Stone f25ca45fd1 Update CURRENT_RUSTC_VERSION post-bump
(cherry picked from commit 813072186c)
2025-10-28 13:22:00 -07:00
Thalia Archibald 5088b3816b Stabilize maybe_uninit_write_slice 2025-10-23 14:02:41 -06:00
Stuart Cook 428be2fbc9 Rollup merge of #147497 - cyrgani:proc-macro-cleanups-3, r=petrochenkov
`proc_macro` cleanups (3/N)

Followup to rust-lang/rust#147386, which removed the old `Decode` trait.
Can be reviewed commit by commit.
2025-10-14 16:30:58 +11:00
dianqk 6967a8561b Rollup merge of #145722 - Qelxiros:112815-tokenstream-extend, r=dtolnay
implement Extend<{Group, Literal, Punct, Ident}> for TokenStream

Tracking issue: rust-lang/rust#112815
2025-10-11 07:05:54 +08:00
cyrgani 6a12470210 rename DecodeMut to Decode 2025-10-10 22:19:04 +02:00
cyrgani e3d2016a22 inline constants in generated enum Encode impls 2025-10-08 21:32:28 +02:00
cyrgani 0355358e6c run zero-size assertion in const {} 2025-10-08 21:32:27 +02:00
cyrgani 7aa52ea97a remove Decode trait and only impl 2025-10-07 21:21:40 +02:00
cyrgani 74ec42e000 refactor confusing loop in proc_macro arena 2025-10-07 21:21:07 +02:00
cyrgani 0a6462be90 remove unneeded imports 2025-10-05 23:25:08 +02:00
cyrgani d7773f6b1c explicitly implement !Send and !Sync 2025-09-30 00:09:12 +02:00
cyrgani 23f3400613 remove unused #![feature(stmt_expr_attributes)] 2025-09-30 00:01:17 +02:00
cyrgani 9bb4081fb0 remove reverse_{encode, decode}! 2025-09-29 23:42:01 +02:00
Jeremy Smart ff7081e6e2 Update library/proc_macro/src/lib.rs
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2025-08-26 17:10:08 +00:00
Jeremy Smart f0fd9cdffd implement Extend<{Group, Literal, Punct, Ident}> for TokenStream 2025-08-21 16:21:28 -04:00
Matthias Krüger 465ae94328 Rollup merge of #143631 - hkBst:update-escaper-2, r=compiler-errors
update to literal-escaper-0.0.5

Quoting from the changelog, this version brings:
- Use `NonZero<char/u8>` in `unescape_c_str` and `check_raw_c_str` to statically exclude nuls
- Add `#[inline]` to small functions for improved performance
2025-07-17 10:41:45 +02:00
Trevor Gross 73d3adc67b Rollup merge of #141996 - Daniel-Aaron-Bloom:dollar_crate, r=petrochenkov
Fix `proc_macro::Ident`'s handling of `$crate`

This PR is addresses a few minor bugs, all relating to `proc_macro::Ident`'s support for `$crate`. `Ident` currently supports `$crate` (as can be seen in the `mixed-site-span` test), but:
* `proc_macro::Symbol::can_be_raw` is out of sync with `rustc_span::Symbol::can_be_raw`
  * former doesn't cover `$crate` while the latter does cover `kw::DollarCrate`
* `Ident::new` rejects `$crate`
  * This conflicts with the [reference definition](https://doc.rust-lang.org/nightly/reference/macros-by-example.html#r-macro.decl.meta.specifier) of `ident` which includes `$crate`.
  * This also conflicts with the documentation on [`Display for Ident`](https://doc.rust-lang.org/proc_macro/struct.Ident.html#impl-Display-for-Ident) which says the output "should be losslessly convertible back into the same identifier".

This PR fixes the above issues and extends the `mixed-site-span` test to exercise these fixed code paths, as well as validating the different possible spans resolve `$crate`  as expected (for both the new and old `$crate` construction code paths).
2025-07-10 03:23:52 -04:00
Marijn Schouten d44dcd4513 update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
bors 2c2bb995af Auto merge of #140999 - hkBst:update-escaper, r=nnethercote
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing

This is the replacement for just the part of https://github.com/rust-lang/rust/pull/138163 dealing with the changed API of unescape functionality, since that got moved into its own crate.

<del>This uses an unpublished version of literal-escaper (https://github.com/rust-lang/literal-escaper/pull/8).</del>

r? `@nnethercote`
2025-06-25 01:03:30 +00:00
Marijn Schouten 707a6f5463 update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
Tomoaki Kobayashi 23e35c6bd3 Add support for repetition to proc_macro::quote 2025-06-17 01:36:54 +09:00
bjorn3 3e944fa391 Remove all support for wasm's legacy ABI 2025-06-14 09:57:06 +00:00
Daniel Bloom 6d1e93d8cd Add support for $crate to Ident 2025-06-12 01:13:24 -07:00
bjorn3 026baa1c6f Do not get proc_macro from the sysroot in rustc
With the stage0 refactor the proc_macro version found in the sysroot
will no longer always match the proc_macro version that proc-macros get
compiled with by the rustc executable that uses this proc_macro. This
will cause problems as soon as the ABI of the bridge gets changed to
implement new features or change the way existing features work.

To fix this, this commit changes rustc crates to depend directly on the
local version of proc_macro which will also be used in the sysroot that
rustc will build.
2025-05-27 15:49:28 +00:00
Pietro Albini 779dd35649 manual clippy fixes 2025-05-12 15:33:41 +02:00
Pietro Albini a360940ac9 update version placeholders 2025-05-12 15:33:30 +02:00
Mara Bos 2a053c7a15 Update doc comments. 2025-04-30 15:28:45 +02:00
Mara Bos d6ae459af8 Stabilize proc_macro::Span::{file, local_file}. 2025-04-30 15:28:09 +02:00
Mara Bos c5c93626a0 Stabilize proc_macro::Span::{start, end, line, column}. 2025-04-15 17:29:04 +02:00
Mara Bos 3962069982 Replace proc_macro::SourceFile by Span::{file, local_file}. 2025-04-11 15:07:08 +02:00
Mara Bos 6788ce76c9 Remove proc_macro::SourceFile::is_real(). 2025-04-11 14:02:06 +02:00
Boxy c93005ee65 update cfgs 2025-04-09 12:29:59 +01:00
Guillaume Gomez 2b533e6b49 bootstrap: Only add rustc_randomized_layouts if the crate has it 2025-04-04 22:26:10 +02:00
Guillaume Gomez 13400c2c10 Add _value methods to proc_macro lib 2025-04-04 15:04:17 +02:00
Ralf Jung 61e24e630d allow wasm_c_abi in proc_macro bridge 2025-03-25 08:22:35 +01:00
Ralf Jung 20d04d8a40 Revert "Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu"
This reverts commit 08dfbf49e3, reversing
changes made to 10bcdad7df.
2025-03-18 13:28:56 +01:00
Jacob Pratt 08dfbf49e3 Rollup merge of #136355 - GuillaumeGomez:proc-macro_add_value_retrieval_methods, r=Amanieu
Add `*_value` methods to proc_macro lib

This is the implementation of https://github.com/rust-lang/libs-team/issues/459.

It allows to get the actual value (unescaped) of the different string literals.

Part of https://github.com/rust-lang/rust/issues/136652.

r? libs-api
2025-03-17 05:47:48 -04:00
Guillaume Gomez ec4b3c2779 Add test for new proc_macro literal methods 2025-03-16 14:28:45 +01:00
Eric Huss 0b2489c226 Migrate proc_macro to Rust 2024 2025-03-11 09:46:34 -07:00
Thalia Archibald 988eb19970 library: Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-06 20:20:38 -08:00
Eric Huss 80a7eb1c09 proc_macro: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Guillaume Gomez b993f9c835 Add _value methods to proc_macro lib 2025-02-10 10:38:22 +01:00
Urgau bf5e634b68 proc_macro: add #![warn(unreachable_pub)] 2025-01-20 18:46:29 +01:00
ltdk e37daf0c86 Add inherent versions of MaybeUninit methods for slices 2025-01-11 23:57:00 -05:00
Jacob Pratt 34fa27b0bd Rollup merge of #134693 - SpriteOvO:proc-macro-use-to-tokens-in-quote, 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-10 03:55:19 -05:00
Asuna ef69c3001b Fix proc_macro::quote! for raw ident 2025-01-09 22:16:21 +01:00