about summary refs log tree commit diff
path: root/tests/ui/const-generics
AgeCommit message (Collapse)AuthorLines
2025-09-29Make replacement suggestion `_` in type verboseEsteban Küber-13/+23
``` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/in-signature.rs:6:21 | LL | fn arr_fn() -> [u8; _] { | ^ not allowed in type signatures | help: replace with the correct return type | LL - fn arr_fn() -> [u8; _] { LL + fn arr_fn() -> [u8; 3] { | ```
2025-09-24Rollup merge of #146894 - tiif:suggest_feature_attr, r=BoxyUwUMatthias Krüger-5/+5
Improve derive suggestion of const param Make the suggestion not to remove the adt and use the name of the adt variant in the diagnostic. r? `@BoxyUwU`
2025-09-24Improve the pretty print of UnstableFeature clausetiif-3/+3
2025-09-24Improve derive suggestion of const paramtiif-5/+5
Make the suggestion not to remove the adt and use the name of the adt variant
2025-09-16Rollup merge of #145095 - tiif:unstable_const_param, r=BoxyUwUStuart Cook-268/+184
Migrate `UnsizedConstParamTy` to unstable impl of `ConstParamTy_` Now that we have ``#[unstable_feature_bound]``, we can remove ``UnsizedConstParamTy`` that was meant to be an unstable impl of stable type and ``ConstParamTy_`` trait. r? `@BoxyUwU`
2025-09-15Fix the testcases to not use UnsizedConstParamTytiif-268/+184
2025-09-15Rollup merge of #143314 - tshepang:fix-filename, r=compiler-errorsMatthias Krüger-0/+1
add reference id to test, and fix filename Noticed the filename is wrong, then took advantage of being there by adding Reference id
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-18/+2
2025-09-10Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhprattMatthias Krüger-9/+9
inclusive `Range`s: change `end` to `last` Tracking issue: rust-lang/rust#125687 ACP: rust-lang/libs-team#511
2025-09-08change end to lastJeremy Smart-9/+9
2025-09-06Rollup merge of #144801 - estebank:issue-144734, r=spastorinoMatthias Krüger-4/+0
Suggest bounds in more cases, accounting for type parameters referenced in predicate Use a `ty::Visitor` to see if the failed predicate references a type parameter. If it does, then we only suggest adding a bound to an (associated) item only if the referenced parameter is present in its generics. Provide adding bound suggestion in trait and impl associated functions in cases we previously weren't: ``` error[E0277]: `?` couldn't convert the error to `ApplicationError` --> $DIR/suggest-complex-bound-on-method.rs:18:16 | LL | t.run()?; | -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError` | | | this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>` | note: `ApplicationError` needs to implement `From<<T as Trait>::Error>` --> $DIR/suggest-complex-bound-on-method.rs:12:1 | LL | enum ApplicationError { | ^^^^^^^^^^^^^^^^^^^^^ = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | LL | fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> { | +++++++++++++++++++++++++++++++++++++++++++++++++ ``` Fix rust-lang/rust#144734.
2025-09-03don't uppercase error messagesSasha Pourcelot-4/+4
a more general version of https://github.com/rust-lang/rust/pull/146080. after a bit of hacking in [`fluent.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_fluent_macro/src/fluent.rs), i discovered that i'm not the only one that is bad at following guidelines :sweat_smile:. this pr lowercases the first letter of all the error messages in the codebase. (i did not change things that are traditionally uppercased such as _MIR_, _ABI_ or _C_) i think it's reasonable to run a `@bors try` so all the test suite is checked, as i cannot run some of the tests on my machine. i double checked (and replaced manually) all the old error messages, but better be safe than sorry. in the future i will try to add a check in `x test tidy` that errors if an error message starts with an uppercase letter.
2025-08-26fix: Add col separator before secondary messages with no sourceScott Schafer-0/+1
2025-08-26fix: Don't add an end column separator after a file with no sourceScott Schafer-1/+0
2025-08-26Rollup merge of #145481 - mu001999-contrib:fix/closure-sugg, r=SparrowLiiGuillaume Gomez-2/+3
Add parentheses for closure when suggesting calling closure Fixes rust-lang/rust#145404
2025-08-23Use unnamed lifetime spans as primary spans for MISMATCHED_LIFETIME_SYNTAXESMichael Goulet-2/+2
2025-08-23Auto merge of #145773 - jhpratt:rollup-kocqnzv, r=jhprattbors-8/+43
Rollup of 28 pull requests Successful merges: - rust-lang/rust#132087 (Fix overly restrictive lifetime in `core::panic::Location::file` return type) - rust-lang/rust#137396 (Recover `param: Ty = EXPR`) - rust-lang/rust#137457 (Fix host code appearing in Wasm binaries) - rust-lang/rust#142185 (Convert moves of references to copies in ReferencePropagation) - rust-lang/rust#144648 (Implementation: `#[feature(nonpoison_rwlock)]`) - rust-lang/rust#144897 (print raw lifetime idents with r#) - rust-lang/rust#145218 ([Debuginfo] improve enum value formatting in LLDB for better readability) - rust-lang/rust#145380 (Add codegen-llvm regression tests) - rust-lang/rust#145573 (Add an experimental unsafe(force_target_feature) attribute.) - rust-lang/rust#145597 (resolve: Remove `ScopeSet::Late`) - rust-lang/rust#145633 (Fix some typos in LocalKey documentation) - rust-lang/rust#145641 (On E0277, point at type that doesn't implement bound) - rust-lang/rust#145669 (rustdoc-search: GUI tests check for `//` in URL) - rust-lang/rust#145695 (Introduce ProjectionElem::try_map.) - rust-lang/rust#145710 (Fix the ABI parameter inconsistency issue in debug.rs for LoongArch64) - rust-lang/rust#145726 (Experiment: Reborrow trait) - rust-lang/rust#145731 (Make raw pointers work in type-based search) - rust-lang/rust#145736 (triagebot: Update style team reviewers) - rust-lang/rust#145738 (Uplift rustc_mir_transform::coverage::counters::union_find to rustc_data_structures.) - rust-lang/rust#145742 (rustdoc js: Even more typechecking improvments ) - rust-lang/rust#145743 (doc: fix some typos in comment) - rust-lang/rust#145745 (tests: Ignore basic-stepping.rs on LoongArch) - rust-lang/rust#145747 (Refactor lint buffering to avoid requiring a giant enum) - rust-lang/rust#145751 (fix(lexer): Allow '-' in the frontmatter infostring continue set) - rust-lang/rust#145761 (Add aarch64_be-unknown-hermit target) - rust-lang/rust#145762 (convert strings to symbols in attr diagnostics) - rust-lang/rust#145763 (Ship LLVM tools for the correct target when cross-compiling) - rust-lang/rust#145765 (Revert suggestions for missing methods in tuples) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-22Separate transmute checking from typeck.Camille Gillot-8/+8
2025-08-22On E0277, point at type that doesn't implement boundEsteban Küber-8/+43
When encountering an unmet trait bound, point at local type that doesn't implement the trait: ``` error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied --> $DIR/issue-64855.rs:9:19 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | help: the trait `Foo` is not implemented for `Bar<T>` --> $DIR/issue-64855.rs:9:1 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^ ```
2025-08-19bless tests with new lint messagesKarol Zwolak-11/+11
2025-08-16Add parentheses for closure when suggesting calling closureMu001999-2/+3
2025-08-10Rollup merge of #144553 - Oneirical:uncountable-integer-4, r=jieyouxuJacob Pratt-0/+82
Rehome 32 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that `@Kivooeo` was using. r? `@jieyouxu`
2025-08-10Rehome tests/ui/issues/ tests [4/?]Oneirical-0/+82
2025-08-07Rollup merge of #144133 - oli-obk:stabilize-const-type-id, r=lcnrStuart Cook-3/+2
Stabilize const TypeId::of fixes rust-lang/rust#77125 # Stabilization report for `const_type_id` ## General design ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized? N/A the constness was never RFCed ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con. `const_type_id` was kept unstable because we are currently unable to stabilize the `PartialEq` impl for it (in const contexts), so we feared people would transmute the type id to an integer and compare that integer. ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those? `TypeId::eq` is not const at this time, and will only become const once const traits are stable. ## Has a Call for Testing period been conducted? If so, what feedback was received? This feature has been unstable for a long time, and most people just worked around it on stable by storing a pointer to `TypeId::of` and calling that at "runtime" (usually LLVM devirtualized the function pointer and inlined the call so there was no real performance difference). A lot of people seem to be using the `const_type_id` feature gate (600 results for the feature gate on github: https://github.com/search?q=%22%23%21%5Bfeature%28const_type_id%29%5D%22&type=code) We have had very little feedback except desire for stabilization being expressed. ## Implementation quality Until these three PRs * https://github.com/rust-lang/rust/pull/142789 * https://github.com/rust-lang/rust/pull/143696 * https://github.com/rust-lang/rust/pull/143736 there was no difference between the const eval feature and the runtime feature except that we prevented you from using `TypeId::of` at compile-time. These three recent PRs have hardened the internals of `TypeId`: * it now contains an array of pointers instead of integers * these pointers at compile-time (and in miri) contain provenance that makes them unique and prevents inspection. Both miri and CTFE will in fact error if you mess with the bits or the provenance of the pointers in any way and then try to use the `TypeId` for an equality check. This also guards against creating values of type `TypeId` by any means other than `TypeId::of` ### Summarize the major parts of the implementation and provide links into the code (or to PRs) N/A see above ### Summarize existing test coverage of this feature Since we are not stabilizing any operations on `TypeId` except for creating `TypeId`s, the test coverage of the runtime implementation of `TypeId` covers all the interesting use cases not in the list below #### Hardening against transmutes * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_transmute_type_id.rs * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_transmute_type_id2.rs * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_transmute_type_id3.rs * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_transmute_type_id4.rs * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_transmute_type_id5.rs #### TypeId::eq is still unstable * https://github.com/rust-lang/rust/blob/master/tests/ui/consts/const_cmp_type_id.rs ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking? https://github.com/rust-lang/rust/issues/129014 is still unresolved, but it affects more the runtime version of `TypeId` than the compile-time. ### What FIXMEs are still in the code for that feature and why is it ok to leave them there? none ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization * `@eddyb` * `@RalfJung` ### Which tools need to be adjusted to support this feature. Has this work been done? N/A ## Type system and execution rules ### What compilation-time checks are done that are needed to prevent undefined behavior? Already covered above. Transmuting types with private fields to expose those fields has always been library UB, but for the specific case of `TypeId` CTFE and Miri will detect it if that is done in any way other than for reconstructing the exact same `TypeId` in another location. ### Does the feature's implementation need checks to prevent UB or is it sound by default and needs opt in in places to perform the dangerous/unsafe operations? If it is not sound by default, what is the rationale? N/A ### Can users use this feature to introduce undefined behavior, or use this feature to break the abstraction of Rust and expose the underlying assembly-level implementation? (Describe.) N/A ### What updates are needed to the reference/specification? (link to PRs when they exist) Nothing more than what needs to exist for `TypeId` already. ## Common interactions ### Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries? N/A ### What other unstable features may be exposed by this feature? N/A
2025-08-07Auto merge of #115746 - tgross35:unnamed-threads-panic-message, r=cuviperbors-1/+1
Print thread ID in panic message `panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (12345) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print. try-job: aarch64-apple try-job: aarch64-gnu try-job: dist-apple-various try-job: dist-various-* try-job: dist-x86_64-freebsd try-job: dist-x86_64-illumos try-job: dist-x86_64-netbsd try-job: dist-x86_64-solaris try-job: test-various try-job: x86_64-gnu try-job: x86_64-mingw-1 try-job: x86_64-msvc-1
2025-08-06Print thread ID in panic message if thread name is unknownTrevor Gross-1/+1
`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
2025-08-06Fortify generic param default checksLeón Orell Valerian Liehr-9/+9
2025-08-05Rollup merge of #144548 - Oneirical:uncountable-integer-2, r=jieyouxuSamuel Tardieu-0/+49
Rehome 21 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` rust-lang/rust#143902 divided into smaller, easier to review chunks. Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that ``@Kivooeo`` was using. r? ``@jieyouxu``
2025-08-04Suggest bounds in more cases, accounting for type parameters referenced in ↵Esteban Küber-4/+0
predicate
2025-08-02Rehome tests/ui/issues/ tests [2/?]Oneirical-0/+49
2025-08-01Rollup merge of #144397 - Kivooeo:issue2, r=jieyouxuRalf Jung-0/+21
`tests/ui/issues/`: The Issues Strike Back [2/N] Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895. r? ``@jieyouxu``
2025-07-31commentsKivooeo-0/+15
2025-07-29Rollup merge of #144587 - petrochenkov:optstdprel, r=nnethercoteStuart Cook-2/+2
expand: Micro-optimize prelude injection Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-07-29Add a regression test for an ICE with the `generic_const_exprs` feature ↵Jacob Adam-0/+42
attribute. It ensures that using the `generic_const_exprs` feature in a library crate without enabling it in a dependent crate does not lead to an ICE.
2025-07-28expand: Micro-optimize prelude injectionVadim Petrochenkov-2/+2
Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-07-26Rollup merge of #144409 - GuillaumeGomez:macro-expansion-early-abort, r=oli-obkJacob Pratt-44/+80
Stop compilation early if macro expansion failed Fixes rust-lang/rust#116180. So there isn't really a type that is central for macro expansion and some errors are actually emitted (because the resolution happens after the expansion I suppose) after the expansion pass (like "not found macro"). Sometimes, errors are only emitted on the second "try" (to improve error output). So I couldn't reach a similar solution than what was done in https://github.com/rust-lang/rust/pull/133937 and suggested by ````@estebank```` in https://github.com/rust-lang/rust/issues/116180#issuecomment-3109468922. But maybe I missed something? So in the end, I realized that there is method called every time (except one, described below) a macro error is actually emitted: `ExtCtxt::trace_macros_diag`. Considering I updated what it did, I renamed it into `macro_error_and_trace_macros_diag` to better reflect it. There is only one call of `trace_macros_diag` which isn't reporting an error but just used for `macro_trace` feature, so I kept it as is. r? ````@oli-obk````
2025-07-25Update ui tests with new macro early erroringGuillaume Gomez-44/+80
2025-07-24Rehome tests/ui/issues/ tests [1/?]Oneirical-0/+34
2025-07-24moved 35 tests to organized locationsKivooeo-0/+6
2025-07-23Auto merge of #144233 - cjgillot:unsat-mir, r=oli-obkbors-9/+17
Consider parent predicates in ImpossiblePredicates pass. This pass is double edged. It avoids some ICEs (yay!) but also degrades diagnostics from constant evaluation. Fixes rust-lang/rust#121363 Fixes rust-lang/rust#131507 Fixes rust-lang/rust#140100 Fixes rust-lang/rust#140365
2025-07-21Stabilize const `TypeId::of`Oli Scherer-3/+2
2025-07-20Consider parent predicates in ImpossiblePredicates pass.Camille GILLOT-9/+17
2025-07-18Show the memory of uninit readsOli Scherer-0/+16
2025-07-17Report the range of uninit bytes in CTFE errorsOli Scherer-4/+4
2025-07-14Reword mismatched-lifetime-syntaxes text based on feedbackJake Goulding-6/+7
Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion.
2025-07-13Rollup merge of #143519 - mu001999-contrib:dead-code/impl-items, r=petrochenkovMatthias Krüger-0/+1
Check assoc consts and tys later like assoc fns This PR 1. checks assoc consts and tys later like assoc fns 2. marks assoc consts appear in poly-trait-ref live For assoc consts, considering ```rust #![deny(dead_code)] trait Tr { // ERROR trait `Tr` is never used const I: Self; } struct Foo; //~ ERROR struct `Foo` is never constructed impl Tr for Foo { const I: Self = Foo; } fn main() {} ``` Current this will produce unused `I` instead of unused `Tr` and `Foo` ([play](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=e0490d4a2d522cb70437b26e514a3d9c)), because `const I: Self = Foo;` will be added into the worklist at first: ``` error: associated constant `I` is never used --> src/main.rs:4:11 | 3 | trait Tr { // ERROR trait `Tr` is never used | -- associated constant in this trait 4 | const I: Self; | ^ | note: the lint level is defined here --> src/main.rs:1:9 | 1 | #![deny(dead_code)] | ^^^^^^^^^ error: could not compile `playground` (bin "playground") due to 1 previous error ``` This also happens to assoc tys, see the [new test](https://github.com/rust-lang/rust/compare/master...mu001999-contrib:rust:dead-code/impl-items?expand=1#diff-bf45fa403934a31c9d610a073ed2603d885e7e81572e8edf38b7f4e08a1f3531) Fixes rust-lang/rust#126729 r? `````@petrochenkov`````
2025-07-13Rollup merge of #143803 - RalfJung:const-trait-tracking, r=compiler-errorsLeón Orell Valerian Liehr-1/+1
New tracking issues for const_ops and const_cmp Let's do a clean start with new tracking issues to avoid mixing things up with the previous constification. I assume the fact that the `PartialEq` *trait* and *impls* used different feature names was a mistake (the feature name on the impl is entirely irrelevant anyway). Part of https://github.com/rust-lang/rust/issues/143800, https://github.com/rust-lang/rust/issues/143802 r? ``@oli-obk``
2025-07-12Auto merge of #143810 - matthiaskrgr:rollup-iw7a23z, r=matthiaskrgrbors-7/+11
Rollup of 9 pull requests Successful merges: - rust-lang/rust#143403 (Port several trait/coherence-related attributes the new attribute system) - rust-lang/rust#143633 (fix: correct assertion to check for 'noinline' attribute presence before removal) - rust-lang/rust#143647 (Clarify and expand documentation for std::sys_common dependency structure) - rust-lang/rust#143716 (compiler: doc/comment some codegen-for-functions interfaces) - rust-lang/rust#143747 (Add target maintainer information for aarch64-unknown-linux-musl) - rust-lang/rust#143759 (Fix typos in function names in the `target_feature` test) - rust-lang/rust#143767 (Bump `src/tools/x` to Edition 2024 and some cleanups) - rust-lang/rust#143769 (Remove support for SwitchInt edge effects in backward dataflow) - rust-lang/rust#143770 (build-helper: clippy fixes) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-11Rollup merge of #143403 - GrigorenkoPV:attributes/traits, r=jdonszelmannMatthias Krüger-7/+11
Port several trait/coherence-related attributes the new attribute system Part of rust-lang/rust#131229 This ports: - `#[const_trait]` - `#[rustc_deny_explicit_impl]` - `#[rustc_do_not_implement_via_object]` - `#[rustc_coinductive]` - `#[type_const]` - `#[rustc_specialization_trait]` - `#[rustc_unsafe_specialization_marker]` - `#[marker]` - `#[fundamental]` - `#[rustc_paren_sugar]` - `#[rustc_allow_incoherent_impl]` - `#[rustc_coherence_is_core]` This also changes `#[marker]` to error on duplicates instead of warning. cc rust-lang/rust#142838, but I don't think it matters too much, since it's unstable. r? ``@oli-obk``
2025-07-11fix PartialEq const feature name and const_cmp tracking issueRalf Jung-1/+1