about summary refs log tree commit diff
path: root/tests/ui/rfcs
AgeCommit message (Collapse)AuthorLines
2025-01-27Rollup merge of #136112 - fmease:clean-up-all-dead-files-in-ui-tests, ↵Guillaume Gomez-1240/+0
r=compiler-errors Clean up all dead files inside `tests/ui/` While rebasing #135860 I noticed that there are several dead `*.stderr` files inside `tests/ui/`. When I checked thoroughly, I found 69 dead `*.$revision.stderr` files, 3 other dead `*.stderr` files and one dead `*.rs` file. Prior to #134808, compiletest's `--bless` didn't remove dead `*.stderr` files when the set of revisions changed in any way (renamings, removals, additions, …) which explains their existence. Regarding the dead `*.rs` file, that one was located inside an `auxiliary/` directory (together with a `*.stderr` file) despite not being meant to be an auxiliary file (it's not referenced by any `//@ aux-*`, it has an accompanying `*.stderr` file and it's obvious from looking at #111056 which added it). Ideally compiletest or tidy would forbid `*.std{out,err}` files inside `auxiliary/` dirs, that would've caught it. I moved it, updated it and turned it into a proper UI test. --- How to reproduce: 1. Run `rm tests/ui/**/*.stderr` 2. Run `./x test tests/ui --bless` (or similar) 3. Manually / semi-automatically go through all tests that were ignored (likely due to your OS etc. not matching) and restore any stderr files that were overzealously removed --- r? compiler
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-1240/+0
2025-01-25Add a suggestion to cast target_feature fn items to fn pointers.Luca Versari-13/+44
See https://github.com/rust-lang/rust/pull/134090#issuecomment-2612197095 for the motivation behind this suggestion.
2025-01-25Auto merge of #133154 - estebank:issue-133137, r=wesleywiserbors-1/+3
Reword resolve errors caused by likely missing crate in dep tree Reword label and add `help`: ``` error[E0432]: unresolved import `some_novel_crate` --> f704.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` | = help: if you wanted to use a crate named `some_novel_crate`, use `cargo add some_novel_crate` to add it to your `Cargo.toml` ``` Fix #133137.
2025-01-24Reword "crate not found" resolve messageEsteban Küber-1/+3
``` error[E0432]: unresolved import `some_novel_crate` --> file.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` ``` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From<nope::Thing> for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ```
2025-01-23tests: use `needs-subprocess` instead of `ignore-{wasm32,emscripten,sgx}`许杰友 Jieyou Xu (Joe)-4/+4
2025-01-22Rollup merge of #135409 - ↵Matthias Krüger-0/+106
Shunpoco:issue-133117-ICE-never-false-edge-start-block, r=Nadrieril Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block Fixes #133117 , and close fixes #133063 , fixes #130779 In order to fix ICE-133117, at first I needed to tackle to ICE-133063 (this fixed 130779 as well). ### ICE-133063 and ICE-130779 This ICE is caused by those steps: 1. An arm has or-pattern, and all of the sub-candidates are never-pattern 2. In that case, all sub-candidates are removed in remove_never_subcandidates(). So the arm (candidate) has no sub-candidate. 3. In the current implementation, if there is no sub-candidate, the function assigns `pre_binding_block` into the candidate ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L2002-L2004)). However, otherwise_block should be assigned to the candidate as well, because the otherwise_block is unwrapped in multiple place (like in lower_match_tree()). As a result, it causes the panic. I simply added the same block as pre_binding_block into otherwise_block, but I'm wondering if there is a better block to assign to otherwise_block (is it ok to assign the same block into pre_binding and otherwise?) ### ICE-133117 This is caused by those steps: 1. There are two arms, both are or-pattern and each has one match-pair (in the test code, both are `(!|!)`), and the second arm has a guard. 2. In match_candidate() for the first arm, it expands the second arm’s sub-candidates as well ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1800-L1805)). As a result, the root candidate of the second arm is not evaluated/modified in match_candidate(). So a false_edge_start_block is not assigned to the candidate. 3. merge_trivial_subcandidates() is called against the candidate for the second arm. It just returns immediately because the candidate has a guard. So a flase_edge_start_block is not assigned to the candidate also in this function. 4. remove_never_subcandidates() is called against the candidate. Since all sub-candidates are never-pattern. they are removed. 5. In lower_match_tree(), since there is no sub-candidate for the candidate, the candidate itself is evaluated in visit_leave_rev ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1532)). Because the candidate has no false_edge_start_block, it causes the panic. So I modified the order of if blocks in merge_trivial_subcandidates() to assign a false_edge_start_block if the candidate doesn't have.
2025-01-22address review: modify ICE-133063-never-arm-no-otherwise-block.rsShunpoco-43/+12
- Use enum Void to avoid mismatched types error - We don't need to use if let to check the ICE Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-22address review: modify ICE-133117-duplicated-never-arm.rsShunpoco-29/+15
Use enum Void to avoid mistmatched types error Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-37/+0
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
2025-01-21remove support for the #[start] attributeRalf Jung-37/+0
2025-01-16Coerce safe-to-call target_feature functions to fn pointers.Luca Versari-2/+53
2025-01-15Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, ↵bors-23/+34
r=wesleywiser Treat safe target_feature functions as unsafe by default [less invasive variant] This unblocks * #134090 As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions. This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
2025-01-15Avoid notes that only make sense for unsafe functionsOli Scherer-13/+0
2025-01-15Try to render shorthand differentlyOli Scherer-6/+3
2025-01-15Render fn defs with target_features attrs with the attribute [second site]Oli Scherer-10/+10
2025-01-15Render fn defs with target_features attrs with the attributeOli Scherer-12/+12
2025-01-15Hide the internal unsafety of safe target_feature fn itemsOli Scherer-1/+1
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-23/+50
2025-01-12Fix ICE-130779Shunpoco-0/+45
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-12Fix ICE-133117Shunpoco-0/+48
If all subcandidates have never-pattern, we should assign false_edge_start_block to the parent candidate if it doesn't have. merge_trivial_subcandidates does so, but if the candidate has guard it returns before the assignment. Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-12Fix ICE-133063Shunpoco-0/+58
If all subcandidates have never-pattern, the parent candidate should have otherwise_block because some methods expect the candidate has the block. Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-01-07Update tests.Mara Bos-1/+1
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-6/+6
2024-12-15Use links to edition guide for edition migrationsEric Huss-1/+1
2024-12-13Stabilize async closuresMichael Goulet-21/+20
2024-12-10Fix type (exit → exist)Tobias Bucher-2/+2
2024-12-09fix ICE on type error in promotedRalf Jung-6/+0
2024-12-04Add more context to fall-through "const pattern of non-structural type" errorEsteban Küber-1/+3
Point at types that need to be marked with `#[derive(PartialEq)]`. We use a visitor to look at a type that isn't structural, looking for all ADTs that don't derive `PartialEq`. These can either be manual `impl PartialEq`s or no `impl` at all, so we differentiate between those two cases to provide more context to the user. We also only point at types and impls from the local crate, otherwise show only a note. ``` error: constant of non-structural type `&[B]` in a pattern --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 | LL | struct B(i32); | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns LL | LL | const A: &[B] = &[]; | ------------- constant defined here ... LL | A => (), | ^ constant of non-structural type | = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details ```
2024-12-04Add context to fall-through "const pattern of non-structural type" errorEsteban Küber-0/+3
Unify wording with the regular non-structural type error.
2024-12-04Add additional context for non-sructural type constant used in patternEsteban Küber-48/+112
- Point at type that should derive `PartialEq` to be structural. - Point at manual `impl PartialEq`, explaining that it is not sufficient to be structural. ``` error: constant of non-structural type `MyType` in a pattern --> $DIR/const-partial_eq-fallback-ice.rs:14:12 | LL | struct MyType; | ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns ... LL | const CONSTANT: &&MyType = &&MyType; | ------------------------ constant defined here ... LL | if let CONSTANT = &&MyType { | ^^^^^^^^ constant of non-structural type | note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details --> $DIR/const-partial_eq-fallback-ice.rs:5:1 | LL | impl PartialEq<usize> for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2024-12-04Reword message for non-structural type constant in patternEsteban Küber-3/+2
2024-12-04Tweak output of some const pattern errorsEsteban Küber-8/+8
- Add primary span labels. - Point at const generic parameter used as pattern. - Point at statics used as pattern. - Point at let bindings used in const pattern.
2024-12-04Tweak ptr in pattern errorEsteban Küber-24/+48
Conform to error style guide.
2024-12-04On `const` pattern errors, point at the `const` item definitionEsteban Küber-0/+87
Centralize emitting an error in `const_to_pat` so that all errors from that evaluating a `const` in a pattern can add addditional information. With this, now point at the `const` item's definition: ``` error[E0158]: constant pattern depends on a generic parameter --> $DIR/associated-const-type-parameter-pattern.rs:20:9 | LL | pub trait Foo { | ------------- LL | const X: EFoo; | ------------- constant defined here ... LL | A::X => println!("A::X"), | ^^^^ ```
2024-12-01fix ICE when promoted has layout size overflowRalf Jung-0/+6
2024-11-27Update tests to use new proc-macro headerEric Huss-17/+4
2024-11-23Update tests for new TRPL chapter orderChris Krycho-1/+1
2024-11-22Stabilize the 2024 editionEric Huss-1/+1
2024-11-16Add regression test for issue #103476, fixed in edition 2024est31-0/+25
2024-11-16Also check if let chains with multiple lets in these two testsest31-1/+28
2024-11-10Add more places where expressions can occurest31-398/+835
2024-11-10Unify disallowed-positions test files into one fileest31-652/+2405
Also make the file have a third mode for where everything is cfg'd out to make sure it's an early error.
2024-11-04Rollup merge of #132303 - nyurik:non-exhaustive-err, r=compiler-errorsJubilee-1/+10
More tests for non-exhaustive C-like enums in FFI Add a few more tests for the `improper_ctypes` lint as found with the [varnish-rs](https://github.com/gquintard/varnish-rs) project. This follows up on #116831, fixed in #116863 by ``@workingjubilee`` - I have been seeing these fail with the bindgen-generated non-exhaustive enums inside other structs. Seems the issue does not exist in the primary branch, so this PR just makes sure more cases are covered for the future.
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-2/+2
library feature" This is consistent with all other diagnostics I could find containing features and enables the use of `DiagSymbolList` for generalizing diagnostics for unstable library features to multiple features.
2024-10-30Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebankMatthias Krüger-4/+4
Use `token_descr` more in error messages This is the first two commits from #124141, put into their own PR to get things rolling. Commit messages have the details. r? ``@estebank`` cc ``@petrochenkov``
2024-10-30Rollup merge of #129394 - Jarcho:irrefutable_let_patterns, r=NadrierilMatthias Krüger-1/+39
Don't lint `irrefutable_let_patterns` on leading patterns if `else if` let-chains fixes #128661 Is there any preference where the test goes? There looks to be several places it could fit.
2024-10-29Don't lint `irrefutable_let_patterns` on leading patterns if `else if` ↵Jason Newcomb-1/+39
let-chains.
2024-10-29Remove detail from label/note that is already available in other noteEsteban Küber-2/+2
Remove the "which is required by `{root_obligation}`" post-script in "the trait `X` is not implemented for `Y`" explanation in E0277. This information is already conveyed in the notes explaining requirements, making it redundant while making the text (particularly in labels) harder to read. ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ``` vs the prior ``` error[E0277]: the trait bound `NotCopy: Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `NotCopy`, which is required by `Option<NotCopy>: Copy` | = note: required for `Option<NotCopy>` to implement `Copy` note: required by a bound in `IsCopy` --> $DIR/wf-static-type.rs:7:17 | LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` ```
2024-10-28More test for non-exhaustive C-like enums in FFIYuri Astrakhan-1/+10
Add a few more possibly false-positive tests for the `improper_ctypes` lint