about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-07-19Use `?` in `prepare_vtable_segments`Maybe Waffle-9/+15
2023-07-19Auto merge of #113690 - aliemjay:opaque-defined-by-trait, r=compiler-errorsbors-5/+6
allow opaques to be defined by trait queries, again This basically reverts #112963. Moreover, all call-sites of `enter_canonical_trait_query` can now define opaque types, see the ui test `defined-by-user-annotation.rs`. Fixes #113689 r? `@compiler-errors` `@oli-obk`
2023-07-17Rename arg_iter to iter_instantiatedMichael Goulet-3/+4
2023-07-17Rollup merge of #113651 - lcnr:parent-def-id, r=compiler-errorsMatthias Krüger-7/+4
self type param infer, avoid ICE fixes #113610, which is caused by https://github.com/rust-lang/rust/blob/33a2c2487ac5d9927830ea4c1844335c6b9f77db/compiler/rustc_hir_analysis/src/collect/generics_of.rs#L190-L205
2023-07-17Auto merge of #113336 - compiler-errors:new-solver-iat, r=lcnrbors-5/+84
Add support for inherent projections in new solver Not hard to support these, and it cuts out a really big chunk of failing UI tests with `--compare-mode=next-solver` r? `@lcnr` (feel free to reassign, anyone can review this)
2023-07-16Auto merge of #113769 - matthiaskrgr:rollup-p6i1rco, r=matthiaskrgrbors-1/+1
Rollup of 7 pull requests Successful merges: - #113042 (Add Platform Support documentation for MIPS Release 6 targets) - #113539 (fixed typo) - #113614 (platform-support.md: It's now verified that NetBSD/riscv64 can self-h…) - #113750 (Add missing italicization to `sort_unstable_by_key` complexity ) - #113755 (Normalize lazy type aliases when probing for ADTs) - #113756 (fix wrong link) - #113762 (Fix typo) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-17Rollup merge of #113539 - agnarrarendelle:master, r=workingjubileeMatthias Krüger-1/+1
fixed typo Hi, I have fixed a few typos in commands. Please review my pr.
2023-07-16Auto merge of #113742 - ↵bors-2/+2
compiler-errors:dont-short-circuit-intercrate-global-preds, r=lcnr Don't call `predicate_must_hold`-esque functions during fulfillment in intercrate Fixes #113415 Given that this only happens in `translate_substs`, I don't actually think that this is something that you can weaponize, but it's still sketchy regardless. r? `@lcnr`
2023-07-16Check GAT, IAT, and weak type where clauses during projectionMichael Goulet-9/+45
2023-07-16Add support for inherent projectionsMichael Goulet-2/+45
2023-07-16stop mentioning number of applicate implementationslcnr-7/+4
2023-07-16Don't call predicate_must_hold during fulfillment in intercrateMichael Goulet-2/+2
2023-07-15Rollup merge of #113625 - compiler-errors:structurally-norm-in-selection, r=lcnrMatthias Krüger-6/+33
Structurally normalize in selection We need to do this because of the fact that we're checking the `Ty::kind` on a type during selection, but goals passed into select are not necessarily normalized. Right now, we're (kinda) unnecessarily normalizing the RHS of a trait upcasting goal, which is broken for different reasons (#113393). But I'm waiting for this PR to land before discussing that one. r? `@lcnr`
2023-07-14Auto merge of #113471 - compiler-errors:new-solver-norm-escaping, r=lcnrbors-22/+37
Allow escaping bound vars during `normalize_erasing_regions` in new solver Add `AllowEscapingBoundVars` to `deeply_normalize`, and use it in the new solver in the `query_normalize` routine. Ideally, we'd make all `query_normalize` calls handle pass in `AllowEscapingBoundVars` individually, because really the only `query_normalize` call that needs `AllowEscapingBoundVars::Yes` is the one in `try_normalize_generic_arg_after_erasing_regions`, but I think that's kind of overkill. I am happy to be convinced otherwise, though. r? `@lcnr`
2023-07-14Structurally normalize in selectionMichael Goulet-6/+33
2023-07-14Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorinoMatthias Krüger-2/+2
Make it clearer that we're just checking for an RPITIT Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`. r? `@spastorino`
2023-07-14Make it clearer that we're just checking for an RPITITMichael Goulet-2/+2
2023-07-14assertion, commentMichael Goulet-0/+4
2023-07-14Allow escaping bound vars during normalize_erasing_regions in new solverMichael Goulet-22/+33
2023-07-14allow opaques to be defined by trait queriesAli MJ Al-Nasrawy-5/+6
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-681/+649
2023-07-13Rollup merge of #113536 - lcnr:proof-tree-select, r=BoxyUwUMatthias Krüger-28/+22
avoid building proof trees in select otherwise we ICE because select isn't currently set up to print proof trees. r? `````@BoxyUwU`````
2023-07-13Auto merge of #113637 - Mark-Simulacrum:bootstrap-bump, r=ozkanonurbors-221/+281
Bump bootstrap to 1.72 beta
2023-07-13Rollup merge of #113353 - compiler-errors:select-better, r=lcnrMatthias Krüger-1/+144
Implement selection for `Unsize` for better coercion behavior In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of `Unsize` traits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs#L126 This implements a proper "rematch" procedure for dealing with built-in `Unsize` goals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop: https://github.com/rust-lang/rust/blob/9227ff28aff55b252314076fcf21c9a66f10ac1e/compiler/rustc_hir_typeck/src/coercion.rs#L702 Second commit just moves a `resolve_vars_if_possible` call to fix a bug where we weren't detecting a trait upcasting to occur. r? ``@lcnr``
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-219/+279
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-2/+2
2023-07-12fixed typosagnarrarendelle-1/+1
2023-07-11Auto merge of #113470 - compiler-errors:new-solver-structurally-resolve-pat, ↵bors-0/+2
r=lcnr Structurally resolve in pattern matching when peeling refs in new solver Let me know if you want me to commit the minimized test: ```rust fn test() {} fn test2() {} fn main() { let tests: &[(_, fn())] = &[ ("test", test), ("test2", test2), ]; for (a, b) in tests { todo!(); } } ``` In that test above, the match scrutinee is `<std::vec::Iter<(&'static str, fn())> as Iterator>::Item`, which we cannot peel the refs from. We also need to structurally resolve in the loop, since structural resolve is inherently shallow. I haven't come up with a test where this matters, but I can if you care. Also, I removed two other calls to `resolve_vars_with_obligations` in diagnostics code that I'm pretty convinced are not useful. r? `@lcnr`
2023-07-11Structurally resolve in pattern matching when peeling refs in new solverMichael Goulet-0/+2
2023-07-10Auto merge of #112988 - spastorino:new-rpitit-24, r=compiler-errorsbors-153/+2
Replace RPITIT current impl with new strategy that lowers as a GAT This PR replaces the current implementation of RPITITs with the new implementation that we had under -Zlower-impl-trait-in-trait-to-assoc-ty flag that lowers the RPIT as a GAT on the trait and on the impls that implement that trait. Opening this PR as a draft because this goes after #112682, ~#112981~ and ~#112983~. As soon as those are merged, I can rebase and we should run perf, crater and test a lot. r? `@compiler-errors`
2023-07-10avoid building proof trees in selectlcnr-28/+22
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-153/+2
2023-07-08Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgrbors-32/+34
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-32/+34
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 #113335 - compiler-errors:reveal-opaques-in-new-solver, r=lcnrMatthias Krüger-3/+1
Reveal opaques in new solver We were testing against the wrong reveal mode :fearful: Also a couple of misc commits that I don't want to really put in separate prs r? ``@lcnr``
2023-07-08Auto merge of #113474 - compiler-errors:rollup-07x1up7, r=compiler-errorsbors-19/+1
Rollup of 8 pull requests Successful merges: - #113413 (Add needs-triage to all new issues) - #113426 (Don't ICE in `resolve_bound_vars` when associated return-type bounds are in bad positions) - #113427 (Remove `variances_of` on RPITIT GATs, remove its one use-case) - #113441 (miri: check that assignments do not self-overlap) - #113453 (Remove unused from_method from rustc_on_unimplemented) - #113456 (Avoid calling report_forbidden_specialization for RPITITs) - #113466 (Update cargo) - #113467 (Fix comment of `fn_can_unwind`) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-07Rollup merge of #113453 - spastorino:new-rpitit-30, r=compiler-errorsMichael Goulet-19/+1
Remove unused from_method from rustc_on_unimplemented Fixes #113439 `on_unimplemented_note` was calling `item_name` for RPITITs and that produced ICEs. I've added a regression test for that but also have removed `from_method` symbol entirely because it wasn't even used and by doing that the `item_name` call was also removed. r? ``@compiler-errors``
2023-07-08Implement selection for unsize for better coercion behaviorMichael Goulet-1/+144
2023-07-08Auto merge of #112652 - oli-obk:tait_only_in_sig, r=compiler-errorsbors-1/+1
Require TAITs to be mentioned in the signatures of functions that register hidden types for them r? `@lcnr` `@compiler-errors` This implements the lang team decision from [the TAIT design meeting](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.202023-05-31.20TAITs/near/362518164).
2023-07-07Remove unused from_method symbolSantiago Pastorino-19/+1
2023-07-07Normalize opaques during codegen in new solverMichael Goulet-3/+1
2023-07-07Auto merge of #113245 - lukas-code:unsizing-sanity-check, r=the8472bors-13/+3
sanity check field offsets in unsizeable structs As promised in https://github.com/rust-lang/rust/pull/112062#issuecomment-1567494994, this PR extends the layout sanity checks to ensure that structs fields don't move around when unsizing and prevent issues like https://github.com/rust-lang/rust/issues/112048 in the future. Like most other layout sanity checks, this only runs on compilers with debug assertions enabled. Here is how it looks when it fails: ```text error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:533:21: unsizing GcNode<std::boxed::Box<i32>> changed field order! Layout { size: Size(32 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes), Size(24 bytes)], memory_index: [0, 1, 2] }, largest_niche: Some(Niche { offset: Size(24 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } Layout { size: Size(24 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [Size(16 bytes), Size(0 bytes), Size(24 bytes)], memory_index: [1, 0, 2] }, largest_niche: None, variants: Single { index: 0 } } ``` r? `@the8472`
2023-07-07Require TAITs to be mentioned in the signatures of functions that register ↵Oli Scherer-1/+1
hidden types for them
2023-07-07Auto merge of #113308 - compiler-errors:poly-select, r=lcnrbors-79/+91
Split `SelectionContext::select` into fns that take a binder and don't *most* usages of `SelectionContext::select` don't need to use a binder, but wrap them in a dummy because of the signature. Let's split this out into `SelectionContext::{select,poly_select}` and limit the usages of the latter. Right now, we only have 3 places where we're calling `poly_select` -- fulfillment, internally within the old solver, and the auto-trait finder. r? `@lcnr`
2023-07-06Rollup merge of #113397 - compiler-errors:new-select-prefer-obj, r=lcnrMichael Goulet-0/+8
Prefer object candidates in new selection `dyn Any` shouldn't be using [this implementation](https://doc.rust-lang.org/std/any/trait.Any.html#impl-Any-for-T) during codegen. Prefer object candidates over other candidates, except for other object candidates.
2023-07-06Don't call type_of on TAIT in defining scope in new solverMichael Goulet-1/+28
2023-07-06get rid of a bit more calls to poly_selectMichael Goulet-4/+4
2023-07-06Separate select calls that don't need a binderMichael Goulet-25/+37
2023-07-06TraitObligation -> PolyTraitObligationMichael Goulet-67/+67
2023-07-06add helper methods for accessing struct tailLukas Markeffsky-13/+3