Commit Graph

1044 Commits

Author SHA1 Message Date
Michael Goulet
44911b7c67 Make some matches exhaustive to avoid bugs, fix tools 2023-12-08 17:23:26 +00:00
Michael Goulet
a208bae00e Support async gen fn 2023-12-08 17:23:26 +00:00
Michael Goulet
2806c2df7b coro_kind -> coroutine_kind 2023-12-08 17:23:25 +00:00
Michael Goulet
96bb542a31 Implement async gen blocks 2023-12-08 17:23:25 +00:00
bors
f32d29837d Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errors
Remove `#[rustc_host]`, use internal desugaring

Also removed a way for users to explicitly specify the host param since that isn't particularly useful. This should eliminate any pain with encoding attributes across crates and etc.

r? `@compiler-errors`
2023-12-06 16:00:24 +00:00
Deadbeef
65212a07e7 Remove #[rustc_host], use internal desugaring 2023-12-05 01:15:21 +00:00
Eric Holk
50ef8006eb
Address code review feedback 2023-12-04 14:33:46 -08:00
Eric Holk
26f9954971
Fix some broken tests 2023-12-04 13:03:41 -08:00
Eric Holk
f9d1f922dc
Option<CoroutineKind> 2023-12-04 13:03:37 -08:00
Eric Holk
48d5f1f0f2
Merge Async and Gen into CoroutineKind 2023-12-04 12:48:01 -08:00
Eric Holk
c104f3b629
Lower return types for gen fn to impl Iterator 2023-12-04 11:23:05 -08:00
Vadim Petrochenkov
17e799c270 rustc: Harmonize DefKind and DefPathData
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`.

`DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`.
It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change.

Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values.

`DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-03 16:24:56 +03:00
Mark Rousskov
5980a17c52 Avoid per-register closure expansions 2023-12-02 15:31:18 -05:00
bors
4e3dc976e7 Auto merge of #117912 - GeorgeWort:master, r=petrochenkov
Name explicit registers in conflict register errors for inline assembly
2023-12-02 13:38:47 +00:00
Nicholas Nethercote
61f93563d8 Inline and remove LoweringContext::handler().
It has a single call site.
2023-12-02 09:01:35 +11:00
Nicholas Nethercote
5d1d384443 Rename HandlerInner::delay_span_bug as HandlerInner::span_delayed_bug.
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug`
follows the pattern used everywhere else: `span_err`, `span_warning`,
etc.
2023-12-02 09:01:19 +11:00
Matthias Krüger
c03f8917ee
Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
bors
ec1f21cb04 Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116839 (Implement thread parking for xous)
 - #118265 (remove the memcpy-on-equal-ptrs assumption)
 - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`)
 - #118394 (Remove HIR opkinds)
 - #118398 (Add proper cfgs in std)
 - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context)
 - #118422 (Fix coroutine validation for mixed panic strategy)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-29 08:51:01 +00:00
Matthias Krüger
82eda5865a
Rollup merge of #118401 - nnethercote:rustc_ast_lowering, r=compiler-errors
`rustc_ast_lowering` cleanups

Just some cleanups I found while looking through this code.

r? `@spastorino`
2023-11-29 04:23:29 +01:00
Matthias Krüger
8cfdccf7c8
Rollup merge of #118419 - compiler-errors:await-span2, r=cjgillot
Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context

This PR does 2 things:
1. Refuses to lower `.await` or `yield` when we are outside of the right coroutine context for the operator. Instead, we lower to `hir::ExprKind::Err`, to silence subsequent redundant errors.
2. Reworks a bit of the span tracking in `LoweringContext` to fix a bad span when we have something like `let x = [0; async_fn().await]` where the `await` is inside of an anon const. The span for the "item" still kinda sucks, since it overlaps with the `await` span, but at least it's accurate.
2023-11-29 04:23:24 +01:00
Matthias Krüger
20473eba0b
Rollup merge of #118394 - nnethercote:rm-hir-Ops, r=cjgillot
Remove HIR opkinds

`hir::BinOp`, `hir::BinOpKind`, and `hir::UnOp` are identical to `ast::BinOp`, `ast::BinOpKind`, and `ast::UnOp`, respectively. This seems silly, so this PR removes the HIR ones. (A re-export lets the AST ones be referred to using a `hir::` qualifier, which avoids renaming churn.)

r? `@cjgillot`
2023-11-29 04:23:23 +01:00
Nadrieril
a3838c8550 Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
Michael Goulet
f2c500bb43 Fix spans for bad await in inline const 2023-11-28 19:29:56 +00:00
Michael Goulet
a76d2e1fd1 Eagerly return ExprKind::Err on yield/await in wrong coroutine context 2023-11-28 19:29:56 +00:00
Vadim Petrochenkov
f0dc906319 resolve: Feed the def_kind query immediately on DefId creation 2023-11-28 15:39:31 +03:00
George Wort
e0bfb615da Name explicit registers in conflict register errors for inline assembly 2023-11-28 10:37:19 +00:00
Nicholas Nethercote
5c680e1bcb Remove unnecessary Option from LoweringContext::allow_{try_trait,gen_future}.
Also remove some unnecessary slicing.
2023-11-28 14:32:40 +11:00
Nicholas Nethercote
3bae9276fa Add LoweringContext::new. 2023-11-28 14:32:40 +11:00
Nicholas Nethercote
ed2868eb9d Create LoweringContext::lower_assoc_item.
By moving most of `ItemLowerer::lower_assoc_item` into it. This is
similar to `LoweringContext::lower_foreign_item`.
2023-11-28 14:32:40 +11:00
Nicholas Nethercote
dbaa78621a Reduce exposure of some things. 2023-11-28 14:32:40 +11:00
Nicholas Nethercote
3570468ce7 Remove unused feature. 2023-11-28 14:32:40 +11:00
Nicholas Nethercote
d9fef774e3 Remove hir::BinOp, hir::BinOpKind, and hir::UnOp.
They're identical to the same-named types from `ast`. I find it silly
(and inefficient) to have all this boilerplate code to convert one type
to an identical type.

