about summary refs log tree commit diff
path: root/src/test/ui/rfc-2632-const-trait-impl
AgeCommit message (Collapse)AuthorLines
2021-10-15Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebankMatthias Krüger-6/+6
move implicit `Sized` predicate to end of list In `Bounds::predicates()`, move the implicit `Sized` predicate to the end of the generated list. This means that if there is an explicit `Sized` bound, it will be checked first, and any resulting diagnostics will have a more useful span. Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter. I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason. I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful. ``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?
2021-10-11Split impl-with-default-fn test into a pass test and a fail testGary Guo-8/+38
2021-10-08update ui test expectationsTaylor Yu-6/+6
2021-10-04Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplettManish Goregaokar-1/+1
Follow the diagnostic output style guide Detected by #89455.
2021-10-04Stabilize `const_panic`Jacob Pratt-1/+0
2021-10-03Follow the diagnostic output style guideHirochika Matsumoto-1/+1
2021-10-01Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obkManish Goregaokar-0/+31
Coerce const FnDefs to implement const Fn traits You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`. r? ``@oli-obk`` ``@rustbot`` label T-compiler F-const_trait_impl
2021-09-16fix rebaseEsteban Kuber-0/+18
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-1/+3
2021-09-15Coerce const FnDefs to implement const Fn traitsDeadbeef-0/+31
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-0/+274
Const drop The changes are pretty primitive at this point. But at least it works. ^-^ Problems with the current change that I can think of now: - [x] `~const Drop` shouldn't change anything in the non-const world. - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`. - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue. Fixes #88424. Significant Changes: - `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue) - `T: ~const Drop` will not be linted like `T: Drop`. - Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others. Changes not related to `const Drop`ping and/or changes that are insignificant: - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed. - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir. - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor. r? `@oli-obk`
2021-09-11Fix duplicate bounds for const_trait_implDeadbeef-4/+9
2021-09-09Allow ~const bounds on inherent implsDeadbeef-0/+21
2021-09-09Add another test case + fmtDeadbeef-10/+92
2021-09-09fix precise live dropsDeadbeef-4/+35
2021-09-09Use trait select logic instead of queryDeadbeef-4/+34
2021-09-09fmtDeadbeef-1/+1
2021-09-09Failing testDeadbeef-0/+31
2021-09-09Const drop selection candidatesDeadbeef-0/+51
2021-09-09better testDeadbeef-35/+15
2021-09-09Add a simple test caseDeadbeef-0/+48
2021-08-28Add test casesDeadbeef-3/+107
2021-08-28Allow `~const` bounds on trait assoc functionsDeadbeef-6/+74
2021-08-27Revive testsDeadbeef-0/+28
2021-08-27Fix UI testDeadbeef-1/+3
2021-08-27Fix #88155Deadbeef-0/+22
2021-08-27Fix more testsDeadbeef-30/+83
2021-08-27Try fixing some testsDeadbeef-255/+52
2021-08-27Introduce `~const`Deadbeef-3/+31
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix #88155 - [ ] Do something with constness bounds in chalk
2021-08-17Auto merge of #86808 - fee1-dead:constify-1, r=oli-obkbors-0/+30
constified implementations of `Default`
2021-08-17Add ui testDeadbeef-0/+30
2021-08-17Auto merge of #87668 - estebank:tweak-bound-output, r=oli-obkbors-6/+10
Use note for pointing at bound introducing requirement Modify output for pointing where a trait bound obligation is introduced in an E0277 from using a span label to using a note in order to always preserve order of the output: Before: ``` error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug` --> $DIR/bounds-on-assoc-in-trait.rs:18:28 | LL | type A: Iterator<Item: Debug>; | ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` | ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | --------------- required by this bound in `Debug` | = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item` ``` After: ``` error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug` --> $DIR/bounds-on-assoc-in-trait.rs:18:28 | LL | type A: Iterator<Item: Debug>; | ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item` note: required by a bound in `Debug` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL | LL | pub trait Debug { | ^^^^^^^^^^^^^^^ required by this bound in `Debug` ```
2021-08-16Use note to point at bound introducing requirementEsteban Küber-6/+10
2021-08-16Add ui testDeadbeef-0/+18
2021-08-13Fix Cargo.lock and ui testDeadbeef-1/+1
2021-08-13Make assoc types work with `?const `opt=outDeadbeef-1/+11
2021-08-13Fix call-generic-method-nonconst testDeadbeef-3/+15
2021-08-13Fix assoc-type testDeadbeef-5/+20
2021-08-13move Constness into TraitPredicateDeadbeef-1/+1
2021-08-11Modify structured suggestion outputEsteban Küber-4/+6
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-07-29Update testsJonas Schievink-2/+5
2021-07-19Recognize bounds on impls as const boundsDeadbeef-0/+15
2021-07-16Mark `const_trait_impl` as activeDeadbeef-44/+23
2021-07-10Test for misusing attributeDeadbeef-0/+46
2021-07-10Update testsDeadbeef-4/+10
2021-07-10Skip check for calling functions in same traitDeadbeef-2/+4
2021-07-10Treat trait fns marked with the attr as constDeadbeef-0/+32
2021-07-10Add #[default_method_body_is_const]Deadbeef-4/+45
2021-07-03Auto merge of #86571 - fee1-dead:const-trait-impl-fix, r=jackh726bors-0/+42
deny using default function in impl const Trait Fixes #79450. I don't know if my implementation is correct: - The check is in `rustc_passes::check_const`, should I put it somewhere else instead? - Is my approach (to checking the impl) optimal? It works for the current tests, but it might have some issues or there might be a better way of doing this.
2021-07-01Test for const trait impls behind feature gatesDeadbeef-0/+89