about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-04-16Rollup merge of #123574 - notriddle:notriddle/issue-d, r=fmeaseGuillaume Gomez-33/+69
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6) Follow up * https://github.com/rust-lang/rust/pull/116214 * https://github.com/rust-lang/rust/pull/116432 * https://github.com/rust-lang/rust/pull/116824 * https://github.com/rust-lang/rust/pull/118105 * https://github.com/rust-lang/rust/pull/119561
2024-04-16Rollup merge of #123491 - gurry:123154-ice-unsized-struct-eval, r=oli-obkGuillaume Gomez-34/+58
Fix ICE in `eval_body_using_ecx` Ensures `TypeckResults` is tainted by failing candidate assembly for types with error Fixes #123154
2024-04-16Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-SimulacrumGuillaume Gomez-4/+4
sess: stabilize `-Zrelro-level` as `-Crelro-level` Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16Auto merge of #123963 - lqd:gdb15-failures, r=Kobzolbors-0/+4
Disable two debuginfo tests failing under the future GDB 15 release As seen in #123960, it seems two of our debuginfo tests started failing on gdb 15, which is also already in use in the `x86_64-gnu-llvm-18` builder: CI will randomly start to fail whenever this cached docker image expires. This PR disables the following two tests under gdb 15+, to prevent future CI failures. - `tests/debuginfo/include_string.rs` - `tests/debuginfo/vec-slices.rs` This seems very much related to https://sourceware.org/bugzilla/show_bug.cgi?id=30330 and https://sourceware.org/bugzilla/show_bug.cgi?id=31517 -- and I just now saw #122751 as well, where one of these bugzilla issues and one of the two test failures here was previously mentioned. I don't know whether these are unexpected gdb changes, or if we need to change our tests as it seems some of the gdb changes are definitely intentional, so I'll just cc `@rust-lang/wg-debugging` and `@tromey.` (In the same area, `tests/debuginfo/unsized.rs` was previously disabled due to https://sourceware.org/bugzilla/show_bug.cgi?id=30330. This issue has been fixed but I don't believe our test passes, so it's in the same boat as the 2 above regarding whether this test is expected to work or needs changes as well) r? wg-debugging I've confirmed this is enough to have CI pass on gdb 15 with the llvm 18 builder.
2024-04-16Fail candidate assembly for erroneous typesGurinder Singh-34/+58
Trait predicates for types which have errors may still evaluate to OK leading to downstream ICEs. Now we return a selection error for such types in candidate assembly and thereby prevent such issues
2024-04-16Rollup merge of #123973 - matthiaskrgr:crashs_fix_cmt, r=fmeaseLeón Orell Valerian Liehr-0/+7
crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues.
2024-04-16Rollup merge of #123926 - compiler-errors:no-ann, r=estebankLeón Orell Valerian Liehr-3/+22
Fix pretty HIR for anon consts in diagnostics This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`. There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh. r? estebank
2024-04-16Rollup merge of #123603 - compiler-errors:no-intrinsic, r=estebankLeón Orell Valerian Liehr-67/+56
Don't even parse an intrinsic unless the feature gate is enabled Don't return true in `tcx.is_intrinsic` if the function is defined locally and `#![feature(intrinsics)]` is not enabled. This is a slightly more general fix than #123526, since #123587 shows that we have simplifying assumptions about intrinsics elsewhere in the compiler. This will make the code ICE again if the user **enables** `#[feature(intrinsics)]`, but I kind of feel like if we want to fix that, we should make the `INTERNAL_FEATURES` lint `Deny` again. Perhaps we could do that on non-nightly compilers. Or we should just stop compilation altogether if they have `#![feature]` enabled on a non-nightly compiler. As for the UX of *real* cases of hitting these ICEs, I believe pretty strongly that if a compiler/stdlib dev is modifying internal intrinsics (intentionally, like when making a change to rustc) we have no guarantee to make the ICE better looking for them. Honestly, *not* spitting out a stack trace is probably a disservice to the people who hit those ICEs in that case. r? `@Nilstrieb` `@estebank`
2024-04-15Add testMichael Goulet-0/+17
2024-04-15Fix pretty hir for anon consts in diagnosticsMichael Goulet-3/+5
2024-04-15rustdoc: move tests into applicable subdirectoriesMichael Howell-0/+0
2024-04-15rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-0/+0
2024-04-15Move ice tests to rustdoc-uiMichael Howell-1/+3
2024-04-15Add URL and crate_name to test casesMichael Howell-16/+50
2024-04-15crashes: readme: add reminder to add Fixes #abcde to prs to automatically ↵Matthias Krüger-0/+7
close issues.
2024-04-15Rollup merge of #123943 - saethlin:less-sysroot-libc, r=workingjubileeMichael Goulet-125/+88
Use the rustc_private libc less in tests I started looking into our use of `rustc_private` + `extern crate libc;` in tests because of https://github.com/rust-lang/rust/pull/123938 and it looks like some fraction of the users of libc simply don't need the libc crate anymore.
2024-04-15Rollup merge of #123924 - compiler-errors:tuple-sugg, r=estebankMichael Goulet-0/+58
Fix various bugs in `ty_kind_suggestion` Consolidates two implementations of `ty_kind_suggestion` Fixes some misuse of the empty param-env Fixes a problem where we suggested `(42)` instead of `(42,)` for tuple suggestions Suggest a value when `return;`, making it consistent with `break;` Fixes #123906
2024-04-15Rollup merge of #123931 - compiler-errors:variance-unnameables, r=fmease许杰友 Jieyou Xu (Joe)-0/+25
Don't leak unnameable types in `-> _` recover Fixes #123899
2024-04-15Rollup merge of #123919 - RalfJung:discriminant, r=compiler-errors许杰友 Jieyou Xu (Joe)-47/+47
builtin-derive: tag → discriminant As far as I can tell, all of this operates on the discriminant, not the tag. After all, with something like `Option<&T>`, the "tag" of the `Some` variant is basically just the reference value, which is never what you want to compare when figuring out which variant the enum is in. See [here](https://rustc-dev-guide.rust-lang.org/appendix/glossary.html) for an explanation of the difference between tag and discriminant.
2024-04-15Use the rustc_private libc less in testsBen Kimock-125/+88
2024-04-15disable two debuginfo tests under gdb 15Rémy Rakic-0/+4
it seems gdb 15 regresses some of our debuginfo tests. disable them temporarily so that CI doesn't randomly start failing soon.
2024-04-15Auto merge of #115717 - jsgf:stablize-json-unused-externs, r=oli-obkbors-3/+3
Stabilize --json unused-externs(-silent) Implement https://github.com/rust-lang/compiler-team/issues/674 ~~(pending its approval)~~
2024-04-15Auto merge of #122917 - saethlin:atomicptr-to-int, r=nikicbors-0/+38
Add the missing inttoptr when we ptrtoint in ptr atomics Ralf noticed this here: https://github.com/rust-lang/rust/pull/122220#discussion_r1535172094 Our previous codegen forgot to add the cast back to integer type. The code compiles anyway, because of course all locals are in-memory to start with, so previous codegen would do the integer atomic, store the integer to a local, then load a pointer from that local. Which is definitely _not_ what we wanted: That's an integer-to-pointer transmute, so all pointers returned by these `AtomicPtr` methods didn't have provenance. Yikes. Here's the IR for `AtomicPtr::fetch_byte_add` on 1.76: https://godbolt.org/z/8qTEjeraY ```llvm define noundef ptr `@atomicptr_fetch_byte_add(ptr` noundef nonnull align 8 %a, i64 noundef %v) unnamed_addr #0 !dbg !7 { start: %0 = alloca ptr, align 8, !dbg !12 %val = inttoptr i64 %v to ptr, !dbg !12 call void `@llvm.lifetime.start.p0(i64` 8, ptr %0), !dbg !28 %1 = ptrtoint ptr %val to i64, !dbg !28 %2 = atomicrmw add ptr %a, i64 %1 monotonic, align 8, !dbg !28 store i64 %2, ptr %0, align 8, !dbg !28 %self = load ptr, ptr %0, align 8, !dbg !28 call void `@llvm.lifetime.end.p0(i64` 8, ptr %0), !dbg !28 ret ptr %self, !dbg !33 } ``` r? `@RalfJung` cc `@nikic`
2024-04-15Auto merge of #122997 - matthiaskrgr:compiletest_ices, r=oli-obkbors-0/+3284
compiletest ice tracking see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/where.20to.20mass-add.20known.20ices.20.2F.20merging.20glacier.20into.20rust/near/429082963 This will allow us to sunset most of https://github.com/rust-lang/glacier The rustc ices will be tracked directly inside the rust testsuite There are a couple of .sh tests remaining that I have not ported over yet. This adds `tests/crashes`, a file inside this directory MUST ice, otherwise it is considered test-fail. This will be used to track ICEs from glacier and the bugtracker. When someones pr accidentally fixes one of these ICEs, they can move the test from `crashes` into `ui` for example. I also added a new tidy lint that warns when a test inside `tests/crashes` does not have a `//@ known-bug: ` line the env var `COMPILETEST_VERBOSE_CRASHES` can be set to get exit code, stderr and stdout of a crash-test to aid debugging/adding tests.
2024-04-14crashes: limit a couple tests to only run on x86_64 and/or not on windowsMatthias Krüger-10/+6
2024-04-14Rollup merge of #123905 - notriddle:notriddle/redundant-explicit-link-hunks, ↵Guillaume Gomez-0/+14
r=GuillaumeGomez rustdoc: check redundant explicit links with correct itemid Fixes #123677 (a regression caused by #120702)
2024-04-14Rollup merge of #123618 - compiler-errors:overflow-ambig, r=spastorinoGuillaume Gomez-0/+37
Discard overflow obligations in `impl_may_apply` Hacky fix for #123493. Throws away obligations that are overflowing in `impl_may_apply` when we recompute if an impl applies, since those will lead to fatal overflow if processed during fulfillment. Something about #114811 (I think it's the predicate reordering) caused us to evaluate predicates differently in error reporting leading to fatal overflow, though I believe the underlying overflow is possible to hit since this code was rewritten to use fulfillment. Fixes #123493
2024-04-14Stabilize --json unused-externs(-silent)Jeremy Fitzhardinge-3/+3
Implement https://github.com/rust-lang/compiler-team/issues/674
2024-04-14Don't leak unnameable types in -> _ recoverMichael Goulet-0/+25
2024-04-14Fix 1-tuple value suggestionMichael Goulet-2/+2
2024-04-14Suggest value on bare returnMichael Goulet-0/+32
2024-04-14Fix value suggestion for array in generic contextMichael Goulet-0/+26
2024-04-14builtin-derive: tag → discriminantRalf Jung-47/+47
2024-04-14update README and add COMPILETEST_VERBOSE_CRASHES env var which when set ↵Matthias Krüger-1/+4
print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests
2024-04-14crashes: fix ice detection which did not trigger if code compiled without ↵Matthias Krüger-1/+14
error by accident
2024-04-14tests/crashes: add ICEs from matthiaskrgr/glacier2Matthias Krüger-39/+2620
2024-04-14add .rs crashes from https://github.com/rust-lang/glacierMatthias Krüger-1/+664
2024-04-14tidy: add tidy check agains \.rs files inside tests/crashes that are missing ↵Matthias Krüger-4/+0
"//@ known-bug: "
2024-04-14crashes: add another test showing that everything works fine when we need ↵Matthias Krüger-1/+28
compile-flags to repro an ice and add README
2024-04-14bootstrap/compiletest: implement "crashes" tests that fail if no ice is ↵Matthias Krüger-0/+1
reproduced
2024-04-14add initial ice as testMatthias Krüger-0/+4
2024-04-14Rollup merge of #123898 - fmease:gci-cmp-impl-item-lt-params, r=compiler-errorsMatthias Krüger-17/+29
Generic associated consts: Check regions earlier when comparing impl with trait item def Fixes #123836. r? compiler-errors or compiler
2024-04-13rustdoc: check redundant explicit links with correct itemidMichael Howell-0/+14
Fixes a regression caused by 0a50dba50bedd24377bd1066da3b4b7066df4d28
2024-04-14Auto merge of #123819 - joboet:fmt_usize_marker, r=Mark-Simulacrumbors-0/+4
Get rid of `USIZE_MARKER` in formatting infrastructure An alternative to #123780. The `USIZE_MARKER` function used to differentiate between placeholder and count arguments is never called anyway, so we can just replace the function-pointer-comparison hack with an `enum` and an `unreachable_unchecked`, hopefully without causing a regression. CC `@RalfJung`
2024-04-13Check regions earlier when comparing impl with trait item defLeón Orell Valerian Liehr-17/+29
2024-04-13Auto merge of #123656 - lqd:linker-features, r=petrochenkovbors-1/+5
Linker flavors next steps: linker features This is my understanding of the first step towards `@petrochenkov's` vision for the future of linker flavors, described in https://github.com/rust-lang/rust/pull/119906#issuecomment-1895693162 and the discussion that followed. To summarize: having `Cc` and `Lld` embedded in linker flavors creates tension about naming, and a combinatorial explosion of flavors for each new linker feature we'd want to use. Linker features are an extension mechanism that is complementary to principal flavors, with benefits described in #119906. The most immediate use of this flag would be to turn self-contained linking on and off via features instead of flavors. For example, `-Clinker-features=+/-lld` would toggle using lld instead of selecting a precise flavor, and would be "generic" and work cross-platform (whereas linker flavors are currently more tied to targets). Under this scheme, MCP510 is expected to be `-Clink-self-contained=+linker -Zlinker-features=+lld -Zunstable-options` (though for the time being, the original flags using lld-cc flavors still work). I purposefully didn't add or document CLI support for `+/-cc`, as it would be a noop right now. I only expect that we'd initially want to stabilize `+/-lld` to begin with. r? `@petrochenkov` You had requested that minimal churn would be done to the 230 target specs and this does none yet: the linker features are inferred from the flavor since they're currently isomorphic. We of course expect this to change sooner rather than later. In the future, we can allow targets to define linker features independently from their flavor, and remove the cc and lld components from the flavors to use the features instead, this actually doesn't need to block stabilization, as we discussed. (Best reviewed per commit)
2024-04-13Auto merge of #122603 - estebank:clone-o-rama, r=lcnrbors-81/+1255
Detect borrow checker errors where `.clone()` would be an appropriate user action When a value is moved twice, suggest cloning the earlier move: ``` error[E0509]: cannot move out of type `U2`, which implements the `Drop` trait --> $DIR/union-move.rs:49:18 | LL | move_out(x.f1_nocopy); | ^^^^^^^^^^^ | | | cannot move out of here | move occurs because `x.f1_nocopy` has type `ManuallyDrop<RefCell<i32>>`, which does not implement the `Copy` trait | help: consider cloning the value if the performance cost is acceptable | LL | move_out(x.f1_nocopy.clone()); | ++++++++ ``` When a value is borrowed by an `fn` call, consider if cloning the result of the call would be reasonable, and suggest cloning that, instead of the argument: ``` error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:53:14 | LL | let a = AffineU32(1); | - binding `a` declared here LL | let x = bat(&a); | -- borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here LL | drop(x); | - borrow later used here | help: consider cloning the value if the performance cost is acceptable | LL | let x = bat(&a).clone(); | ++++++++ ``` otherwise, suggest cloning the argument: ``` error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:59:14 | LL | let a = ClonableAffineU32(1); | - binding `a` declared here LL | let x = foo(&a); | -- borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here LL | drop(x); | - borrow later used here | help: consider cloning the value if the performance cost is acceptable | LL - let x = foo(&a); LL + let x = foo(a.clone()); | ``` This suggestion doesn't attempt to square out the types between what's cloned and what the `fn` expects, to allow the user to make a determination on whether to change the `fn` call or `fn` definition themselves. Special case move errors caused by `FnOnce`: ``` error[E0382]: use of moved value: `blk` --> $DIR/once-cant-call-twice-on-heap.rs:8:5 | LL | fn foo<F:FnOnce()>(blk: F) { | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait LL | blk(); | ----- `blk` moved due to this call LL | blk(); | ^^^ value used here after move | note: `FnOnce` closures can only be called once --> $DIR/once-cant-call-twice-on-heap.rs:6:10 | LL | fn foo<F:FnOnce()>(blk: F) { | ^^^^^^^^ `F` is made to be an `FnOnce` closure here LL | blk(); | ----- this value implements `FnOnce`, which causes it to be moved when called ``` Account for redundant `.clone()` calls in resulting suggestions: ``` error[E0507]: cannot move out of dereference of `S` --> $DIR/needs-clone-through-deref.rs:15:18 | LL | for _ in self.clone().into_iter() {} | ^^^^^^^^^^^^ ----------- value moved due to this method call | | | move occurs because value has type `Vec<usize>`, which does not implement the `Copy` trait | note: `into_iter` takes ownership of the receiver `self`, which moves value --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | for _ in <Vec<usize> as Clone>::clone(&self).into_iter() {} | ++++++++++++++++++++++++++++++ ~ ``` We use the presence of `&mut` values in a move error as a proxy for the user caring about side effects, so we don't emit a clone suggestion in that case: ``` error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | LL | let mut s = "hello".to_string(); | ----- binding `s` declared here LL | let rs = &mut s; | ------ borrow of `s` occurs here ... LL | f[s] = 10; | ^ move out of `s` occurs here ... LL | use_mut(rs); | -- borrow later used here ``` We properly account for `foo += foo;` errors where we *don't* suggest `foo.clone() += foo;`, instead suggesting `foo += foo.clone();`. --- Each commit can be reviewed in isolation. There are some "cleanup" commits, but kept them separate in order to show *why* specific changes were being made, and their effect on tests' output. Fix #49693, CC #64167.
2024-04-13Rollup merge of #123868 - eduardosm:stabilize-slice_ptr_len, r=jhprattJacob Pratt-1/+0
Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull Stabilized API: ```rust impl<T> *mut [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> *const [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> NonNull<[T]> { pub const fn is_empty(self) -> bool; } ``` FCP completed in tracking issue: https://github.com/rust-lang/rust/issues/71146
2024-04-13Rollup merge of #123835 - saethlin:vec-from-nonnull, r=the8472Jacob Pratt-2/+2
Avoid more NonNull-raw-NonNull roundtrips in Vec r? the8472 The standard library in general has a lot of these round-trips from niched types to their raw innards and back. Such round-trips have overhead in debug builds since https://github.com/rust-lang/rust/pull/120594. I removed some such round-trips in that initial PR and I've been meaning to come back and hunt down more such examples (this is the last item on https://github.com/rust-lang/rust/issues/120848).
2024-04-12Auto merge of #121430 - madsmtm:mac-catalyst-iOSSupport, r=wesleywiserbors-0/+25
Add `/System/iOSSupport` to the library search path on Mac Catalyst On macOS, `/System/iOSSupport` contains iOS frameworks like UIKit, which is the whole idea of Mac Catalyst. To link to these, we need to explicitly tell the linker about the support library stubs provided in the macOS SDK under the same path. Concretely, when building a binary for Mac Catalyst, Xcode passes the following flags to the linker: ``` -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/System/Library/Frameworks -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/iOSSupport/usr/lib ``` This is not something that can be disabled (it's enabled as soon as you enable `SUPPORTS_MACCATALYST`), so I think it's pretty safe to say that we don't need an option to turn these off. I've chosen to slightly deviate from what Xcode does and use `-F` instead of `-iframework`, since we don't need to change the header search path, and this way the flags nicely match on all the linkers. From what I could tell by reading Clang sources, there shouldn't be a difference when just running the linker. CC `@BlackHoleFox,` `@shepmaster` (I accidentally let rustbot choose the reviewer).