There is already a small amount of type sharing between the AST and HIR,
e.g. `Attribute`, `MacroDef`.

The commit adds a `pub use` to `rustc_hir` so that, for example,
`ast::BinOp` can also be referred to as `hir::BinOp`. This is so the
many existing `hir`-qualified mentions of these types don't need to
change.

The commit also moves a couple of operations from the (removed) HIR
types to the AST types, e.g. `is_by_value`.
2023-11-28 12:14:25 +11:00
bohan
f23befe6c1 merge DefKind::Coroutine into DefKind::Closure 2023-11-26 21:05:08 +08:00
Michael Goulet
3b2f33ee28
Rollup merge of #118158 - nnethercote:reduce-fluent-boilerplate, r=compiler-errors
Reduce fluent boilerplate

Best reviewed one commit at a time.

r? `@davidtwco`
2023-11-25 17:23:33 -05:00
Nicholas Nethercote
57cd5e6551 Use rustc_fluent_macro::fluent_messages! directly.
Currently we always do this:
```
use rustc_fluent_macro::fluent_messages;
...
fluent_messages! { "./example.ftl" }
```
But there is no need, we can just do this everywhere:
```
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
```
which is shorter.
2023-11-26 08:38:40 +11:00
Nicholas Nethercote
a733082be9 Avoid need for {D,Subd}iagnosticMessage imports.
The `fluent_messages!` macro produces uses of
`crate::{D,Subd}iagnosticMessage`, which means that every crate using
the macro must have this import:
```
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
```

This commit changes the macro to instead use
`rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the
imports.
2023-11-26 08:38:00 +11:00
Michael Goulet
fa7633dda1 Remove HirId from QPath::LangItem 2023-11-25 18:02:11 +00:00
Deadbeef
16040a1628 Add Span to TraitBoundModifier 2023-11-24 14:32:05 +00:00
Nilstrieb
21a870515b Fix clippy::needless_borrow in the compiler
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`.

Then I had to remove a few unnecessary parens and muts that were exposed
now.
2023-11-21 20:13:40 +01:00
Matthias Krüger
aa2289d3bc
Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber
Use `copied` instead of manual `map`
2023-11-17 23:04:22 +01:00
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
Takayuki Maeda
cf21b6ef28
Rollup merge of #117858 - compiler-errors:span, r=lcnr
Compute layout with spans for better cycle errors in coroutines

Split out from #117703, this PR at least gives us a nicer span to point at when we hit a cycle error in coroutine layout cycles.
2023-11-14 00:54:16 +09:00
Michael Goulet
7994b5849c Compute layout with spans for better cycle errors in coroutines 2023-11-13 02:22:25 +00:00
Nicholas Nethercote
2e40d11f8c Remove -Zkeep-hygiene-data.
It was added way back in #28585 under the name `-Zkeep-mtwt-tables`. The
justification was:

> This is so that the resolution results can be used after analysis,
> potentially for tool support.

There are no uses of significance in the code base, and various Google
searches for both option names (and variants) found nothing of interest.

@petrochenkov says removing this part (and it's only part) of the
hygiene data is dubious. It doesn't seem that big, so let's just keep it
around.
2023-11-10 14:00:08 +11:00
Dinu Blanovschi
241a654c07 Fix remaining uses of CaptureBy::Value 2023-11-04 19:48:44 +01:00
DaniPopes
27364309a5
compiler: use copied instead of manual map 2023-11-03 17:18:56 +01:00
Nicholas Nethercote
f405ce86c2 Minimize pub usage in source_map.rs.
Most notably, this commit changes the `pub use crate::*;` in that file
to `use crate::*;`. This requires a lot of `use` items in other crates
to be adjusted, because everything defined within `rustc_span::*` was
also available via `rustc_span::source_map::*`, which is bizarre.

The commit also removes `SourceMap::span_to_relative_line_string`, which
is unused.
2023-11-02 19:35:00 +11:00
Michael Goulet
add09e66f2 Some more coroutine renamings 2023-10-30 23:46:27 +00:00
Guillaume Gomez
824e3677c2
Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiser
Clean up `compiler/rustc*/Cargo.toml`

Mostly by sorting dependencies, plus some other minor things.

r? ``@wesleywiser``
2023-10-30 17:33:15 +01:00
León Orell Valerian Liehr
2915707622
Rollup merge of #117147 - DaniPopes:pphir-fn-variadic, r=compiler-errors
Print variadic argument pattern in HIR pretty printer

Variadic argument name/pattern was ignored during HIR pretty printing.
Could not figure out why it only works on normal functions (`va2`) and not in foreign ones (`va1`).
2023-10-30 10:48:17 +01:00