summary refs log tree commit diff
path: root/compiler/rustc_hir/src
AgeCommit message (Collapse)AuthorLines
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-4/+8
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-16/+15
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-15Rollup merge of #119004 - matthiaskrgr:conv, r=compiler-errorsJubilee-6/+4
NFC don't convert types to identical types
2023-12-15NFC don't convert types to identical typesMatthias Krüger-6/+4
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-7/+36
Collect lang items from AST, get rid of `GenericBound::LangItemTrait` r? `@cjgillot` cc #115178 Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change: 1. A lot of `rustc_ast_lowering` for things like expr `..` 2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently. 3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem` Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15Fix enforcement of generics for associated itemsMichael Goulet-0/+36
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-7/+0
2023-12-15Annotate some bugsMichael Goulet-1/+1
2023-12-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-17/+18
Introduce support for `async gen` blocks I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`. **This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078). ### Technical note on the pre-generator-transform yield type: The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant). This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden. r? `@ghost`
2023-12-08Support async gen fnMichael Goulet-5/+0
2023-12-08Implement `async gen` blocksMichael Goulet-12/+18
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-0/+17
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-06Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errorsbors-1/+2
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-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-1/+2
2023-12-04Lower return types for gen fn to impl IteratorEric Holk-0/+2
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-9/+46
`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-03Disallow an arm without a body (except for never patterns)Nadrieril-0/+17
Parsing now accepts a match arm without a body, so we must make sure to only accept that if the pattern is a never pattern.
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-3/+6
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-29Add `never_patterns` feature gateNadrieril-3/+6
2023-11-28Remove `hir::BinOp`, `hir::BinOpKind`, and `hir::UnOp`.Nicholas Nethercote-151/+2
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-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-5/+1
2023-11-25Remove HirId from QPath::LangItemMichael Goulet-4/+4
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Replace `custom_encodable` with `encodable`.Nicholas Nethercote-0/+1
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
2023-11-21Use macros to avoid `expect_*` boilerplate.Nicholas Nethercote-369/+102
The majority of these aren't actually used, but I kept them anyway.
2023-11-21Remove some unused functions.Nicholas Nethercote-54/+4
And remove `pub` from some local-only ones.
2023-11-21Wrap a long line.Nicholas Nethercote-1/+1
2023-11-20Remove unused feature.Nicholas Nethercote-1/+0
2023-11-20Put derives on a single line where possible.Nicholas Nethercote-26/+13
2023-11-20Add a comment.Nicholas Nethercote-0/+2
2023-11-20Remove unused arena kinds in `rustc_hir` and `rustc_middle`.Nicholas Nethercote-1/+0
2023-11-06Add suggestion to THIR unsafe_op_in_unsafe_fn lintMatthew Jasper-0/+9
2023-11-02Replace two `create_default_session_if_not_set_then` uses.Nicholas Nethercote-2/+2
With `create_default_session_globals_then`, which is preferable when it is appropriate.
2023-10-30Some more coroutine renamingsMichael Goulet-2/+2
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-0/+12
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-26Auto merge of #117171 - fee1-dead-contrib:deny-explicit-effect-params, r=oli-obkbors-1/+10
Deny providing explicit effect params r? `@oli-obk` cc https://github.com/rust-lang/rust/issues/110395
2023-10-26Deny providing explicit effect paramsDeadbeef-1/+10
2023-10-26Add hir::GeneratorKind::GenOli Scherer-0/+12
2023-10-25Rollup merge of #117175 - oli-obk:gen_fn_split, r=compiler-errorsMatthias Krüger-31/+20
Rename AsyncCoroutineKind to CoroutineSource pulled out of https://github.com/rust-lang/rust/pull/116447 Also refactors the printing infra of `CoroutineSource` to be ready for easily extending it with a `Gen` variant for `gen` blocks
2023-10-25Refactor away the need for some `descr` methods.Oli Scherer-23/+12
Instead we use `Display` impls and their `alternate` render scheme to decide whether we want backticks or not.
2023-10-25Rename in preparation for moving the `async` printing out of `CoroutineSource`Oli Scherer-1/+1
2023-10-25Make `Iterator` a lang itemOli Scherer-0/+1
2023-10-25Rename `AsyncCoroutineKind` to `CoroutineSource`Oli Scherer-15/+15
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-23Factor signature type walking out of opaque_types_defined_byOli Scherer-0/+1
2023-10-20Rename `CoroutineKind::Gen` to `::Coroutine`Oli Scherer-4/+4
2023-10-20s/generator/coroutine/Oli Scherer-18/+18
2023-10-20s/Generator/Coroutine/Oli Scherer-30/+30
2023-10-01Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrumbors-1/+0
Partially outline code inside the panic! macro This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-09-26Don't store lazyness in DefKindMichael Goulet-7/+5
2023-09-21Record asyncness span in HIRMichael Goulet-9/+9