about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/collect
AgeCommit message (Collapse)AuthorLines
2024-02-22`report_mismatch` did not actually report anymoreOli Scherer-5/+7
2024-02-22Avoid emitting type mismatches against `{type error}`Oli Scherer-18/+23
2024-02-21Prevent cycle in implied predicates computationMichael Goulet-8/+22
2024-02-21Use existing query feeding workaroundsOli Scherer-18/+0
2024-02-21Convert `delayed_bug`s to `bug`s.Nicholas Nethercote-6/+5
I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. The next commit will convert some more back, based on human judgment.
2024-02-18Propagate the resolved type of assoc const bindings via query feedingLeón Orell Valerian Liehr-29/+16
2024-02-18Auto merge of #120780 - fmease:lta-in-impls, r=oli-obkbors-1/+1
Properly deal with weak alias types as self types of impls Fixes #114216. Fixes #116100. Not super happy about the two ad hoc “normalization” implementations for weak alias types: 1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [#97974](https://github.com/rust-lang/rust/pull/97974) followed the same approach. 2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective. Both have ad hoc overflow detection mechanisms. **Coherence** is handled in #117164. r? `@oli-obk` or types [whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
2024-02-17Properly check constrainedness of gen params in the presence of weak alias typesLeón Orell Valerian Liehr-1/+1
2024-02-16Move trait into attr so it's greppableMichael Goulet-2/+2
2024-02-16Use extension trait deriveMichael Goulet-10/+2
2024-02-13Bump `indexmap`clubby789-1/+2
`swap` has been deprecated in favour of `swap_remove` - the behaviour is the same though.
2024-02-12Dejargnonize substShoyu Vanilla-2/+3
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-7/+6
2024-02-08Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgrbors-0/+2
Rollup of 9 pull requests Successful merges: - #119592 (resolve: Unload speculatively resolved crates before freezing cstore) - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation) - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - #120214 (match lowering: consistently lower bindings deepest-first) - #120688 (GVN: also turn moves into copies with projections) - #120702 (docs: also check the inline stmt during redundant link check) - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered") - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.) - #120739 (improve pretty printing for associated items in trait objects) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-08Rollup merge of #120206 - petrochenkov:somehir, r=compiler-errorsMatthias Krüger-0/+2
hir: Make sure all `HirId`s have corresponding HIR `Node`s And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
2024-02-08Already poison the `type_of` result of the anon const used in the `typeof` ↵Oli Scherer-2/+14
expression
2024-02-07Record coroutine kind in genericsMichael Goulet-3/+10
2024-02-07hir: Make sure all `HirId`s have corresponding HIR `Node`sVadim Petrochenkov-0/+2
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-1/+7
2024-02-06Make async closures directly lower to ClosureKind::CoroutineClosureMichael Goulet-0/+1
2024-02-03`Diagnostic` cleanupsNicholas Nethercote-1/+0
- `emitted_at` isn't used outside the crate. - `code` and `messages` are public fields, so there's no point have trivial getters/setters for them. - `suggestions` is public, so the comment about "functionality on `Diagnostic`" isn't needed.
2024-01-30hir: Remove `hir::Map::{owner,expect_owner}`Vadim Petrochenkov-1/+1
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-1/+1
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-23Rollup merge of #119766 - oli-obk:split_tait_and_atpit, r=compiler-errorsLeón Orell Valerian Liehr-7/+77
Split tait and impl trait in assoc items logic And simplify the assoc item logic where applicable. This separation shows that it is easier to reason about impl trait in assoc items compared with TAITs. See https://rust-lang.zulipchat.com/#narrow/stream/315482-t-compiler.2Fetc.2Fopaque-types/topic/impl.20trait.20in.20associated.20type for some discussion. The current plan is to try to stabilize impl trait in associated items before TAIT, as they do not have any issues with their defining scopes (see https://github.com/rust-lang/rust/issues/107645 for why this is not a trivial or uncontroversial topic).
2024-01-23Rename `TyCtxt::struct_span_lint_hir` as `TyCtxt::node_span_lint`.Nicholas Nethercote-2/+2
2024-01-22Use an enum instead of a boolOli Scherer-10/+17
2024-01-22Add a simpler and more targetted code path for impl trait in assoc itemsOli Scherer-7/+70
2024-01-18Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasperMatthias Krüger-3/+5
replace `track_errors` usages with bubbling up `ErrorGuaranteed` more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-17Stop using track_errors for some forever unstable rustc_attr analysesOli Scherer-3/+5
2024-01-16Don't ICE if TAIT-defining fn contains a closure with `_` in return typeLukas Markeffsky-12/+19
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-7/+8
2024-01-11Silence follow up errors if astconv already erroredOli Scherer-1/+5
2024-01-11Rollup merge of #119803 - oli-obk:even_more_follow_up_errors, r=compiler-errorsMatthias Krüger-12/+23
Silence some follow-up errors [1/x] this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449 When we use `-> impl SomeTrait<_>` as a return type, we are both using the "infer return type suggestion" code path, and the infer opaque type code path within the same function. That can lead to confusing diagnostics, so silence all opaque type diagnostics in that case.
2024-01-10Avoid follow up errorsOli Scherer-0/+15
2024-01-10Turn some free functions into methodsOli Scherer-5/+5
2024-01-10Use a ty::Error instead of patching up a type after erroringOli Scherer-7/+3
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-1/+1
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-7/+4
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-2/+2
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
2024-01-09Rollup merge of #119721 - compiler-errors:constness-implication, r=fee1-deadGuillaume Gomez-32/+6
`~const` trait and projection bounds do not imply their non-const counterparts This PR removes the hack where we install a non-const trait and projection bound for every `const_trait` and `~const` projection bound we have in the AST. It ends up messing up more things than it fixes, see words below. Fixes #119718 cc `@fmease` `@fee1-dead` `@oli-obk` r? fee1-dead or one of y'all i don't care --- My understanding is that this hack was added to support the following code: ```rust pub trait Owo<X = <Self as Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` Which is concretely lifted from in the `FromResidual` and `Try` traits. Since within the param-env of `trait Uwu`, we only know that `Self: ~const Uwu` and not `Self: Uwu`, the projection `<Self as Uwu>::T` is not satsifyable. This causes problems such as #119718, since instantiations of `FnDef` types coming from `const fn` really do **only** implement one of `FnOnce` or `const FnOnce`! --- In the long-term, I believe that such code should really look something more like: ```rust #[const_trait] pub trait Owo<X = <Self as ~const Uwu>::T> {} #[const_trait] pub trait Uwu: Owo {} ``` ... and that we should introduce some sort of `<T as ~const Foo>::Bar` bound syntax, since due to the fact that `~const` bounds can be present in item bounds, e.g. ```rust #[const_trait] trait Foo { type Bar: ~const Destruct; } ``` It's easy to see that `<T as Foo>::Bar` and `<T as ~const Foo>::Bar` (or `<T as const Foo>::Bar`) can be distinct types with distinct item bounds! **Admission**: I know I've said before that I don't like `~const` projection syntax, I do at this point believe they're necessary to fully express bounds and types in a maybe-const world.
2024-01-08~const trait or projection bounds do not imply non-const boundsMichael Goulet-32/+6
2024-01-08Use chaining for `DiagnosticBuilder` construction and `emit`.Nicholas Nethercote-4/+4
To avoid the use of a mutable local variable, and because it reads more nicely.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-1/+1
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2024-01-05Do not run check on foreign items.Camille GILLOT-1/+1
2024-01-05Handle ForeignItem as TAIT scope.Camille GILLOT-0/+7
2024-01-02Turn a bug!() into a span_delay_bug()León Orell Valerian Liehr-1/+4
No reason why this needs to be a `bug!()`.
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-6/+6
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Only regular coroutines have movabilityMichael Goulet-1/+1
2023-12-25Make closures carry their own ClosureKind, rather than deducing what it is ↵Michael Goulet-6/+6
from movability
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-21/+21
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.