about summary refs log tree commit diff
path: root/tests/ui/fn
AgeCommit message (Collapse)AuthorLines
2025-09-29Make replacement suggestion `_` in type verboseEsteban Küber-28/+45
``` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/in-signature.rs:6:21 | LL | fn arr_fn() -> [u8; _] { | ^ not allowed in type signatures | help: replace with the correct return type | LL - fn arr_fn() -> [u8; _] { LL + fn arr_fn() -> [u8; 3] { | ```
2025-08-30On unused binding in pattern, suggest unit struct/variant with similar nameEsteban Küber-31/+10
When encountering a typo in a pattern that gets interpreted as an unused binding, look for unit struct/variant of the same type as the binding: ``` error: unused variable: `Non` --> $DIR/binding-typo-2.rs:36:9 | LL | Non => {} | ^^^ | help: if this is intentional, prefix it with an underscore | LL | _Non => {} | + help: you might have meant to pattern match on the similarly named variant `None` | LL - Non => {} LL + std::prelude::v1::None => {} | ```
2025-08-22On E0277, point at type that doesn't implement boundEsteban Küber-1/+5
When encountering an unmet trait bound, point at local type that doesn't implement the trait: ``` error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied --> $DIR/issue-64855.rs:9:19 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | help: the trait `Foo` is not implemented for `Bar<T>` --> $DIR/issue-64855.rs:9:1 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^ ```
2025-08-19bless tests with new lint messagesKarol Zwolak-1/+1
2025-08-11Rollup merge of #144966 - scrabsha:push-rozroqqmurvu, r=jdonszelmannGuillaume Gomez-3/+37
Improve suggestion for "missing function argument" on multiline call `rustc` has a very neat suggestion when the argument count does not match, with a nice placeholder that shows where an argument may be missing. Unfortunately the suggestion is always single-line, even when the function call spans across multiple lines. With this PR, `rustc` tries to guess if the function call is multiline or not, and emits a multiline suggestion when required. r? `@jdonszelmann`
2025-08-10Rollup merge of #144403 - Kivooeo:issue4, r=jieyouxuStuart Cook-0/+41
`tests/ui/issues/`: The Issues Strike Back [4/N] Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895. r? ````````@jieyouxu````````
2025-08-09commentsKivooeo-0/+14
2025-08-06Allow function argument mismatch suggestion to be multilineSasha Pourcelot-8/+4
2025-08-05Add test for "missing function argument" on multiline callSasha Pourcelot-3/+41
2025-07-31commentsKivooeo-0/+2
2025-07-25moved 34 tests to organized locationsKivooeo-0/+27
2025-07-24moved 35 tests to organized locationsKivooeo-0/+9
2025-07-04Rollup merge of #143296 - Kivooeo:tf21, r=tgross35Jubilee-0/+148
`tests/ui`: A New Order [21/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@tgross35`
2025-07-04Rollup merge of #143202 - Kivooeo:tf18, r=tgross35Jubilee-0/+24
`tests/ui`: A New Order [18/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@tgross35`
2025-07-05cleaned up some testsKivooeo-14/+15
2025-07-05moved testsKivooeo-0/+147
2025-07-01Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errorsbors-8/+8
Start moving wf checking away from HIR I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better. I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks. Especially https://github.com/rust-lang/rust/commit/b862d8828e375ab8c128a9d9e93bf98b77cb5928 is interesting here, because I think it improves spans in all cases
2025-07-01cleaned up some testsKivooeo-2/+7
2025-07-01moved test filesKivooeo-0/+19
2025-06-30Replace `ItemCtxt::report_placeholder_type_error` `match` with a call to ↵Guillaume Gomez-1/+1
`TyCtxt::def_descr`
2025-06-30Unconditionally run `check_item_type` on all itemsOli Scherer-8/+8
2025-06-27Report infer ty errors during hir ty loweringOli Scherer-6/+0
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-05-19Fixed possible ICE in annotate_mut_binding_to_immutable_bindingJosh Gunter-0/+38
2025-05-07Rollup merge of #140671 - xizheyin:issue-140169, r=petrochenkovGuillaume Gomez-0/+50
Parser: Recover error from named params while parse_path Fixes #140169 I added test to the first commit and the second added the code and changes to test. r? `@petrochenkov`
2025-05-07Use `parse_param_general` when parsing `(T, U)->R` in `parse_path_segment`xizheyin-17/+41
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2025-05-05Add ui test fn-trait-use-named-paramsxizheyin-0/+26
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-03compiletest: Do not require annotations on empty labels and suggestionsVadim Petrochenkov-4/+2
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-48/+52
2025-04-10compiletest: Make `SUGGESTION` annotations viralVadim Petrochenkov-3/+4
2025-04-07compiletest: Avoid ignoring empty diagnostics in one more placeVadim Petrochenkov-1/+2
This catches some silly notes emitted by rustc, which should ideally be fixed
2025-04-03compiletest: Require `//~` annotations even if `error-pattern` is specifiedVadim Petrochenkov-4/+2
2025-04-02Fix two incorrect turbofish suggestionsFreya Arbjerg-0/+33
Fixes #121901
2025-03-22Add test to ensure no index out of bounds panic (#135474)Redddy-0/+44
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-2/+10
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-2/+2
2025-02-21More sophisticated span trimmingMichael Goulet-3/+2
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-18/+27
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-06Label mismatched parameters at the def site for foreign functions.Jason Newcomb-0/+30
2025-02-03Fix ICE when function argument mismatches.Jason Newcomb-0/+66
2025-02-03Check for generic parameter mismatches on trait functions.Jason Newcomb-0/+33
2025-02-02Tweak fn pointer suggestion spanEsteban Küber-1/+1
Use a more targeted span when suggesting casting an `fn` item to an `fn` pointer. ``` error[E0308]: cannot coerce functions which must be inlined to function pointers --> $DIR/cast.rs:10:33 | LL | let _: fn(isize) -> usize = callee; | ------------------ ^^^^^^ cannot coerce functions which must be inlined to function pointers | | | expected due to this | = note: expected fn pointer `fn(_) -> _` found fn item `fn(_) -> _ {callee}` = note: fn items are distinct from fn pointers help: consider casting to a fn pointer | LL | let _: fn(isize) -> usize = callee as fn(isize) -> usize; | +++++++++++++++++++++ ``` ``` error[E0308]: mismatched types --> $DIR/fn-pointer-mismatch.rs:42:30 | LL | let d: &fn(u32) -> u32 = foo; | --------------- ^^^ expected `&fn(u32) -> u32`, found fn item | | | expected due to this | = note: expected reference `&fn(_) -> _` found fn item `fn(_) -> _ {foo}` help: consider using a reference | LL | let d: &fn(u32) -> u32 = &foo; | + ``` Previously we'd point at the whole expression for replacement, instead of marking what was being added. We could also modify the suggestions for `&(name as fn())`, but for that we require storing more accurate spans than we have now.
2025-01-25Rollup merge of #136032 - estebank:issue-136028, r=SparrowLiiJacob Pratt-31/+84
Account for mutable borrow in argument suggestion ``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:21:5 | LL | object = &mut object2; | ^^^^^^ | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object3(object: &mut Object) { LL | LL | let object2 = Object; LL ~ *object = object2; | ``` instead of ``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:21:5 | LL | object = &mut object2; | ^^^^^^ | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object3(object: &mut mut Object) { LL | LL | let object2 = Object; LL ~ *object = object2; | ``` Fix #136028.
2025-01-24Account for mutable borrow in argument suggestionEsteban Küber-31/+84
``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:21:5 | LL | object = &mut object2; | ^^^^^^ | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object3(object: &mut Object) { LL | LL | let object2 = Object; LL ~ *object = object2; | ``` instead of ``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:21:5 | LL | object = &mut object2; | ^^^^^^ | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object3(object: &mut mut Object) { LL | LL | let object2 = Object; LL ~ *object = object2; | ``` Fix #136028.
2025-01-23tests: use `needs-subprocess` instead of `ignore-{wasm32,emscripten,sgx}`许杰友 Jieyou Xu (Joe)-1/+1
2025-01-11review comments and make test `run-rustfix`Esteban Küber-10/+36
2025-01-11On unused assign lint, detect `mut arg: &Ty` meant to be `arg: &mut Ty`Esteban Küber-1/+6
``` error: value assigned to `object` is never read --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:11:5 | LL | object = &object2; | ^^^^^^ | note: the lint level is defined here --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:1:9 | LL | #![deny(unused_assignments, unused_variables)] | ^^^^^^^^^^^^^^^^^^ help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object2(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` This might be the first thing someone tries to write to mutate the value *behind* an argument, trying to avoid an E0308.
2025-01-11On E0308, detect `mut arg: &Ty` meant to be `arg: &mut Ty`Esteban Küber-3/+5
``` error[E0308]: mismatched types --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:6:14 | LL | fn change_object(mut object: &Object) { | ------- expected due to this parameter type LL | let object2 = Object; LL | object = object2; | ^^^^^^^ expected `&Object`, found `Object` | help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | LL ~ fn change_object(object: &mut Object) { LL | let object2 = Object; LL ~ *object = object2; | ``` This might be the first thing someone tries to write to mutate the value *behind* an argument. We avoid suggesting `object = &object2;`, as that is less likely to be what was intended.
2025-01-11Add test for `mut arg: &Ty` meant to be `arg: &mut Ty`Esteban Küber-0/+80
This is a mistake I've seen newcomers make where they want to express an "out" argument.
2025-01-06only avoid blaming assignments from argument patternsdianne-5/+8
2025-01-06make outlives constraints from generic arguments less boringdianne-1/+1