summary refs log tree commit diff
path: root/src/test/ui/error-codes
AgeCommit message (Collapse)AuthorLines
2020-09-29Bless testsDylan MacKenzie-51/+13
2020-09-26`char` not charvarkor-4/+4
2020-09-26Make invalid integer operation messages consistentvarkor-3/+3
2020-09-17Auto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomezbors-2/+22
Improve E0118 - Changes the "base type" terminology to "nominal type" (according to the [reference](https://doc.rust-lang.org/stable/reference/items/implementations.html#inherent-implementations)). - Suggests removing a reference, if one is present on the type. - Clarify what is meant by a "nominal type". closes #69392 This is my first not-entirely-trivial PR, so please let me know if I missed anything or if something could be improved. Though I probably won't be able to fix anything in the upcoming week.
2020-09-11Provide suggestion for missing fields in patternsEsteban Küber-29/+29
2020-09-11Improve E0118 descriptionaticu-2/+22
2020-09-10Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obkbors-11/+73
Add CONST_ITEM_MUTATION lint Fixes #74053 Fixes #55721 This PR adds a new lint `CONST_ITEM_MUTATION`. Given an item `const FOO: SomeType = ..`, this lint fires on: * Attempting to write directly to a field (`FOO.field = some_val`) or array entry (`FOO.array_field[0] = val`) * Taking a mutable reference to the `const` item (`&mut FOO`), including through an autoderef `FOO.some_mut_self_method()` The lint message explains that since each use of a constant creates a new temporary, the original `const` item will not be modified.
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-2/+2
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-07Add CONST_ITEM_MUTATION lintAaron Hill-11/+73
Fixes #74053 Fixes #55721 This PR adds a new lint `CONST_ITEM_MUTATION`. Given an item `const FOO: SomeType = ..`, this lint fires on: * Attempting to write directly to a field (`FOO.field = some_val`) or array entry (`FOO.array_field[0] = val`) * Taking a mutable reference to the `const` item (`&mut FOO`), including through an autoderef `FOO.some_mut_self_method()` The lint message explains that since each use of a constant creates a new temporary, the original `const` item will not be modified.
2020-09-03specialization_graph: avoid trimmed paths for OverlapErrorDan Aloni-8/+8
2020-09-02pretty: trim paths of unique symbolsDan Aloni-45/+45
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-09-01Clarify message about unresolved useKornel-2/+2
2020-08-30Suggest `if let x = y` when encountering `if x = y`Esteban Küber-6/+6
Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-08-22Use smaller def span for functionsAaron Hill-7/+5
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-16Auto merge of #75536 - estebank:e0255-suggestion, r=varkorbors-5/+8
Tweak output of E0225 When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are. _Inspired by https://fasterthanli.me/articles/frustrated-its-not-you-its-rust_
2020-08-14Rollup merge of #75509 - estebank:coming-merrily-from-java-land, r=lcnrTyler Mandry-12/+32
Tweak suggestion for `this` -> `self` * When referring to `this` in associated `fn`s always suggest `self`. * Point at ident for `fn` lacking `self` * Suggest adding `self` to assoc `fn`s when appropriate _Improvements based on the narrative in https://fasterthanli.me/articles/i-am-a-java-csharp-c-or-cplusplus-dev-time-to-do-some-rust_
2020-08-14Tweak output of E0225Esteban Küber-5/+8
When encountering multiple non-auto trait bounds suggest creating a new trait and explain what auto-traits are.
2020-08-13Suggest adding `&self` when accessing `self` in static assoc `fn`Esteban Küber-12/+32
2020-08-11Suggest using `'static` in assoc consts and suggest when multiple lts are neededEsteban Küber-0/+9
2020-08-10Add missing primary labelEsteban Küber-1/+1
2020-08-10Tweak ordering of suggestionsEsteban Küber-4/+7
Modify logic to make it easier to follow and recover labels that would otherwise be lost.
2020-07-27mv std libs to library/mark-3/+3
2020-07-23added a test case for reporting mismatched traitsAyrton-0/+30
2020-07-19disallow non-static lifetimes in const genericsGabriel Smith-0/+28
This has been put in place to patch over an ICE caused when we encounter a non-static lifetime in a const generic during borrow checking. This restriction may be relaxed in the future, but we need more discussion before then, and in the meantime we should still deal with this ICE. Fixes issue #60814
2020-07-14Rollup merge of #74228 - estebank:unsized-param, r=davidtwcoManish Goregaokar-5/+7
Provide structured suggestion on unsized fields and fn params * Suggest borrowing or boxing unsized fields * Suggest borrowing fn parameters * Remove some verbosity of unsized errors * Remove `on_unimplemented` note from `trait Sized` Fix #23286, fix #28653. r? @davidtwco
2020-07-14Rollup merge of #74211 - estebank:struct-pat-as-unit, r=petrochenkovManish Goregaokar-6/+9
Structured suggestion when not using struct pattern r? @petrochenkov
2020-07-14Suggest borrowing in more unsized fn param casesEsteban Küber-1/+4
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-2/+1
2020-07-14Suggest boxing or borrowing unsized fieldsEsteban Küber-2/+2
2020-07-14Suggest struct pat on incorrect unit or tuple patEsteban Küber-6/+9
When encountering a unit or tuple pattern for a struct-like item, suggest using the correct pattern. Use `insert_field_names_local` when evaluating variants and store field names even when the list is empty in order to produce accurate structured suggestions.
2020-07-10Tweak wordingYuki Okushi-2/+2
2020-07-10Add a help to use `in_band_lifetimes` in nightlyYuki Okushi-0/+4
2020-07-06Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebankManish Goregaokar-3/+27
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
2020-07-02resolve: disallow label use through closure/asyncDavid Wood-0/+21
This commit modifies resolve to disallow `break`/`continue` to labels through closures or async blocks. This doesn't make sense and should have been prohibited anyway. Signed-off-by: David Wood <david@davidtw.co>
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-3/+27
2020-06-30Switch crate_extern_paths to a query, and tweak wording.Eric Huss-1/+1
2020-06-30Provide more information on duplicate lang item error.Eric Huss-1/+4
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-3/+3
propagation
2020-06-23Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisaManish Goregaokar-7/+3
A way forward for pointer equality in const eval r? @varkor on the first commit and @RalfJung on the second commit cc #53020
2020-06-20Refer just to the issue in the raw ptr cmp diagnostic instead of explaining ↵Oliver Scherer-4/+2
everything in the diagnostic
2020-06-19Rollup merge of #72934 - christianpoveda:mut-borrows-in-consts, r=oli-obkManish Goregaokar-45/+24
forbid mutable references in all constant contexts except for const-fns PR to address #71212 cc: @ecstatic-morse
2020-06-19Rollup merge of #71420 - RalfJung:specialization-incomplete, r=matthewjasperManish Goregaokar-2/+12
Specialization is unsound As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound. I also expanded the "incomplete feature" warning to link the user to the tracking issue.
2020-06-19add new error codeChristian Poveda-16/+16
2020-06-19update diagnostics for &mut in constantsChristian Poveda-44/+23
2020-06-19Add fuzzy pointer comparison intrinsicsOliver Scherer-2/+3
2020-06-19Remove the const_raw_ptr_comparison feature gate.Oliver Scherer-8/+5
We can never supply a meaningful implementation of this. Instead, the follow up commits will create two intrinsics that approximate comparisons: * `ptr_maybe_eq` * `ptr_maybe_ne` The fact that `ptr_maybe_eq(a, b)` is not necessarily the same value as `!ptr_maybe_ne(a, b)` is a symptom of this entire problem.
2020-06-16bless allRalf Jung-2/+12
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-7/+3
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-02Improve E0433, so that it suggests missing importsPatryk Wychowaniec-4/+4
2020-05-30Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, ↵Ralf Jung-3/+4
r=varkor mir: adjust conditional in recursion limit check Fixes #67552. This PR adjusts the condition used in the recursion limit check of the monomorphization collector, from `>` to `>=`. In #67552, the test case had infinite indirect recursion, repeating a handful of functions (from the perspective of the monomorphization collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold` -> `Iterator::next` -> `rec`. During this process, `resolve_associated_item` was invoked for `Iterator::fold` (during the construction of an `Instance`), and ICE'd due to substitutions needing inference. However, previous iterations of this recursion would have called this function for `Iterator::fold` - and did! - and succeeded in doing so (trivially checkable from debug logging, `()` is present where `_` is in the substs of the failing execution). The expected outcome of this test case would be a recursion limit error (which is present when the `identity` fn indirection is removed), and the recursion depth of `rec` is increasing (other functions finish collecting their neighbours and thus have their recursion depths reset). When the ICE occurs, the recursion depth of `rec` is 256 (which matches the recursion limit), which suggests perhaps that a different part of the compiler is using a `>=` comparison and returning a different result on this recursion rather than what it returned in every previous recursion, thus stopping the monomorphization collector from reporting an error on the next recursion, where `recursion_depth_of_rec > 256` would have been true. With grep and some educated guesses, we can determine that the recursion limit check at line 818 in `src/librustc_trait_selection/traits/project.rs` is the other check that is using a different comparison. Modifying either comparison to be `>` or `>=` respectively will fix the error, but changing the monomorphization collector produces the nicer error.