Commit Graph

650 Commits

Author SHA1 Message Date
Mark Rousskov 67b0cfc761 Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
bors 921f669749 Auto merge of #113270 - the8472:opt-macro-tts, r=nnethercote
perform TokenStream replacement in-place when possible in expand_macro
2023-07-07 08:04:48 +00:00
Deadbeef 1c837cb6f7 Add effects during lowering for `~const` bounds 2023-07-04 11:47:45 +00:00
The 8472 7916a2c1c9 Use Lrc::make_mut instead of Lrc::get_mut 2023-07-03 13:40:25 +02:00
The 8472 14e57d7c13 perform TokenStream replacement in-place when possible in expand_macro 2023-07-03 13:29:15 +02:00
Maybe Waffle d7713feb99 Syntatically accept `become` expressions 2023-06-19 12:54:34 +00:00
Nilstrieb a647ba250a Remember names of `cfg`-ed out items to mention them in diagnostics
`#[cfg]`s are frequently used to gate crate content behind cargo
features. This can lead to very confusing errors when features are
missing. For example, `serde` doesn't have the `derive` feature by
default. Therefore, `serde::Serialize` fails to resolve with a generic
error, even though the macro is present in the docs.

This commit adds a list of all stripped item names to metadata. This is
filled during macro expansion and then, through a fed query, persisted
in metadata. The downstream resolver can then access the metadata to
look at possible candidates for mentioning in the errors.

This slightly increases metadata (800k->809k for the feature-heavy
windows crate), but not enough to really matter.
2023-06-01 19:17:19 +02:00
许杰友 Jieyou Xu (Joe) b9606589c4
Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00
bors a2b1646c59 Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelix
Support #[global_allocator] without the allocator shim

This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim.

Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist.

To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors.

(Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-25 16:59:57 +00:00
Maybe Waffle fb0f74a8c9 Use `Option::is_some_and` and `Result::is_ok_and` in the compiler 2023-05-24 14:20:41 +00:00
Caleb Cartwright 00c3f7552e refactor: add chunks method to TokenStream to obviate rustdoc clones 2023-05-13 16:59:28 -05:00
bors dd8ec9c88d Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillot
Introduce `DynSend` and `DynSync` auto trait for parallel compiler

part of parallel-rustc #101566

This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency.

r? `@cjgillot`
2023-05-13 13:47:53 +00:00
bjorn3 66982a383b Prevent insta-stable no alloc shim support
You will need to add the following as replacement for the old __rust_*
definitions when not using the alloc shim.

    #[no_mangle]
    static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-05-11 14:35:09 +00:00
bjorn3 6ba7c5db07 Split AllocatorKind::fn_name in global_fn_name and default_fn_name 2023-05-11 14:35:08 +00:00
bjorn3 4ce20663f7 Don't use an allocator shim for `#[global_allocator]`
This makes it possible to use liballoc/libstd in combination with
`--emit obj` if you use `#[global_allocator]`. Making it work for the
default libstd allocator would require weak functions, which are not
well supported on all systems.
2023-05-11 14:23:31 +00:00
Matthias Krüger 363d158cd8
Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillot
Various changes to name resolution of anon consts

Sorry this PR is kind of all over the place ^^'

Fixes #111012

- Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments)
- Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy`
- Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993
- Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters
- Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)`

I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands.

r? `@cjgillot` cc `@compiler-errors`
2023-05-09 20:49:32 +02:00
SparrowLii 089a38880b correct literals for dyn thread safe 2023-05-06 09:34:53 +08:00
SparrowLii b9746ce039 introduce `DynSend` and `DynSync` auto trait 2023-05-06 09:34:18 +08:00
Boxy 442617c046 misc nameres changes for anon consts 2023-05-05 21:31:35 +01:00
Dylan DPC 4891f02cff
Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors
Implement RFC 3348, `c"foo"` literals

RFC: https://github.com/rust-lang/rfcs/pull/3348
Tracking issue: #105723
2023-05-05 18:40:33 +05:30
Michael Goulet 6e01e910cb Implement negative bounds 2023-05-02 22:36:24 +00:00
Deadbeef abb181dfd9 make it semantic error 2023-05-02 10:32:08 +00:00
Deadbeef 78e3455d37 address comments 2023-05-02 10:32:07 +00:00
Deadbeef a49570fd20 fix TODO comments 2023-05-02 10:32:07 +00:00
Deadbeef 76d1f93896 update and add a few tests 2023-05-02 10:30:09 +00:00
Deadbeef 8ff3903643 initial step towards implementing C string literals 2023-05-02 10:30:09 +00:00
Nilstrieb c63b6a437e Rip it out
My type ascription
Oh rip it out
Ah
If you think we live too much then
You can sacrifice diagnostics
Don't mix your garbage
Into my syntax
So many weird hacks keep diagnostics alive
Yet I don't even step outside
So many bad diagnostics keep tyasc alive
Yet tyasc doesn't even bother to survive!
2023-05-01 16:15:13 +08:00
Matthias Krüger 1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
Matthias Krüger 29f5ec3640
Rollup merge of #110873 - clubby789:migrate-rustc-parse-trivial, r=compiler-errors
Migrate trivially translatable `rustc_parse` diagnostics

