about summary refs log tree commit diff
path: root/tests/ui/issues
AgeCommit message (Collapse)AuthorLines
2023-10-09Extend impl's def_span to include where clausesMichael Goulet-2/+2
2023-10-06Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiserbors-19/+27
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-05Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, ↵Matthias Krüger-0/+5
r=compiler-errors,estebank Add a note to duplicate diagnostics Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
2023-10-05Rollup merge of #116431 - estebank:issue-80476, r=compiler-errorsJubilee-8/+8
Tweak wording of E0562 Fix #80476.
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-0/+5
2023-10-04Point to where missing return type should goMichael Goulet-3/+3
2023-10-04Tweak wording of E0562Esteban Küber-8/+8
Fix #80476.
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-19/+27
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-02Point out the actual mismatch errorMichael Goulet-0/+4
2023-10-02For a single impl candidate, try to unify it with error trait refMichael Goulet-3/+3
2023-09-26Add context to `let: Ty = loop { break };`Esteban Küber-1/+6
We weren't accounting for the case where `break` was immediately within the `loop` block.
2023-09-25Use verbose suggestion for `break` without valueEsteban Küber-4/+6
2023-09-22Rollup merge of #116062 - eduardosm:start-fn-diag, r=WaffleLapkinMatthias Krüger-2/+2
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-11/+11
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-2/+2
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-11/+11
2023-09-19rustc_hir_analysis: add a helper to check function the signature mismatchesEduardo Sánchez Muñoz-2/+2
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-19Rollup merge of #115869 - ferrocene:pa-fix-tests-cargo-remap, r=compiler-errorsMatthias Krüger-3/+0
Avoid blessing cargo deps's source code in ui tests Before this PR, the source code of dependencies was included in UI test error messages whenever possible. Unfortunately, "whenever possible" means in some cases the source code wouldn't be injected, resulting in a test failure. One such case is when `$CARGO_HOME` is remapped to something that is not present on disk [^1]. As the remapped path doesn't exist on disk, the source code wouldn't be showed in `tests/ui/issues/issue-21763.rs`: ```diff = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send` note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>` --> $HASHBROWN_SRC_LOCATION - | -LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> { - | ^^^^^^^ note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>` --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL note: required by a bound in `foo` ``` This PR fixes the problem by always hiding dependencies source code in the error messages generated during UI tests. This is implemented with a new internal flag, `-Z ignore-directory-in-diagnostics-source-blocks=$path`, which compiletest passes during UI tests. Once this is merged, remapping the Cargo home will be supported. This PR is best reviewed commit-by-commit. [^1]: After being puzzled for a bit, I discovered why this never impacted `rust-lang/rust`: we don't remap `$CARGO_HOME` :sweat_smile:. Instead, we set `$CARGO_HOME` to `/cargo` in CI, which sort-of-but-not-really achieves the same effect.
2023-09-15avoid blessing cargo deps's source code in ui testsPietro Albini-3/+0
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-7/+1
also share the code that emits the actual error
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-9/+40
2023-09-11Rollup merge of #115744 - fmease:fix-e0401, r=compiler-errorsMatthias Krüger-15/+15
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-10Point out if a local trait has no implementationsMichael Goulet-0/+34
2023-09-10Generalize E0401León Orell Valerian Liehr-15/+15
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-32/+6
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-30Test and note unsafe ctor to fn ptr coercionMichael Goulet-1/+0
Also remove a note that I don't consider to be very useful in context.
2023-08-29Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkovbors-371/+0
Move tests r? `@petrochenkov`
2023-08-28Move testsCaio-371/+0
2023-08-28Revert "Suggest using `Arc` on `!Send`/`!Sync` types"David Tolnay-4/+0
This reverts commit 9de1a472b68ed85f396b2e2cc79c3ef17584d6e1.
2023-08-26Remove unnecessary `select_obligations_where_possible` and redundant errorsEsteban Küber-8/+1
2023-08-26More accurately point at argumentsEsteban Küber-4/+6
2023-08-26On let binding type point to type parameter that introduced unmet boundEsteban Küber-1/+8
On the following example, point at `String` instead of the whole type: ``` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/own-bound-span.rs:14:24 | LL | let _: <S as D>::P<String>; | ^^^^^^ the trait `Copy` is not implemented for `String` | note: required by a bound in `D::P` --> $DIR/own-bound-span.rs:4:15 | LL | type P<T: Copy>; | ^^^^ required by this bound in `D::P` ```
2023-08-26Point at appropriate type parameter in more trait bound errorsEsteban Küber-4/+2
2023-08-25Handle Self in paths tooMichael Goulet-2/+2
2023-08-25Auto merge of #115193 - weihanglo:rollup-6s3mz06, r=weihanglobors-399/+0
Rollup of 9 pull requests Successful merges: - #114987 (elaborate a bit on the (lack of) safety in 'Mmap::map') - #115084 (Add smir `predicates_of`) - #115117 (Detect and report nix shell) - #115124 (kmc-solid: Import `std::sync::PoisonError` in `std::sys::solid::os`) - #115152 (refactor(lint): translate `RenamedOrRemovedLint`) - #115154 (Move some ui tests to subdirectories) - #115167 (Fix ub-int-array test for big-endian platforms) - #115172 (Add more tests for if_let_guard) - #115177 (Add symbols for Clippy usage) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-25Auto merge of #114201 - Centri3:explicit-repr-rust, r=WaffleLapkinbors-2/+2
Allow explicit `#[repr(Rust)]` This is identical to no `repr()` at all. For `Rust, packed` and `Rust, align(x)`, it should be the same as no `Rust` at all (as, afaik, `#[repr(align(16))]` uses the Rust ABI.) The main use case for this is being able to explicitly say "I want to use the Rust ABI" in very very rare circumstances where the first obvious choice would be the C ABI yet is undesirable, which is already possible with functions as `extern "Rust"`. This would be useful for silencing https://github.com/rust-lang/rust-clippy/pull/11253. It's also more consistent with `extern`. The lack of this also tripped me up a bit when I was new to Rust, as I expected this to be possible.
2023-08-24Move issue 29181, 2804, 17431, 66768Olanti-399/+0
2023-08-20Clarify that `Rust` is default reprCatherine Flores-2/+2
2023-08-16Auto merge of #112500 - lukas-code:span-ctxt, r=petrochenkovbors-1/+0
Fix argument removal suggestion around macros Fixes #112437. Fixes #113866. Helps with #114255. The issue was that `span.find_ancestor_inside(outer)` could previously return a span with a different expansion context from `outer`. This happens for example for the built-in macro `panic!`, which expands to another macro call of `panic_2021!` or `panic_2015!`. Because the call site of `panic_20xx!` has not associated source code, its span currently points to the call site of `panic!` instead. Something similar also happens items that get desugared in AST->HIR lowering. For example, `for` loops get two spans: One "inner" span that has the `.desugaring_kind()` kind set to `DesugaringKind::ForLoop` and one "outer" span that does not. Similar to the macro situation, both of these spans point to the same source code, but have different expansion contexts. This causes problems, because joining two spans with different expansion contexts will usually[^1] not actually join them together to avoid creating "spaghetti" spans that go from the macro definition to the macro call. For example, in the following snippet `full_span` might not actually contain the `adjusted_start` and `adjusted_end`. This caused the broken suggestion / debug ICE in the linked issues. ```rust let adjusted_start = start.find_ancestor_inside(shared_ancestor); let adjusted_end = end.find_ancestor_inside(shared_ancestor); let full_span = adjusted_start.to(adjusted_end) ``` To fix the issue, this PR introduces a new method, `find_ancestor_inside_same_ctxt`, which combines the functionality of `find_ancestor_inside` and `find_ancestor_in_same_ctxt`: It finds an ancestor span that is contained within the parent *and* has the same syntax context, and is therefore safe to extend. This new method should probably be used everywhere, where the returned span is extended, but for now it is just used for the argument removal suggestion. Additionally, this PR fixes a second issue where the function call itself is inside a macro but the arguments come from outside the macro. The test is added in the first commit to include stderr diff, so this is best reviewed commit by commit. [^1]: If one expansion context is the root context and the other is not.
2023-08-14Point at return type when it influences non-first `match` armEsteban Küber-0/+2
When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-09Suggest using `Arc` on `!Send`/`!Sync` typesEsteban Kuber-0/+4
2023-08-05Rename tests/ui/issues/issue-100605.rs to ../type/option-ref-advice.rsMartin Nordholts-54/+0
The test is a regression test for a bug where the compiler gave bad advice for an `Option<&String>`. Rename the file appropriately.
2023-08-04Improve spans for indexing expressionsNilstrieb-8/+8
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-32/+6
2023-08-01introduce `Span::find_ancestor_inside_same_ctxt`Lukas Markeffsky-1/+0
and use it for function argument diagnostics
2023-07-29Change default panic handler message format.Mara Bos-2/+4
2023-07-29Allow explicit `#[repr(Rust)]`Catherine Flores-2/+2
2023-07-29Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, ↵bors-0/+2
r=compiler-errors make `noop_method_call` warn by default r? `@compiler-errors`
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-12/+6
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-28/+19