about summary refs log tree commit diff
path: root/tests/ui/error-codes
AgeCommit message (Collapse)AuthorLines
2025-10-01Rollup merge of #146593 - Jules-Bertholet:restrict-e0719, r=BoxyUwUMatthias Krüger-36/+3
Allow specifying multiple bounds for same associated item, except in trait objects Supersedes https://github.com/rust-lang/rust/pull/143146, fixes https://github.com/rust-lang/rust/issues/143143. This PR proposes to stop enforcing E0719 in all contexts other than trait object types. E0719 forbids constraining the same associated item twice within the same angle-bracket delimited associated item bound list (the `…` inside `T: Trait<…>`). For example, the following are forbidden: | Forbidden | Working alternative | |--------------------------------------------|--------------------------------------------------------------------| | `T: Trait<Gat<u32> = u32, Gat<u64> = u64>` | `T: Trait<Gat<u32> = u32> + Trait<Gat<u64> = u64>` | | `T: Iterator<Item = u32, Item = i32>` | `T: Iterator<Item = u32> + Iterator<Item = i32>` (trivially false) | | `T: Iterator<Item = u32, Item = u32>` | `T: Iterator<Item = u32>` | | `T: Iterator<Item: Send, Item: Sync>` | `T: Iterator<Item: Send + Sync>` | | `T: Trait<ASSOC = 3, ASSOC = 4>` | `T: Trait<ASSOC = 3> + Trait<ASSOC = 4>` (trivially false) | | `T: Trait<ASSOC = 3, ASSOC = 3>` | `T: Trait<ASSOC = 3>` | With this PR, all those previously forbidden examples would start working, as well as their APIT and RPIT equivalents. Types like `dyn Iterator<Item = u32, Item = u32>` will continue to be rejected, however. See https://github.com/rust-lang/rust/pull/143146#issuecomment-3274421752 for the reason why. ```@rustbot``` label T-lang T-types needs-fcp
2025-09-29Make replacement suggestion `_` in type verboseEsteban Küber-4/+7
``` 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-09-18Enforce E0719 only for trait aliasesJules Bertholet-36/+3
2025-08-27Changes to the uitestsJonathan Brouwer-6/+25
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-14Update uitestsJonathan Brouwer-30/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-12Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmannStuart Cook-4/+11
Tweak invalid builtin attribute output - Add link to reference/docs when possible - More accurate suggestions by supporting multiple alternative suggestions ``` error: malformed `crate_type` attribute input --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> help: the following are the possible correct uses | LL - #![crate_type = foo!()] LL + #![crate_type = "bin"] | LL - #![crate_type = foo!()] LL + #![crate_type = "cdylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "dylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "lib"] | = and 4 other candidates ```
2025-08-11Tweak trait modifier errorsCameron Steffen-1/+1
2025-08-11Factor out InherentImplCannotUnsafeCameron Steffen-0/+2
2025-08-11Add more docs to templates for attrs with incorrect argumentsEsteban Küber-0/+1
2025-08-11Allow attr entries to declare list of alternatives for `List` and ↵Esteban Küber-4/+10
`NamedValueStr` Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles. Suggestions now provide more correct suggested code: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler)] | LL - #[used(compiler, linker)] LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] | ``` instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler|linker)] | LL - #[used(compiler, linker)] LL + #[used] | ```
2025-08-08Rollup merge of #144649 - estebank:issue-144602, r=lcnrTrevor Gross-5/+1
Account for bare tuples and `Pin` methods in field searching logic When looking for the field names and types of a given type, account for tuples. This allows suggestions for incorrectly nested field accesses and field name typos to trigger as intended. Previously these suggestions only worked on `ty::Adt`, including tuple structs which are no different to tuples, so they should behave the same in suggestions. When suggesting field access which would encounter a method not found, do not suggest pinning when those methods are on `impl Pin` itself. ``` error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope --> $DIR/missing-field-access.rs:11:15 | LL | let x = f.get_ref(); | ^^^^^^^ method not found in `(BufReader<File>,)` | help: one of the expressions' fields has a method of the same name | LL | let x = f.0.get_ref(); | ++ ``` instead of ``` error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope --> $DIR/missing-field-access.rs:11:15 | LL | let x = f.get_ref(); | ^^^^^^^ method not found in `(BufReader<File>,)` | help: consider pinning the expression | LL ~ let mut pinned = std::pin::pin!(f); LL ~ let x = pinned.as_ref().get_ref(); | ``` Fix rust-lang/rust#144602.
2025-08-07Do not provide field typo suggestions for tuples and tuple structsEsteban Küber-5/+1
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-3/+6
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-07-31Extend `is_case_difference` to handle digit-letter confusablesxizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-18Rollup merge of #143699 - compiler-errors:async-drop-fund, r=oli-obkMatthias Krüger-1/+1
Make `AsyncDrop` check that it's being implemented on a local ADT Fixes https://github.com/rust-lang/rust/issues/143691
2025-07-13Retire hir::*ItemRef.Camille GILLOT-2/+2
2025-07-09Make AsyncDrop check that it's being implemented on a local ADTMichael Goulet-1/+1
2025-07-08Rollup merge of #143177 - xizheyin:143134, r=lcnrTrevor Gross-2/+0
Remove false label when `self` resolve failure does not relate to macro Fixes rust-lang/rust#143134 In the first commit, I did some code-clean, moving `suggest*` to `suggestions/` dir. In the second, commit, I added ui test. In the third, I change the code, and present the test result. r? compiler
2025-07-03Return early when `self` resolve failure because of `let self = ...`xizheyin-2/+0
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-01Suggest use another lifetime specifier instead of underscore lifetimexizheyin-0/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-27const checks: avoid 'top-level scope' terminologyRalf Jung-11/+25
2025-06-27Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errorsbors-8/+8
Rollup of 18 pull requests Successful merges: - rust-lang/rust#137843 (make RefCell unstably const) - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns) - rust-lang/rust#142549 (small iter.intersperse.fold() optimization) - rust-lang/rust#142637 (Remove some glob imports from the type system) - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation) - rust-lang/rust#142700 (Remove incorrect comments in `Weak`) - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`) - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition) - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143001 (Rename run always ) - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`) - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`) - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes) - rust-lang/rust#143041 (Remove cache for citool) - rust-lang/rust#143056 (Move an ACE test out of the GCI directory) - rust-lang/rust#143059 (Fix 1.88 relnotes) - rust-lang/rust#143067 (Tracking issue number for `iter_macro`) - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains) Failed merges: - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26clarify and unify 'transient mutable borrow' errorsRalf Jung-8/+8
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-5/+11
2025-06-17make error codes reflect reality betterJana Dönszelmann-37/+50
2025-06-17use consistent attr errors in all attribute parsersJana Dönszelmann-1/+1
2025-06-17fix bugs in inline/force_inline and diagnostics of all attr parsersJana Dönszelmann-3/+16
2025-06-14Rollup merge of #142464 - RalfJung:variadic-fn-abi-error, r=workingjubileeMatthias Krüger-1/+1
variadic functions: remove list of supported ABIs from error I think this list is problematic for multiple reasons: - It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`). - Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in https://github.com/rust-lang/rust/issues/110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.) - Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work. Cc ``@workingjubilee``
2025-06-13variadic functions: remove list of supported ABIs from errorRalf Jung-1/+1
2025-06-13Unimplement unsized_localsmejrs-10/+3
2025-06-08Auto merge of #142008 - RalfJung:const-eval-error-here, r=oli-obkbors-2/+2
const-eval error: always say in which item the error occurred I don't see why "is this generic" should make a difference. It may be reasonable to key this on whether the error occurs in a `const fn` that was invoked by a const (making it non-obvious which constant it is) vs inside the body of the const. r? `@oli-obk`
2025-06-07intrinsics: use const generic to set atomic orderingRalf Jung-15/+0
2025-06-07const-eval error: always say in which item the error occurredRalf Jung-2/+2
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-06reword suggestion messageEsteban Küber-2/+2
2025-06-06Make cast suggestions verboseEsteban Küber-7/+13
``` error[E0604]: only `u8` can be cast as `char`, not `u32` --> $DIR/E0604.rs:2:5 | LL | 1u32 as char; | ^^^^^^^^^^^^ invalid cast | help: try `char::from_u32` instead | LL - 1u32 as char; LL + char::from_u32(1u32); | ``` ``` error[E0620]: cast to unsized type: `&[u8]` as `[char]` --> $DIR/cast-to-slice.rs:6:5 | LL | arr as [char]; | ^^^^^^^^^^^^^ | help: try casting to a reference instead | LL | arr as &[char]; | + ``` ``` error[E0620]: cast to unsized type: `Box<{integer}>` as `dyn Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5 | LL | Box::new(1) as dyn Send; | ^^^^^^^^^^^^^^^^^^^^^^^ | help: you can cast to a `Box` instead | LL | Box::new(1) as Box<dyn Send>; | ++++ + ```
2025-06-04Rollup merge of #141888 - ferrocene:lw/decouple-tests-from-2015, ↵Matthias Krüger-6/+6
r=compiler-errors Use non-2015 edition paths in tests that do not test for their resolution This allows for testing these tests on editions other than 2015
2025-06-03Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJungMatthias Krüger-12/+9
Use the informative error as the main const eval error message r? `@RalfJung` I only did the minimal changes necessary to the const eval error machinery. I'd prefer not to mix test changes with refactorings 😆
2025-06-03Use non-2015 edition paths in tests that do not test for their resolutionLukas Wirth-6/+6
This allows for testing these tests on editions other than 2015
2025-06-02Clarify why we are talking about a failed const eval at a random placeOli Scherer-2/+2
2025-06-02Use the informative error as the main const eval error messageOli Scherer-12/+9
2025-06-02Add missing `dyn` keywords to tests that do not test for themLukas Wirth-14/+14
This ensures that these tests can be run on editions other than 2015
2025-05-28Stabilise `repr128`beetrees-10/+6
2025-05-23Do not try to confirm non-dyn compatible methodMichael Goulet-31/+2
2025-05-22Rollup merge of #140218 - fmease:hirtylo-clean-up-path-low, r=compiler-errorsMatthias Krüger-1/+7
HIR ty lowering: Clean up & refactor the lowering of type-relative paths While rebasing #126651 I realized that HIR ty lowering could benefit from some *spring cleaning* now that it's been extended to handle RTN and mGCA paths. More seriously, similar to my merged PR #118668 which unified the handling of all *associated item constraints* (assoc ty, const (ACE) & fn (RTN)), this PR (commit https://github.com/rust-lang/rust/pull/140218/commits/695fcf517d8864b4812225643ef8cfc036ba9f61) partially[^1] deduplicates the resolution code for all *type-relative paths* (assoc ty, const (mGCA) & fn (RTN)). **Why**? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like `Ty::AssocTy::assoc_fn(..)` and it also implies shared diagnostic code and thus better diagnostics for RTN. --- The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering `QPath(Resolved)` paths now have `_resolved_` in their name and ones lowering `QPath(TypeRelative)` paths now have `_type_relative_` in their name. This should make it stupidly obvious what their purpose is. --- Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier. r? compiler-errors [^1]: Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary `unreachable!()`s or rendering the code otherwise illegible with flags and micro helper traits.
2025-05-07Better error message for late/early lifetime param mismatchMichael Goulet-11/+50
2025-05-07Point out region bound mismatches in check_region_bounds_on_impl_itemMichael Goulet-1/+5
2025-05-06Preserve generic args in suggestions for ambiguous associated itemsLeón Orell Valerian Liehr-1/+7
Most notably, this preserves the `(..)` of ambiguous RTN paths.
2025-05-02resolve: Support imports of associated types and glob imports from traitsVadim Petrochenkov-19/+0
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-10/+15
2025-04-13UI tests: migrate remaining compile time `error-pattern`s to line annotationsVadim Petrochenkov-5/+8
when possible.