cc #100717

Migrate diagnostics in `rustc_parse` which are emitted in a single statement. I worked on this by expanding the lint introduced in #108760, although that isn't included here as there is much more work to be done to satisfy it
2023-04-28 07:34:02 +02:00
bors c14882f74e Auto merge of #107782 - Zoxc:worker-local, r=cjgillot
Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures

This PR moves the definition of the `WorkerLocal` type from `rustc-rayon` into `rustc_data_structures`. This is enabled by the introduction of the `Registry` type which allows you to group up threads to be used by `WorkerLocal` which is basically just an array with an per thread index. The `Registry` type mirrors the one in Rayon and each Rayon worker thread is also registered with the new `Registry`. Safety for `WorkerLocal` is ensured by having it keep a reference to the registry and checking on each access that we're still on the group of threads associated with the registry used to construct it.

Accessing a `WorkerLocal` is micro-optimized due to it being hot since it's used for most arena allocations.

Performance is slightly improved for the parallel compiler:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.9992s</td><td align="right">1.9949s</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2977s</td><td align="right">0.2970s</td><td align="right"> -0.22%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.1335s</td><td align="right">1.1315s</td><td align="right"> -0.18%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.8235s</td><td align="right">1.8171s</td><td align="right"> -0.35%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.9047s</td><td align="right">6.8930s</td><td align="right"> -0.17%</td></tr><tr><td>Total</td><td align="right">12.1586s</td><td align="right">12.1336s</td><td align="right"> -0.21%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9977s</td><td align="right"> -0.23%</td></tr></table>

cc `@SparrowLii`
2023-04-27 17:43:09 +00:00
Michael Goulet f0fc4f9acf Tweak await span 2023-04-27 17:18:11 +00:00
clubby789 1ce9d7254e Migrate trivially translatable `rustc_parse` diagnostics 2023-04-27 01:53:06 +01:00
DrMeepster 631ea7cc15 use P<[Ident]> instead of Vec<Ident> 2023-04-21 02:14:03 -07:00
DrMeepster 511e457c4b offset_of 2023-04-21 02:14:02 -07:00
bors 3a5c8e91f0 Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
Rm const traits in libcore

See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework)

* [x] Bless ui tests
* [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19 13:03:40 +00:00
Matthias Krüger 0790996a07
Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkin
Various minor Idx-related tweaks

Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.

cc https://github.com/rust-lang/compiler-team/issues/606
r? `@WaffleLapkin`
2023-04-17 18:13:35 +02:00
Matthias Krüger bcc15bba95 use matches! macro in more places 2023-04-16 12:08:30 +02:00
Scott McMurray c98895d9f2 Various minor Idx-related tweaks
Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
2023-04-16 02:42:50 -07:00
Deadbeef ede7bc032a make rustc compilable 2023-04-16 07:25:13 +00:00
John Kåre Alsaker efe7cf468f Remove WorkerLocal from AttrIdGenerator 2023-04-16 05:50:58 +02:00
Matthias Krüger a34bcd70b2
Rollup merge of #110203 - compiler-errors:rtn-dots, r=eholk
Remove `..` from return type notation

`@nikomatsakis` and I decided that using `..` in the return-type notation syntax is probably overkill.

r? `@eholk` since you reviewed the last one

Since this is piggybacking now totally off of a pre-existing syntax (parenthesized generics), let me know if you need any explanation of the logic here, since it's a bit more complicated now.
2023-04-12 20:56:22 +02:00
Michael Goulet 24cbf81b85 Remove `..` from return type notation 2023-04-10 22:19:46 +00:00
DaniPopes 677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
Oli Scherer 373807a95c Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem` 2023-04-04 15:34:40 +00:00
Oli Scherer 4bebdd7104 box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer ec74653652 Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer e3828777a6 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer b08a557f80 rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
bors 7402519c63 Auto merge of #109010 - compiler-errors:rtn, r=eholk
Initial support for return type notation (RTN)

See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/

1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter.
    * I'd add this in a follow-up.
3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~
    * I don't think we actually want this.
5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`.
    * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it.
7. ~I'm not in love with the feature gate name 😺~
    * I renamed it to `return_type_notation` ✔️

Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later.

r? `@ghost`
2023-03-31 18:04:12 +00:00
David Tolnay c5da0619d1
Fix mismatched punctuation in Debug impl of AttrId 2023-03-28 20:21:23 -07:00