about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-05-13Add mir-opt test.Camille GILLOT-0/+173
2023-05-13Add debuginfo test.Camille GILLOT-0/+165
2023-05-13Support ConstantIndex in debuginfo.Camille GILLOT-12/+3
2023-05-13Implement references VarDebugInfo.Camille GILLOT-334/+331
2023-05-13Auto merge of #111526 - Dylan-DPC:rollup-h75agro, r=Dylan-DPCbors-184/+371
Rollup of 6 pull requests Successful merges: - #110454 (Require impl Trait in associated types to appear in method signatures) - #111096 (Add support for `cfg(overflow_checks)`) - #111451 (Note user-facing types of coercion failure) - #111469 (Fix data race in llvm source code coverage) - #111494 (Encode `VariantIdx` so we can decode ADT variants in the right order) - #111499 (asm: loongarch64: Drop efiapi) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-13Rollup merge of #111494 - compiler-errors:variant-order, r=petrochenkovDylan DPC-0/+18
Encode `VariantIdx` so we can decode ADT variants in the right order As far as I can tell, we don't guarantee anything about the ordering of `DefId`s and module children... The code that motivated this PR (#111483) looks something like: ```rust #[derive(Protocol)] pub enum Data { #[protocol(discriminator(0x00))] Disconnect(Disconnect), EncryptionRequest, /* more variants... */ } ``` The specific macro ([`protocol`](https://github.com/dylanmckay/protocol)) doesn't really matter, but as far as I can tell (from calls to `build_reduced_graph`), the presence of that `#[protocol(..)]` helper attribute causes the def-id of the `Disconnect` enum variant to be collected *after* its siblings, and it shows up after the other variants in `module_children`. When we decode the variants for `Data` in a child crate (an example test, in this case), this means that the `Disconnect` variant is moved to the end of the variants list, and all of the other variants now have incorrect relative discriminant data, causing the ICE. This PR fixes this by sorting manually by variant index after they are decoded. I guess there are alternative ways of fixing this, such as not reusing `module_children_non_reexports` to encode the order-sensitive ADT variants, or to do some sorting in `rustc_resolve`... but none of those seemed particularly satisfying either. ~I really struggled to create a reproduction here -- it required at least 3 crates, one of which is a proc macro, and then some code to actually compute discriminants in the child crate... Needless to say, I failed to repro this in a test, but I can confirm that it fixes the regression in #111483.~ Test exists now. r? `@petrochenkov` but feel free to reassign. ~Again, sorry for no test, but I hope the explanation at least suggests why a fix like this is likely necessary.~ Feedback is welcome.
2023-05-13Rollup merge of #111469 - Dushistov:fix-coverage-data-race, r=wesleywiserDylan DPC-1/+1
Fix data race in llvm source code coverage Fixes #91092 . Before this patch, increment of counters for code coverage looks like this: ``` movq .L__profc__RNvCsd6wgJFC5r19_3lib6bugaga+8(%rip), %rax addq $1, %rax movq %rax, .L__profc__RNvCsd6wgJFC5r19_3lib6bugaga+8(%rip) ``` after this patch: ``` lock incq .L__profc__RNvCs3JgIB2SjHh2_3lib6bugaga+8(%rip) ```
2023-05-13Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naberDylan DPC-171/+92
Note user-facing types of coercion failure When coercing, for example, `Box<A>` into `Box<dyn B>`, make sure that any failure notes mention *those* specific types, rather than mentioning inner types, like "the cast from `A` to `dyn B`". I expect end-users are often confused when we skip layers of types and only mention the "innermost" part of a coercion, especially when other notes point at HIR, e.g. #111406.
2023-05-13Rollup merge of #111096 - AngelicosPhosphoros:overflow_checks_issue_91130, ↵Dylan DPC-0/+56
r=petrochenkov Add support for `cfg(overflow_checks)` This PR adds support for detecting if overflow checks are enabled in similar fashion as `debug_assertions` are detected. Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g. ```rust pub fn cast(val: usize)->u16 { if cfg!(overflow_checks) { val.try_into().unwrap() } else{ vas as _ } } ``` Resolves #91130.
2023-05-13Rollup merge of #110454 - oli-obk:limited_impl_trait_in_assoc_type, ↵Dylan DPC-12/+204
r=compiler-errors Require impl Trait in associated types to appear in method signatures This implements the limited version of TAIT that was proposed in https://github.com/rust-lang/rust/issues/107645#issuecomment-1477899536 Similar to `impl Trait` in return types, `impl Trait` in associated types may only be used within the impl block which it is a part of. To make everything simpler and forward compatible to getting desugared to a plain type alias impl trait in the future, we're requiring that any associated functions or constants that want to register hidden types must be using the associated type in their signature (type of the constant or argument/return type of the associated method. Where bounds mentioning the associated type are ignored). We have preexisting tests checking that this works transitively across multiple associated types in situations like ```rust impl Foo for Bar { type A = impl Trait; type B = impl Iterator<Item = Self::A>; fn foo() -> Self::B { ...... } } ```
2023-05-13Auto merge of #111447 - scottmcm:remove-more-assumes, r=thomccbors-59/+300
Remove useless `assume`s from `slice::iter(_mut)` You were right in https://github.com/rust-lang/rust/pull/111395#discussion_r1190312704, r? `@the8472` LLVM already removes these assumes while optimizing, as can be seen in <https://rust.godbolt.org/z/KTfWKbdEM>.
2023-05-12Remove useless `assume`s from `slice::iter(_mut)`Scott McMurray-59/+300
2023-05-13Encode VariantIdx so we can decode variants in the right orderMichael Goulet-0/+18
2023-05-13Auto merge of #103413 - RalfJung:phantom-dropck, r=lcnrbors-0/+22
PhantomData: fix documentation wrt interaction with dropck As far as I could find out, the `PhantomData`-dropck interaction *only* affects code using `may_dangle`. The documentation in the standard library has not been updated for 8 years and thus stems from a time when Rust still used "parametric dropck", before [RFC 1238](https://rust-lang.github.io/rfcs/1238-nonparametric-dropck.html). Back then what the docs said was correct, but with `may_dangle` dropck it stopped being entirely accurate and these days, with NLL, it is actively misleading. Fixes https://github.com/rust-lang/rust/issues/102810 Fixes https://github.com/rust-lang/rust/issues/70841 Cc `@nikomatsakis` I hope what I am saying here is right.^^
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-64/+829
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12Use the opaque_types_defined_by query to cheaply check for whether a hidden ↵Oli Scherer-9/+164
type may be registered for an opaque type
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-4/+41
2023-05-12Auto merge of #111493 - matthiaskrgr:rollup-iw1z59b, r=matthiaskrgrbors-38/+337
Rollup of 6 pull requests Successful merges: - #111179 (Fix instrument-coverage tests by using Python to sort instantiation groups) - #111393 (bump windows crate 0.46 -> 0.48) - #111441 (Verify copies of mutable pointers in 2 stages in ReferencePropagation) - #111456 (Update cargo) - #111490 (Don't ICE in layout computation for placeholder types) - #111492 (use by ref TokenTree iterator to avoid a few clones) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-12Rollup merge of #111490 - compiler-errors:layout-placeholder, r=aliemjayMatthias Krüger-1/+19
Don't ICE in layout computation for placeholder types We use `layout_of` for the built-in `PointerLike` trait to check if a type can be coerced to a `dyn*`. Since the new solver canonicalizes parameter types to placeholders, that code needs to be able to treat placeholders like params, and for the most part it does, **except** for a call to `is_trivially_sized`. This PR fixes that.
2023-05-12Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegenMatthias Krüger-4/+170
Verify copies of mutable pointers in 2 stages in ReferencePropagation Fixes #111422 In the first stage, we mark the copies as reborrows, to be checked later. In the second stage, we walk the reborrow chains to verify that all stages are fully replacable. The replacement itself mirrors the check, and iterates through the reborrow chain. r? ``````@RalfJung`````` cc ``````@JakobDegen``````
2023-05-12Rollup merge of #111179 - Zalathar:sort-groups, r=Mark-SimulacrumMatthias Krüger-33/+148
Fix instrument-coverage tests by using Python to sort instantiation groups #110942 was intended to fix a set of `-Cinstrument-coverage` tests, but it ended up silently *breaking* those tests on Linux, for annoying reasons detailed at #111171. Dealing with `diff --ignore-matching-lines` across multiple platforms has been such a hassle that I've instead written a simple Python script that can detect instantiation groups in the output of `llvm-cov show`, and sort them in a predictable order so that they can be used as snapshots for an ordinary invocation of `diff`. This approach should be much less error-prone, because it can't accidentally ignore the wrong lines, and any unforeseen problems will tend to result in a Python exception or a failing diff.
2023-05-12Auto merge of #111489 - compiler-errors:rollup-g3vgzss, r=compiler-errorsbors-81/+363
Rollup of 7 pull requests Successful merges: - #106038 (use implied bounds when checking opaque types) - #111366 (Make `NonUseContext::AscribeUserTy` carry `ty::Variance`) - #111375 (CFI: Fix SIGILL reached via trait objects) - #111439 (Fix backtrace normalization in ice-bug-report-url.rs) - #111444 (Only warn single-use lifetime when the binders match.) - #111459 (Update browser-ui-test version to 0.16.0) - #111460 (Improve suggestion for `self: Box<self>`) Failed merges: - #110454 (Require impl Trait in associated types to appear in method signatures) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-12Don't ICE in layout computation for placeholder typesMichael Goulet-1/+19
2023-05-11Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-errorsMichael Goulet-0/+16
Improve suggestion for `self: Box<self>` Fixes #110642
2023-05-11Rollup merge of #111459 - GuillaumeGomez:update-browser-ui-test, r=notriddleMichael Goulet-79/+67
Update browser-ui-test version to 0.16.0 This new version brings one major improvement: it allows to use the original color format in checks (I plan to slowly continue converting colors back to their "original" format, ie the one used in CSS). It also provides some improvements in some commands API. r? `````@notriddle`````
2023-05-11Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obkMichael Goulet-0/+1
Only warn single-use lifetime when the binders match. Fixes https://github.com/rust-lang/rust/issues/111400
2023-05-11Rollup merge of #111439 - uweigand:backtrace-normalize, r=compiler-errorsMichael Goulet-2/+3
Fix backtrace normalization in ice-bug-report-url.rs This test case currently fails on s390x, and probably other platforms where the last line of a backtrace does not contain and " at <source location>" specification. The problem with the existing normalization lines // normalize-stderr-test "\s*\d{1,}: .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> "" is that \s matches all whitespace, including newlines, so the first (but not second) of these regexes may merge multiple lines. Thus the output differs depending on which of these matches on the last line of a backtrace. As the whitespace used in backtraces is just normal space characters, change both regexes to just match at least one space character instead: // normalize-stderr-test " +\d{1,}: .*\n" -> "" // normalize-stderr-test " + at .*\n" -> ""
2023-05-11Rollup merge of #111375 - rcvalle:rust-cfi-fix-106547, r=bjorn3Michael Goulet-0/+113
CFI: Fix SIGILL reached via trait objects Fix #106547 by transforming the concrete self into a reference to a trait object before emitting type metadata identifiers for trait methods.
2023-05-11Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnrMichael Goulet-0/+163
use implied bounds when checking opaque types During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT. However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following: ```rust trait Service<Req> { type Output; fn call(req: Req) -> Self::Output; } impl<'a, Req> Service<&'a Req> for u8 { type Output= impl Sized; // we can't prove WF of hidden type `WF(&'a Req)` although it's implied by the impl //~^ ERROR type parameter Req doesn't live long enough fn call(req: &'a Req) -> Self::Output { req } } ``` although adding an explicit bound would make it pass: ```diff - impl<'a, Req> Service<&'a Req> for u8 { + impl<'a, Req> Service<&'a Req> for u8 where Req: 'a, { ``` I believe it should pass as we already allow the concrete type to be used: ```diff impl<'a, Req> Service<&'a Req> for u8 { - type Output= impl Sized; + type Output= &'a Req; ``` Fixes #95922 Builds on #105982 cc ``@lcnr`` (because implied bounds) r? ``@oli-obk``
2023-05-12Note base types of coercionMichael Goulet-171/+92
2023-05-12Usage of atomic counters for llvm code coverageEvgeniy A. Dushistov-1/+1
2023-05-11Bless tests for portable-simd syncJubilee Young-5/+5
API changes resulted in subtle MIR and impl differences
2023-05-11Add support for `cfg(overflow_checks)`AngelicosPhosphoros-0/+56
This PR adds support for detecting if overflow checks are enabled in similar fashion as debug_assertions are detected. Possible use-case of this, for example, if we want to use checked integer casts in builds with overflow checks, e.g. ```rust pub fn cast(val: usize)->u16 { if cfg!(overflow_checks) { val.try_into().unwrap() } else{ vas as _ } } ``` Resolves #91130. Tracking issue: #111466.
2023-05-11Improve error for `self: Box<self>`clubby789-0/+16
2023-05-11Fix backtrace normalization in ice-bug-report-url.rsUlrich Weigand-2/+3
This test case currently fails on s390x, and probably other platforms where the last line of a backtrace does not contain and " at <source location>" specification. The problem with the existing normalization lines // normalize-stderr-test "\s*\d{1,}: .*\n" -> "" // normalize-stderr-test "\s at .*\n" -> "" is that \s matches all whitespace, including newlines, so the first (but not second) of these regexes may merge multiple lines. Thus the output differs depending on which of these matches on the last line of a backtrace. As the whitespace used in backtraces is just normal space characters, change both regexes to just match at least one space character instead: // normalize-stderr-test " +\d{1,}: .*\n" -> "" // normalize-stderr-test " + at .*\n" -> ""
2023-05-11Convert some GUI tests color checks to use original formatGuillaume Gomez-14/+14
2023-05-11Migrate to 0.16.0 browser-ui-test versionGuillaume Gomez-65/+53
2023-05-11Rollup merge of #111448 - compiler-errors:rustdoc-alias-impl, r=notriddleMatthias Krüger-0/+9
Use proper impl self type for alias impl in rustdoc We don't want to use `type_of(type_alias)`, we want to use `type_of(impl)` -- this will give us the self type of the impl *properly substituted* in the case that it's an alias. Fixes #111420
2023-05-11Rollup merge of #111432 - cjgillot:issue-111426, r=oli-obkMatthias Krüger-0/+31
Use visit_assign to detect SSA locals. I screwed up the logic in 3c43b61b870add2daddbd8e480477e5a8aa409c2. Fixes https://github.com/rust-lang/rust/issues/111426
2023-05-11Rollup merge of #111385 - durin42:vec-panik-17, r=AmanieuMatthias Krüger-2/+2
vec-shrink-panik: update expectations to work on LLVM 17 For some reason, the called function is `cleanup` on LLVM 17 instead of `filter`. r? `@Amanieu`
2023-05-11Rollup merge of #111292 - Urgau:check-cfg-issue-111291, r=petrochenkovMatthias Krüger-0/+54
Fix mishandled `--check-cfg` arguments order This PR fixes a bug in `--check-cfg` where the order of `--check-cfg=names(a)` and `--check-cfg=values(a,…)` would trip the compiler. Fixes https://github.com/rust-lang/rust/issues/111291 cc `@taiki-e` `@petrochenkov`
2023-05-11Rollup merge of #108705 - clubby789:refutable-let-closure-borrow, r=cjgillotMatthias Krüger-0/+136
Prevent ICE with broken borrow in closure r? `@Nilstrieb` Fixes #108683 This solution isn't ideal, I'm hoping to find a way to continue compilation without ICEing.
2023-05-10Use proper impl self type for alias impl in rustdocMichael Goulet-0/+9
2023-05-10Only warn single-use lifetime when the binders match.Camille GILLOT-0/+1
2023-05-10Do not see through copies of mutable pointers.Camille GILLOT-7/+7
2023-05-10Iteratively replace pointers.Camille GILLOT-8/+6
2023-05-10Add note to suggest using `let _ = x` to ignore the valueUrgau-0/+72
2023-05-10Improve warning message by saying that it "does nothing"Urgau-39/+39
2023-05-10Use label instead of note to be more consistent with other lintsUrgau-267/+117
2023-05-10Adjust tests for new drop and forget lintsUrgau-64/+136