about summary refs log tree commit diff
path: root/tests/ui/const-generics
AgeCommit message (Collapse)AuthorLines
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
2025-07-10Check assoc consts and tys later like assoc fnsMu001999-0/+1
2025-07-10chore: Improve how the other suggestions message gets renderedScott Schafer-1/+1
2025-07-09Add opaque TypeId handles for CTFEOli Scherer-25/+3
2025-07-09Port `#[type_const]` to the new attribute systemPavel Grigorenko-7/+11
2025-07-08Auto merge of #143621 - matthiaskrgr:rollup-p1ce8l7, r=matthiaskrgrbors-1/+1
Rollup of 7 pull requests Successful merges: - rust-lang/rust#142098 (Implement `int_format_into` feature) - rust-lang/rust#143567 (Point to correct argument in Func Call when Self type fails trait bound) - rust-lang/rust#143570 (consider nested cases for duplicate RPITIT) - rust-lang/rust#143571 (remove `has_nested` from builtin candidates) - rust-lang/rust#143586 (Fix wrong cache event query key) - rust-lang/rust#143589 (const-block-as-pattern: do not refer to no-longer-existing nightly feature) - rust-lang/rust#143608 (Fix in std::String docs) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-07Point to correct argument in Func Call when Self type fails trait boundxizheyin-1/+1
When a trait bound fails due to the Self type parameter, adjust_fulfillment_errors now correctly points to the corresponding function argument instead of incorrectly pointing to other arguments. Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07Add `ty_span` queryOli Scherer-0/+8
2025-06-30Avoid looking at HIR for trait and impl itemsOli Scherer-1/+1
2025-06-30Unconditionally run `check_item_type` on all itemsOli Scherer-23/+58
2025-06-27Rollup merge of #143106 - yotamofek:pr/gce/non-local-ice, r=BoxyUwUMatthias Krüger-0/+20
gce: don't ICE on non-local const Fixes rust-lang/rust#133808 I have absolutely no idea what I'm doing here, but I followed `@BoxyUwU` 's [instructions](https://github.com/rust-lang/rust/issues/133808#issuecomment-3009122957), and turns out this small change fixes rust-lang/rust#133808, and doesn't seem to break anything else. (This code path is only reachable when the GCE feature gate is enabled, so even if it does break in a way that is not caught by current test coverage, I guess it's not as bad as breaking stable or non-incomplete features?) Anyways, r? `@BoxyUwU` , if you don't mind.
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-4/+3
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27gce: don't ICE on non-local constYotam Ofek-0/+20
2025-06-27Report infer ty errors during hir ty loweringOli Scherer-10/+20
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-06-27Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errorsbors-4/+40
Rollup of 18 pull requests Successful merges: - rust-lang/rust#137843 (make RefCell unstably const) - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns) - rust-lang/rust#142549 (small iter.intersperse.fold() optimization) - rust-lang/rust#142637 (Remove some glob imports from the type system) - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation) - rust-lang/rust#142700 (Remove incorrect comments in `Weak`) - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`) - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition) - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143001 (Rename run always ) - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`) - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`) - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes) - rust-lang/rust#143041 (Remove cache for citool) - rust-lang/rust#143056 (Move an ACE test out of the GCI directory) - rust-lang/rust#143059 (Fix 1.88 relnotes) - rust-lang/rust#143067 (Tracking issue number for `iter_macro`) - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains) Failed merges: - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-4/+40
such constants as patterns
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-4/+3
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-5/+11
2025-06-20Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=petrochenkovTrevor Gross-2/+22
Marks ADT live if it appears in pattern Marks ADT live if it appears in pattern, it implies the construction of the ADT. 1. Then we can detect unused private ADTs impl `Default`, without special logics for `Default` and other std traits. 2. We can also remove `rustc_trivial_field_reads` on `Default`, and the logic in `should_ignore_item` (introduced by rust-lang/rust#126302). Fixes rust-lang/rust#120770 Extracted from rust-lang/rust#128637. r? `@petrochenkov`
2025-06-18Rollup merge of #141610 - BoxyUwU:stabilize_generic_arg_infer, ↵Jakub Beránek-139/+37
r=lcnr,traviscross Stabilize `feature(generic_arg_infer)` Fixes rust-lang/rust#85077 r? lcnr cc ````@rust-lang/project-const-generics````
2025-06-16tests: bless remaining testsDavid Wood-0/+2
These tests just need blessing, they don't have any interesting behaviour changes. Some of these tests have new errors because `LegacyReceiver` cannot be proven to be implemented now that it is also testing for `MetaSized` - but this is just a consequence of the other errors in the test.
2025-06-14Marks ADT live if it appears in patternMu001999-2/+22
2025-06-13Require generic params for const generic paramsOli Scherer-0/+35
2025-06-12Rollup merge of #142157 - Enselic:trivial-anon-const-use-cases, ↵Matthias Krüger-34/+77
r=compiler-errors rustc_resolve: Improve `resolve_const_param_in_non_trivial_anon_const` wording In some contexts, const expressions are OK. Add a `here` to the error message to clarify this. Closes rust-lang/rust#79429 which has 15 x 👍
2025-06-11stabilize gaiBoxy-139/+37
2025-06-07const-eval error: always say in which item the error occurredRalf Jung-8/+8
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-07rustc_resolve: Improve `resolve_const_param_in_non_trivial_anon_const` wordingMartin Nordholts-34/+77
In some contexts, const expressions are OK. Add a `here` to the error message to clarify this.
2025-06-06Rollup merge of #142043 - estebank:const-suggestion, r=wesleywiserGuillaume Gomez-9/+21
Verbose suggestion to make param `const` ``` error[E0747]: type provided when a constant was expected --> $DIR/invalid-const-arguments.rs:10:19 | LL | impl<N> Foo for B<N> {} | ^ | help: consider changing this type parameter to a const parameter | LL - impl<N> Foo for B<N> {} LL + impl<const N: u8> Foo for B<N> {} | ``` Part of rust-lang/rust#141973.
2025-06-05Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, ↵bors-14/+13
r=traviscross,jieyouxu Add a new `mismatched-lifetime-syntaxes` lint The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is: - Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples: ```rust // Lint will warn about these fn(v: ContainsLifetime) -> ContainsLifetime<'_>; fn(&'static u8) -> &u8; ``` - Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule: ```rust // Lint will not warn about these fn(&u8) -> &'_ u8; fn(&'_ u8) -> &u8; fn(&u8) -> ContainsLifetime<'_>; ``` - Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler. --- This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-04Verbose suggestion to make param `const`Esteban Küber-9/+21
``` error[E0747]: type provided when a constant was expected --> $DIR/invalid-const-arguments.rs:10:19 | LL | impl<N> Foo for B<N> {} | ^ | help: consider changing this type parameter to a const parameter | LL - impl<N> Foo for B<N> {} LL + impl<const N: u8> Foo for B<N> {} | ```
2025-06-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-14/+13
2025-06-02Clarify why we are talking about a failed const eval at a random placeOli Scherer-11/+11
2025-06-02Use the informative error as the main const eval error messageOli Scherer-48/+46
2025-05-23Do not try to confirm non-dyn compatible methodMichael Goulet-40/+3
2025-05-23Auto merge of #140553 - BoxyUwU:defer_type_system_ctfe, r=compiler-errorsbors-53/+364
Defer evaluating type system constants when they use infers or params Split out of #137972, the parts necessary for associated const equality and min generic const args to make progress and have correct semantics around when CTFE is invoked. According to a [previous perf run](https://perf.rust-lang.org/compare.html?start=93257e2d20809d82d1bc0fcc1942480d1a66d7cd&end=01b4cbf0f47c3f782330db88fa5ba199bba1f8a2&stat=instructions:u) of adding the new `const_arg_kind` query we should expect minor regressions here. I think this is acceptable as we should be able to remove this query relatively soon once mgca is more complete as we'll then be able to implement GCE in terms of mgca and rip out `GCEConst` at which point it's trivial to determine what kind of anon const we're dealing with (either it has generics and is a repeat expr hack, or it doesnt and is a normal anon const). This should only affect unstable code as we handle repeat exprs specially and those are the only kinds of type system consts that are allowed to make use of generic parameters. Fixes #133066 Fixes #133199 Fixes #136894 Fixes #137813 r? compiler-errors
2025-05-22Review CommentsBoxy-0/+2
2025-05-22Return correct error term kind on projection errorsBoxy-0/+56
2025-05-21Fix testsBoxy-53/+362
2025-05-05Do not gather local all together at the beginning of typeckMichael Goulet-74/+74
2025-05-01Set groundwork for proper const normalizationBoxy-10/+5
2025-04-30Rollup merge of #140467 - BoxyUwU:no_fcw_assoc_consts, r=lcnrMatthias Krüger-0/+23
Don't FCW assoc consts in patterns Fixes #140447 See comment in added test. We could also check that the anon const is a const arg by looking at the HIR. I'm not sure that's necessary though :thinking: The only consts that are evaluated "for the type system" are const args (which *should* get FCWs) and const patterns (which cant be anon consts afaik).
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-33/+39
2025-04-29Don't FCW assoc consts in patternsBoxy-0/+23