about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
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-24Add regression testsOli Scherer-22/+136
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-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
2024-05-23Rollup merge of #125054 - nnethercote:fix-124973, r=compiler-errorsMatthias Krüger-0/+21
Handle `ReVar` in `note_and_explain_region` PR #124918 made this path abort. The added test, from fuzzing, identified that it is reachable. r? `@lcnr`
2024-05-23Rollup merge of #123623 - surechen:fix_123261, r=estebankMatthias Krüger-19/+140
Fix OutsideLoop's error suggestion: adding label `'block` for `if` block. For OutsideLoop we should not suggest add `'block` label in `if` block, or we wiil get another err: block label not supported here. fixes #123261
2024-05-23Rollup merge of #122665 - ehuss:pub-priv-tests, r=davidtwcoMatthias Krüger-9/+360
Add some tests for public-private dependencies. This adds some tests to show more scenarios for the `exported_private_dependencies` lint. Several of these illustrate that the lint is not working as expected, and I have annotated those places with `FIXME`. Note also that this includes some diamond dependency structures which compiletest doesn't exactly support. However, I don't think it should be a problem, it just results in the common dependency being built twice.
2024-05-23Auto merge of #125359 - RalfJung:interpret-overflowing-ops, r=oli-obkbors-3/+3
interpret: make overflowing binops just normal binops Follow-up to https://github.com/rust-lang/rust/pull/125173 (Cc `@scottmcm)`
2024-05-22Rewrite and rename `issue-38237` to rmakeOneirical-18/+26
2024-05-22rewrite and rename issue-46239Oneirical-14/+21
2024-05-23Handle `ReVar` in `note_and_explain_region`.Nicholas Nethercote-0/+21
PR #124918 made this path abort. The added test, from fuzzing, identified that it is reachable.
2024-05-23Detect unused structs which implement private traitsr0cky-1/+51
2024-05-22Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmeasebors-51/+131
Rollup of 7 pull requests Successful merges: - #125043 (reference type safety invariant docs: clarification) - #125306 (Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce`) - #125355 (Use Backtrace::force_capture instead of Backtrace::capture in rustc_log) - #125382 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7)) - #125391 (Minor serialize/span tweaks) - #125395 (Remove unnecessary `.md` from the documentation sidebar) - #125399 (Stop using `to_hir_binop` in codegen) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-22Rollup merge of #125382 - notriddle:notriddle/issue-d, r=fmeaseLeón Orell Valerian Liehr-51/+80
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7) 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 * https://github.com/rust-lang/rust/pull/123574 As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-05-22Rollup merge of #125306 - compiler-errors:closure-incongruency, r=oli-obkLeón Orell Valerian Liehr-0/+51
Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce` See the detailed comment in `upvar.rs`. Fixes #124867. Fixes #124487. r? oli-obk
2024-05-22Add some tests for public-private dependencies.Eric Huss-9/+360
2024-05-22Cleanup: Fix up some diagnosticsLeón Orell Valerian Liehr-20/+25
2024-05-22rewrite and rename issue-53964Oneirical-5/+12
2024-05-22rewrite issue-30063Oneirical-36/+38
2024-05-22rewrite and rename `issue-24445` to rmakeOneirical-11/+36
2024-05-22Don't suggest adding the unexpected cfgs the build-script it-selfUrgau-0/+65
2024-05-22Rewrite `core-no-oom-handling` as rmake.rsOneirical-6/+16
2024-05-22Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obkLeón Orell Valerian Liehr-0/+23
An async closure may implement `FnMut`/`Fn` if it has no self-borrows There's no reason that async closures may not implement `FnMut` or `Fn` if they don't actually borrow anything with the closure's env lifetime. Specifically, #123660 made it so that we don't always need to borrow captures from the closure's env. See the doc comment on `should_reborrow_from_env_of_parent_coroutine_closure`: https://github.com/rust-lang/rust/blob/c00957a3e269219413041a4e3565f33b1f9d0779/compiler/rustc_hir_typeck/src/upvar.rs#L1777-L1823 If there are no such borrows, then we are free to implement `FnMut` and `Fn` as permitted by our closure's inferred `ClosureKind`. As far as I can tell, this change makes `async || {}` work in precisely the set of places they used to work before #120361. Fixes #125247. r? oli-obk
2024-05-22Rollup merge of #125049 - dtolnay:castbrace, r=compiler-errorsLeón Orell Valerian Liehr-282/+101
Disallow cast with trailing braced macro in let-else This fixes an edge case I noticed while porting #118880 and #119062 to syn. Previously, rustc incorrectly accepted code such as: ```rust let foo = &std::ptr::null as &'static dyn std::ops::Fn() -> *const primitive! { 8 } else { return; }; ``` even though a right curl brace `}` directly before `else` in a `let...else` statement is not supposed to be valid syntax.
2024-05-22Rollup merge of #125015 - fmease:pat-tys-proh-gen-args-on-ct-params, ↵León Orell Valerian Liehr-1/+49
r=spastorino Pattern types: Prohibit generic args on const params Addresses https://github.com/rust-lang/rust/pull/123689/files#r1562676629. NB: Technically speaking, *not* prohibiting generics args on const params is not a bug as `pattern_types` is an *internal* feature and as such any uncaught misuses of it are considered to be the fault of the user. However, permitting this makes me slightly uncomfortable esp. since we might want to make pattern types available to the public at some point and I don't want this oversight to be able to slip into the language (for comparison, ICEs triggered by the use of internal features are like super fine). Furthermore, this is an ad hoc fix. A more general fix would be changing the representation of the pattern part of pattern types in such a way that it can reuse preexisting lowering routines for exprs / anon consts. See also this [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/pattern.20type.20HIR.20nodes/near/432410768) and #124650. Also note that we currently don't properly typeck the pattern of pat tys. This however is out of scope for this PR. cc ``@oli-obk`` r? ``@spastorino`` as discussed