about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-01-05Auto merge of #119621 - compiler-errors:rollup-5mxtvuk, r=compiler-errorsbors-436/+713
Rollup of 10 pull requests Successful merges: - #119034 (Allow coverage tests to ignore test modes, and to enable color in coverage reports) - #119148 (Tweak suggestions for bare trait used as a type) - #119538 (Cleanup error handlers: round 5) - #119566 (Remove `-Zdump-mir-spanview`) - #119567 (Remove `-Zreport-delayed-bugs`.) - #119577 (Migrate memory overlap check from validator to lint) - #119583 (Make `intrinsics::assume` const stable) - #119586 ([rustdoc] Fix invalid handling for static method calls in jump to definition feature) - #119588 (Move `i586-unknown-netbsd` from tier 2 to tier 3 platform support table) - #119601 (`Emitter` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-05Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obkMichael Goulet-3/+423
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
2024-01-05Rollup merge of #119586 - GuillaumeGomez:jump-to-def-static-methods, r=notriddleMichael Goulet-1/+28
[rustdoc] Fix invalid handling for static method calls in jump to definition feature I realized when working on a clippy lint that static method calls on `Self` could not give me the method `Res`. For that, we need to use `typeck` and so that's what I did in here. It fixes the linking to static method calls. r? ````@notriddle````
2024-01-05Rollup merge of #119577 - tmiasko:lint, r=oli-obkMichael Goulet-197/+55
Migrate memory overlap check from validator to lint The check attempts to identify potential undefined behaviour, rather than whether MIR is well-formed. It belongs in the lint not validator. Follow up to changes from #119077.
2024-01-05Rollup merge of #119566 - Zalathar:remove-spanview, r=Swatinem,NilstriebMichael Goulet-218/+0
Remove `-Zdump-mir-spanview` The `-Zdump-mir-spanview` flag was added back in #76074, as a development/debugging aid for the initial work on what would eventually become `-Cinstrument-coverage`. It causes the compiler to emit an HTML file containing a function's source code, with various spans highlighted based on the contents of MIR. When the suggestion was made to [triage and remove unnecessary `-Z` flags (Zulip)](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Z.60.20option.20triage), I noted that this flag could potentially be worth removing, but I wanted to keep it around to see whether I found it useful for my own coverage work. But when I actually tried to use it, I ran into various issues (e.g. it crashes on `tests/coverage/closure.rs`). If I can't trust it to work properly without a full overhaul, then instead of diving down a rabbit hole of trying to fix arcane span-handling bugs, it seems better to just remove this obscure old code entirely. --- ````@rustbot```` label +A-code-coverage
2024-01-05Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errorsMichael Goulet-4/+4
Cleanup error handlers: round 5 More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171. r? ````@compiler-errors````
2024-01-05Rollup merge of #119148 - estebank:bare-traits, r=davidtwcoMichael Goulet-13/+161
Tweak suggestions for bare trait used as a type ``` error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:11 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use a generic type parameter, constrained by the trait `Foo` | LL | fn bar<T: Foo>(x: T) -> Foo { | ++++++++ ~ help: you can also use `impl Foo`, but users won't be able to specify the type paramer when calling the `fn`, having to rely exclusively on type inference | LL | fn bar(x: impl Foo) -> Foo { | ++++ help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch | LL | fn bar(x: &dyn Foo) -> Foo { | ++++ error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:19 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use `impl Foo` to return an opaque type, as long as you return a single underlying type | LL | fn bar(x: Foo) -> impl Foo { | ++++ help: alternatively, you can return an owned trait object | LL | fn bar(x: Foo) -> Box<dyn Foo> { | +++++++ + ``` Fix #119525: ``` error[E0038]: the trait `Ord` cannot be made into an object --> $DIR/bare-trait-dont-suggest-dyn.rs:3:33 | LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ `Ord` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter ::: $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter help: consider using an opaque type instead | LL | fn ord_prefer_dot(s: String) -> impl Ord { | ++++ ```
2024-01-05Rollup merge of #119034 - Zalathar:ignore-mode, r=davidtwcoMichael Goulet-0/+42
Allow coverage tests to ignore test modes, and to enable color in coverage reports This PR adds two new header directives to compiletest, intended for use by coverage tests (and by #119033 in particular). The new headers are: - `// ignore-mode-{mode}` causes a test to not be run in a particular compiletest mode (e.g. `ignore-mode-coverage-run`). - This can theoretically be used by any test, but coverage tests are currently the only ones that automatically run in multiple modes, so it's not very useful for other kinds of test. - `// llvm-cov-flags: --use-color` makes `coverage-run` tests pass the flag `--use-color` when generating coverage reports. - For most tests, non-coloured reports are easier to read and more portable across platforms. But for #119033 specifically, we want to test that `llvm-cov` slices up source text correctly, which only happens when colour output is enabled.
2024-01-05Auto merge of #118991 - nikic:scalar-pair, r=nagisabors-34/+33
Separate immediate and in-memory ScalarPair representation Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirements. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2024-01-05Auto merge of #117673 - matthewjasper:thir-unsafeck-stabilization, r=cjgillotbors-4817/+845
Stabilize THIR unsafeck - Removes `-Zthir-unsafeck`, stabilizing the behaviour of `-Zthir-unsafeck=on`. - Removes MIR unsafeck. - Union patterns are now unsafe unless the field is matched to a wildcard pattern. Opening for a crater run in case we need a compatibility lint.
2024-01-05Make test compatible with 32-bit as wellNikita Popov-1/+1
2024-01-05Handle context for const patterns correctlyMatthew Jasper-0/+24
2024-01-05Stabilize THIR unsafeckMatthew Jasper-303/+280
2024-01-05Remove revisions for THIR unsafeckMatthew Jasper-4667/+694
This is to make the diff when stabilizing it easier to review.
2024-01-05Auto merge of #118899 - veera-sivarajan:fix-makefile, r=Mark-Simulacrumbors-1/+0
fix(tests): remove check for `echo` fixes: #56222 Removes check for `echo` as it doesn't seem to be used anywhere.
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-209/+223
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-05Unbreak `tests/ui/lint/use_suggestion_json.rs`.Nicholas Nethercote-3/+423
PR #82639 changed UI tests so `-Z unstable-options` aren't passed to UI tests by default. This completely broke `use_suggestion_json.rs`, which uses the unstable `--error-format=pretty-json` option. The expected output went from 400 lines of pretty JSON error messages to a single JSON error saying "`--error-format=pretty-json` is unstable"! This commit adds `-Z unstable-options` back and reinstates the old expected output, with some minor changes to account for shifted spans and slightly JSON output changes since then.
2024-01-05Allow coverage tests to enable `llvm-cov --use-color`Zalathar-0/+24
2024-01-05Allow tests to ignore individual test modesZalathar-0/+18
Normally, each test in `tests/coverage` is automatically run in both `coverage-map` mode and `coverage-run` mode. This new family of directives allows an individual test to specify that it should not be run in a particular mode.
2024-01-05Auto merge of #117213 - oli-obk:check_item_type_cleanup, r=estebankbors-231/+320
Reorder check_item_type diagnostics so they occur next to the corresponding `check_well_formed` diagnostics The first commit is just a cleanup. The second commit moves most checks from `check_mod_item_types` into `check_well_formed`, invoking the checks in lockstep per-item instead of iterating over all items twice.
2024-01-04Migrate memory overlap check from validator to lintTomasz Miąsko-184/+42
The check attempts to identify potential undefined behaviour, rather than whether MIR is well-formed. It belongs in the lint not validator.
2024-01-04Fix validation and linting of injected MIRTomasz Miąsko-13/+13
Reevaluate `body.should_skip()` after updating the MIR phase to ensure that injected MIR is processed correctly. Update a few custom MIR tests that were ill-formed for the injected phase.
2024-01-04Auto merge of #119569 - matthiaskrgr:rollup-4packja, r=matthiaskrgrbors-84/+289
Rollup of 10 pull requests Successful merges: - #118521 (Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag) - #119026 (std::net::bind using -1 for openbsd which in turn sets it to somaxconn.) - #119195 (Make named_asm_labels lint not trigger on unicode and trigger on format args) - #119204 (macro_rules: Less hacky heuristic for using `tt` metavariable spans) - #119362 (Make `derive(Trait)` suggestion more accurate) - #119397 (Recover parentheses in range patterns) - #119417 (Uplift some miscellaneous coroutine-specific machinery into `check_closure`) - #119539 (Fix typos) - #119540 (Don't synthesize host effect args inside trait object types) - #119555 (Add codegen test for RVO on MaybeUninit) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-04Add regression test for jump to def static method callsGuillaume Gomez-1/+28
2024-01-04Rollup merge of #119553 - bvanjoi:fix-119463, r=petrochenkovMatthias Krüger-0/+40
stop feed vis when cant access for trait item Fixes #119463 It's not necessary to feed visibility when use a private trait. r? ``@petrochenkov``
2024-01-04Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31Matthias Krüger-220/+150
Make offset_of field parsing use metavariable which handles any spacing As discussed at and around comments https://github.com/rust-lang/rust/issues/106655#issuecomment-1793485081 and https://github.com/rust-lang/rust/issues/106655#issuecomment-1793774183, the current arguments to offset_of do not accept all the whitespace combinations: `0. 1.1.1` and `0.1.1. 1` are currently treated specially in `tests/ui/offset-of/offset-of-tuple-nested.rs`. They also do not allow [forwarding individual fields as in](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=444cdf0ec02b99e8fd5fd8d8ecb312ca) ```rust macro_rules! off { ($a:expr) => { offset_of!(m::S, 0. $a) } } ``` This PR replaces the macro arguments with `($Container:ty, $($fields:expr)+ $(,)?)` which does allow any arrangement of whitespace that I could come up with and the forwarding of fields example above. This also allows for array indexing in the future, which I think is the last future extension to the syntax suggested in the offset_of RFC. Tracking issue for offset_of: #106655 ``@rustbot`` label F-offset_of ``@est31``
2024-01-04Rollup merge of #119431 - taiki-e:asm-s390x-reg-addr, r=AmanieuMatthias Krüger-0/+24
Support reg_addr register class in s390x inline assembly In s390x, `r0` cannot be used as an address register (it is evaluated as zero in an address context). Therefore, currently, in assemblies involving memory accesses, `r0` must be [marked as clobbered](https://github.com/taiki-e/atomic-maybe-uninit/blob/1a1155653a26667396c805954ab61c8cbb14de8c/src/arch/s390x.rs#L58) or [explicitly used to a non-address](https://github.com/taiki-e/atomic-maybe-uninit/blob/1a1155653a26667396c805954ab61c8cbb14de8c/src/arch/s390x.rs#L135) or explicitly use an address register to prevent `r0` from being allocated to a register for the address. This patch adds a register class for allocating general-purpose registers, except `r0`, to make it easier to use address registers. (powerpc already has a register class (reg_nonzero) for a similar purpose.) This is identical to the `a` constraint in LLVM and GCC: https://llvm.org/docs/LangRef.html#supported-constraint-code-list > a: A 32, 64, or 128-bit integer address register (excludes R0, which in an address context evaluates as zero). https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html > a > Address register (general purpose register except r0) cc ``@uweigand`` r? ``@Amanieu``
2024-01-04Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errorsMatthias Krüger-33/+33
custom mir: make it clear what the return block is Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments: ``` Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue()) ``` Also fix some outdated docs and add some docs to `Call` and `Drop`.
2024-01-04Rollup merge of #119184 - Rajveer100:branch-for-issue-118752, r=davidtwcoMatthias Krüger-640/+647
Switch from using `//~ERROR` annotations with `--error-format` to `error-pattern` Fixes #118752 As noticed by ```@jyn514``` while working on a patch, tests failed due to `//~ERROR` annotations used in combination with the older `--error-format` which is now `error-pattern`.
2024-01-04Rollup merge of #117636 - bvanjoi:fix-117626, r=TaKO8KiMatthias Krüger-0/+21
add test for #117626 Close #117626
2024-01-04Rollup merge of #119555 - Kobzol:maybeuninit-rvo-codegen-test, r=nikicMatthias Krüger-0/+33
Add codegen test for RVO on MaybeUninit Codegen test for https://github.com/rust-lang/rust/issues/90595. Currently, this only works with `-Cpanic=abort`, but hopefully in the [future](https://www.npopov.com/2024/01/01/This-year-in-LLVM-2023.html#writable-and-dead_on_unwind) it should also work in the presence of panics. r? ``@nikic``
2024-01-04Rollup merge of #119540 - fmease:no-effect-args-inside-dyn-trait, ↵Matthias Krüger-2/+32
r=compiler-errors Don't synthesize host effect args inside trait object types While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them. Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end. Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to #119505). Fixes #119524.
2024-01-04Rollup merge of #119417 - compiler-errors:closure-checking, r=davidtwcoMatthias Krüger-8/+8
Uplift some miscellaneous coroutine-specific machinery into `check_closure` This PR uplifts some of the logic in `check_fn` that is specific to checking coroutines, which always flows through `check_closure`. This is just some miscellaneous clean up that I've wanted to do, especially because I'm poking around this code to make it work for async closures.
2024-01-04Rollup merge of #119397 - ShE3py:pat-range-paren-recovery, r=fmeaseMatthias Krüger-15/+74
Recover parentheses in range patterns Before: ```rs match n { (0).. => (), _ => () } ``` ``` error: expected one of `=>`, `if`, or `|`, found `..` --> src/lib.rs:3:12 | 3 | (0).. => (), | ^^ expected one of `=>`, `if`, or `|` ``` After: ``` error: range pattern bounds cannot have parentheses --> main.rs:3:5 | 3 | (0).. => (), | ^ ^ | help: remove these parentheses | 3 - (0).. => (), 3 + 0.. => (), | ``` This sets the groundwork for #118625, which will extend the recovery to expressions like `(0 + 1)..` where users may tend to add parentheses to avoid dealing with precedence. --- ```@rustbot``` label +A-parser +A-patterns +A-diagnostics
2024-01-04Rollup merge of #119362 - estebank:restrict-derive-suggestion, r=fmeaseMatthias Krüger-10/+0
Make `derive(Trait)` suggestion more accurate Only suggest `derive(PartialEq)` when both LHS and RHS types are the same, otherwise the suggestion is not useful.
2024-01-04Rollup merge of #119204 - petrochenkov:dialoc2, r=WaffleLapkinMatthias Krüger-34/+21
macro_rules: Less hacky heuristic for using `tt` metavariable spans See the big comment on `fn maybe_use_metavar_location` for a more detailed description.
2024-01-04Rollup merge of #119195 - asquared31415:named_asm_labels_fix, r=AmanieuMatthias Krüger-11/+113
Make named_asm_labels lint not trigger on unicode and trigger on format args Someone showed me some cursed code that used format args to create named labels, and rustc wasn't linting on that. Additionally while fixing that, I noticed that Unicode alphabetic characters were being used as part of labels, when they are not actually permitted in labels. r? ```@Amanieu```
2024-01-04Rollup merge of #118521 - dpaoliello:asan, r=wesleywiserMatthias Krüger-4/+8
Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170> Implements https://github.com/rust-lang/compiler-team/issues/702 Fixes #89339 (for MSVC targets using the MSVC linker only) Supercedes #89369 Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
2024-01-04Remove `-Zdump-mir-spanview`Zalathar-218/+0
2024-01-04macro_rules: Less hacky heuristic for using `tt` metavariable spansVadim Petrochenkov-34/+21
2024-01-04Silence redundant warning when E0038 will be emittedEsteban Küber-25/+19
2024-01-03Make `derive(Trait)` suggestion more accurateEsteban Küber-10/+0
Only suggest `derive(PartialEq)` when both LHS and RHS types are the same, otherwise the suggestion is not useful.
2024-01-03Account for object unsafe traitsEsteban Küber-0/+57
Fix #119525.
2024-01-03Add codegen test for RVO on MaybeUninitJakub Beránek-0/+33
Currently, this only works with `-Cpanic=abort`.
2024-01-03Track `HirId` instead of `Span` in `ObligationCauseCode::SizedArgumentType`Esteban Küber-13/+9
This gets us more accurate suggestions.
2024-01-03Account for multiple trait bounds in bare trait object suggestionEsteban Küber-2/+22
Note the parentheses in the last suggestion: ``` error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time --> $DIR/not-on-bare-trait.rs:7:8 | LL | fn foo(_x: Foo + Send) { | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Foo + Send + 'static)` = help: unsized fn params are gated as an unstable feature help: you can use `impl Trait` as the argument type | LL | fn foo(_x: impl Foo + Send) { | ++++ help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn foo(_x: &(Foo + Send)) { | ++ + ```
2024-01-03Provide better suggestions when encountering a bare trait as a typeEsteban Küber-3/+84
Add the following suggestions: ``` error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:11 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use a generic type parameter, constrained by the trait `Foo` | LL | fn bar<T: Foo>(x: T) -> Foo { | ++++++++ ~ help: you can also use `impl Foo`, but users won't be able to specify the type paramer when calling the `fn`, having to rely exclusively on type inference | LL | fn bar(x: impl Foo) -> Foo { | ++++ help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch | LL | fn bar(x: &dyn Foo) -> Foo { | ++++ error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:19 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use `impl Foo` to return an opaque type, as long as you return a single underlying type | LL | fn bar(x: Foo) -> impl Foo { | ++++ help: alternatively, you can return an owned trait object | LL | fn bar(x: Foo) -> Box<dyn Foo> { | +++++++ + ```
2024-01-04fallback visibility for unexpected trait itembohan-0/+40
2024-01-03Enable address sanitizer for MSVC targets using INFERASANLIBS linker flagDaniel Paoliello-4/+8
2024-01-03Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikicLeón Orell Valerian Liehr-2/+2
llvm: Allow `noundef` in codegen tests LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now. ``@rustbot`` label:+llvm-main