about summary refs log tree commit diff
path: root/src/test/ui/traits
AgeCommit message (Collapse)AuthorLines
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`
2021-08-18Properly generate multiple candidates for trait upcasting coercion.Charles Lew-96/+12
2021-08-16Use note to point at bound introducing requirementEsteban Küber-170/+267
2021-08-12Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylevGuillaume Gomez-1/+1
Link to edition guide instead of issues for 2021 lints. This changes the 2021 lints to not link to github issues, but to the edition guide instead. Fixes #86996
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-1/+1
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-11Modify structured suggestion outputEsteban Küber-59/+68
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-09Link to edition guide instead of issues for 2021 lints.Mara Bos-1/+1
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-20/+20
2021-08-03Auto merge of #86400 - FabianWolff:issue-85735, r=estebankbors-0/+29
Remove invalid suggestion involving `Fn` trait bound This pull request closes #85735. The actual issue is a duplicate of #21974, but #85735 contains a further problem, which is an invalid suggestion if `Fn`/`FnMut`/`FnOnce` trait bounds are involved: The suggestion code checks whether the trait bound ends with `>` to determine whether it has any generic arguments, but the `Fn*` traits have a special syntax for generic arguments that doesn't involve angle brackets. The example given in #85735: ```rust trait Foo {} impl<'a, 'b, T> Foo for T where T: FnMut(&'a ()), T: FnMut(&'b ()), { } ``` currently produces: ``` error[E0283]: type annotations needed --> src/lib.rs:4:8 | 4 | T: FnMut(&'a ()), | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` | = note: cannot satisfy `T: FnMut<(&'a (),)>` help: consider specifying the type arguments in the function call | 4 | T: FnMut(&'a ())::<Self, Args>, | ^^^^^^^^^^^^^^ error: aborting due to previous error ``` which is incorrect, because there is no function call, and applying the suggestion would lead to a parse error. With my changes, I get: ``` error[E0283]: type annotations needed --> test.rs:4:8 | 4 | T: FnMut(&'a ()), | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` | ::: [...]/library/core/src/ops/function.rs:147:1 | 147 | pub trait FnMut<Args>: FnOnce<Args> { | ----------------------------------- required by this bound in `FnMut` | = note: cannot satisfy `T: FnMut<(&'a (),)>` error: aborting due to previous error ``` i.e. I have added a check to prevent the invalid suggestion from being issued for `Fn*` bounds, while the underlying issue #21974 remains for now.
2021-08-03Remove invalid suggestion involving Fn trait boundFabian Wolff-0/+29
2021-08-03bless trait upcasting tests under poloniusRémy Rakic-0/+55
The diagnostics are different from the NLL ones but the same errors are emitted.
2021-08-03Various adjustments to historic tests and documents.Charles Lew-192/+327
2021-08-03Added tests.Alexander Regueiro-0/+764
2021-08-03Implement pointer casting.Charles Lew-0/+49
2021-07-31Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakisbors-0/+391
Trait upcasting coercion (part1) This revives the first part of earlier PR #60900 . It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details. This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part. (I hope i have dealt with the `ExistentialTraitRef` values correctly...) The next part will be implementing the pointer casting.
2021-07-31Add more tests to cover more corner cases of type-checking.Charles Lew-0/+342
2021-07-31Implement trait upcasting coercion type-checking.Charles Lew-0/+49
2021-07-30Do not discard `?Sized` type params and suggest their removalEsteban Küber-0/+9
2021-07-27Make all tests use type_alias_impl_trait feature instead of minSantiago Pastorino-1/+1
2021-07-22Add comment and more tests.Charles Lew-0/+384
2021-07-20Switch to store `Instance` directly within `VtblEntry`, fix `TraitVPtr` ↵Charles Lew-80/+48
representation.
2021-07-20Add internal attribute and tests.Charles Lew-0/+170
2021-07-19Auto merge of #87225 - estebank:cleanup, r=oli-obkbors-29/+95
Various diagnostics clean ups/tweaks * Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-29/+95
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-18Add `#![allow(dyn_drop)]` to test cases with `dyn Drop` in themMichael Howell-3/+4
These are all testing corner-cases in the compiler. Adding a new warning broke these test cases, but --cap-lints stops it from actually breaking things in production.
2021-06-29Return `EvaluatedToOk` when type in outlives predicate is globalAaron Hill-15/+15
A global type doesn't reference any local regions or types, so it's guaranteed to outlive any region.
2021-06-26Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkovbors-1/+1
Use HTTPS links where possible While looking at #86583, I wondered how many other (insecure) HTTP links were in `rustc`. This changes most other `http` links to `https`. While most of the links are in comments or documentation, there are a few other HTTP links that are used by CI that are changed to HTTPS. Notes: - I didn't change any to or in licences - Some links don't support HTTPS :( - Some `http` links were dead, in those cases I upgraded them to their new places (all of which used HTTPS)
2021-06-25Address PR feedbackRyan Levick-2/+2
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-2/+2
2021-06-23Use HTTPS links where possibleSmitty-1/+1
2021-06-22Rollup merge of #86393 - yerke:add-test-for-issue-52025, r=JohnTitorYuki Okushi-0/+57
Add regression test for issue #52025 Closes #52025 Took the test from #52025
2021-06-22add regression test for issue #52025Yerkebulan Tulibergenov-0/+57
2021-06-15add regression test for issue #78632Yerkebulan Tulibergenov-0/+59
2021-05-26Lint against non-camelCase trait alias namesSmitty-0/+18
Type aliases are linted as such, so (unstable) trait aliases should be treated the same way.
2021-05-24Replace more "NULL" with "null"LeSeulArtichaut-1/+1
2021-05-20Check for raw pointer dereference in THIR unsafeckLeSeulArtichaut-1/+15
2021-05-15Revert to only using opportunistic_resolve_vars for existing placesJack Huey-2/+6
2021-05-14Store Option<Region> as value for RegionVidJack Huey-6/+2
2021-05-14Make the UnifyValue for RegionVid ()Jack Huey-1/+5
2021-05-13Auto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726bors-0/+160
have on_completion record subcycles have on_completion record subcycles Rework `on_completion` method so that it removes all provisional cache entries that are "below" a completed node (while leaving those entries that are not below the node). This corrects an imprecise result that could in turn lead to an incremental compilation failure. Under the old scheme, if you had: * A depends on... * B depends on A * C depends on... * D depends on C * T: 'static then the provisional results for A, B, C, and D would all be entangled. Thus, if A was `EvaluatedToOkModuloRegions` (because of that final condition), then the result for C and D would also be demoted to "ok modulo regions". In reality, though, the result for C depends only on C and itself, and is not dependent on regions. If we happen to evaluate the cycle starting from C, we would never reach A, and hence the result would be "ok". Under the new scheme, the provisional results for C and D are moved to the permanent cache immediately and are not affected by the result of A. Fixes #83538 r? `@Aaron1011`
2021-05-13have on_completion record subcyclesNiko Matsakis-5/+61
Rework `on_completion` method so that it removes all provisional cache entries that are "below" a completed node (while leaving those entries that are not below the node). This corrects an imprecise result that could in turn lead to an incremental compilation failure. Under the old scheme, if you had: * A depends on... * B depends on A * C depends on... * D depends on C * T: 'static then the provisional results for A, B, C, and D would all be entangled. Thus, if A was `EvaluatedToOkModuloRegions` (because of that final condition), then the result for C and D would also be demoted to "ok modulo regions". In reality, though, the result for C depends only on C and itself, and is not dependent on regions. If we happen to evaluate the cycle starting from C, we would never reach A, and hence the result would be "ok". Under the new scheme, the provisional results for C and D are moved to the permanent cache immediately and are not affected by the result of A.
2021-05-13introduce a unit testing feature `rustc_evaluate_where_clauses`Niko Matsakis-0/+104
This attribute will cause us to invoke evaluate on every where clause of an invoked function and to generate an error with the result. Without this, it is very difficult to observe the effects of invoking the trait evaluator.
2021-05-13Auto merge of #85041 - mibac138:suggest-generics, r=estebankbors-2/+13
Suggest adding a type parameter for impls Add a new suggestion upon encountering an unknown type in a `impl` that suggests adding a new type parameter. This diagnostic suggests to add a new type parameter even though it may be a const parameter, however after adding the parameter and running rustc again a follow up error steers the user to change the type parameter to a const parameter. ```rust struct X<const C: ()>(); impl X<C> {} ``` suggests ``` error[E0412]: cannot find type `C` in this scope --> bar.rs:2:8 | 1 | struct X<const C: ()>(); | ------------------------ similarly named struct `X` defined here 2 | impl X<C> {} | ^ | help: a struct with a similar name exists | 2 | impl X<X> {} | ^ help: you might be missing a type parameter | 2 | impl<C> X<C> {} | ^^^ ``` After adding a type parameter the code now becomes ```rust struct X<const C: ()>(); impl<C> X<C> {} ``` and the error now fully steers the user towards the correct code ``` error[E0747]: type provided when a constant was expected --> bar.rs:2:11 | 2 | impl<C> X<C> {} | ^ | help: consider changing this type parameter to be a `const` generic | 2 | impl<const C: ()> X<C> {} | ^^^^^^^^^^^ ``` r? `@estebank` Somewhat related #84946
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-2/+2
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-11improve diagnosts for GATsb-naber-15/+15
2021-05-05Suggest adding a type parameter for implsmibac138-2/+13