about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2024-07-18More accurate span for type parameter suggestionEsteban Küber-3/+5
After: ``` error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:3:10 | LL | impl Foo<T: Default> for String {} | ^^^^^^^^^^ associated item constraint not allowed here | help: declare the type parameter right after the `impl` keyword | LL - impl Foo<T: Default> for String {} LL + impl<T: Default> Foo<T> for String {} | ``` Before: ``` error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:3:10 | LL | impl Foo<T: Default> for String {} | ^^^^^^^^^^ associated item constraint not allowed here | help: declare the type parameter right after the `impl` keyword | LL | impl<T: Default> Foo<T> for String {} | ++++++++++++ ~ ```
2024-07-17Fix associated item removal suggestionEsteban Küber-8/+6
We were previously telling people to write what was already there, instead of removal. ``` error[E0229]: associated item constraints are not allowed here --> $DIR/E0229.rs:13:25 | LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {} | ^^^^^^^ associated item constraint not allowed here | help: consider removing this associated item binding | LL - fn baz<I>(x: &<I as Foo<A = Bar>>::A) {} LL + fn baz<I>(x: &<I as Foo>::A) {} | ```
2024-07-17Account for self ty aliasMichael Goulet-6/+11
2024-07-17Mention that type parameters are used recursivelyMichael Goulet-21/+82
2024-07-17Add cross-crate precise capturing support to rustdocMichael Goulet-0/+21
2024-07-17Split part of `adt_const_params` into `unsized_const_params`Boxy-28/+52
2024-07-17Forbid `!Sized` types and referencesBoxy-12/+58
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-41/+74
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-07-16Use `ConstArg` for const param defaultsNoah Lev-4/+7
Now everything that actually affects the type system (i.e., excluding const blocks, enum variant discriminants, etc.) *should* be using `ConstArg`.
2024-07-16Use `ConstArg` for array lengthsNoah Lev-1/+1
2024-07-16Use `ConstArg` for assoc item constraintsNoah Lev-12/+21
2024-07-16Setup ty::Const functions for `ConstArg`Noah Lev-7/+4
2024-07-16hir: Create `hir::ConstArgKind` enumNoah Lev-8/+11
This will allow lowering const params to a dedicated enum variant, rather than to an `AnonConst` that is later examined during `ty` lowering.
2024-07-15Move rustc_infer::infer::error_reporting to rustc_infer::error_reporting::inferMichael Goulet-1/+1
2024-07-15make invalid_type_param_default lint show up in cargo future-compat reportsRalf Jung-2/+0
and remove the feature gate that silenced the lint
2024-07-14find_field does not need to be a query.Camille GILLOT-19/+0
2024-07-11Auto merge of #127575 - chenyukang:yukang-fix-struct-fields-ice, ↵bors-1/+4
r=compiler-errors Avoid "no field" error and ICE on recovered ADT variant Fixes https://github.com/rust-lang/rust/issues/126744 Fixes https://github.com/rust-lang/rust/issues/126344, a more general fix compared with https://github.com/rust-lang/rust/pull/127426 r? `@oli-obk` From `@compiler-errors` 's comment https://github.com/rust-lang/rust/pull/127502#discussion_r1669538204 Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
2024-07-11report pat no field error no recoverd struct variantyukang-1/+4
2024-07-10Rollup merge of #127094 - Borgerr:E0191-suggestion-correction, r=fmeaseMatthias Krüger-1/+13
E0191 suggestion correction, inserts turbofish closes #91997
2024-07-09E0191 suggestion correction, inserts turbofish without dyn (#91997)Ashton Hunt-1/+13
2024-07-09Auto merge of #127358 - oli-obk:taint_itemctxt, r=fmeasebors-182/+194
Automatically taint when reporting errors from ItemCtxt This isn't very robust yet, as you need to use `itemctxt.dcx()` instead of `tcx.dcx()` for it to take effect, but it's at least more convenient than sprinkling `set_tainted_by_errors` calls in individual places. based on https://github.com/rust-lang/rust/pull/127357 r? `@fmease`
2024-07-09Auto merge of #127493 - compiler-errors:crate-level-import, r=lcnrbors-13/+13
Move trait selection error reporting to its own top-level module This effectively moves `rustc_trait_selection::traits::error_reporting` to `rustc_trait_selection::error_reporting::traits`. There are only a couple of actual changes to the code, like moving the `pretty_impl_header` fn out of the specialization module for privacy reasons. This is quite pointless on its own, but having `error_reporting` as a top-level module in `rustc_trait_selection` is very important to make sure we have a meaningful file structure for when we move **type** error reporting (and region error reporting, with which it's incredibly entangled currently) into `rustc_trait_selection`. I've opened a tracking issue here: #127492 r? lcnr
2024-07-09Remove HirTyLowerer::set_tainted_by_errors, since it is now redundantOli Scherer-91/+96
2024-07-09Automatically taint when reporting errors from ItemCtxtOli Scherer-94/+101
2024-07-09Auto merge of #127200 - fee1-dead-contrib:trait_def_const_trait, ↵bors-12/+12
r=compiler-errors Add `constness` to `TraitDef` Second attempt at fixing the regression @ https://github.com/rust-lang/rust/pull/120639#issuecomment-2198373716 r? project-const-traits
2024-07-08Move trait selection error reporting to its own top-level moduleMichael Goulet-13/+13
2024-07-08Remove `structured_errors` moduleOli Scherer-5/+2
2024-07-08Remove `StructuredDiag`Oli Scherer-78/+43
2024-07-08Remove another `StructuredDiag` implOli Scherer-77/+1
2024-07-08Rollup merge of #127452 - fee1-dead-contrib:fx-intrinsic-counting, r=fmease许杰友 Jieyou Xu (Joe)-6/+12
Fix intrinsic const parameter counting with `effects` r? project-const-traits
2024-07-08Rollup merge of #127439 - compiler-errors:uplift-elaborate, r=lcnr许杰友 Jieyou Xu (Joe)-12/+11
Uplift elaboration into `rustc_type_ir` Allows us to deduplicate and consolidate elaboration (including these stupid elaboration duplicate fns i added for pretty printing like 3 years ago) so I'm pretty hyped about this change :3 r? lcnr
2024-07-08Rollup merge of #127437 - compiler-errors:uplift-trait-ref-is-knowable, r=lcnr许杰友 Jieyou Xu (Joe)-8/+10
Uplift trait ref is knowable into `rustc_next_trait_solver` Self-explanatory. Eliminates one more delegate method. r? lcnr cc ``@fmease``
2024-07-07Auto merge of #127172 - compiler-errors:full-can_eq-everywhere, r=lcnrbors-49/+44
Make `can_eq` process obligations (almost) everywhere Move `can_eq` to an extension trait on `InferCtxt` in `rustc_trait_selection`, and change it so that it processes obligations. This should strengthen it to be more accurate in some cases, but is most important for the new trait solver which delays relating aliases to `AliasRelate` goals. Without this, we always basically just return true when passing aliases to `can_eq`, which can lead to weird errors, for example #127149. I'm not actually certain if we should *have* `can_eq` be called on the good path. In cases where we need `can_eq`, we probably should just be using a regular probe. Fixes #127149 r? lcnr
2024-07-07Uplift trait_ref_is_knowable and friendsMichael Goulet-8/+8
2024-07-07Add fundamental to trait defMichael Goulet-0/+2
2024-07-07Fix intrinsic const parameter counting with `effects`Deadbeef-6/+12
2024-07-07iter_identity is a better nameMichael Goulet-12/+11
2024-07-06Import via rustc_type_ir::outlivesMichael Goulet-1/+1
We could use rustc_middle::ty::outlives I guess?
2024-07-05Rollup merge of #127392 - estebank:arg-type, r=jieyouxuJubilee-3/+3
Use verbose suggestion for changing arg type
2024-07-05Use verbose suggestion for changing arg typeEsteban Küber-3/+3
2024-07-05Rework receiver_is_validMichael Goulet-50/+42
2024-07-05Actually just make can_eq process obligations (almost) everywhereMichael Goulet-9/+4
2024-07-05Process alias-relate obligations when proving receiver_is_validMichael Goulet-1/+9
2024-07-05Use `ControlFlow` results for visitors that are only looking for a single valueOli Scherer-42/+32
2024-07-04Rollup merge of #127319 - oli-obk:fail2taint, r=compiler-errorsMatthias Krüger-71/+1
Remove a use of `StructuredDiag`, which is incompatible with automatic error tainting and error translations fixes #127219 I want to remove all of `StructuredDiag`, but it's a bit more involved as it is also used from the `ItemCtxt`, which doesn't support tainting yet.
2024-07-04Remove a use of `StructuredDiag`, which is incompatible with automatic error ↵Oli Scherer-71/+1
tainting and error translations
2024-07-04Better suggestion span for missing type parameterEsteban Küber-4/+3
2024-07-03Add `constness` to `TraitDef`Deadbeef-12/+12
2024-07-02Rewrite dropckBoxy-9/+25
2024-07-01Rollup merge of #127181 - BoxyUwU:dump_def_parents, r=compiler-errorsMatthias Krüger-1/+50
Introduce a `rustc_` attribute to dump all the `DefId` parents of a `DefId` We've run into a bunch of issues with anon consts having the wrong generics and it would have been incredibly helpful to be able to quickly slap a `rustc_` attribute to check what `tcx.parent(` will return on the relevant DefIds. I wasn't sure of a better way to make this work for anon consts than requiring the attribute to be on the enclosing item and then walking the inside of it to look for any anon consts. This particular method will honestly break at some point when we stop having a `DefId` available for anon consts in hir but that's for another day... r? ``@compiler-errors``