about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-35/+18
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-22Rollup merge of #119215 - mu001999:fix/119209, r=NilstriebMatthias Krüger-1/+4
Emits error if has bound regions Fixes #119209
2023-12-22Emits error if has bound regionsr0cky-1/+4
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-9/+7
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-20Rollup merge of #119145 - aDotInTheVoid:variantdata-struct-struct, ↵Matthias Krüger-2/+2
r=compiler-errors Give `VariantData::Struct` named fields, to clairfy `recovered`. Implements https://github.com/rust-lang/rust/pull/119121#discussion_r1431467066. Supersedes #119121 This way, it's clear what the bool fields means, instead of having to find where it's generated. Changes both ast and hir. r? `@compiler-errors`
2023-12-20Rollup merge of #119089 - fmease:dont-ice-on-tilde-const-non-const-trait, ↵Matthias Krüger-1/+1
r=fee1-dead effects: fix a comment r? fee1-dead or compiler
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-2/+2
2023-12-19effects: fix commentLeón Orell Valerian Liehr-1/+1
2023-12-19Auto merge of #119047 - mu001999:fix/118772, r=wesleywiserbors-50/+52
Check generic params after sigature for main-fn-ty Fixes #118772
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-9/+7
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Check generic params after sigature for main-fn-tyr0cky-50/+52
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-2/+2
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-12/+7
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-2/+2
2023-12-17skip rpit constraint check if borrowck return type errorbohan-0/+4
2023-12-15Rollup merge of #119004 - matthiaskrgr:conv, r=compiler-errorsJubilee-1/+1
NFC don't convert types to identical types
2023-12-16Make IMPLIED_BOUNDS_ENTAILMENT into a hard error from a lintMichael Goulet-189/+12
2023-12-15NFC don't convert types to identical typesMatthias Krüger-1/+1
2023-12-15Rollup merge of #118727 - compiler-errors:lint-decorate, r=WaffleLapkinJubilee-13/+8
Don't pass lint back out of lint decorator Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved. r? nnethercote though feel free to reassign
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-147/+35
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-15Simplify instantiate_poly_trait_refMichael Goulet-75/+35
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-73/+1
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-13/+8
2023-12-15Annotate some more bugsMichael Goulet-9/+0
2023-12-15Annotate some bugsMichael Goulet-122/+185
2023-12-14update use of feature flagslcnr-2/+2
2023-12-13Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkovbors-52/+48
Move some methods from `tcx.hir()` to `tcx` https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834 Renamed: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id
2023-12-12Rollup merge of #118885 - matthiaskrgr:compl_2023, r=compiler-errorsJubilee-7/+4
clippy::complexity fixes filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-12clippy::complexity fixesMatthias Krüger-7/+4
filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-52/+48
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-12review + rename fnlcnr-2/+2
2023-12-10remove redundant importssurechen-8/+4
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09Add simd_masked_{load,store} platform-intrinsicsJakub Okoński-0/+2
This maps to the LLVM intrinsics: llvm.masked.load and llvm.masked.store
2023-12-08Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, ↵bors-326/+377
r=compiler-errors Resolve associated item bindings by namespace This is the 3rd commit split off from #118360 with tests reblessed (they no longer contain duplicated diags which were caused by 4c0addc80af4666f26d7ad51fe34a0e2dd0b8b74) & slightly adapted (removed supertraits from a UI test, cc #118040). > * Resolve all assoc item bindings (type, const, fn (feature `return_type_notation`)) by namespace instead of trying to resolve a type first (in the non-RTN case) and falling back to consts afterwards. This is consistent with RTN. E.g., for `Tr<K = {…}>` we now always try to look up assoc consts (this extends to supertrait bounds). This gets rid of assoc tys shadowing assoc consts in assoc item bindings which is undesirable & inconsistent (types and consts live in different namespaces after all) > * Consolidate the resolution of assoc {ty, const} bindings and RTN (dedup, better diags for RTN) > * Fix assoc consts being labeled as assoc *types* in several diagnostics > * Make a bunch of diagnostics translatable Fixes #112560 (error → pass). As discussed r? `@compiler-errors` --- **Addendum**: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.
2023-12-07Resolve assoc item bindings by namespaceLeón Orell Valerian Liehr-326/+377
If a const is expected, resolve a const. If a type is expected, resolve a type. Don't try to resolve a type first falling back to consts.
2023-12-06Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errorsbors-12/+10
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-06Auto merge of #117661 - TheLazyDutchman:point_out_shadowed_associated_types, ↵bors-4/+58
r=petrochenkov Added shadowed hint for overlapping associated types Previously, when you tried to set an associated type that is shadowed by an associated type in a subtrait, like this: ```rust trait A { type X; } trait B: A { type X; // note: this is legal } impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { fn clone(&self) -> Self { todo!() } } you got a confusing error message, that says nothing about the shadowing: error[E0719]: the value of the associated type `X` (from trait `B`) is already specified --> test.rs:9:34 | 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | --- ^^^ re-bound here | | | `X` bound here first error[E0191]: the value of the associated type `X` (from trait `A`) must be specified --> test.rs:9:27 | 2 | type X; | ------ `X` defined here ... 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | ^^^^^^^^^^^ help: specify the associated type: `B<X=Y, X=Y, X = Type>` error: aborting due to 2 previous errors Some errors have detailed explanations: E0191, E0719. For more information about an error, try `rustc --explain E0191`. ``` Now instead, the error shows that the associated type is shadowed, and suggests renaming as a potential fix. ```rust error[E0719]: the value of the associated type `X` in trait `B` is already specified --> test.rs:9:34 | 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | --- ^^^ re-bound here | | | `X` bound here first error[E0191]: the value of the associated type `X` in `A` must be specified --> test.rs:9:27 | 2 | type X; | ------ `A::X` defined here ... 6 | type X; // note: this is legal | ------ `A::X` shadowed here ... 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | ^^^^^^^^^^^ associated type `X` must be specified | help: consider renaming this associated type --> test.rs:2:5 | 2 | type X; | ^^^^^^ help: consider renaming this associated type --> test.rs:6:5 | 6 | type X; // note: this is legal | ^^^^^^ ``` error: aborting due to 2 previous errors Some errors have detailed explanations: E0191, E0719. For more information about an error, try `rustc --explain E0191`. The rename help message is only emitted when the trait is local. This is true both for the supertrait as for the subtrait. There might be cases where you can use the fully qualified path (for instance, in a where clause), but this PR currently does not deal with that. fixes #100109 (continues from #117642, because I didn't know renaming the branch would close the PR)
2023-12-06Point out shadowed associated typesTheLazyDutchman-4/+58
Shadowing the associated type of a supertrait is allowed. This however makes it impossible to set the associated type of the supertrait in a dyn object. This PR makes the error message for that case clearer, like adding a note that shadowing is happening, as well as suggesting renaming of one of the associated types. r=petrochenckov
2023-12-05Rollup merge of #118268 - compiler-errors:pretty-print, r=estebankMichael Goulet-8/+6
Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always It's almost always better, at least in diagnostics, to print `Fn(i32, u32)` instead of `Fn<(i32, u32)>`. Related to but doesn't fix #118225. That needs a separate fix.
2023-12-05Add moreMichael Goulet-4/+4
2023-12-05Add print_trait_sugaredMichael Goulet-4/+2
2023-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-12/+10
2023-12-04Use default params until effects in desugaringDeadbeef-0/+25
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-40/+46
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-0/+1
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-0/+1
2023-11-27Auto merge of #118118 - spastorino:do-not-erase-late-bound-regions-on-iat, ↵bors-115/+92
r=compiler-errors Do not erase late bound regions when selecting inherent associated types In the fix for #97156 we would want the following code: ```rust #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct Foo<T>(T); impl Foo<fn(&'static ())> { type Assoc = u32; } trait Other {} impl Other for u32 {} // FIXME(inherent_associated_types): Avoid emitting two diagnostics (they only differ in span). // FIXME(inherent_associated_types): Enhancement: Spruce up the diagnostic by saying something like // "implementation is not general enough" as is done for traits via // `try_report_trait_placeholder_mismatch`. fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} //~^ ERROR mismatched types //~| ERROR mismatched types fn main() {} ``` to fail with ... ``` error[E0220]: associated type `Assoc` not found for `Foo<for<'a> fn(&'a ())>` in the current scope --> tests/ui/associated-inherent-types/issue-109789.rs:18:36 | 4 | struct Foo<T>(T); | ------------- associated item `Assoc` not found for this struct ... 18 | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {} | ^^^^^ associated item not found in `Foo<for<'a> fn(&'a ())>` | = note: the associated type was found for - `Foo<fn(&'static ())>` error: aborting due to previous error For more information about this error, try `rustc --explain E0220`. ``` This PR fixes the ICE we are currently getting "was a subtype of Foo<Binder(fn(&ReStatic ()), [])> during selection but now it is not" Also fixes #112631 r? `@lcnr`
2023-11-26Rollup merge of #118311 - bvanjoi:merge_coroutinue_into_closure, r=petrochenkovGuillaume Gomez-2/+2
merge `DefKind::Coroutine` into `Defkind::Closure` Related to #118188 We no longer need to be concerned about the precise type whether it's `DefKind::Closure` or `DefKind::Coroutine`. Furthermore, thanks for the great work done by `@petrochenkov` on investigating https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Why.20does.20it.20hang.20when.20querying.20.EF.BB.BF.60opt_def_kind.60.3F r? `@petrochenkov`
2023-11-26merge `DefKind::Coroutine` into `DefKind::Closure`bohan-2/+2
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-41/+39
cleanup