about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-10-22adjust asm testRalf Jung-2/+4
2024-10-20x86-32 float return for 'Rust' ABI: treat all float types consistentlyRalf Jung-24/+31
2024-10-19Rollup merge of #131925 - clubby789:redundant-revision-cfg, r=jieyouxuMatthias Krüger-11/+9
Warn on redundant `--cfg` directive when revisions are used r? ``@jieyouxu`` Fixes #131390 Not sure of the best way to test this
2024-10-19Rollup merge of #131920 - clubby789:108395-test, r=jieyouxuMatthias Krüger-0/+27
Add codegen test for branchy bool match Closes #108395
2024-10-19Rollup merge of #131795 - compiler-errors:expectation, r=NadrierilMatthias Krüger-61/+44
Stop inverting expectation in normalization errors We have some funky special case logic to invert the expectation and actual type for normalization errors depending on their cause code. IMO most of the error messages get better, except for `try {}` blocks' type expectations. I think that these need to be special cased in some other way, rather than via this hack. Fixes #131763
2024-10-19Rollup merge of #131789 - compiler-errors:capture-more, r=fmeaseMatthias Krüger-0/+37
Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax When lowering an opaque, we must capture and duplicate all of the lifetimes in the opaque's bounds to correctly lower the opaque's bounds. We do this *even if* the lifetime is not captured according to the `+ use<>` precise capturing bound; in that case, we will later reject that captured lifetime. For example, Given an opaque like `impl Sized + 'a + use<>`, we will still duplicate `'a` but later error that it is not mentioned in the `use<>` bound. The current heuristic was not properly handling cases like: ``` //@ edition: 2024 fn foo<'a>() -> impl Trait<Assoc = impl Trait2> + use<> {} ``` Which forces the outer `impl Trait` to capture `'a` since `impl Trait2` *implicitly* captures `'a` due to the new lifetime capture rules for edition 2024. We were only capturing lifetimes syntactically mentioned in the bounds. (Note that this still is an error; we just need to capture `'a` so it is handled later in the compiler correctly -- hence the ICE in #131769 where a late-bound lifetime was being referenced outside of its binder). This PR reworks the way we collect lifetimes to capture and duplicate in AST lowering to fix this. Fixes #131769
2024-10-19Rollup merge of #127675 - chenyukang:yukang-fix-127562-addr, r=petrochenkovMatthias Krüger-0/+16
Remove invalid help diagnostics for const pointer Partially addresses #127562
2024-10-19Rollup merge of #116863 - workingjubilee:non-exhaustive-is-not-ffi-unsafe, ↵Matthias Krüger-6/+25
r=jieyouxu warn less about non-exhaustive in ffi Bindgen allows generating `#[non_exhaustive] #[repr(u32)]` enums. This results in nonintuitive nonlocal `improper_ctypes` warnings, even when the types are otherwise perfectly valid in C. Adjust for actual tooling expectations by avoiding warning on simple enums with only unit variants. Closes https://github.com/rust-lang/rust/issues/116831
2024-10-19Make sure that outer opaques capture inner opaques's lifetimes even with ↵Michael Goulet-0/+37
precise capturing syntax
2024-10-19Auto merge of #131934 - matthiaskrgr:rollup-pd3dwxu, r=matthiaskrgrbors-0/+17
Rollup of 8 pull requests Successful merges: - #127462 (std: uefi: Add basic Env variables) - #131537 (Fix range misleading field access) - #131838 (bootstrap: allow setting `--jobs` in config.toml) - #131890 (Update `use` keyword docs to describe precise capturing) - #131899 (Mark unexpected variant res suggestion as having placeholders) - #131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.) - #131916 (small interpreter error cleanup) - #131919 (zero-sized accesses are fine on null pointers) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-19Rollup merge of #131537 - hirschenberger:master, r=compiler-errorsMatthias Krüger-0/+17
Fix range misleading field access Fixes #131471 by checking if the range-start is a literal.
2024-10-19Auto merge of #131211 - bjorn3:rust_abi_follow_c_rules, r=nikic,jieyouxubors-74/+173
Return values larger than 2 registers using a return area pointer LLVM and Cranelift disagree about how to return values that don't fit in the registers designated for return values. LLVM will force the entire return value to be passed by return area pointer, while Cranelift will look at each IR level return value independently and decide to pass it in a register or not, which would result in the return value being passed partially in registers and partially through a return area pointer. While Cranelift may need to be fixed as the LLVM behavior is generally more correct with respect to the surface language, forcing this behavior in rustc itself makes it easier for other backends to conform to the Rust ABI and for the C ABI rustc already handles this behavior anyway. In addition LLVM's decision to pass the return value in registers or using a return area pointer depends on how exactly the return type is lowered to an LLVM IR type. For example `Option<u128>` can be lowered as `{ i128, i128 }` in which case the x86_64 backend would use a return area pointer, or it could be passed as `{ i32, i128 }` in which case the x86_64 backend would pass it in registers by taking advantage of an LLVM ABI extension that allows using 3 registers for the x86_64 sysv call conv rather than the officially specified 2 registers. This adjustment is only necessary for the Rust ABI as for other ABI's the calling convention implementations in rustc_target already ensure any return value which doesn't fit in the available amount of return registers is passed in the right way for the current target. Helps with https://github.com/rust-lang/rustc_codegen_cranelift/issues/1525 cc https://github.com/bytecodealliance/wasmtime/issues/9250
2024-10-19Fix test expectations for 32bit x86bjorn3-16/+12
2024-10-19Warn on redundant `--cfg` directive when revisions are usedclubby789-11/+9
2024-10-19Add codegen test for branchy bool matchclubby789-0/+27
2024-10-18Fix #131471, range misleading field accessFalco Hirschenberger-0/+17
Fixes #131471 by checking if the range-start is a literal.
2024-10-18Rollup merge of #131864 - lrh2000:upcast_reorder, r=WaffleLapkin许杰友 Jieyou Xu (Joe)-8/+31
Never emit `vptr` for empty/auto traits Emiting `vptr`s for empty/auto traits is unnecessary (#114942) and causes unsoundness in `trait_upcasting` (#131813). This PR should ensure that we never emit vtables for such traits. See the linked issues for more details. I'm not sure if I can add tests for the vtable layout. So this PR only adds tests for the soundness hole (i.e., the segmentation fault will disappear after this PR). Fixes #114942 Fixes #131813 Cc #65991 (tracking issue for `trait_upcasting`) r? `@WaffleLapkin` (per https://github.com/rust-lang/rust/issues/131813#issuecomment-2419969745)
2024-10-18Rollup merge of #131802 - compiler-errors:fnonce-coverage, r=Zalathar许杰友 Jieyou Xu (Joe)-19/+95
Dont ICE when computing coverage of synthetic async closure body I'm not totally certain if this is *right*, but at least it doesn't ICE. The issue is that we end up generating two MIR bodies for each async closure, since the `FnOnce` and `Fn`/`FnMut` implementations have different borrowing behavior of their captured variables. They should ideally both contribute to the coverage, since those MIR bodies are (*to the user*) the same code and should have no behavioral differences. This PR at least suppresses the ICEs, and then I guess worst case we can fix this the right way later. r? Zalathar or re-roll Fixes #131190
2024-10-18Rollup merge of #131755 - jfrimmel:avr-rjmp-offset-regression-test, r=jieyouxu许杰友 Jieyou Xu (Joe)-0/+107
Regression test for AVR `rjmp` offset This adds a regression test for #129301 by minimizing the code in the linked issue and putting it into a `#![no_core]`-compatible format, so that it can easily be used within an `rmake`-test. This needs to be a `rmake` test (opposed to a `tests/assembly` one), since the linked issue describes, that the problem only occurs if the code is directly compiled. Note, that `lld` is used instead of `avr-gcc`; see the [comments](https://github.com/rust-lang/rust/pull/131755#issuecomment-2416469675) [below](https://github.com/rust-lang/rust/pull/131755#issuecomment-2417160045). Closes #129301. To show, that the test actually catches the wrong behavior, this can be tested with a faulty rustc: ```bash $ rustup install nightly-2024-08-19 $ rustc +nightly-2024-08-19 -C opt-level=s -C panic=abort --target avr-unknown-gnu-atmega328 -Clinker=build/x86_64-unknown-linux-gnu/ci-llvm/bin/lld -Clink-arg='--entry=main' -o compiled tests/run-make/avr-rjmp-offset/avr-rjmp-offsets.rs $ llvm-objdump -d compiled | grep '<main>' -A 6 000110b4 <main>: 110b4: 81 e0 ldi r24, 0x1 110b6: 92 e0 ldi r25, 0x2 110b8: 85 b9 out 0x5, r24 110ba: 95 b9 out 0x5, r25 110bc: fe cf rjmp .-4 ``` One can see, that the wrong label offset (`4` instead of `6`) is produced, which would trigger an assertion in the test case. This would be a good candidate for using the `minicore` proposed in #130693. Since this is not yet merged, there is a FIXME. r? Patryk27 I think, you are the yet-to-be official target maintainer, hence I'll assign to you. `@rustbot` label +O-AVR
2024-10-18Dont ICE when computing coverage of synthetic async closure bodyMichael Goulet-19/+95
2024-10-18Rollup merge of #131857 - WaffleLapkin:dyn-drop-principal-3, r=compiler-errorsMatthias Krüger-30/+99
Allow dropping dyn principal Revival of #126660, which was a revival of #114679. Fixes #126313. Allows dropping principal when coercing trait objects, e.g. `dyn Debug + Send` -> `dyn Send`. cc `@compiler-errors` `@Jules-Bertholet` r? `@lcnr`
2024-10-18Never emit `vptr` for empty/auto traitsRuihan Li-8/+31
2024-10-18Add more testsJules Bertholet-1/+30
2024-10-17Auto merge of #131572 - cuviper:ub-index_range, r=thomccbors-0/+5
Avoid superfluous UB checks in `IndexRange` `IndexRange::len` is justified as an overall invariant, and `take_prefix` and `take_suffix` are justified by local branch conditions. A few more UB-checked calls remain in cases that are only supported locally by `debug_assert!`, which won't do anything in distributed builds, so those UB checks may still be useful. We generally expect core's `#![rustc_preserve_ub_checks]` to optimize away in user's release builds, but the mere presence of that extra code can sometimes inhibit optimization, as seen in #131563.
2024-10-17Rollup merge of #131833 - c-ryan747:patch-1, r=NoratriebMatthias Krüger-4/+4
Add `must_use` to `CommandExt::exec` [CommandExt::exec](https://fburl.com/0qhpo7nu) returns a `std::io::Error` in the case exec fails, but its not currently marked as `must_use` making it easy to accidentally ignore it. This PR adds the `must_use` attributed here as i think it fits the definition in the guide of [When to add #[must_use]](https://std-dev-guide.rust-lang.org/policy/must-use.html#when-to-add-must_use)
2024-10-17Allow dropping dyn principalMichael Goulet-30/+70
2024-10-17Fix must_use lint for command exec testsCallum Ryan-4/+4
2024-10-17Rollup merge of #131798 - maurer:range-inlining, r=durin42Matthias Krüger-1/+1
llvm: Tolerate propagated range metadata llvm/llvm-project#91101 propagates range information across inlining, resulting in more metadata in this test. Tolerate the range metadata if it appears. ``@rustbot:`` label +llvm-main r? ``@durin42`` Please wait a moment before approving, putting the llvm-main tag on it to make sure it fixes the integration test.
2024-10-17Rollup merge of #131748 - lcnr:typing-mode, r=compiler-errorsMatthias Krüger-44/+44
cleanup canonical queries best reviewed commit by commit. adding `CanonicalQueryInput` to stop returning `defining_opaque_types` in query responses is the most involved change here. r? ``@compiler-errors``
2024-10-17Rollup merge of #131595 - fmease:rustdoc-json-mv-obj-safe-dyn-compat, ↵Matthias Krüger-19/+19
r=aDotInTheVoid rustdoc-JSON: Rename "object safe" to "dyn compatible" ~~Blocked: Sits atop #131594. Only the last commit is relevant.~~ (rebased) Part of #130852. r? aDotInTheVoid or rustdoc
2024-10-17Rollup merge of #128391 - cafce25:issue-128390, r=lcnrMatthias Krüger-193/+250
Change orphan hint from "only" to "any uncovered type inside..." Fix #128390
2024-10-17bless mir-opt testslcnr-44/+44
2024-10-17Use `rust-lld` instead of `avr-gcc` as the linkerJulian Frimmel-0/+9
This fixes the [build error] caused by the `avr-gcc` (used as linker) not being available in the Rust CI. This is a viable solution, which shows the wrong/right behavior and, since no functions from `libgcc` are called, does not produce errors. This was discussed [here]. Another small problem is, that `lld` doesn't link the correct startup-code by default. This is not a problem for this test (since it does not actually use anything the startup code is needed for (no variables, no stack, no interrupts)), but this causes the `main`-function to be removed by the default flag `--gc-sections`. Therefore the `rmake`-driver also adds the linker flag `--entry=main` to mark the `main`-function as the entry point and thus preventing it from getting removed. The code would work on a real AVR device. [build error]: https://github.com/rust-lang/rust/pull/131755#issuecomment-2415127952 [here]: https://github.com/rust-lang/rust/pull/131755#issuecomment-2416469675
2024-10-17Auto merge of #129582 - nbdd0121:unwind, r=nnethercotebors-11/+80
Make destructors on `extern "C"` frames to be executed This would make the example in #123231 print "Noisy Drop". I didn't mark this as fixing the issue because the behaviour is yet to be spec'ed. Tracking: - https://github.com/rust-lang/rust/issues/74990
2024-10-16rustdoc-JSON: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-19/+19
2024-10-16Auto merge of #131797 - matthiaskrgr:rollup-lzpze2k, r=matthiaskrgrbors-19/+159
Rollup of 9 pull requests Successful merges: - #130989 (Don't check unsize goal in MIR validation when opaques remain) - #131657 (Rustfmt `for<'a> async` correctly) - #131691 (Delay ambiguous intra-doc link resolution after `Cache` has been populated) - #131730 (Refactor some `core::fmt` macros) - #131751 (Rename `can_coerce` to `may_coerce`, and then structurally resolve correctly in the probe) - #131753 (Unify `secondary_span` and `swap_secondary_and_primary` args in `note_type_err`) - #131776 (Emscripten: Xfail backtrace ui tests) - #131777 (Fix trivially_copy_pass_by_ref in stable_mir) - #131778 (Fix needless_lifetimes in stable_mir) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-16llvm: Tolerate propagated range metadataMatthew Maurer-1/+1
llvm/llvm-project#91101 propagates range information across inlining, resulting in more metadata in this test. Tolerate the range metadata if it appears.
2024-10-16Rollup merge of #131776 - hoodmane:emscripten-xfail-backtrace-tests, r=jieyouxuMatthias Krüger-0/+2
Emscripten: Xfail backtrace ui tests It is possible to link libunwind and use the normal backtrace code, but it fails to symbolize stack traces. I investigated and could get the list of instruction pointers and symbol names, but I'm not sure how to use the dwarf info to map from instruction pointer to source location. In any case, fixing this is not a high priority. See https://github.com/rust-lang/rust/issues/131738 r?jieyouxu
2024-10-16Rollup merge of #131751 - compiler-errors:structurally-resolve, r=lcnrMatthias Krüger-9/+55
Rename `can_coerce` to `may_coerce`, and then structurally resolve correctly in the probe We need to structurally resolve the lhs and rhs of the coercion. Also, renaming the method so it's less ambiguous about what it's doing... the word "may" gives more clear signal that it has false positives imo. r? lcnr
2024-10-16Rollup merge of #131691 - GuillaumeGomez:intra-doc-link-filter-out-2, ↵Matthias Krüger-0/+90
r=notriddle Delay ambiguous intra-doc link resolution after `Cache` has been populated Fixes https://github.com/rust-lang/rust/issues/130233. I was getting nowhere with #130278. I took a wrong turn at some point and ended making way too many changes so instead I started again back from 0 and this time it worked out as expected. r? ```@notriddle```
2024-10-16Rollup merge of #130989 - compiler-errors:unsize-opaque, r=estebankMatthias Krüger-10/+12
Don't check unsize goal in MIR validation when opaques remain Similarly to `mir_assign_valid_types`, let's just skip when there are opaques. Fixes #130921.
2024-10-16Auto merge of #131792 - matthiaskrgr:rollup-480nwg4, r=matthiaskrgrbors-485/+1037
Rollup of 8 pull requests Successful merges: - #130822 (Add `from_ref` and `from_mut` constructors to `core::ptr::NonNull`.) - #131381 (Implement edition 2024 match ergonomics restrictions) - #131594 (rustdoc: Rename "object safe" to "dyn compatible") - #131686 (Add fast-path when computing the default visibility) - #131699 (Try to improve error messages involving aliases in the solver) - #131757 (Ignore lint-non-snake-case-crate#proc_macro_ on targets without unwind) - #131783 (Fix explicit_iter_loop in rustc_serialize) - #131788 (Fix mismatched quotation mark) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-16Stop inverting expectation in normalization errorsMichael Goulet-61/+44
2024-10-16Rollup merge of #131788 - dufucun:master, r=lqdMatthias Krüger-1/+1
Fix mismatched quotation mark
2024-10-16Rollup merge of #131757 - c6c7:fixup-lint-non-snake-case-crate, r=jieyouxuMatthias Krüger-12/+16
Ignore lint-non-snake-case-crate#proc_macro_ on targets without unwind The lint-non-snake-case-crate test may emit a warning in stderr if the target does not support unwinding ``` warning: building proc macro crate with `panic=abort` may crash the compiler should the proc-macro panic ``` Consequently, the test will fail on targets that don't support unwinding as written. This change modifies the expected stderr for lint-non-snake-case-crate in the proc_macro_ to ignore lines that indicate a warning was emitted.
2024-10-16Rollup merge of #131699 - compiler-errors:better-errors-for-projections, r=lcnrMatthias Krüger-169/+217
Try to improve error messages involving aliases in the solver 1. Treat aliases as rigid only if it may not be defined and it's well formed (i.e. for projections, its trait goal is satisfied). 2. Record goals that are related to alias normalization under a new `GoalKind`, so we can look into them in the `BestObligation` visitor. 3. Try to deduplicate errors due to self types of goals that are un-normalizable aliases. r? lcnr
2024-10-16Rollup merge of #131594 - fmease:rustdoc-mv-obj-safe-dyn-compat, r=notriddleMatthias Krüger-30/+30
rustdoc: Rename "object safe" to "dyn compatible" Supersedes #126554: 1. In line with [T-lang's latest resolution](https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118). 2. More comprehensive: Not only updates user-facing text but also source code. Part of #130852. Doesn't update rustdoc-JSON (will be filed separately). r? `@notriddle` (rust-lang/lang-team#286) `@GuillaumeGomez` (for visibility)
2024-10-16Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelixMatthias Krüger-211/+699
Implement edition 2024 match ergonomics restrictions This implements the minimalest version of [match ergonomics for edition 2024](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html). This minimal version makes it an error to ever reset the default binding mode. The implemented proposal is described precisely [here](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q#RFC-3627-nano), where it is called "RFC 3627-nano". Rules: - Rule 1C: When the DBM (default binding mode) is not `move` (whether or not behind a reference), writing `mut`, `ref`, or `ref mut` on a binding is an error. - Rule 2C: Reference patterns can only match against references in the scrutinee when the DBM is `move`. This minimal version is forward-compatible with the main proposals for match ergonomics 2024: [RFC3627](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html) itself, the alternative [rule 4-early variant](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html), and [others](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q). The idea is to give us more time to iron out a final proposal. This includes a migration lint that desugars any offending pattern into one that doesn't make use of match ergonomics. Such patterns have identical meaning across editions. This PR insta-stabilizes the proposed behavior onto edition 2024. r? `@ghost` Tracking: - https://github.com/rust-lang/rust/issues/123076
2024-10-16Rollup merge of #130822 - bjoernager:non-null-from-ref, r=dtolnayMatthias Krüger-62/+74
Add `from_ref` and `from_mut` constructors to `core::ptr::NonNull`. Relevant tracking issue: #130823 The `core::ptr::NonNull` type should have the convenience constructors `from_ref` and `from_mut` for parity with `core::ptr::from_ref` and `core::ptr::from_mut`. Although the type in question already implements `From<&T>` and `From<&mut T>`, these new functions also carry the ability to be used in constant expressions (due to not being behind a trait).
2024-10-16Simplify test and make it more reliableJulian Frimmel-21/+31
The new `rmake`-content asserts the exact assembly sequence for the loop preventing false-negatives if some instructions would change and thus the label offset might need to change.