about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-05-25Auto merge of #121571 - clarfonthey:unchecked-math-preconditions, r=saethlinbors-154/+130
Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods (Old PR is haunted, opening a new one. See #117494 for previous discussion.) This ensures that these preconditions are actually checked in debug mode, and hopefully should let people know if they messed up. I've also replaced the calls (I could find) in the code that use these intrinsics directly with those that use these methods, so that the asserts actually apply. More discussions on people misusing these methods in the tracking issue: https://github.com/rust-lang/rust/issues/85122.
2024-05-25Rollup merge of #125527 - programmerjake:patch-2, r=workingjubileeMatthias Krüger-0/+35
Add manual Sync impl for ReentrantLockGuard Fixes: #125526 Tracking Issue: #121440 this impl is even shown in the summary in the tracking issue, but apparently was forgotten in the actual implementation
2024-05-25Rollup merge of #125514 - compiler-errors:builtin-index, r=lcnrMatthias Krüger-0/+13
Structurally resolve before `builtin_index` in EUV r? lcnr
2024-05-25Rollup merge of #125513 - compiler-errors:impossible-drop, r=jackh726Matthias Krüger-0/+18
Don't eagerly monomorphize drop for types that are impossible to instantiate Self-explanatory title I think Fixes #125509
2024-05-25Rollup merge of #125498 - zmodem:avx512er, r=workingjubileeMatthias Krüger-2/+2
Stop using the avx512er and avx512pf x86 target features They are no longer supported by LLVM 19. Fixes #125492
2024-05-25Rollup merge of #125451 - oli-obk:const_type_mismatch, r=compiler-errorsMatthias Krüger-118/+121
Fail relating constants of different types fixes #121585 fixes #121858 fixes #124151 I gave this several attempts before, but we lost too many important diagnostics until I managed to make compilation never bail out early. We have reached this point, so now we can finally fix all those ICEs by bubbling up an error instead of continueing when we encounter a bug.
2024-05-24Don't eagerly monomorphize drop for types that are impossible to instantiateMichael Goulet-0/+18
2024-05-24Stabilize the runtime of libtest-paddingBen Kimock-6/+2
The body of these benchmarks is close to empty but not literally empty. This was making the runtime of the benchmarks (which are compiled without optimizations!) flicker between 9 ns and 10 ns runtime, which changes the padding and breaks the test. Recent changes to the standard library have pushed the runtime closer to 10 ns when unoptimized, which is why we haven't seen such failures before in CI. Contributors can also induce such failures before this PR by running the run-make tests while the system is under heavy load.
2024-05-25Auto merge of #124187 - compiler-errors:self-ctor, r=petrochenkovbors-82/+86
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned https://github.com/rust-lang/rust/pull/117246#discussion_r1374648388. This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do. This also reverts part of https://github.com/rust-lang/rust/pull/117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.
2024-05-24Add manual Sync impl for ReentrantLockGuardJacob Lifshay-0/+35
Fixes: #125526
2024-05-24Rollup merge of #125503 - aDotInTheVoid:rdj-keyword-attr, r=GuillaumeGomezMatthias Krüger-0/+20
rustdoc-json: Add test for keywords with `--document-private-items` Turns out this does work as-expected. I was worried that the rustdoc's clean would produce a `ItemKind::KeywordItem` for the module, and loose the module itself. But turns out we get this right. Prompted by [this discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Where.20to.20find.20keyword.20entries.20in.20JSON.20rustdoc) r? `@GuillaumeGomez`
2024-05-24Rollup merge of #125501 - compiler-errors:opaque-opaque-anon-ct, r=BoxyUwUMatthias Krüger-22/+24
Resolve anon const's parent predicates to direct parent instead of opaque's parent When an anon const is inside of an opaque, #99801 added a hack to resolve the anon const's parent predicates *not* to the opaque's predicates, but to the opaque's *parent's* predicates. This is insufficient when considering nested opaques. This means that the `predicates_of` an anon const might reference duplicated lifetimes (installed by `compute_bidirectional_outlives_predicates`) when computing known outlives in MIR borrowck, leading to these ICEs: Fixes #121574 Fixes #118403 ~~Instead, we should be using the `OpaqueTypeOrigin` to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.~~ ~~I think it's a bit sketchy that we're doing this at all, tbh; I think it *should* be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure the `generics_of` that anon const line up in the same way.~~ ~~None of this is important to solve right now; I just want to fix these ICEs so we can land #125468, which accidentally fixes these issues in a different and unrelated way.~~ edit: We don't need this special case anyways because we install the right parent item in `generics_of` anyways: https://github.com/rust-lang/rust/blob/213ad10c8f0fc275648552366275dc4e07f97462/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L150 r? `@BoxyUwU`
2024-05-24Rollup merge of #125485 - GuillaumeGomez:migrate-rmake-rustdoc, r=jieyouxuMatthias Krüger-8/+16
Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? `@jieyouxu`
2024-05-24Rollup merge of #125467 - compiler-errors:binop-in-bool-expectation, r=estebankMatthias Krüger-0/+43
Only suppress binop error in favor of semicolon suggestion if we're in an assignment statement Similar to #123722, we are currently too aggressive when delaying a binop error with the expectation that we'll emit another error elsewhere. This adjusts that heuristic to be more accurate, at the cost of some possibly poorer suggestions. Fixes #125458
2024-05-24Structurally resolve before builtin_index in EUVMichael Goulet-0/+13
2024-05-24Stop using the avx512er and avx512pf x86 target featuresHans Wennborg-2/+2
They are no longer supported by LLVM 19. Fixes #125492
2024-05-24Actually just remove the special case altogetherMichael Goulet-22/+24
2024-05-24rustdoc-json: Add test for keywords with `--document-private-items`Alona Enraght-Moony-0/+20
2024-05-24Add regression testsOli Scherer-22/+136
2024-05-24Migrate `run-make/rustdoc-with-output-dir-option` to `rmake.rs`Guillaume Gomez-8/+16
2024-05-24Use regular type equating instead of a custom queryOli Scherer-7/+42
2024-05-24Fail relating constants of different typesOli Scherer-111/+79
2024-05-24Auto merge of #125457 - fmease:gacs-diag-infer-plac-missing-ty, ↵bors-10/+69
r=compiler-errors Properly deal with missing/placeholder types inside GACs Fixes #124833. r? oli-obk (#123130)
2024-05-23Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methodsltdk-148/+128
2024-05-23Only suppress binop error in favor of semicolon suggestion if we're in an ↵Michael Goulet-0/+43
assignment statement
2024-05-24Handle trait/impl GAC mismatches when inferring missing/placeholder typesLeón Orell Valerian Liehr-15/+25
2024-05-24Properly deal with missing/placeholder types inside GACsLeón Orell Valerian Liehr-0/+49
2024-05-23Rollup merge of #125445 - GuillaumeGomez:rustdoc-migrate-short-out-dir, ↵Guillaume Gomez-8/+16
r=jieyouxu Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? `@jieyouxu`
2024-05-23Rollup merge of #125412 - Urgau:check-cfg-less-build-rs, r=wesleywiserGuillaume Gomez-0/+65
Don't suggest adding the unexpected cfgs to the build-script it-self This PR adds a check to avoid suggesting to add the unexpected cfgs inside the build-script when building the build-script it-self, as it won't have any effect, since build-scripts applies to their descended target. Fixes #125368
2024-05-23Rollup merge of #125401 - ↵León Orell Valerian Liehr-19/+64
GuillaumeGomez:migrate-rustdoc-scrape-examples-macros, r=jieyouxu Migrate `run-make/rustdoc-scrape-examples-macros` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? `````@jieyouxu`````
2024-05-23Rollup merge of #125336 - momvart:smir-77-intrinsic, r=celinvalLeón Orell Valerian Liehr-17/+37
Add dedicated definition for intrinsics Closes rust-lang/project-stable-mir#77
2024-05-23Rollup merge of #125227 - Oneirical:seventh, r=jieyouxuLeón Orell Valerian Liehr-36/+38
Migrate `run-make/issue-30063` to `rmake` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). (Sorry about the [inconvenience](https://github.com/rust-lang/rust/pull/125224#issuecomment-2118340932) of all these PRs, this is the last one batched for today. I will discuss how we can cut these down a bit.) The last check was previously commented out in the Makefile, and I have readded it. If it fails the CI, this can be reconsidered.
2024-05-23Rollup merge of #125224 - Oneirical:sixth, r=jieyouxuLeón Orell Valerian Liehr-5/+12
Migrate `run-make/issue-53964` to `rmake` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). This is extremely similar to #125146. Could it be interesting to merge the two in some way? This one seems to do the same thing as the #125146, but with an added check that a useless lint is not shown.
2024-05-23Rollup merge of #122382 - mu001999:dead_code/enhance, r=petrochenkovLeón Orell Valerian Liehr-1/+51
Detect unused structs which implement private traits Fixes #122361
2024-05-23Add conversion from IntrinsicDef to FnDefMohammad Omidvar-6/+10
2024-05-23Auto merge of #116123 - joboet:rewrite_native_tls, r=m-ou-sebors-81/+0
Rewrite native thread-local storage (part of #110897) The current native thread-local storage implementation has become quite messy, uses indescriptive names and unnecessarily adds code to the macro expansion. This PR tries to fix that by using a new implementation that also allows more layout optimizations and potentially increases performance by eliminating unnecessary TLS accesses. This does not change the recursive initialization behaviour I described in [this comment](https://github.com/rust-lang/rust/issues/110897#issuecomment-1525705682), so it should be a library-only change. Changing that behaviour should be quite easy now, however. r? `@m-ou-se` `@rustbot` label +T-libs
2024-05-23Rollup merge of #125421 - Oneirical:bundle-them-yet-again, r=jieyouxuMatthias Krüger-26/+69
Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). The test which is now called `non-pie-thread-local` has an unexplained "only-linux" flag. Could it be worth trying to remove it and changing the CI to test non-Linux platforms on it?
2024-05-23Rollup merge of #125416 - compiler-errors:param-env-missing-copy, r=lcnrMatthias Krüger-0/+21
Use correct param-env in `MissingCopyImplementations` We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses. fixes #125394
2024-05-23Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwcoMatthias Krüger-20/+25
Cleanup: Fix up some diagnostics Several diagnostics contained their error code inside their primary message which is no bueno. This PR moves them out of the message and turns them into structured error codes. Also fixes another occurrence of `->` after a selector in a Fluent message which is not correct. I've fixed two other instances of this issue in #104345 (2022) but didn't update all instances as I've noted here: https://github.com/rust-lang/rust/pull/104345#issuecomment-1312705977 (“the future is now!”).
2024-05-23Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obkMatthias Krüger-8/+1
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-23Rollup merge of #124516 - oli-obk:taint_const_eval, r=RalfJungMatthias Krüger-7/+54
Allow monomorphization time const eval failures if the cause is a type layout issue r? `@RalfJung` fixes #124348
2024-05-23Rollup merge of #124297 - oli-obk:define_opaque_types13, r=jackh726Matthias Krüger-0/+95
Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type r? `@compiler-errors` This accepts more code on stable. It is now possible to have match arms return a function item `foo` and a different function item `bar` in another, and that will constrain OpaqueTypeInDefiningScope to have the hidden type ConcreteType and make the type of the match arms a function pointer that matches the signature. So the following function will now compile, but on master it errors with a type mismatch on the second match arm ```rust fn foo<T>(t: T) -> T { t } fn bar<T>(t: T) -> T { t } fn k() -> impl Sized { fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F { f } let x = match true { true => { let f = foo; bind(k(), f) } false => bar::<()>, }; todo!() } ``` cc https://github.com/rust-lang/rust/issues/116652 This is very similar to https://github.com/rust-lang/rust/pull/123794, and with the same rationale: > this is for consistency with `-Znext-solver`. the new solver does not have the concept of "non-defining use of opaque" right now and we would like to ideally keep it that way. Moving to `DefineOpaqueTypes::Yes` in more cases removes subtlety from the type system. Right now we have to be careful when relating `Opaque` with another type as the behavior changes depending on whether we later use the `Opaque` or its hidden type directly (even though they are equal), if that later use is with `DefineOpaqueTypes::No`*
2024-05-23delete UI tests that only check internal implementation details of thread-localsjoboet-81/+0
2024-05-23Allow const eval failures if the cause is a type layout issueOli Scherer-21/+26
2024-05-23Add regression testsOli Scherer-0/+42
2024-05-23Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs`Guillaume Gomez-8/+16
2024-05-23Auto merge of #125436 - matthiaskrgr:rollup-uijo2ga, r=matthiaskrgrbors-81/+645
Rollup of 8 pull requests Successful merges: - #122665 (Add some tests for public-private dependencies.) - #123623 (Fix OutsideLoop's error suggestion: adding label `'block` for `if` block.) - #125054 (Handle `ReVar` in `note_and_explain_region`) - #125156 (Expand `for_loops_over_fallibles` lint to lint on fallibles behind references.) - #125222 (Migrate `run-make/issue-46239` to `rmake`) - #125316 (Tweak `Spacing` use) - #125392 (Wrap Context.ext in AssertUnwindSafe) - #125417 (self-contained linker: retry linking without `-fuse-ld=lld` on CCs that don't support it) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-23Rollup merge of #125392 - workingjubilee:unwind-a-problem-in-context, r=AmanieuMatthias Krüger-38/+20
Wrap Context.ext in AssertUnwindSafe Fixes https://github.com/rust-lang/rust/issues/125193 Alternative to https://github.com/rust-lang/rust/pull/125377 Relevant to https://github.com/rust-lang/rust/issues/123392 I believe this approach is justifiable due to the fact that this function is unstable API and we have been considering trying to dispose of the notion of "unwind safety". Making a more long-term decision should be considered carefully as part of stabilizing `fn ext`, if ever. r? `@Amanieu`
2024-05-23Rollup merge of #125222 - Oneirical:fifth, r=jieyouxuMatthias Krüger-14/+21
Migrate `run-make/issue-46239` to `rmake` Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-23Rollup merge of #125156 - zachs18:for_loops_over_fallibles_behind_refs, ↵Matthias Krüger-1/+83
r=Nilstrieb Expand `for_loops_over_fallibles` lint to lint on fallibles behind references. Extends the scope of the (warn-by-default) lint `for_loops_over_fallibles` from just `for _ in x` where `x: Option<_>/Result<_, _>` to also cover `x: &(mut) Option<_>/Result<_>` ```rs fn main() { // Current lints for _ in Some(42) {} for _ in Ok::<_, i32>(42) {} // New lints for _ in &Some(42) {} for _ in &mut Some(42) {} for _ in &Ok::<_, i32>(42) {} for _ in &mut Ok::<_, i32>(42) {} // Should not lint for _ in Some(42).into_iter() {} for _ in Some(42).iter() {} for _ in Some(42).iter_mut() {} for _ in Ok::<_, i32>(42).into_iter() {} for _ in Ok::<_, i32>(42).iter() {} for _ in Ok::<_, i32>(42).iter_mut() {} } ``` <details><summary><code>cargo build</code> diff</summary> ```diff diff --git a/old.out b/new.out index 84215aa..ca195a7 100644 --- a/old.out +++ b/new.out `@@` -1,33 +1,93 `@@` warning: for loop over an `Option`. This is more readably written as an `if let` statement --> src/main.rs:3:14 | 3 | for _ in Some(42) {} | ^^^^^^^^ | = note: `#[warn(for_loops_over_fallibles)]` on by default help: to check pattern in a loop use `while let` | 3 | while let Some(_) = Some(42) {} | ~~~~~~~~~~~~~~~ ~~~ help: consider using `if let` to clear intent | 3 | if let Some(_) = Some(42) {} | ~~~~~~~~~~~~ ~~~ warning: for loop over a `Result`. This is more readably written as an `if let` statement --> src/main.rs:4:14 | 4 | for _ in Ok::<_, i32>(42) {} | ^^^^^^^^^^^^^^^^ | help: to check pattern in a loop use `while let` | 4 | while let Ok(_) = Ok::<_, i32>(42) {} | ~~~~~~~~~~~~~ ~~~ help: consider using `if let` to clear intent | 4 | if let Ok(_) = Ok::<_, i32>(42) {} | ~~~~~~~~~~ ~~~ -warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 2 warnings - Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s +warning: for loop over a `&Option`. This is more readably written as an `if let` statement + --> src/main.rs:7:14 + | +7 | for _ in &Some(42) {} + | ^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +7 | while let Some(_) = &Some(42) {} + | ~~~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +7 | if let Some(_) = &Some(42) {} + | ~~~~~~~~~~~~ ~~~ + +warning: for loop over a `&mut Option`. This is more readably written as an `if let` statement + --> src/main.rs:8:14 + | +8 | for _ in &mut Some(42) {} + | ^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +8 | while let Some(_) = &mut Some(42) {} + | ~~~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +8 | if let Some(_) = &mut Some(42) {} + | ~~~~~~~~~~~~ ~~~ + +warning: for loop over a `&Result`. This is more readably written as an `if let` statement + --> src/main.rs:9:14 + | +9 | for _ in &Ok::<_, i32>(42) {} + | ^^^^^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +9 | while let Ok(_) = &Ok::<_, i32>(42) {} + | ~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +9 | if let Ok(_) = &Ok::<_, i32>(42) {} + | ~~~~~~~~~~ ~~~ + +warning: for loop over a `&mut Result`. This is more readably written as an `if let` statement + --> src/main.rs:10:14 + | +10 | for _ in &mut Ok::<_, i32>(42) {} + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: to check pattern in a loop use `while let` + | +10 | while let Ok(_) = &mut Ok::<_, i32>(42) {} + | ~~~~~~~~~~~~~ ~~~ +help: consider using `if let` to clear intent + | +10 | if let Ok(_) = &mut Ok::<_, i32>(42) {} + | ~~~~~~~~~~ ~~~ + +warning: `for-loops-over-fallibles` (bin "for-loops-over-fallibles") generated 6 warnings + Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s ``` </details> ----- Question: * ~~Currently, the article `an` is used for `&Option`, and `&mut Option` in the lint diagnostic, since that's what `Option` uses. Is this okay or should it be changed? (likewise, `a` is used for `&Result` and `&mut Result`)~~ The article `a` is used for `&Option`, `&mut Option`, `&Result`, `&mut Result` and (as before) `Result`. Only `Option` uses `an` (as before). `@rustbot` label +A-lint