about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2022-10-30Add parser testmejrs-0/+17
2022-10-30Rollup merge of #103560 - zbyrn:issue-103358-fix, r=cjgillotDylan DPC-10/+11
Point only to the identifiers in the typo suggestions of shadowed names instead of the entire struct Fixes #103358. As discussed in the issue, the `Span` of the candidate `Ident` for a typo replacement is stored alongside its `Symbol` in `TypoSuggestion`. Then, the span of the identifier is what the "you might have meant to refer to" note is pointed at, rather than the entire struct definition. Comments in #103111 and the issue both suggest that it is desirable to: 1. include names defined in the same crate as the typo, 2. ignore names defined elsewhere such as in `std`, _and_ 3. include names introduced indirectly via `use`. Since a name from another crate but introduced via `use` has non-local `def_id`, to achieve this, a suggestion is displayed if either the `def_id` of the suggested name is local, or the `span` of the suggested name is in the same file as the typo itself. Some UI tests have also been modified to reflect this change. r? `@cjgillot`
2022-10-30Rollup merge of #93582 - WaffleLapkin:rpitirpit, r=compiler-errorsDylan DPC-75/+277
Allow `impl Fn() -> impl Trait` in return position _This was originally proposed as part of #93082 which was [closed](https://github.com/rust-lang/rust/pull/93082#issuecomment-1027225715) due to allowing `impl Fn() -> impl Trait` in argument position._ This allows writing the following function signatures: ```rust fn f0() -> impl Fn() -> impl Trait; fn f3() -> &'static dyn Fn() -> impl Trait; ``` These signatures were already allowed for common traits and associated types, there is no reason why `Fn*` traits should be special in this regard. `impl Trait` in both `f0` and `f3` means "new existential type", just like with `-> impl Iterator<Item = impl Trait>` and such. Arrow in `impl Fn() ->` is right-associative and binds from right to left, it's tested by [this test](https://github.com/WaffleLapkin/rust/blob/a819fecb8dea438fc70488ddec30a61e52942672/src/test/ui/impl-trait/impl_fn_associativity.rs). There even is a test that `f0` compiles: https://github.com/rust-lang/rust/blob/2f004d2d401682e553af3984ebd9a3976885e752/src/test/ui/impl-trait/nested_impl_trait.rs#L25-L28 But it was changed in [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-ccecca938872d65ffe8cd1c3ef1956e309fac83bcda547d8b16b89257e53a437R37) to test the opposite, probably unintentionally given [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-5a02f1ed43debed1fd24f7aad72490064f795b9420f15d847bac822aa4621a1cR476-R477). r? `@nikomatsakis` ---- This limitation is especially annoying with async code, since it forces one to write this: ```rust trait AsyncFn3<A, B, C>: Fn(A, B, C) -> <Self as AsyncFn3<A, B, C>>::Future { type Future: Future<Output = Self::Out>; type Out; } impl<A, B, C, Fut, F> AsyncFn3<A, B, C> for F where F: Fn(A, B, C) -> Fut, Fut: Future, { type Future = Fut; type Out = Fut::Output; } fn async_closure() -> impl AsyncFn3<i32, i32, i32, Out = u32> { |a, b, c| async move { (a + b + c) as u32 } } ``` Instead of: ```rust fn async_closure() -> impl Fn(i32, i32, i32) -> impl Future<Output = u32> { |a, b, c| async move { (a + b + c) as u32 } } ```
2022-10-30Reduce span of let else irrefutable_let_patterns warningest31-5/+18
Huge spans aren't good for IDE users as they underline constructs that are possibly multiline.
2022-10-30fix #103783, fix ICE checking transmutability of NaughtyLenArrayyukang-0/+33
2022-10-30Rollup merge of #103124 - ldm0:nohard_tests, r=Mark-SimulacrumMatthias Krüger-0/+149
Add tests for autoderef on block tail ref: https://github.com/rust-lang/rust/pull/83850#issuecomment-1270598506
2022-10-29Auto merge of #103450 - cjgillot:elision-nodedup, r=Mark-Simulacrumbors-1/+19
Do not consider repeated lifetime params for elision. Fixes https://github.com/rust-lang/rust/issues/103330
2022-10-29Run rustfix test for 103317 caseKitsu-3/+18
2022-10-29Rollup merge of #103699 - compiler-errors:dyn-star-cast-bad, r=TaKO8KiGuillaume Gomez-0/+58
Emit proper error when casting to `dyn*` Fixes #103679
2022-10-29Rollup merge of #103704 - xxchan:xxchan/applicable-bug, r=compiler-errorsMatthias Krüger-0/+37
Add a test for TAIT used with impl/dyn Trait inside RPIT close https://github.com/rust-lang/rust/issues/101750
2022-10-29Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obkMatthias Krüger-4/+4
Note scope of TAIT more accurately This maybe explains why the person was confused in #101897, since we say "same module" but really should've said "same impl". r? ``@oli-obk``
2022-10-29Rollup merge of #103342 - Rageking8:add-test-for-issue-98634, r=compiler-errorsMatthias Krüger-0/+110
Add test for issue 98634 Fixes #98634
2022-10-29Auto merge of #102233 - petrochenkov:effvis, r=jackh726bors-209/+209
privacy: Rename "accessibility levels" to "effective visibilities" And a couple of other naming and comment tweaks. Related to https://github.com/rust-lang/rust/issues/48054 For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often. So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.
2022-10-28Add a test for TAIT used with impl/dyn Trait inside RPITxxchan-0/+37
2022-10-28Auto merge of #103683 - ↵bors-0/+5
fee1-dead-contrib:fix-deferred-cast-checks-constness, r=oli-obk Retain ParamEnv constness when running deferred cast checks Fixes #103677.
2022-10-28Emit proper error when casting to Ddyn-starMichael Goulet-0/+58
2022-10-28Retain ParamEnv constness when running deferred cast checksDeadbeef-0/+5
Fixes #103677.
2022-10-28libtest: run all tests in their own thread, if supported by the hostRalf Jung-2/+2
2022-10-28Auto merge of #103671 - matthiaskrgr:rollup-iuugpep, r=matthiaskrgrbors-28/+761
Rollup of 5 pull requests Successful merges: - #102642 (Add tests for static async functions in traits) - #103283 (Add suggestions for unsafe impl error codes) - #103523 (Fix unwanted merge of inline doc comments for impl blocks) - #103550 (diagnostics: do not suggest static candidates as traits to import) - #103641 (Don't carry MIR location in `ConstraintCategory::CallArgument`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-28Rollup merge of #103631 - Rageking8:Add-test-for-issue-36007, r=compiler-errorsMatthias Krüger-0/+20
Add test for issue 36007 Fixes #36007 r? ``@compiler-errors``
2022-10-28Rollup merge of #103609 - BoxyUwU:fix_impl_self_cycle, r=compiler-errorsMatthias Krüger-74/+27
Emit a nicer error on `impl Self {` currently it emits a "cycle detected error" but this PR makes it emit a more user friendly error specifically saying that `Self` is disallowed in that position. this is a pretty hacky fix so i dont expect this to be merged (I basically only made this PR because i wanted to see if CI passes) r? ``@compiler-errors``
2022-10-28Rollup merge of #103608 - compiler-errors:rpitit-early-lt, r=cjgillotMatthias Krüger-0/+23
Remap early bound lifetimes in return-position `impl Trait` in traits too Fixes part of #103457 r? ``@cjgillot,`` though feel free to reassign, just thought you'd have sufficient context to review.
2022-10-28Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillotMatthias Krüger-28/+94
Don't carry MIR location in `ConstraintCategory::CallArgument` It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies. So instead, revert the commit a6b5f95fb028f9feb4a2957c06b35035be2c6155, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in #103220. Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen. Fixes #103624
2022-10-28Rollup merge of #103550 - notriddle:notriddle/no-suggest-static-candidates, ↵Matthias Krüger-0/+34
r=wesleywiser diagnostics: do not suggest static candidates as traits to import If it's a static candidate, then it's already implemented. Do not suggest it a second time for implementing. Partial fix for #102354
2022-10-28Rollup merge of #103283 - nbarrios1337:unsafe-impl-suggestions, r=cjgillotMatthias Krüger-0/+54
Add suggestions for unsafe impl error codes Adds suggestions for users to add `unsafe` to trait impls that should be `unsafe`, and remove `unsafe` from trait impls that do not require `unsafe` With the folllowing code: ```rust struct Foo {} struct Bar {} trait Safe {} unsafe trait Unsafe {} impl Safe for Foo {} // ok impl Unsafe for Foo {} // E0200 unsafe impl Safe for Bar {} // E0199 unsafe impl Unsafe for Bar {} // ok // omitted empty main fn ``` The current rustc output is: ``` error[E0199]: implementing the trait `Safe` is not unsafe --> e0200.rs:13:1 | 13 | unsafe impl Safe for Bar {} // E0199 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration --> e0200.rs:11:1 | 11 | impl Unsafe for Foo {} // E0200 | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors Some errors have detailed explanations: E0199, E0200. For more information about an error, try `rustc --explain E0199`. ``` With this PR, the future rustc output would be: ``` error[E0199]: implementing the trait `Safe` is not unsafe --> ../../temp/e0200.rs:13:1 | 13 | unsafe impl Safe for Bar {} // E0199 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `unsafe` from this trait implementation | 13 - unsafe impl Safe for Bar {} // E0199 13 + impl Safe for Bar {} // E0199 | error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration --> ../../temp/e0200.rs:11:1 | 11 | impl Unsafe for Foo {} // E0200 | ^^^^^^^^^^^^^^^^^^^^^^ | = note: the trait `Unsafe` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword help: add `unsafe` to this trait implementation | 11 | unsafe impl Unsafe for Foo {} // E0200 | ++++++ error: aborting due to 2 previous errors Some errors have detailed explanations: E0199, E0200. For more information about an error, try `rustc --explain E0199`. ``` ``@rustbot`` label +T-compiler +A-diagnostics +A-suggestion-diagnostics
2022-10-28Rollup merge of #102642 - bryangarza:afit-tests, r=compiler-errorsMatthias Krüger-0/+579
Add tests for static async functions in traits This patch adds test cases for AFIT, the majority of which are currently expected to run as `check-fail`. --- Note: I grabbed the cases from https://hackmd.io/SwRcXCiWQV-WRJ4BYs53fA Also, I'm not sure if the `async-associated-types2` and `async-associated-types2-desugared` are correct, I modified them a bit from the examples in the HackMD.
2022-10-28add test for issue 98634Rageking8-0/+110
2022-10-27Update tests based on feedbackBryan Garza-26/+7
- Add comment to some tests that will break when #102745 is implemented - Mark a test with known-bug - Delete duplicate test
2022-10-27Update src/test/ui/async-await/in-trait/async-example.rsBryan Garza-2/+2
Co-authored-by: Michael Goulet <michael@errs.io>
2022-10-27Add additional tests for static AFITBryan Garza-0/+169
2022-10-27Update tests based on feedbackBryan Garza-33/+48
2022-10-27Update static AFIT tests based on feedbackBryan Garza-144/+28
2022-10-27Add tests for static async functions in traitsBryan Garza-0/+530
This patch adds test cases for AFIT, the majority of which are currently expected to run as `check-fail`.
2022-10-27use proper spansBoxy-20/+39
2022-10-27DoItBoxy-82/+16
2022-10-27Only ban duplication across parameters.Camille GILLOT-0/+3
2022-10-27Fix rustc_parse_format spans following escaped utf-8 multibyte charsAlex Macleod-0/+82
2022-10-27Erase regions from CallArgument, add test + blessMichael Goulet-6/+72
2022-10-27Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"Michael Goulet-22/+22
This reverts commit a6b5f95fb028f9feb4a2957c06b35035be2c6155.
2022-10-27add test for issue 36007Rageking8-0/+20
2022-10-27Rollup merge of #103110 - RalfJung:manual-send, r=thomccMatthias Krüger-1/+1
remove redundant Send impl for references Also explain why the other instance is not redundant, move it next to the trait they are implementing, and out of the redundant module. This seems to go back all the way to https://github.com/rust-lang/rust/commit/35ca50bd5676db31a8074a216d1aadad7d434de8, not sure why the module was added. The instance for `&mut` is the default instance we get anyway, and we don't have anything similar for `Sync`, so IMO we should be consistent and not have the redundant instance here, either.
2022-10-27Auto merge of #103623 - matthiaskrgr:rollup-318yc1t, r=matthiaskrgrbors-16/+104
Rollup of 9 pull requests Successful merges: - #103035 (Even nicer errors from assert_unsafe_precondition) - #103106 (Try to say that memory outside the AM is always exposed) - #103475 (Make param index generation a bit more robust) - #103525 (Move a wf-check into the site where the value is instantiated) - #103564 (library: allow some unused things in Miri) - #103586 (Process registered region obligation in `resolve_regions_with_wf_tys`) - #103592 (rustdoc: remove redundant CSS selector `.notable-traits .notable`) - #103593 (Remove an unused parser function (`Expr::returns`)) - #103611 (Add test for issue 103574) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-27Add a test for issue #101637Byron Zhong-0/+96
2022-10-27Rollup merge of #103611 - Rageking8:fix-103574, r=lcnrMatthias Krüger-4/+56
Add test for issue 103574 Fixes #103574 Together with some slight formatting. r? `@lcnr`
2022-10-27Rollup merge of #103586 - compiler-errors:issue-103573, r=jackh726Matthias Krüger-0/+36
Process registered region obligation in `resolve_regions_with_wf_tys` Fixes #103573
2022-10-27Rollup merge of #103525 - oli-obk:const_impl_on_non_const_trait, r=lcnrMatthias Krüger-12/+12
Move a wf-check into the site where the value is instantiated r? ``@lcnr``
2022-10-27Auto merge of #103601 - compiler-errors:no-opaque-probe-in-nll-relate, r=oli-obkbors-0/+24
Remove `commit_if_ok` probe from NLL type relation It was not really necessary to add the `commit_if_ok` in #100092 -- I added it to protect us against weird inference error messages due to recursive RPIT calls, but we are always on the error path when this happens anyways, and I can't come up with an example that makes this manifest. Fixes #103599 r? `@oli-obk` since you reviewed #100092, feel free to re-roll. :b: :loudspeaker: beta-nominating this since it's on beta (which forks in ~a week~ two days :fearful:) -- worst case we could revert the original PR on beta and land this on nightly, to give it some extra soak time...
2022-10-27Correct inconsistent error messages in testsByron Zhong-19/+15
2022-10-27add tests and slight formattingRageking8-4/+56
2022-10-27Remap early bound lifetimes tooMichael Goulet-0/+23