about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-10-30Rollup merge of #103746 - notriddle:notriddle/incoherent-dyn-trait, ↵Michael Howell-0/+35
r=GuillaumeGomez rustdoc: add support for incoherent impls on structs and traits Fixes #103170
2022-10-30Rollup merge of #101428 - JakobDegen:build-tests, r=oli-obkMichael Howell-110/+134
Add mir building test directory The first commit renames `mir-map.0` mir dumps to `built.after` dumps. I am happy to drop this commit if someone can explain the origin of the name. The second commit moves a bunch of mir building tests into their own directory. I did my best to make sure that all of these tests are actually testing mir building, and not just incidentally using `built.after` r? ``@oli-obk``
2022-10-30Rollup merge of #97971 - Soveu:varargs, r=jackh726Michael Howell-21/+104
Enable varargs support for calling conventions other than C or cdecl This patch makes it possible to use varargs for calling conventions, which are either based on C (efiapi) or C is based on them (sysv64 and win64). Also pinging ``@phlopsi,`` because he noticed first this oversight when writing a library for UEFI.
2022-10-31Use `br` instead of `switch` in more cases.Nicholas Nethercote-29/+83
`codegen_switchint_terminator` already uses `br` instead of `switch` when there is one normal target plus the `otherwise` target. But there's another common case with two normal targets and an `otherwise` target that points to an empty unreachable BB. This comes up a lot when switching on the tags of enums that use niches. The pattern looks like this: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 switch i64 %_6, label %bb3 [ i64 0, label %bb4 i64 1, label %bb2 ] bb3: ; preds = %bb1 unreachable ``` This commit adds code to convert the `switch` to a `br`: ``` bb1: ; preds = %bb6 %3 = load i8, ptr %_2, align 1, !range !9, !noundef !4 %4 = sub i8 %3, 2 %5 = icmp eq i8 %4, 0 %_6 = select i1 %5, i64 0, i64 1 %6 = icmp eq i64 %_6, 0 br i1 %6, label %bb4, label %bb2 bb3: ; No predecessors! unreachable ``` This has a surprisingly large effect on compile times, with reductions of 5% on debug builds of some crates. The reduction is all due to LLVM taking less time. Maybe LLVM is just much better at handling `br` than `switch`. The resulting code is still suboptimal. - The `icmp`, `select`, `icmp` sequence is silly, converting an `i1` to an `i64` and back to an `i1`. But with the current code structure it's hard to avoid, and LLVM will easily clean it up, in opt builds at least. - `bb3` is usually now truly dead code (though not always, so it can't be removed universally).
2022-10-30better error for rustc_strict_coherence misuseMichael Goulet-0/+17
2022-10-30Auto merge of #103299 - nikic:usub-overflow, r=wesleywiserbors-0/+16
Don't use usub.with.overflow intrinsic The canonical form of a usub.with.overflow check in LLVM are separate sub + icmp instructions, rather than a usub.with.overflow intrinsic. Using usub.with.overflow will generally result in worse optimization potential. The backend will attempt to form usub.with.overflow when it comes to actual instruction selection. This is not fully reliable, but I believe this is a better tradeoff than using the intrinsic in IR. Fixes #103285.
2022-10-30All verbosity checks in `PrettyPrinter` now go through ↵Sarthak Singh-5/+11
`PrettyPrinter::should_print_verbose`
2022-10-30rustdoc: Do not add external traits to the crate in `register_res`Vadim Petrochenkov-0/+12
It's not clear why it was done, and apparently it's no longer necessary now. Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.
2022-10-30Add regression test for reexports in search resultsGuillaume Gomez-0/+28
2022-10-30Add parser testmejrs-0/+17
2022-10-30Rollup merge of #103588 - weihanglo:rustdoc/url-redirect, r=notriddleDylan DPC-6/+6
rustdoc: add missing URL redirect https://github.com/rust-lang/rust/pull/94753 missed some redirect settings, and one of the missing URL shows up in an error message. This PR adds those redirects.
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-29rustdoc: add support for incoherent impls on structs and traitsMichael Howell-0/+35
Fixes #103170
2022-10-30fix #103783, fix ICE checking transmutability of NaughtyLenArrayyukang-0/+33
2022-10-30Rollup merge of #103253 - notriddle:notriddle/test-case-masked-blanket-impl, ↵Matthias Krüger-0/+5
r=Mark-Simulacrum rustdoc: add test case for masked blanket impl
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-29Make --static-root-path point to static.filesJacob Hoffman-Andrews-3/+3
2022-10-29rustdoc: add hash to filename of toolchain filesJacob Hoffman-Andrews-14/+14
All static files used by rustdoc are now stored in static.files/ and include a hash of their contents. They no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration.
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 #103653 - GuillaumeGomez:missing-impl-private-json, r=notriddleGuillaume Gomez-0/+28
Add missing impl blocks for item reexported from private mod in JSON output Fixes #102583. Since we don't inline for the JSON output, the impl blocks from private modules are not present when we generate the output. To go around this limitation, in case the impl block doesn't have `#[doc(hidden)]` and is implementing a public item, we don't strip it. cc `@fmease` `@aDotInTheVoid` r? `@notriddle`
2022-10-29Rollup merge of #103618 - nnethercote:rename-OwnerId-fields, r=compiler-errorsGuillaume Gomez-6/+6
Rename some `OwnerId` fields. `@spastorino` noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone. r? `@compiler-errors`
2022-10-29Rollup merge of #102721 - nbdd0121:panic, r=AmanieuGuillaume Gomez-0/+31
Prevent foreign Rust exceptions from being caught Fix #102715 Use the address of a static variable (which is guaranteed to be unique per copy of std) to tell apart if a Rust exception comes from local or foreign Rust code, and abort for the latter.
2022-10-29Add regression test for missing item from private mod in JSON outputGuillaume Gomez-0/+28
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-6/+6
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
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-28Auto merge of #103071 - wesleywiser:fix_inlined_line_numbers, r=davidtwcobors-0/+25
Fix line numbers for MIR inlined code `should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code. Fixes #103068
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-5/+5
2022-10-28Auto merge of #103671 - matthiaskrgr:rollup-iuugpep, r=matthiaskrgrbors-28/+774
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 #103585 - GuillaumeGomez:source-line-css, r=notriddleMatthias Krüger-1/+43
Migrate source line numbers CSS to CSS variables Part of https://github.com/rust-lang/rust/pull/98460. No UI changes. r? ``@notriddle``
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 #103523 - GuillaumeGomez:inline-doc-comment-impl-block, ↵Matthias Krüger-0/+13
r=notriddle Fix unwanted merge of inline doc comments for impl blocks Fixes https://github.com/rust-lang/rust/issues/102909. We need this merge mechanism for inlined items but it's completely unwanted for impl blocks (at least the doc comments are, not the other attributes) since we want to keep what `cfg()` is put on the `pub use` or other attributes. r? ``@notriddle``
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