about summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-2/+34
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-04-04diagnostics: use correct span for const genericsMichael Howell-3/+3
Fixes #95616
2022-04-04Rollup merge of #95609 - compiler-errors:borrow-unsized-to-dyn, r=nagisaDylan DPC-0/+4
Suggest borrowing when trying to coerce unsized type into `dyn Trait` A helpful error in response to #95598, since we can't coerce e.g. `&str` into `&dyn Display`, but we can coerce `&&str` into `&dyn Display` :) Not sure if the suggestion message needs some help. Let me know, and I can refine this PR.
2022-04-03Improve method name suggestionsOliver Downard-2/+2
Attempts to improve method name suggestions when a matching method name is not found. The approach taken is use the Levenshtein distance and account for substrings having a high distance but can sometimes be very close to the intended method (eg. empty vs is_empty).
2022-04-02Suggest borrowing when trying to coerce unsized type into dyn TraitMichael Goulet-0/+4
2022-04-02Fix late-bound ICE in unsized return suggestionMichael Goulet-1/+1
2022-04-01Rollup merge of #95260 - compiler-errors:fn, r=davidtwcoMatthias Krüger-0/+2
Better suggestions for `Fn`-family trait selection errors 1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}` 2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments) 3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required). Fixes #95147
2022-03-31Specialize suggestion for Option<T>Michael Goulet-12/+12
2022-03-29Rollup merge of #95386 - compiler-errors:try-wrapping, r=oli-obkDylan DPC-0/+16
Suggest wrapping patterns in enum variants Structured suggestion to wrap a pattern in a single-field enum or struct: ```diff struct A; enum B { A(A), } fn main(b: B) { match b { - A => {} + B::A(A) => {} } } ``` Half of #94942, the other half I'm not exactly sure how to fix. Also includes two drive-by changes (that I am open to splitting out into another PR, but thought they could be rolled up into this one): - 07776c111f07b887cd46b752870cd3fd76b2ba7c: Makes sure not to suggest wrapping if it doesn't have tuple field constructor (i.e. has named fields) - 8f2bbb18fd53e5008bb488302dbd354577698ede: Also suggest wrapping expressions in a tuple struct (not just enum variants)
2022-03-28Remove duplicated and unused test filesCaio-51/+0
2022-03-27suggest wrapping patterns with compatible enum variantsMichael Goulet-0/+16
2022-03-27Auto merge of #94495 - estebank:missing-closing-gt, r=jackh726bors-0/+5
Provide suggestion for missing `>` in a type parameter list When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-27Rollup merge of #93469 - compiler-errors:issue-93450, r=estebankDylan DPC-25/+14
Skip pointing out ambiguous impls in alloc/std crates too in inference errors This generalizes the logic in `annotate_source_of_ambiguity` to skip printing ambiguity errors traits in `alloc` and `std` as well, not just `core`. While this does spot-fix the issue mentioned below, it would be nicer to generalize this logic, for example to detect when the trait predicate's `self_ty` has any numerical inference variables. Is it worthwhile to scrap this solution for one like that? Fixes #93450 r? `@estebank` feel free to reassign
2022-03-27Rollup merge of #91981 - estebank:tweakaroo, r=lcnrDylan DPC-9/+26
Recover suggestions and useful information lost in previous PR Follow up to #91898.
2022-03-27Provide suggestion for missing `>` in a type parameter listEsteban Kuber-0/+5
When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-6/+23
2022-03-27Eagerly replace `{integer}`/`{float}` with `i32`/`f64` for suggestionEsteban Kuber-3/+3
2022-03-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-3/+16
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-23Better suggestions for Fn trait selection errorsMichael Goulet-0/+2
2022-03-21move `adt_const_params` to its own tracking issuelcnr-39/+1
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-3/+16
2022-03-10Auto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgrbors-3/+3
Rollup of 5 pull requests Successful merges: - #92150 (Improve suggestion when casting usize to (possibly) wide pointer) - #94635 (Merge `#[deprecated]` and `#[rustc_deprecated]`) - #94657 (Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`) - #94746 (diagnostics: use rustc_on_unimplemented to recommend `[].iter()`) - #94788 (Account for suggestions for complete removal of lines) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-10Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, ↵Matthias Krüger-2/+2
r=davidtwco diagnostics: use rustc_on_unimplemented to recommend `[].iter()` To make this work, the `#[rustc_on_unimplemented]` data needs to be used to report method resolution errors, which is most of what this commit does. Fixes #94581
2022-03-10Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwcoMatthias Krüger-1/+1
Merge `#[deprecated]` and `#[rustc_deprecated]` The first commit makes "reason" an alias for "note" in `#[rustc_deprecated]`, while still prohibiting it in `#[deprecated]`. The second commit changes "suggestion" to not just be a feature of `#[rustc_deprecated]`. This is placed behind the new `deprecated_suggestion` feature. This needs a tracking issue; let me know if this PR will be approved and I can create one. The third commit is what permits `#[deprecated]` to be used when `#![feature(staged_api)]` is enabled. This isn't yet used in stdlib (only tests), as it would require duplicating all deprecation attributes until a bootstrap occurs. I intend to submit a follow-up PR that replaces all uses and removes the remaining `#[rustc_deprecated]` code after the next bootstrap. `@rustbot` label +T-libs-api +C-feature-request +A-attributes +S-waiting-on-review
2022-03-10Auto merge of #94764 - nikic:update-llvm-3, r=nagisabors-1/+0
Update LLVM submodule This merges upstream changes from the 14.x release branch. Fixes #89609. Fixes #93923. Fixes #94032.
2022-03-09Permit `#[deprecated]` in stdlibJacob Pratt-1/+1
2022-03-09diagnostics: use rustc_on_unimplemented to recommend `[].iter()`Michael Howell-2/+2
To make this work, the `#[rustc_on_unimplemented]` data needs to be used to report method resolution errors, which is most of what this commit does. Fixes #94581
2022-03-09Enable issue-23036.rs on wasm32Nikita Popov-1/+0
2022-03-09Auto merge of #94515 - estebank:tweak-move-error, r=davidtwcobors-12/+12
Tweak move error Point at method definition that causes type to be consumed. Fix #94056.
2022-03-06use impl substs in on_unimplementedMichael Goulet-2/+3
2022-03-04Change `rustc_deprecated` to use `note`Jacob Pratt-1/+1
This keeps `reason` around for the time being. This is necessary to avoid breakage during the bootstrap process. This change, as a whole, brings `#[rustc_deprecated]` more in line with `#[deprecated]`.
2022-03-04Add known-bug directive to issue #47511 test casemarmeladema-4/+5
2022-03-04Rollup merge of #94236 - reez12g:add_track_caller_87707, r=yaahcMatthias Krüger-0/+18
Add #[track_caller] to track callers when initializing poisoned Once This PR is for this Issue. https://github.com/rust-lang/rust/issues/87707 With this fix, we expect to be able to track the caller when poisoned Once is initialized.
2022-03-03Add #[track_caller] to track callers when initializing poisoned Oncereez12g-0/+18
2022-03-03Tweak move errorEsteban Kuber-12/+12
Point at method definition that causes type to be consumed. Fix #94056.
2022-03-03Bless nll tests.Camille GILLOT-1/+1
2022-03-03Cleanup feature gates.Camille GILLOT-35/+24
2022-03-02Rollup merge of #94464 - kckeiks:lifetime-elision-mismatch-hint-for-traits, ↵Matthias Krüger-0/+6
r=estebank Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls. Suggest adding a new lifetime parameter when two elided lifetimes should match up for functions in traits and impls. Issue #94462
2022-02-28Suggest adding a new lifetime parameter when two elided lifetimes should ↵Fausto-0/+6
match up for traits and impls. Issue #94462
2022-02-28Rollup merge of #94449 - GuillaumeGomez:explanation-e0726, r=UrgauMatthias Krüger-1/+2
Add long explanation for E0726 This is the cleaned up version of #87655 with the missing fixes. Part of https://github.com/rust-lang/rust/issues/61137. r? `@Urgau`
2022-02-28Tweak diagnosticsEsteban Kuber-4/+6
* Recover from invalid `'label: ` before block. * Make suggestion to enclose statements in a block multipart. * Point at `match`, `while`, `loop` and `unsafe` keywords when failing to parse their expression. * Do not suggest `{ ; }`. * Do not suggest `|` when very unlikely to be what was wanted (in `let` statements).
2022-02-28Update ui test with the add of E0726 explanationGuillaume Gomez-1/+2
2022-02-26Auto merge of #94078 - ↵bors-0/+4
TaKO8Ki:suggest-float-literal-for-float-divided-by-integer, r=estebank Suggest a float literal when dividing a floating-point type by `{integer}` closes #93829
2022-02-26suggest a float literal when dividing a floating-point type by {integer}Takayuki Maeda-0/+4
fix a message implement a rustfix-applicable suggestion implement `suggest_floating_point_literal` add `ObligationCauseCode::BinOp` remove duplicate code fix function names in uitests use `Diagnostic` instead of `DiagnosticBuilder`
2022-02-25Do not suggest using a const parameter when there are bounds on an unused ↵Chayim Refael Friedman-2/+0
type parameter The user wrote the bound, so it's obvious they want a type.
2022-02-19Rollup merge of #93658 - cchiw:issue-77443-fix, r=joshtriplettMatthias Krüger-1/+0
Stabilize `#[cfg(panic = "...")]` [Stabilization PR](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr) for #77443
2022-02-18Rollup merge of #92806 - compiler-errors:better-impl-trait-deny, r=estebankMatthias Krüger-8/+8
Add more information to `impl Trait` error Fixes #92458 Let me know if I went overboard here, or if the suggestions could use some refinement. r? `@estebank` Feel free to reassign to someone else
2022-02-18Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebankMatthias Krüger-14/+0
Add more info and suggestions to use of #[test] on invalid items This pr changes the diagnostics for using `#[test]` on an item that can't be used as a test to explain that the attribute has no meaningful effect on non-functions and suggests the use of `#[cfg(test)]` for conditional compilation instead. Example change: ```rs #[test] mod test {} ``` previously output ``` error: only functions may be used as tests --> src/lib.rs:2:1 | 2 | mod test {} | ^^^^^^^^^^^ ``` now outputs ``` error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] | ^^^^^^^ LL | mod test {} | ----------- expected a non-associated function, found a module | = note: the `#[test]` macro causes a a function to be run on a test and has no effect on non-functions help: replace with conditional compilation to make the item only exist when tests are being run | LL | #[cfg(test)] | ~~~~~~~~~~~~ ```
2022-02-17skip pointing out ambuguous impls in alloc/std crates tooMichael Goulet-25/+14
2022-02-17fix impl trait message, bless testsMichael Goulet-16/+8