about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits
AgeCommit message (Collapse)AuthorLines
2025-07-21Constify Try, From, TryFromEvgenii Zheltonozhskii-117/+12
2025-07-18Rollup merge of #142693 - fmease:unbound-bettering, r=compiler-errorsMatthias Krüger-6/+37
More robustly deal with relaxed bounds and improve their diagnostics Scaffolding for https://github.com/rust-lang/rust/issues/135229 (CC https://github.com/rust-lang/rust/pull/135331) Fixes https://github.com/rust-lang/rust/issues/136944 (6th commit). Fixes https://github.com/rust-lang/rust/issues/142718 (8th commit).
2025-07-18Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-deadMatthias Krüger-21/+25
Make slice comparisons const This needed a fix for `derive_const`, too, as it wasn't usable in libcore anymore as trait impls need const stability attributes. I think we can't use the same system as normal trait impls while `const_trait_impl` is still unstable. r? ```@fee1-dead``` cc rust-lang/rust#143800
2025-07-18HIR ty lowering: Simplify signature of `lower_poly_trait_ref`León Orell Valerian Liehr-6/+37
2025-07-17Make slices `[const] PartialEq`Oli Scherer-21/+24
2025-07-17Make `derive_const` usable within libcore againOli Scherer-0/+1
Also make it *only* usable on nightly
2025-07-17parse `const trait Trait`Deadbeef-139/+137
2025-07-17Rollup merge of #143895 - compiler-errors:trait-wc-item-bound-host-eff, ↵León Orell Valerian Liehr-0/+32
r=oli-obk Dont collect assoc ty item bounds from trait where clause for host effect predicates For background, we uplift `where Self::Assoc: Trait` bounds in a trait's where clauses into *item bounds* on `type Assoc;`. This is because before we *had* syntactical item bounds, users would express their item bounds like so. Let's opt out of doing this same behavior for `HostEffect` predicates like `where Self::Assoc: [const] Trait`. I left a comment in the code: ```rust // FIXME(const_trait_impl): We *could* uplift the // `where Self::Assoc: [const] Trait` bounds from the parent trait // here too, but we'd need to split `const_conditions` into two // queries (like we do for `trait_explicit_predicates_and_bounds`) // since we need to also filter the predicates *out* of the const // conditions or they lead to cycles in the trait solver when // utilizing these bounds. For now, let's do nothing. ``` As an aside, this was an ICE that was only triggerable when building libraries and not binaries because we never were calling `tcx.ensure_ok().explicit_implied_const_bounds(def_id);` on associated types like we should have been. I adjusted the calls to `ensure_ok` to make sure this happens, so we catch bugs like this in the future more easily. As another aside, I fixed the bound uplifting logic for *always const* predicates, since those act like normal clauses and have no notion of conditional constness. r? ```@oli-obk``` ```@fee1-dead``` or anyone really Fixes rust-lang/rust#133275
2025-07-15Rollup merge of #143927 - oli-obk:const-dyn-trait-hir-ty, r=fmeaseSamuel Tardieu-2/+26
Preserve constness in trait objects up to hir ty lowering r? ``@compiler-errors`` While we don't support `dyn const Trait`, we can at least also inform the user that `const Trait` is only legal for `#[const_trait] trait Trait {}`
2025-07-14Preserve constness in trait objects up to hir ty loweringOli Scherer-2/+26
2025-07-14Rollup merge of #143875 - fee1-dead-contrib:push-zvqrmzrprpzt, r=compiler-errorsJakub Beránek-29/+29
update issue number for `const_trait_impl` r? project-const-traits cc rust-lang/rust#67792 rust-lang/rust#143874
2025-07-13Imply always-const host effects the same as any other item boundMichael Goulet-0/+19
2025-07-13Dont collect assoc ty item bounds from trait where clause for host effect ↵Michael Goulet-0/+13
predicates
2025-07-13update issue number for `const_trait_impl`Deadbeef-29/+29
2025-07-13Rollup merge of #143774 - oli-obk:const_from, r=fee1-deadMatthias Krüger-32/+2
constify `From` and `Into` tracking issue rust-lang/rust#143773 r? ``````@fee1-dead`````` I did not mark any impls elsewhere as `const`, those can happen on their own timeframe and don't need to be part of this MVP. But if there are some core ones you think should be in there I'll happily add them, just couldn't think of any
2025-07-13Rollup merge of #143803 - RalfJung:const-trait-tracking, r=compiler-errorsLeón Orell Valerian Liehr-7/+7
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-11fix PartialEq const feature name and const_cmp tracking issueRalf Jung-7/+7
2025-07-11Some const_trait_impl test cleanupsOli Scherer-12/+4
2025-07-11constify `From` and `Into`Oli Scherer-32/+2
2025-07-10Rollup merge of #143640 - oli-obk:const-fn-traits, r=compiler-errorsMatthias Krüger-285/+42
Constify `Fn*` traits r? `@compiler-errors` `@fee1-dead` this should unlock a few things. A few `const_closures` tests have broken even more than before, but that feature is marked as incomplete anyway cc rust-lang/rust#67792
2025-07-08Constify `Fn*` traitsOli Scherer-285/+42
2025-07-07Make `Default` const and add some `const Default` implsEsteban Küber-101/+110
Full list of `impl const Default` types: - () - bool - char - Cell - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2025-07-05Rename tests named with `mbe` to use `macro` insteadJosh Triplett-6/+6
Most macro tests use `macro` in the name, making it easy to find and run tests relevant to macros. However, a few use `mbe` instead. Rename those to say `macro`.
2025-07-02Rollup merge of #143235 - compiler-errors:const-item-bound, r=oli-obkMatthias Krüger-0/+19
Assemble const bounds via normal item bounds in old solver too Fixes the first example in https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/elaboration.20of.20const.20bounds.3F/with/526378135 The code duplication here is not that nice, but it's at least very localized. cc `@davidtwco` r? oli-obk
2025-06-30Replace `ItemCtxt::report_placeholder_type_error` `match` with a call to ↵Guillaume Gomez-1/+1
`TyCtxt::def_descr`
2025-06-30Assemble const bounds via normal item bounds in old solver tooMichael Goulet-0/+19
2025-06-29Fix the span of trait bound modifier `[const]`León Orell Valerian Liehr-215/+215
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-1211/+1266
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-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-2/+2
such constants as patterns
2025-06-26Rename `tilde const` test files to `conditionally const`Oli Scherer-61/+65
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-971/+1022
2025-06-24Don't include current rustc version string in feature removed helpJieyou Xu-4/+3
The version string is difficult to properly normalize out, and removing it isn't a huge deal (the user can query version info easily through `rustc --version` or `cargo --version`). The normalization options were all non-ideal: - Per-test version string normalization is nasty to maintain, and we need to maintain `n` copies of it. - Centralized compiletest normalization (with a directive opt-out) is also not ideal, because `cfg(version(..))` tests can't have those accidentally normalized out (and you'd have to remember to opt-out).
2025-06-23Account for beta revisions when normalizing versionsJosh Stone-1/+1
Several UI tests have a `normalize-stderr` for "you are using x.y.z" rustc versions, and that regex is flexible enough for suffixes like "-nightly" and "-dev", but not for "-beta.N". We can just add '.' to that trailing pattern to include this.
2025-06-23Make `PartialEq` a `const_trait`Oli Scherer-541/+27
2025-06-18Rollup merge of #141610 - BoxyUwU:stabilize_generic_arg_infer, ↵Jakub Beránek-7/+6
r=lcnr,traviscross Stabilize `feature(generic_arg_infer)` Fixes rust-lang/rust#85077 r? lcnr cc ````@rust-lang/project-const-generics````
2025-06-16aux: add `{Meta,Pointee}Sized` bounds to minicoreDavid Wood-25/+25
With `MetaSized` bounds replacing `?Sized` and being added as a supertrait, the same relaxations applied to the standard library must be applied to minicore.
2025-06-16aux: add `{Meta,Pointee}Sized` to minicoreDavid Wood-1/+8
Add `MetaSized` and `PointeeSized` to minicore so that fewer tests fail from missing language items.
2025-06-12Rollup merge of #142066 - ferrocene:lw/edition-2015-tests, r=compiler-errorsMatthias Krüger-3/+4
More simple 2015 edition test decoupling This should be the last of these PRs for now. The remaining tests that do not work on other editions than 2015 either need the range support (so blocked on the MCP), need normalization rules (which needs discussions first/same MCP) or revisions. r? compiler-errors
2025-06-11stabilize gaiBoxy-7/+6
2025-06-09Make `since` of removed features the version removed and fill `pull`xizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-09Note the version and PR of removed features when using itxizheyin-2/+4
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-05Move opaque type checks from the hir item types visitor onto the wfcheck of ↵Oli Scherer-13/+13
the opaqe type itself
2025-06-05Add missing `dyn` keywords to tests that do not test for themLukas Wirth-3/+3
2025-06-05Add more missing 2015 edition directivesLukas Wirth-0/+1
2025-05-25const-check: stop recommending the use of rustc_allow_const_fn_unstableRalf Jung-114/+19
2025-05-10Auto merge of #140854 - oli-obk:merge-queries, r=nnethercotebors-18/+18
Merge typeck loop with static/const item eval loop r? `@ghost` Let's try a small one first. Doing this in general has some bad cache coherence issues because the query caches are laid out in `Vec<QueryResult>` lists per query where each index refers to a `DefId` in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2025-05-09Merge typeck loop with static/const item eval loopOli Scherer-18/+18
2025-05-09Add regression test for 125877reddevilmidzy-0/+53
2025-04-29Treat `ManuallyDrop` as `~const Destruct`Oli Scherer-23/+1
2025-04-29Add testOli Scherer-0/+63