about summary refs log tree commit diff
path: root/tests/ui/consts
AgeCommit message (Collapse)AuthorLines
2023-07-18added links as a notenxya-8/+8
2023-07-18add links to query documentation for E0391nxya-8/+8
2023-07-18added links as a notenxya-8/+48
2023-07-18add links to query documentation for E0391nxya-8/+8
2023-07-16Add const-eval test for `#[target_feature(enable = ...)]` function callsEduardo Sánchez Muñoz-0/+26
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-1/+1
2023-07-08Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgrbors-10/+39
Rollup of 6 pull requests Successful merges: - #113005 (Don't call `query_normalize` when reporting similar impls) - #113064 (std: edit [T]::swap docs) - #113138 (Add release notes for 1.71.0) - #113217 (resolve typerelative ctors to adt) - #113254 (Use consistent formatting in Readme) - #113482 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-08Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillotMatthias Krüger-10/+39
Don't call `query_normalize` when reporting similar impls Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well. The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions: ``` error[E0277]: the trait bound `[X; 35]: Default` is not satisfied --> /home/gh-compiler-errors/test.rs:4:5 | 4 | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: &[T] &mut [T] [T; 32] [T; core::::array::{impl#30}::{constant#0}] [T; core::::array::{impl#31}::{constant#0}] [T; core::::array::{impl#32}::{constant#0}] [T; core::::array::{impl#33}::{constant#0}] [T; core::::array::{impl#34}::{constant#0}] and 27 others ``` So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-08Rollup merge of #113158 - davidtwco:unset-rustc-log-color-in-test, r=wesleywiserMatthias Krüger-0/+1
tests: unset `RUSTC_LOG_COLOR` in a test Setting `RUSTC_LOG_COLOR=always` is sometimes useful if tools that one pipes `RUSTC_LOG` into support coloured output, but it makes this test fail because it has a `.stderr` file with `WARN` log output.
2023-07-04implement `ConstEvaluatable` goals in new solverlcnr-2/+20
we don't yet handle `generic_const_exprs`, someone else can do that :3
2023-06-29tests: unset `RUSTC_LOG_COLOR`David Wood-0/+1
Setting `RUSTC_LOG_COLOR=always` is sometimes useful if tools that one pipes `RUSTC_LOG` into support coloured output, but it makes this test fail. Signed-off-by: David Wood <david@davidtw.co>
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-17/+17
2023-06-24use Const::eval instead of QueryNormalize in error reportingMichael Goulet-0/+29
2023-06-22Stop hiding const eval limit in external macrosOli Scherer-0/+40
2023-06-12Adjust UI tests for `unit_bindings`许杰友 Jieyou Xu (Joe)-13/+13
- Either explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Fix disjoint-capture-in-same-closure test
2023-06-02Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errorsbors-4/+16
Rollup of 7 pull requests Successful merges: - #111670 (Require that const param tys implement `ConstParamTy`) - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…) - #112030 (Migrate `item_trait_alias` to Askama) - #112150 (Support 128-bit atomics on all x86_64 Apple targets) - #112174 (Fix broken link) - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.) - #112193 (Check tuple elements are `Sized` in `offset_of`) Failed merges: - #112071 (Group rfcs tests) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-01Implement custom diagnostic for ConstParamTyMichael Goulet-4/+16
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-50/+58
2023-05-31Remove const eval limit and implement an exponential backoff lint insteadOli Scherer-187/+177
2023-05-29Rollup merge of #111558 - c410-f3r:t3st3ss, r=WaffleLapkinMatthias Krüger-0/+95
Move tests r? `@petrochenkov`
2023-05-26Blesses UI tests, add known bug to typeid-equality-by-subtypingonestacked-3/+0
2023-05-24Address commentsCaio-0/+11
2023-05-24Move testsCaio-0/+84
2023-05-23add tests for const `NonNull::as_ref`Lukas Markeffsky-0/+30
2023-05-21Rename `forget_copy` lint to `forgetting_copy_types`Urgau-2/+2
2023-05-15Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko-199/+15
When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not.
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-0/+5
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-10Adjust tests for new drop and forget lintsUrgau-0/+5
2023-05-05Stabilize const_ptr_readbors-25/+22
2023-05-04Rollup merge of #111100 - BoxyUwU:array_repeat_expr_wf, r=compiler-errorsMatthias Krüger-2/+12
check array type of repeat exprs is wf Fixes #111091 Also makes sure that we actually renumber regions in the length of repeat exprs which we previously weren't doing and would cause ICEs in `adt_const_params` + `generic_const_exprs` from attempting to prove the wf goals when the length was an unevaluated constant with `'erased` in the `ty` field of `Const` The duplicate errors are caused by the fact that `const_arg_to_const`/`array_len_to_const` in `FnCtxt` adds a `WellFormed` goal for the created `Const` which is also checked by the added `WellFormed(array_ty)`. I don't want to change this to just emit a `T: Sized` goal for the element type since that would ignore `ConstArgHasType` wf requirements and generally uncomfortable with the idea of trying to sync up `wf::obligations` for arrays and the code in hir typeck for repeat exprs. r? `@compiler-errors`
2023-05-04check array type of repeat exprs is wfBoxy-2/+12
2023-05-04Rollup merge of #110859 - compiler-errors:no-negative-drop-impls, r=oli-obkMatthias Krüger-22/+2
Explicitly reject negative and reservation drop impls Fixes #110858 It doesn't really make sense for a type to have a `!Drop` impl. Or at least, I don't want us to implicitly assign a meaning to it by the way the compiler *currently* handles it (incompletely), and rather I would like to see a PR (or an RFC...) assign a meaning to `!Drop` if we actually wanted one for it.
2023-05-04Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obkDylan DPC-81/+0
interpret: fail more gracefully on uninit unsized locals r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/68538
2023-05-01Rip it outNilstrieb-1/+1
My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
2023-04-28move some const-prop tests to appropriate folderRalf Jung-81/+0
2023-04-27bless testsThe 8472-4/+4
2023-04-27Explicitly reject negative and reservation drop implsMichael Goulet-22/+2
2023-04-25Rollup merge of #110480 - whtahy:105107/known-bug-tests-for-unsound-issues, ↵Yuki Okushi-0/+38
r=jackh726 Add `known-bug` tests for 11 unsound issues r? ``@jackh726`` Should tests for other issues be in separate PRs? Thanks. Edit: Partially addresses #105107. This PR adds `known-bug` tests for 11 unsound issues: - #25860 - #49206 - #57893 - #84366 - #84533 - #84591 - #85099 - #98117 - #100041 - #100051 - #104005
2023-04-22add known-bug test for unsound issue 49206whtahy-0/+38
2023-04-22Encode lifetime param spans tooMichael Goulet-30/+0
2023-04-21Ensure mir_drops_elaborated_and_const_checked when requiring codegen.Camille GILLOT-0/+2
2023-04-19Auto merge of #110061 - WaffleLapkin:duality_of_myself_and_this, r=cjgillotbors-0/+4
Add suggestion to use closure argument instead of a capture on borrowck error Fixes #109271 r? `@compiler-errors` This should probably be refined a bit, but opening a PR so that I don't forget anything.
2023-04-19Extend and use `hir::Node::body_id`Maybe Waffle-0/+4
2023-04-19Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obkbors-130/+254
Rm const traits in libcore See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework) * [x] Bless ui tests * [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-17Encode def span for ConstParamMichael Goulet-0/+30
2023-04-16fix library and rustdoc testsDeadbeef-130/+254
2023-04-15Only enable ConstProp at mir-opt-level >= 2.Camille GILLOT-32/+0
2023-04-12Tweak output for 'add line' suggestionEsteban Küber-9/+18
2023-04-08bless ui testsDeadbeef-5/+34
2023-04-06Auto merge of #108504 - cjgillot:thir-pattern, r=compiler-errors,Nilstriebbors-147/+37
Check pattern refutability on THIR The current `check_match` query is based on HIR, but partially re-lowers HIR into THIR. This PR proposed to use the results of the `thir_body` query to check matches, instead of re-building THIR. Most of the diagnostic changes are spans getting shorter, or commas/semicolons not getting removed. This PR degrades the diagnostic for confusing constants in patterns (`let A = foo()` where `A` resolves to a `const A` somewhere): it does not point ot the definition of `const A` any more.