| Age | Commit message (Collapse) | Author | Lines |
|
A small amount of tidying-up factored out from PR #64648
As requested by @Mark-Simulacrum, I put this in a separate commit to make it easier to review. (As far as I can tell, no violations of the policy here, and they are simply in a separate PR because they're not directly related to the import of that PR.)
r? @Mark-Simulacrum
|
|
|
|
|
|
r=michaelwoerister
No StableHasherResult everywhere
This removes the generic parameter on `StableHasher`, instead moving it to the call to `finish`. This has the side-effect of making all `HashStable` impls nicer, since we no longer need the verbose `<W: StableHasherResult>` that previously existed -- often forcing line wrapping.
This is done for two reasons:
* we should avoid false "generic" dependency on the result of StableHasher
* we don't need to codegen two/three copies of all the HashStable impls when they're transitively used to produce a fingerprint, u64, or u128. I haven't measured, but this might actually make our artifacts somewhat smaller too.
* Easier to understand/read/write code -- the result of the stable hasher is irrelevant when writing a hash impl.
|
|
|
|
|
|
this is necessary for never-type stabilization
|
|
Print out more information for `-Zunpretty=expanded,hygiene`
I've found this helpful when trying to understand how hygiene works.
Closes #16420
|
|
|
|
resolve: Tweak some "cannot find" wording for macros
|
|
|
|
|
|
|
|
Use it for feature-gating `#[bench]`
|
|
Use hygiene for AST passes
AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`.
* Add an ExpnKind for AST passes.
* Remove gensyms in AST passes.
* Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`.
* Allow opaque macros to define tests.
* Move tests for unit tests to their own directory.
* Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists.
cc #60869, #61019
r? @petrochenkov
|
|
Use these to create call-site spans for AST passes when needed.
|
|
`gensym_if_underscore` still exists. The symbol interner can still
create arbitray gensyms, this is just not exposed publicly.
|
|
|
|
|
|
And remove the `unsafe` blocks, they're not necessary.
Also rewrite `InternedString::{with,with2}` to use the new functions.
Finally, add some comments about the speed of the
`as_str()`/`as_interned_str()` functions.
|
|
|
|
|
|
|
|
It has a single use, which is easily changed to something better.
|
|
It's unused.
|
|
This allows lints and other diagnostics to refer to items
by a unique ID instead of relying on whacky path
resolution schemes that may break when items are
relocated.
|
|
Recover `mut $pat` and other improvements
- Recover on e.g. `mut Foo(x, y)` and suggest `Foo(mut x, mut y)`. Fixes https://github.com/rust-lang/rust/issues/63764.
- Recover on e.g. `let mut mut x;`
- Recover on e.g. `let keyword` and `let keyword(...)`.
- Cleanups in `token.rs` with `fn is_non_raw_ident_where` and friends.
|
|
Add tests for -Zast-json and -Zast-json-noexpand, which need this impl.
|
|
|
|
All transparancies are passed explicitly now.
Also remove `#[rustc_macro_transparency]` annotations from built-in macros, they are no longer used.
`#[rustc_macro_transparency]` only makes sense for declarative macros now.
|
|
|
|
Using `ExpnId`s default transparency here instead of the mark's real transparency was actually incorrect.
|
|
|
|
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API.
The new API is much less error prone and doesn't rely on macros having default transparency.
|
|
Normalize newlines when loading files
Fixes #62865
|
|
Initial implementation of or-patterns
An incomplete implementation of or-patterns (e.g. `Some(0 | 1)` as a pattern). This patch set aims to implement initial parsing of `or-patterns`.
Related to: #54883
CC @alexreg @varkor
r? @Centril
|
|
Initial implementation of parsing or-patterns e.g., `Some(Foo | Bar)`.
This is a partial implementation of RFC 2535.
|
|
The implementations were wrong and unused.
|
|
Most `Ident`s are serialized as `InternedString`s the exceptions are:
* Reexports
* Attributes
* Idents in macro definitions
Using gensyms helped reexports emulate hygiene. However, the actual item
wouldn't have a gensymmed name so would be usable cross-crate. So
removing this case until we have proper cross-crate hygiene seems
sensible.
Codegen attributes (`inline`, `export_name`) are resolved by their
`Symbol`. This meant that opaque macro-expanded codegen attributes could
cause linker errors. This prevented making built-in derives hygienic.
|
|
Hygienize use of built-in macros in the standard library
Same as https://github.com/rust-lang/rust/pull/61629, but for built-in macros.
Closes https://github.com/rust-lang/rust/issues/48781
r? @alexcrichton
|
|
|
|
For naming consistency with everything else in this area
|
|
|
|
It was introduced to avoid going through `hygiene_data`, but now it's read only once, when `ParseSess` is created, so going through a lock is ok.
|
|
|
|
The expansion info is not optional and should always exist
|
|
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
|
|
For consistency with `ExpnId::root`.
Also introduce a helper `Span::with_root_ctxt` for creating spans with `SyntaxContext::root()` context
|
|
|
|
|