about summary refs log tree commit diff
path: root/tests/ui/error-codes
AgeCommit message (Collapse)AuthorLines
2023-10-09Auto merge of #116497 - compiler-errors:impl-span, r=cjgillotbors-5/+6
Extend `impl`'s `def_span` to include its where clauses Typically, we highlight the def-span of an impl in a diagnostic due to either: 1. coherence error 2. trait evaluation cycle 3. invalid implementation of built-in trait I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses. r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.
2023-10-09Extend impl's def_span to include where clausesMichael Goulet-5/+6
2023-10-08remove trailing dotsAli MJ Al-Nasrawy-1/+1
2023-10-08always show and explain sub regionAli MJ Al-Nasrawy-11/+3
2023-10-08improve the suggestion of generic_bound_failureAli MJ Al-Nasrawy-3/+3
2023-10-06Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiserbors-8/+14
Show more information when multiple `impl`s apply - When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s). ``` error[E0283]: type annotations needed --> $DIR/multiple-impl-apply.rs:34:9 | LL | let y = x.into(); | ^ ---- type must be known at this point | note: multiple `impl`s satisfying `_: From<Baz>` found --> $DIR/multiple-impl-apply.rs:14:1 | LL | impl From<Baz> for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ ... LL | impl From<Baz> for Foo { | ^^^^^^^^^^^^^^^^^^^^^^ = note: required for `Baz` to implement `Into<_>` help: consider giving `y` an explicit type | LL | let y: /* Type */ = x.into(); | ++++++++++++ ``` - Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user. - Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases. ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/cross-return-site-inference.rs:38:16 | LL | return Err(From::from("foo")); | ^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | return Err(</* self type */ as From>::from("foo")); | +++++++++++++++++++ + ``` Fix #88284.
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-0/+14
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-44/+16
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
2023-10-04Show more information when multiple `impl` applyEsteban Küber-2/+36
2023-09-29Auto merge of #115821 - obeis:hir-analysis-migrate-diagnostics-5, ↵bors-2/+6
r=compiler-errors Migrate `rustc_hir_analysis` to session diagnostic [Part 5] Finishing `coherence/builtin.rs` file
2023-09-26Rollup merge of #116162 - fmease:gate-n-validate-rustc_safe_intrinsic, ↵Matthias Krüger-1/+1
r=Nilstrieb Gate and validate `#[rustc_safe_intrinsic]` Copied over from #116159: > This was added as ungated in https://github.com/rust-lang/rust/pull/100719/files#diff-09c366d3ad3ec9a42125253b610ca83cad6b156aa2a723f6c7e83eddef7b1e8fR502, probably because the author looked at the surrounding attributes, which are ungated because they are gated specially behind the staged_api feature. > > I don't think we need to crater this, the attribute is entirely useless without the intrinsics feature, which is already unstable.. r? ``@Nilstrieb``
2023-09-25Gate and validate #[rustc_safe_intrinsic]León Orell Valerian Liehr-1/+1
2023-09-22Rollup merge of #116062 - eduardosm:start-fn-diag, r=WaffleLapkinMatthias Krüger-4/+4
Change `start` to `#[start]` in some diagnosis They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obkbors-1/+1
adjust how closure/generator types are printed I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22Change `start` to `#[start]` in some diagnosisEduardo Sánchez Muñoz-4/+4
They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-1/+1
2023-09-20Migrate `rustc_hir_analysis` to session diagnosticObei Sideg-2/+6
Part 5: Finishing `coherence/builtin.rs` file
2023-09-19rustc_hir_analysis: add a helper to check function the signature mismatchesEduardo Sánchez Muñoz-4/+4
This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions. The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.
2023-09-18Migrate 'cast to bool' diagnosticclubby789-1/+6
2023-09-15Migrate 'explicit destructor call' diagnosticclubby789-4/+6
2023-09-12Rollup merge of #115765 - asquared31415:cast_diag, r=WaffleLapkinMatthias Krüger-1/+1
Add source type for invalid bool casts Also adds tests for casting various types to `bool` that were otherwise untested. r? `@WaffleLapkin`
2023-09-11add source type for invalid bool castsasquared31415-1/+1
2023-09-11Rollup merge of #115744 - fmease:fix-e0401, r=compiler-errorsMatthias Krüger-11/+11
Improve diagnostic for generic params from outer items (E0401) Generalize the wording of E0401 to talk about *outer items* instead of *outer functions* since the current phrasing is outdated. The outer item can be a function, constant, trait, ADT or impl block (see the new UI test for the more exotic examples). Further, don't suggest introducing generic parameters to constant items unless the feature `generic_const_items` is enabled. Lastly, make E0401 translatable while we're at it. Fixes #115720.
2023-09-11Rollup merge of #115743 - compiler-errors:no-impls, r=davidtwcoMatthias Krüger-0/+5
Point out if a local trait has no implementations Slightly helps with #115741
2023-09-11Auto merge of #115387 - weihanglo:merge-check-and-lint, r=oli-obkbors-3/+10
Make unknown/renamed/removed lints passed via command line respect lint levels
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+5
2023-09-10Generalize E0401León Orell Valerian Liehr-11/+11
2023-09-08Improve "associated type not found" diagnosticsLieselotte-1/+1
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-106/+26
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-08-30feat(rustc_lint): make `CheckLintName` respect lint levelWeihang Lo-3/+10
2023-08-29Don't suggest adding parentheses to call an inaccessible method.Kevin Reid-0/+25
Previously, the test code would emit E0615, thus revealing the existence of private methods that the programmer probably does not care about. Now it ignores their existence instead, producing error E0609 (no field). The motivating example is: ```rust let x = std::rc::Rc::new(()); x.inner; ``` which would previously mention the private method `Rc::inner()`, even though `Rc<T>` intentionally has no public methods so that it can be a transparent smart pointer for any `T`.
2023-08-28Revert "Suggest using `Arc` on `!Send`/`!Sync` types"David Tolnay-1/+0
This reverts commit 9de1a472b68ed85f396b2e2cc79c3ef17584d6e1.
2023-08-09Suggest using `Arc` on `!Send`/`!Sync` typesEsteban Kuber-0/+1
2023-08-04Improve spans for indexing expressionsNilstrieb-2/+2
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-02Replace old private-in-public diagnostic with type privacy lintsBryanskiy-106/+26
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-2/+1
new unstable option: -Zwrite-long-types-to-disk This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-25write-long-types-to-disk: update testsMahdi Dibaiee-9/+6
2023-07-24new unstable option: -Zwrite-long-types-to-diskMahdi Dibaiee-5/+7
This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-16stop mentioning number of applicate implementationslcnr-2/+2
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-8/+7
2023-06-30Rollup merge of #113177 - estebank:hrlt-sugg, r=compiler-errorsMatthias Krüger-4/+3
Use structured suggestion when telling user about `for<'a>` ``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-30Use structured suggestion when telling user about `for<'a>`Esteban Küber-4/+3
``` error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/E0637.rs:13:13 | LL | T: Into<&u32>, | ^ explicit lifetime name needed here | help: consider introducing a higher-ranked lifetime here | LL | T: for<'a> Into<&'a u32>, | +++++++ ++ ```
2023-06-29Fix type privacy lints error messageBryanskiy-13/+13
2023-06-29Rollup merge of #112670 - petrochenkov:typriv, r=eholkMatthias Krüger-10/+11
privacy: Type privacy lints fixes and cleanups See individual commits. Follow up to https://github.com/rust-lang/rust/pull/111801.
2023-06-22Avoid guessing unknown trait impl in suggestionsAlexander Zhang-4/+4
When a trait is used without specifying the implementation (e.g. calling a non-member associated function without fully-qualified syntax) and there are multiple implementations available, use a placeholder comment for the implementation type in the suggestion instead of picking a random implementation. Example: ``` fn main() { let _ = Default::default(); } ``` Previous output: ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> test.rs:2:13 | 2 | let _ = Default::default(); | ^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation (273 found) | 2 | let _ = <FileTimes as Default>::default(); | +++++++++++++ + ``` New output: ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> test.rs:2:13 | 2 | let _ = Default::default(); | ^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation (273 found) | 2 | let _ = </* self type */ as Default>::default(); | +++++++++++++++++++ + ```
2023-06-15privacy: Feature gate new type privacy lintsVadim Petrochenkov-10/+11
2023-06-12Private-in-public lints implementationBryanskiy-4/+55
2023-06-05Don't mention already set fieldsMichael Goulet-1/+1
2023-05-18Simplify suggestion when returning bare dyn traitMichael Goulet-25/+17
2023-05-09Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillotMatthias Krüger-5/+5
Various changes to name resolution of anon consts Sorry this PR is kind of all over the place ^^' Fixes #111012 - Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments) - Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy` - Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993 - Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters - Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)` I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands. r? `@cjgillot` cc `@compiler-errors`