summary refs log tree commit diff
path: root/src/test/ui/traits
AgeCommit message (Collapse)AuthorLines
2022-01-05Add test with `#[rustc_evaluate_where_clauses]`Wesley Wiser-0/+150
As suggested via reviewer feedback.
2022-01-05Fix HashStable implementation on InferTyMichael Goulet-0/+17
2021-11-20Align multiline messages to their label (add left margin)Esteban Kuber-148/+148
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-93/+0
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-21/+73
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-18Move some tests to more reasonable directoriesCaio-0/+132
2021-11-16Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkovYuki Okushi-9/+3
Fixes incorrect handling of TraitRefs when emitting suggestions. Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE. Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations. This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
2021-11-14Move some tests to more reasonable directoriesCaio-0/+409
2021-11-13Fix handling of substitutions and binders when deciding whether to suggest ↵Jakob Degen-9/+3
references When suggesting references, substitutions were being forgotten and some types were misused. This led to at least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to diagnostics changing, and tests have been adjusted.
2021-11-10no overlap errors after failing the orphan checklcnr-14/+14
2021-11-06Move some tests to more reasonable directoriesCaio-0/+248
2021-10-28Add test casesIlya Yanok-0/+41
2021-10-25fix(rustc_typeck): report function argument errors on matching typeMichael Howell-3/+3
Fixes #90101
2021-10-24Always sort suggestions before emitting themEsteban Kuber-2/+2
2021-10-24Point at overlapping impls when type annotations are neededEsteban Kuber-15/+117
2021-10-23Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakisbors-22/+13
Implement coherence checks for negative trait impls The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3). This feature is necessary to handle the following from impl on box. ```rust impl From<&str> for Box<dyn Error> { ... } ``` Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile. We would have this in `alloc`: ```rust impl From<&str> for Box<dyn Error> {} // A impl<E> From<E> for Box<dyn Error> where E: Error {} // B ``` and this in `core`: ```rust trait Error {} impl !Error for &str {} ``` r? `@nikomatsakis` This PR was built on top of `@yaahc` PR #85764. Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-22nice_region_error: Include lifetime placeholders in error outputMichael Howell-8/+8
As you can see in src/test/ui/traits/self-without-lifetime-constraint.stderr you can get very confusing type names if you don't have this. Fixes #87763
2021-10-20Only assemble_candidates_from_impls for polarity NegativeSantiago Pastorino-22/+13
2021-10-13Auto merge of #89555 - oli-obk:nll_member_constraint_diag, r=estebankbors-10/+10
Remove textual span from diagnostic string This is an unnecessary repetition, as the diagnostic prints the span anyway in the source path right below the message. I further removed the identification of the node, as that does not give any new information in any of the cases that are changed in tests. EDIT: also inserted a suggestion that other diagnostics were already emitting
2021-10-13Remove textual span from diagnostic stringOli Scherer-10/+10
2021-10-12add some more testcasesMarcel Hellwig-0/+136
2021-10-07Rollup merge of #89461 - crlf0710:dyn_upcasting_lint, r=nikomatsakisGuillaume Gomez-0/+41
Add `deref_into_dyn_supertrait` lint. Initial implementation of #89460. Resolves #89190. Maybe also worth a beta backport if necessary. r? `@nikomatsakis`
2021-10-04Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwcoJubilee-4/+4
Deny `where` clauses on `auto` traits Fixes #84075.
2021-10-04Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebankJubilee-36/+36
Practice diagnostic message convention Detected by #89455. r? ```@estebank```
2021-10-03Deny `where` clauses on `auto` traitsFabian Wolff-4/+4
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-36/+36
2021-10-03Add `deref_into_dyn_supertrait` lint.Charles Lew-0/+41
2021-10-02Consistently use 'supertrait'.Bruce Mitchener-61/+61
A subset of places referred to 'super-trait', so this changes them to all use 'supertrait'. This matches 'supertype' and some other usages. An exception is 'auto-trait' which is consistently used in that manner.
2021-09-30add regression test for issue 89119Rémy Rakic-0/+71
2021-09-28Improve help for recursion limit errorsRoss MacArthur-1/+1
2021-09-27Auto merge of #89263 - ↵bors-8/+14
TaKO8Ki:suggest-both-immutable-and-mutable-trait-implementations, r=estebank Suggest both of immutable and mutable trait implementations closes #85865
2021-09-27better suggestionsTakayuki Maeda-6/+8
2021-09-26fix the relevant testsTakayuki Maeda-4/+8
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-33/+40
2021-09-17Rollup merge of #88883 - c410-f3r:tests, r=petrochenkovYuki Okushi-0/+103
Move some tests to more reasonable directories - 7 cc #73494 r? ``@petrochenkov``
2021-09-16Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisabors-33/+60
Point at argument instead of call for their obligations When an obligation is introduced by a specific `fn` argument, point at the argument instead of the `fn` call if the obligation fails to be fulfilled. Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`. When giving an error about an obligation introduced by a function call that an argument doesn't fulfill, and that argument is a block, add a span_label pointing at the innermost tail expression. Current output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:31 | 2 | let p = Some(45).and_then({ | ______________________--------_^ | | | | | required by a bound introduced by this call 3 | | |x| println!("doubling {}", x); 4 | | Some(x * 2) | | ----------- 5 | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Previous output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:22 | 2 | let p = Some(45).and_then({ | ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Partially address #27300. Will require rebasing on top of #88546.
2021-09-16Remove unnecessary labelEsteban Kuber-4/+1
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-32/+62
2021-09-16Refactor `FulfillmentError` to track less dataEsteban Kuber-2/+2
Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`.
2021-09-15Move some tests to more reasonable directoriesCaio-0/+103
2021-09-15Move object safety suggestions to the end of the errorEsteban Kuber-7/+7
2021-09-13Auto merge of #87915 - estebank:fancy-spans, r=oli-obkbors-1/+1
Use smaller spans for some structured suggestions Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts
2021-09-05Stop allocating vtable entries for non-object-safe methodsGary Guo-4/+41
2021-09-02Report cycle error using 'deepest' obligation in the cycleAaron Hill-12/+30
2021-09-02Preserve most sub-obligations in the projection cacheAaron Hill-27/+9
2021-08-27Don't use `guess_head_span` in `predicates_of` for foreign spanAaron Hill-2/+6
Previously, the result of `predicates_of` for a foreign trait would depend on the *current* state of the corresponding source file in the foreign crate. This could lead to ICEs during incremental compilation, since the on-disk contents of the upstream source file could potentially change without the upstream crate being recompiled. Additionally, this ensure that that the metadata we produce for a crate only depends on its *compiled* upstream dependencies (e.g an rlib or rmeta file), *not* the current on-disk state of the upstream crate source files.
2021-08-22Fix typos “a”→“an”Frank Steffahn-2/+2
2021-08-21Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakisbors-96/+51
Trait upcasting coercion (part 3) By using separate candidates for each possible choice, this fixes type-checking issues in previous commits. r? `@nikomatsakis`
2021-08-18Add a new test case to verify behavior.Charles Lew-0/+39
2021-08-18Auto merge of #87738 - lqd:polonius-master, r=nikomatsakisbors-0/+55
Update `polonius-engine` to 0.13.0 This PR updates the use of `polonius-engine` to the recently released 0.13.0: - this version renamed a lot of relations to match the current terminology - "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again - some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc. In particular: - a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs - others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name - a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius - some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical. - in a few cases Polonius gets a chance to emit more errors than NLLs A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60): - `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation - `src/test/ui/numbers-arithmetic/num-wrapping.rs` - `src/test/ui/issues/issue-72933-match-stack-overflow.rs` - `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs` - `src/test/ui/repr/repr-no-niche.rs` In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors: - `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static - `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error We'll keep talking about this at the next sprint as well. cc `@rust-lang/wg-polonius` r? `@nikomatsakis`