about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-12-05Change ty_with_args to return Ty instead of ResultCelina G. Val-0/+115
Although, we would like to avoid crashes whenever possible, and that's why I wanted to make this API fallible. It's looking pretty hard to do proper validation. I think many of our APIs will unfortunately depend on the user doing the correct thing since at the MIR level we are working on, we expect types to have been checked already.
2023-12-04Rollup merge of #118540 - RalfJung:unsized-packed-offset, r=TaKO8KiTakayuki Maeda-0/+75
codegen, miri: fix computing the offset of an unsized field in a packed struct `#[repr(packed)]` strikes again. Fixes https://github.com/rust-lang/rust/issues/118537 Fixes https://github.com/rust-lang/miri/issues/3200 `@bjorn3` I assume cranelift needs the same fix.
2023-12-04Rollup merge of #118495 - weiznich:more_tests_for_on_unimplemented, ↵Takayuki Maeda-9/+425
r=compiler-errors Restrict what symbols can be used in `#[diagnostic::on_unimplemented]` format strings This commit restricts what symbols can be used in a format string for any option of the `diagnostic::on_unimplemented` attribute. We previously allowed all the ad-hoc options supported by the internal `#[rustc_on_unimplemented]` attribute. For the stable attribute we only want to support generic parameter names and `{Self}` as parameters. For any other parameter an warning is emitted and the parameter is replaced by the literal parameter string, so for example `{integer}` turns into `{integer}`. This follows the general design of attributes in the `#[diagnostic]` attribute namespace, that any syntax "error" is treated as warning and subsequently ignored. r? `@compiler-errors`
2023-12-04Restrict what symbols can be used in `#[diagnostic::on_unimplemented]` ↵Georg Semmler-9/+425
format strings This commit restricts what symbols can be used in a format string for any option of the `diagnostic::on_unimplemented` attribute. We previously allowed all the ad-hoc options supported by the internal `#[rustc_on_unimplemented]` attribute. For the stable attribute we only want to support generic parameter names and `{Self}` as parameters. For any other parameter an warning is emitted and the parameter is replaced by the literal parameter string, so for example `{integer}` turns into `{integer}`. This follows the general design of attributes in the `#[diagnostic]` attribute namespace, that any syntax "error" is treated as warning and subsequently ignored.
2023-12-04use `assume(idx < self.len())` in `[T]::get_unchecked`bendn-0/+13
2023-12-03Auto merge of #118579 - matthiaskrgr:rollup-22kn8sa, r=matthiaskrgrbors-29/+146
Rollup of 3 pull requests Successful merges: - #117869 ([rustdoc] Add highlighting for comments in items declaration) - #118525 (coverage: Skip spans that can't be un-expanded back to the function body) - #118574 (rustc_session: Address all `rustc::potential_query_instability` lints) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-03Rollup merge of #118525 - Zalathar:skip-spans, r=cjgillotMatthias Krüger-23/+23
coverage: Skip spans that can't be un-expanded back to the function body When we extract coverage spans from MIR, we try to "un-expand" them back to spans that are inside the function's body span. In cases where that doesn't succeed, the current code just swaps in the entire body span instead. But that tends to result in coverage spans that are completely unrelated to the control flow of the affected code, so it's better to just discard those spans. --- Extracted from #118305, since this is a general improvement that isn't specific to branch coverage. --- `@rustbot` label +A-code-coverage
2023-12-03Rollup merge of #117869 - GuillaumeGomez:comment-highlighting-item-decl, ↵Matthias Krüger-6/+123
r=notriddle [rustdoc] Add highlighting for comments in items declaration Fixes #117555. So after the discussion in https://github.com/rust-lang/rust/pull/117643, the outcome was that having the comments in the item declaration at the same level (in term of color) as the rest of the code was actually a bit distracting and could be improved. The current highlighting color for comments is "lighter" than the rest and I think it fits perfectly to improve the current situation. With this, we now have different "levels" which makes it easier to read and filter out what we want when reading the items declaration. Here's a screenshot: ![image](https://github.com/rust-lang/rust/assets/3050060/dbd98029-e98b-4997-9a89-6b823eaac9a4) r? `@notriddle`
2023-12-03Auto merge of #118072 - estebank:issue-98982, r=cjgillotbors-17/+48
Provide structured suggestion for type mismatch in loop We currently provide only a `help` message, this PR introduces the last two structured suggestions instead: ``` error[E0308]: mismatched types --> $DIR/issue-98982.rs:2:5 | LL | fn foo() -> i32 { | --- expected `i32` because of return type LL | / for i in 0..0 { LL | | return i; LL | | } | |_____^ expected `i32`, found `()` | note: the function expects a value to always be returned, but loops might run zero times --> $DIR/issue-98982.rs:2:5 | LL | for i in 0..0 { | ^^^^^^^^^^^^^ this might have zero elements to iterate on LL | return i; | -------- if the loop doesn't execute, this value would never get returned help: return a value for the case when the loop has zero elements to iterate on | LL ~ } LL ~ /* `i32` value */ | help: otherwise consider changing the return type to account for that possibility | LL ~ fn foo() -> Option<i32> { LL | for i in 0..0 { LL ~ return Some(i); LL ~ } LL ~ None | ``` Fix #98982.
2023-12-03Auto merge of #113730 - belovdv:jobserver-init-check, r=petrochenkovbors-3/+19
Report errors in jobserver inherited through environment variables This pr attempts to catch situations, when jobserver exists, but is not being inherited. r? `@petrochenkov`
2023-12-03Auto merge of #118526 - sjwang05:issue-118510, r=petrochenkovbors-0/+36
Fix ICE: `fn_arg_names: unexpected item DefId(..)` Fixes #118510
2023-12-03codegen, miri: fix computing the offset of an unsized field in a packed structRalf Jung-0/+75
2023-12-03Auto merge of #118542 - chenyukang:yukang-fix-parser-ice-118531, r=cjgillotbors-0/+106
Fix parser ICE from attrs Fixes #118531, Fixes #118530.
2023-12-03coverage: Skip spans that can't be un-expanded back to the function bodyZalathar-23/+23
When we extract coverage spans from MIR, we try to "un-expand" them back to spans that are inside the function's body span. In cases where that doesn't succeed, the current code just swaps in the entire body span instead. But that tends to result in coverage spans that are completely unrelated to the control flow of the affected code, so it's better to just discard those spans.
2023-12-02Fix ICE when suggesting closures for non-fn-like defssjwang05-0/+36
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-159/+159
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-12-02Rollup merge of #118539 - RalfJung:packed-struct-tests, r=lqdMatthias Krüger-0/+0
move packed-struct tests into packed/ folder We already have a bunch of other tests named `packed/packed-struct*`, no reason to have these two tests be separate.
2023-12-02Rollup merge of #118524 - celinval:smir-instance-def, r=ouz-aMatthias Krüger-1/+27
Add more information to StableMIR Instance Allow stable MIR users to retrieve an instance function signature, the index for a VTable instance and more information about its underlying definition. These are needed to properly interpret function calls, either via VTable or direct calls. The `CrateDef` implementation will also allow users to emit diagnostic messages. I also fixed a few issues that we had identified before with how we were retrieving body of things that may not have a body available.
2023-12-02Rollup merge of #118514 - Enselic:ice-probe, r=cjgillotMatthias Krüger-1/+10
rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternative Closes #118499 Apparently triggered by https://github.com/rust-lang/rust/pull/118381
2023-12-02Fix parser ICE from attrsyukang-0/+106
2023-12-02move packed-struct tests into packed/ folderRalf Jung-0/+0
2023-12-02Auto merge of #117912 - GeorgeWort:master, r=petrochenkovbors-16/+16
Name explicit registers in conflict register errors for inline assembly
2023-12-02fix an ICE when a valtree failed to evaluateRalf Jung-0/+15
2023-12-02Auto merge of #117754 - matthewjasper:subtype-overflow, r=lcnrbors-0/+100
Handle recursion limit for subtype and well-formed predicates Adds a recursion limit check for subtype predicates and well-formed predicates. `-Ztrait-solver=next` currently panics with unimplemented for these cases. These cases are arguably bugs in the occurs check but: - I could not find a simple way to fix the occurs check - There should still be a recursion limit check to prevent hangs anyway. closes #117151 r? types
2023-12-02Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errorsbors-19/+19
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors
2023-12-01Add more information to stable InstanceCelina G. Val-1/+27
- Retrieve `FnSig`. - Implement CrateDef for InstanceDef. - Add VTable index for Virtual instances.
2023-12-02Auto merge of #118175 - lqd:unify-live-loans, r=matthewjasperbors-0/+46
Centralize live loans maintenance to fix scope differences due to liveness As found in the recent [polonius crater run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1801398892), NLLs and the location-insensitive polonius computed different scopes on some specific CFG shapes, e.g. the following. ![image](https://github.com/rust-lang/rust/assets/247183/c3649f5e-3058-454e-854e-1a6b336bdd5e) I had missed that liveness data was pushed from different sources than just the liveness computation: there are a few places that do this -- and some of them may be unneeded or at the very least untested, as no tests changed when I tried removing some of them. Here, `_6` is e.g. dead on entry to `bb2[0]` during `liveness::trace`, but its regions will be marked as live later during "constraint generation" (which I plan to refactor away and put in the liveness module soon). This should cause the inflowing loans to be marked live, but they were only computed in `liveness::trace`. Therefore, this PR moves live loan maintenance to `LivenessValues`, so that the various places pushing liveness data will all also update live loans at the same time -- except for promoteds which I don't believe need them, and their liveness handling is already interesting/peculiar. All the regressions I saw in the initial crater run were related to this kind of shapes, and this change did fix all of them on the [next run](https://github.com/rust-lang/rust/pull/117593#issuecomment-1826132145). r? `@matthewjasper` (This will conflict with #117880 but whichever lands first is fine by me, the end goal is the same for both)
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-19/+19
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-12-01Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelixbors-9/+105
Restore `#![no_builtins]` crates participation in LTO. After #113716, we can make `#![no_builtins]` crates participate in LTO again. `#![no_builtins]` with LTO does not result in undefined references to the error. I believe this type of issue won't happen again. Fixes #72140. Fixes #112245. Fixes #110606. Fixes #105734. Fixes #96486. Fixes #108853. Fixes #108893. Fixes #78744. Fixes #91158. Fixes https://github.com/rust-lang/cargo/issues/10118. Fixes https://github.com/rust-lang/compiler-builtins/issues/347. The `nightly-2023-07-20` version does not always reproduce problems due to changes in compiler-builtins, core, and user code. That's why this issue recurs and disappears. Some issues were not tested due to the difficulty of reproducing them. r? pnkfelix cc `@bjorn3` `@japaric` `@alexcrichton` `@Amanieu`
2023-12-02Put `$(LLVM_BIN_DIR)` in quotes to prevent missing backslashesDianQK-1/+1
2023-12-01rustc_hir_typeck: Fix ICE when probing for non-ASCII function alternativeMartin Nordholts-1/+10
2023-12-01Handle recursion limit for subtype and well-formed predicatesMatthew Jasper-0/+100
2023-12-01Auto merge of #115993 - bvanjoi:fix-115966, r=petrochenkovbors-6/+74
vis note for no pub reexports glob import Fixes #115966 Only trigger the `unused_import` lint when it's not being used. r? `@petrochenkov`
2023-12-01Fix link name for `extern "C"` in msvcDianQK-1/+2
2023-12-01add tests from crater for liveness causing scope differencesRémy Rakic-0/+46
2023-12-01Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstriebbors-56/+15
Stabilize C string literals RFC: https://rust-lang.github.io/rfcs/3348-c-str-literal.html Tracking issue: https://github.com/rust-lang/rust/issues/105723 Documentation PR (reference manual): https://github.com/rust-lang/reference/pull/1423 # Stabilization report Stabilizes C string and raw C string literals (`c"..."` and `cr#"..."#`), which are expressions of type [`&CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html). Both new literals require Rust edition 2021 or later. ```rust const HELLO: &core::ffi::CStr = c"Hello, world!"; ``` C strings may contain any byte other than `NUL` (`b'\x00'`), and their in-memory representation is guaranteed to end with `NUL`. ## Implementation Originally implemented by PR https://github.com/rust-lang/rust/pull/108801, which was reverted due to unintentional changes to lexer behavior in Rust editions < 2021. The current implementation landed in PR https://github.com/rust-lang/rust/pull/113476, which restricts C string literals to Rust edition >= 2021. ## Resolutions to open questions from the RFC * Adding C character literals (`c'.'`) of type `c_char` is not part of this feature. * Support for `c"..."` literals does not prevent `c'.'` literals from being added in the future. * C string literals should not be blocked on making `&CStr` a thin pointer. * It's possible to declare constant expressions of type `&'static CStr` in stable Rust (as of v1.59), so C string literals are not adding additional coupling on the internal representation of `CStr`. * The unstable `concat_bytes!` macro should not accept `c"..."` literals. * C strings have two equally valid `&[u8]` representations (with or without terminal `NUL`), so allowing them to be used in `concat_bytes!` would be ambiguous. * Adding a type to represent C strings containing valid UTF-8 is not part of this feature. * Support for a hypothetical `&Utf8CStr` may be explored in the future, should such a type be added to Rust.
2023-12-01Update snapshots of rustdoc tests to take into account the comment highlightingGuillaume Gomez-5/+5
2023-12-01Add GUI tests for comments highlighting in items declarationGuillaume Gomez-1/+118
2023-12-01Rollup merge of #118486 - RalfJung:add-feature, r=compiler-errorsTakayuki Maeda-73/+73
generic_const_exprs: suggest to add the feature, not use it Usually our missing feature messages look something like ``` = help: add `#![feature(inline_const)]` to the crate attributes to enable ``` However `generic_const_exprs` used a different verb. That's inconsistent and it also means playground won't add that nice hyperlink to add the feature automatically. So let's use the same verb as everywhere else.
2023-12-01Rollup merge of #118483 - notriddle:notriddle/fmt-newline, r=GuillaumeGomezTakayuki Maeda-33/+33
rustdoc: `div.where` instead of fmt-newline class This is about equally readable, a lot more terse, and stops special-casing functions and methods. ```console $ du -hs doc-old/ doc-new/ 671M doc-old/ 670M doc-new/ ```
2023-12-01vis note for no pub reexports glob importbohan-6/+74
2023-12-01Auto merge of #118472 - nnethercote:rustc_session, r=bjorn3bors-1/+1
`rustc_session` cleanups r? `@bjorn3`
2023-11-30Auto merge of #116892 - ojeda:rethunk, r=wesleywiserbors-0/+107
Add `-Zfunction-return={keep,thunk-extern}` option This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Issue: https://github.com/rust-lang/rust/issues/116853.
2023-11-30Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkovbors-43/+80
On Fn arg mismatch for a fn path, suggest a closure When encountering a fn call that has a path to another fn being passed in, where an `Fn` impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments. The last `help` is new: ``` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:9:9 | LL | fn f(_: u64) {} | ------------ found signature defined here ... LL | foo(f); | --- ^ expected due to this | | | required by a bound introduced by this call | = note: expected function signature `fn(usize) -> _` found function signature `fn(u64) -> _` note: required by a bound in `foo` --> $DIR/E0631.rs:3:11 | LL | fn foo<F: Fn(usize)>(_: F) {} | ^^^^^^^^^ required by this bound in `foo` help: consider wrapping the function in a closure | LL | foo(|arg0: usize| f(/* u64 */)); | +++++++++++++ +++++++++++ ```
2023-11-30generic_const_exprs: suggest to add the feature, not use itRalf Jung-73/+73
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-0/+107
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-30Auto merge of #118448 - ZetaNumbers:link_arg_attribute, r=petrochenkovbors-25/+76
Enable `link-arg` link kind inside of `#[link]` attribute https://github.com/rust-lang/rust/issues/99427#issuecomment-1234443468 > ... > This would help to make `link-arg` usable in `#[link]` attributes and e.g. wrap libc and libgcc into a group (*) in the libc crate like > > ``` > #[link(kind = "link-arg", name = "--start-group")] > #[link(kind = "static", name = "c")] > #[link(kind = "static", name = "gcc")] > #[link(kind = "link-arg", name = "--end-group")] > ``` > > (*) to address cyclic dependencies between them > > This is an analogue of CMake's LINKER: prefix (https://cmake.org/cmake/help/git-stage/command/target_link_options.html#handling-compiler-driver-differences), and was discussed as a possible future extension in the link modifier RFC (https://github.com/rust-lang/rfcs/blob/master/text/2951-native-link-modifiers.md#support-linkarg--string-in-addition-to-the-modifiers).
2023-11-30rustdoc: `div.where` instead of fmt-newline classMichael Howell-33/+33
This is about equally readable, a lot more terse, and stops special-casing functions and methods. ```console $ du -hs doc-old/ doc-new/ 671M doc-old/ 670M doc-new/ ```
2023-11-30Enable link-arg link kind inside of #[link] attributezetanumbers-25/+76
- Implement link-arg as an attribute - Apply suggestions from review - Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> - Add unstable book entry
2023-11-30Auto merge of #118036 - DianQK:thinlto-tests, r=tmiaskobors-0/+32
Add thinlto support to codegen, assembly and coverage tests Using `--emit=llvm-ir` with thinlto usually result in multiple IR files. Resolve test case failure issue reported in #113923.