about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2023-07-21Double check that hidden types match the expected hidden typeOli Scherer-0/+1
2023-07-21new solver: add a separate cache for coherencelcnr-13/+12
2023-07-21Track ABI info. in `NaiveLayout`, and use it for `PointerLike` checksMoulins-6/+28
THis significantly complicates `NaiveLayout` logic, but is necessary to ensure that bounds like `NonNull<T>: PointerLike` hold in generic contexts. Also implement exact layout computation for structs.
2023-07-20Auto merge of #113856 - WaffleLapkin:vtablin', r=oli-obkbors-67/+88
Refactor vtable encoding and optimize it for the case of multiple marker traits This PR does two things - Refactor `prepare_vtable_segments` (this was motivated by the other change, `prepare_vtable_segments` was quite hard to understand and while trying to edit it I've refactored it) - Mostly remove `loop`s labeled `break`s/`continue`s whenever there is a simpler solution - Also use `?` - Make vtable format a bit more efficient wrt to marker traits - See the tests for an example Fixes https://github.com/rust-lang/rust/issues/113840 cc `@crlf0710` ---- Review wise it's probably best to review each commit individually, as then it's more clear why the refactoring is correct. I can split the last two commits (which change behavior) into a separate PR if it makes reviewing easier
2023-07-20update doc commentslcnr-10/+17
2023-07-20reviewlcnr-4/+4
2023-07-20re-add commentlcnr-0/+6
2023-07-20assembly: only consider blanket impls oncelcnr-68/+226
2023-07-20XSimplifiedType to SimplifiedType::Xlcnr-1/+1
2023-07-19Don't emit useless vptrs for marker traitsMaybe Waffle-4/+21
2023-07-19Fix commentMaybe Waffle-1/+1
2023-07-19Simplify last `prepare_vtable_segments` loop even moreMaybe Waffle-25/+22
2023-07-19Slightly refactor 'exiting_out loop in `prepare_vtable_segments`Maybe Waffle-20/+22
1. Hide the option as an iterator, so it's nicer to work with 2. Replace a loop with `find`
2023-07-19Refactor 'diving_in loop internals in `prepare_vtable_segments`Maybe Waffle-17/+17
Less explicit loops -- easier to read.
2023-07-19Replace `if let` with `unwrap` in `prepare_vtable_segments`Maybe Waffle-25/+24
Reasoning: if the stack is empty, the loop will be infinite, so the assumption is that the stack can't be non empty. Unwrap makes the assumption more clear (and removes an indentation level)
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``