about summary refs log tree commit diff
path: root/tests/ui/traits
AgeCommit message (Collapse)AuthorLines
2024-11-26Rollup merge of #133394 - compiler-errors:dyn-more-errors, r=lcnrMichael Goulet-52/+4
Bail on more errors in dyn ty lowering If we have more than one principal trait, or if we have a principal trait with errors in it, then bail with `TyKind::Error` rather than attempting lowering. Lowering a dyn trait with more than one principal just arbitrarily chooses the first one and drops the subsequent ones, and lowering a dyn trait path with errors in it is just kinda useless. This suppresses unnecessary errors which I think is net-good, but also is important to make sure that we don't end up leaking `{type error}` in https://github.com/rust-lang/rust/issues/133388 error messaging :) r? types
2024-11-26Rollup merge of #133495 - lcnr:env-shadowing-tests, r=compiler-errorsGuillaume Gomez-0/+19
add test for alias-bound shadowing, rename folder r? `@BoxyUwU` `@compiler-errors`
2024-11-26Rollup merge of #133473 - Enselic:cow, r=nnethercoteGuillaume Gomez-0/+11
tests: Add regression test for recursive enum with Cow and Clone I could not find any existing test. `git grep "(Cow<'[^>]\+\["` gave no hits before this tests. Closes #100347
2024-11-26Rollup merge of #133470 - jieyouxu:ugly, r=compiler-errorsGuillaume Gomez-29/+0
Cleanup: delete `//@ pretty-expanded` directive This PR removes the `//@ pretty-expanded` directive support in compiletest and removes its usage inside ui tests because it does not actually do anything, and its existence is itself misleading. This PR is split into two commits: 1. The first commit just drops `pretty-expanded` directive support in compiletest. 2. The second commit is created by `sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs`[^1], reblessing, and slightly adjusting some leading whitespace in a few tests. We can tell this is fully removed because compiletest doesn't complain about unknown directive when running the `ui` test suite. cc #23616 ### History Originally, there was some effort to introduce more test coverage for `-Z unpretty=expanded` (in 2015 this was called `--pretty=expanded`). In [Make it an error to not declare used features #23598][pr-23598], there was a flip from `//@ no-pretty-expanded` (opt-out of `-Z unpretty=expanded` test) to `//@ pretty-expanded` (opt-in to `-Z unpretty=expanded` test). This was needed because back then the dedicated `tests/pretty` ("pretty") test suite did not existed, and the pretty tests were grouped together under `run-pass` tests (I believe the `ui` test suite didn't exist back then either). Unfortunately, in this process the replacement `//@ pretty-expanded` directives contained a `FIXME #23616` linking to [There are very few tests for `-Z unpretty` expansion #23616][issue-23616]. But this was arguably backwards and somewhat misleading, as noted in [#23616](https://github.com/rust-lang/rust/issues/23616#issuecomment-484999901): The attribute is off by default and things just work if you don't test it, people have not been adding the `pretty-expanded` annotation to new tests even if it would work. Which basically renders this useless. ### Current status As of Nov 2024, we have a dedicated `pretty` test suite, and some time over the years the split between `run-pass` into `ui` and `pretty` test suites caused all the `//@ pretty-expanded` in `ui` tests to do absolutely nothing: the compiletest logic for `pretty-expanded` only triggers in the *pretty* test suite, but none of the pretty tests use it. Oops. Nobody remembers this, nobody uses this, it's misleading in ui tests. Let's get rid of this directive altogether. [pr-23598]: https://github.com/rust-lang/rust/pull/23598 [issue-23616]: https://github.com/rust-lang/rust/issues/23616 ### Follow-ups - [x] Yeet this directive from rustc-dev-guide docs. https://github.com/rust-lang/rustc-dev-guide/pull/2147 [^1]: https://github.com/chmln/sd r? compiler
2024-11-26add test for alias-bound shadowing, rename folderlcnr-0/+19
2024-11-26do not constrain infer vars in `find_best_leaf_obligation`lcnr-60/+4
2024-11-26tests: Add regression test for self referential struct with cow as last fieldMartin Nordholts-0/+19
2024-11-25tests: Add regression test for recursive enum with Cow and CloneMartin Nordholts-0/+11
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-29/+0
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-11-25tests: Add recursive associated type bound regression testsMartin Nordholts-0/+74
2024-11-25Constify Drop and DestructMichael Goulet-465/+71
2024-11-23Dont create object type when more than one principal is presentMichael Goulet-52/+4
2024-11-23Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors许杰友 Jieyou Xu (Joe)-58/+4
Minimally constify `Add` * This PR removes the requirement for `impl const` to have a const stability attribute. cc ``@RalfJung`` I believe you mentioned that it would make much more sense to require `const_trait`s to have const stability instead. I agree with that sentiment but I don't think that is _required_ for a small scale experimentation like this PR. https://github.com/rust-lang/project-const-traits/issues/16 should definitely be prioritized in the future, but removing the impl check should be good for now as all callers need `const_trait_impl` enabled for any const impl to work. * This PR is intentionally minimal as constifying other traits can become more complicated (`PartialEq`, for example, would run into requiring implementing it for `str` as that is used in matches, which runs into the implementation for slice equality which uses specialization) Per the reasons above, anyone who is interested in making traits `const` in the standard library are **strongly encouraged** to reach out to us on the [Zulip channel](https://rust-lang.zulipchat.com/#narrow/channel/419616-t-compiler.2Fproject-const-traits) before proceeding with the work. cc ``@rust-lang/project-const-traits`` I believe there is prior approval from libs that we can experiment, so r? project-const-traits
2024-11-23Delay a bug when encountering an impl with unconstrained generics in ↵Michael Goulet-0/+29
codegen_select
2024-11-23Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errorsbors-45/+46
Rollup of 8 pull requests Successful merges: - #132090 (Stop being so bail-y in candidate assembly) - #132658 (Detect const in pattern with typo) - #132911 (Pretty print async fn sugar in opaques and trait bounds) - #133102 (aarch64 softfloat target: always pass floats in int registers) - #133159 (Don't allow `-Zunstable-options` to take a value ) - #133208 (generate-copyright: Now generates a library file too.) - #133215 (Fix missing submodule in `./x vendor`) - #133264 (implement OsString::truncate) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-22Rollup merge of #132090 - compiler-errors:baily, r=lcnrMichael Goulet-45/+46
Stop being so bail-y in candidate assembly A conceptual follow-up to #132084. We gotta stop bailing so much when there are errors; it's both unnecessary, leads to weird knock-on errors, and it's messing up the vibes lol
2024-11-23Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnrbors-15/+152
Implement `~const Destruct` effect goal in the new solver This also fixed a subtle bug/limitation of the `NeedsConstDrop` check. Specifically, the "`Qualif`" API basically treats const drops as totally structural, even though dropping something that has an explicit `Drop` implementation cannot be structurally decomposed. For example: ```rust #![feature(const_trait_impl)] #[const_trait] trait Foo { fn foo(); } struct Conditional<T: Foo>(T); impl Foo for () { fn foo() { println!("uh oh"); } } impl<T> const Drop for Conditional<T> where T: ~const Foo { fn drop(&mut self) { T::foo(); } } const FOO: () = { let _ = Conditional(()); //~^ This should error. }; fn main() {} ``` In this example, when checking if the `Conditional(())` rvalue is const-drop, since `Conditional` has a const destructor, we would previously recurse into the `()` value and determine it has nothing to drop, which means that it is considered to *not* need a const drop -- even though dropping `Conditional(())` would mean evaluating the destructor which relies on that `T: const Foo` bound to hold! This could be fixed alternatively by banning any const conditions on `const Drop` impls, but that really sucks -- that means that basically no *interesting* const drop impls could be written. We have the capability to totally and intuitively support the right behavior, which I've implemented here.
2024-11-22Check drop is trivial before checking ty needs dropMichael Goulet-69/+8
2024-11-22Deduplicate checking drop terminatorMichael Goulet-7/+8
2024-11-22Gate const drop behind const_destruct feature, and fix ↵Michael Goulet-14/+124
const_precise_live_drops post-drop-elaboration check
2024-11-22Implement ~const Destruct in new solverMichael Goulet-5/+92
2024-11-22Bail in effects in old solver if self ty is ty varMichael Goulet-0/+16
2024-11-22Get rid of HIR const checkerMichael Goulet-39/+24
2024-11-21E0277: suggest dereferencing function arguments in more casesdianne-0/+113
2024-11-21constify `Add`Deadbeef-58/+4
2024-11-21Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-deadMatthias Krüger-5/+75
Implement `~const` item bounds in RPIT an RPIT in a `const fn` is allowed to be conditionally const itself :) r? fee1-dead or reroll
2024-11-21Stop being so bail-y in candidate assemblyMichael Goulet-45/+46
2024-11-19Implement ~const Fn trait goals in the new solverMichael Goulet-90/+58
2024-11-19Implement ~const opaquesMichael Goulet-5/+75
2024-11-18Add reference annotations for diagnostic attributesEric Huss-1/+3
This adds reference annotations for `diagnostic::on_unimplmented` and the `diagnostic` namespace in general.
2024-11-15Move diagnostic::on_unimplemented test to the directory with all the other testsEric Huss-51/+0
2024-11-13Rollup merge of #133001 - lcnr:test-next-solver, r=compiler-errorsMatthias Krüger-1/+15
actually test next solver uwu r? `@compiler-errors`
2024-11-13actually test next solverlcnr-1/+15
2024-11-12Consolidate type system const evaluation under `traits::evaluate_const`Boxy-61/+0
mew
2024-11-09give a hint which feature is missingRalf Jung-4/+23
2024-11-09require const_impl_trait gate for all conditional and trait const callsRalf Jung-321/+177
2024-11-04Rollup merge of #132559 - bvanjoi:fix-132534, r=compiler-errorsMatthias Krüger-0/+58
find the generic container rather than simply looking up for the assoc with const arg Fixes #132534 This issue is caused by mismatched generic parameters. Previously, it tried to find `T` in `trait X`, but after this change, it will find `T` in `fn a`. r? `@compiler-errors` as this assertion was introduced by you.
2024-11-04Rollup merge of #132544 - dianne:unstable-library-feature-backticks, ↵Matthias Krüger-5/+5
r=compiler-errors Use backticks instead of single quotes for library feature names in diagnostics This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2024-11-04Fix minicore, add tests based off of itMichael Goulet-129/+97
2024-11-04find the generic container rather than simply looking up for the assoc with ↵bohan-0/+58
const arg
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-5/+5
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-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-20/+18
2024-11-03Yeet effects featureMichael Goulet-619/+225
2024-11-03Gate checking ~const bounds on const_trait_implMichael Goulet-131/+21
2024-11-03Rollup merge of #132523 - ranger-ross:test-issue-117446, r=compiler-errorsMatthias Krüger-0/+57
Added regression test for generics index out of bounds Added a regression test for #117446 This ICE was fixed in Rust 1.75 but a regression test was never added. This PR adds a UI test with a reduced version of the original bug report that does not rely on external crates.
2024-11-02fix testsEsteban Küber-1/+1
Paths in CI can be longer than in devs' machines.
2024-11-02Added regression test for 117446ranger-ross-0/+57
2024-11-02Account for negative bounds in E0277 note and suggestionEsteban Küber-18/+0
Do not suggest `#[derive(Copy)]` when we wanted a `!Copy` type. Do not say "`Copy` is not implemented for `T` but `Copy` is". Do not talk about `Trait` having no implementations when `!Trait` was desired.
2024-11-02On long E0277 primary span label, move it to a `help`Esteban Küber-1/+2
Long span labels don't read well.
2024-11-02Add trait diff highlighting logic and use it in E0277Esteban Küber-2/+4
When a trait is not implemented for a type, but there *is* an `impl` for another type or different trait params, we format the output to use highlighting in the same way that E0308 does for types. The logic accounts for 3 cases: - When both the type and trait in the expected predicate and the candidate are different - When only the types are different - When only the trait generic params are different For each case, we use slightly different formatting and wording.