summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-09-12 unconstrained region vars: do not ICE ICE babylcnr-9/+5
2023-07-21allow opaques to be defined by trait queriesAli MJ Al-Nasrawy-5/+6
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-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
2023-07-06Auto merge of #113406 - matthiaskrgr:rollup-0rprs5k, r=matthiaskrgrbors-4/+6
Rollup of 4 pull requests Successful merges: - #112295 (Fix the tests-listing-format-json test on Windows) - #113246 (fix compiletest crash) - #113395 (Dont ICE for `dyn* Trait: Trait` (built-in object) goals during selection in new trait solver) - #113402 (Diagnose unsorted CGUs.) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-06Prefer object candidates over impl candidates in new selectionMichael Goulet-0/+8
2023-07-06Dont ICE for `dyn* Trait: Trait` goals during selection in new trait solverMichael Goulet-4/+6
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-54/+64
2023-07-05Rollup merge of #113337 - compiler-errors:next-solver-winnow-specializing, ↵Michael Goulet-2/+13
r=lcnr Winnow specialized impls during selection in new solver We need to be able to winnow impls that are specialized by more specific impls in order for codegen to be able to proceed. r? ``@lcnr``
2023-07-05Rollup merge of #113321 - BoxyUwU:move_constkind_to_typeir, r=oli-obkMichael Goulet-3/+3
Move `ty::ConstKind` to `rustc_type_ir` Needed this in another PR for custom debug impls, and this will also be required to move the new solver into a separate crate that does not use `TyCtxt` so that r-a and friends can depend on the trait solver. Rebased on top of #113325, only the second and third commits needs reviewing
2023-07-05Rollup merge of #113320 - oli-obk:eval_obligation_query, r=petrochenkov,BoxyUwUMichael Goulet-18/+60
Add some extra information to opaque type cycle errors Plus a bunch of cleanups. This should help users debug query cycles due to auto trait checking. We'll probably want to fix cycle errors in most (or all?) cases by looking at the current item's hidden types (new solver does this), and by delaying the auto trait checks to after typeck.
2023-07-05Rollup merge of #113319 - lcnr:type-param-def-def-id, r=compiler-errorsMichael Goulet-2/+2
`TypeParameterDefinition` always require a `DefId` the `None` case never actually reaches diagnostics so it feels better for diagnostics to be able to rely on the `DefId` being there, cc #113310
2023-07-05Rollup merge of #113317 - lcnr:sketchy-new-select, r=oli-obkMichael Goulet-60/+74
-Ztrait-solver=next: stop depending on old solver removes the final dependencies on the old solver when `-Ztrait-solver=next` is enabled.
2023-07-05Deal with falloutBoxy-3/+3
2023-07-05Make all generics_require_sized_self go through the query to get caching.Oli Scherer-3/+3
2023-07-05Add some extra information to opaque type cycle errorsOli Scherer-9/+57
2023-07-05Remove redundant `delay_span_bug`Oli Scherer-9/+3
2023-07-05Don't require associated types with `Self: Sized` bounds in `dyn Trait` objectsOli Scherer-1/+6
2023-07-05Winnow specializing implsMichael Goulet-2/+13
2023-07-05Auto merge of #113329 - lcnr:probe_candidate, r=BoxyUwUbors-298/+280
add `ecx.probe_candidate` Not yet changing the candidate source to an enum because that would be more involved, but this by itself should already be a significant improvement imo r? `@BoxyUwU`
2023-07-04Auto merge of #113330 - matthiaskrgr:rollup-zm3owin, r=matthiaskrgrbors-42/+187
Rollup of 5 pull requests Successful merges: - #113192 (`assemble_candidates_after_normalizing_self_ty` docs) - #113251 (Use scoped-tls for SMIR to map between TyCtxt and SMIR datastructures) - #113282 (Update platform-support.md to improve ARM target descriptions) - #113296 (add flag for enabling global cache usage for proof trees and printing proof trees on error) - #113324 (implement `ConstEvaluatable` goals in new solver) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-04Rollup merge of #113324 - lcnr:const-evaluatable-goal, r=BoxyUwUMatthias Krüger-6/+42
implement `ConstEvaluatable` goals in new solver this only supports stable const generics. `feature(generic_const_exprs)` needs to extend that function is non-trivial ways. Leaving this for someone else or some later date. r? `@BoxyUwU`
2023-07-04Rollup merge of #113296 - BoxyUwU:proof_trees_on_error, r=lcnrMatthias Krüger-32/+132
add flag for enabling global cache usage for proof trees and printing proof trees on error This adds a few new things: - `-Zdump-solver-proof-tree=always/never/on-error` - `always`/`never` were previosuly specifiable by whether the flag exists or not, th new flag is `on_error` which reruns obligations of fulfillment and selection errors with proof tree generation enabled and prints them out - `-Zdump-solver-proof-tree-uses-cache` - allows forcing global cache to be used or unused for all generated proof trees, global cache is enabled by default for `always` so that it accurately represents what happend. This flag currently would affect misc uses of `GenerateProofTree::Yes` which will be added in the future for things like diagnostics logic and rustdoc's auto_trait file. We can fix this when we start using proof tree generation for those use cases if it's desirable. I also changed the output to go straight to stdout instead of going through `debug!` so that `-Zdump-solver-proof-tree` can be adequately used on `nightly` not just a locally built toolchain. The idea for `on-error` is that it should hopefully make it easier to quickly figure out "why doesnt this code compile"- you just pass in `-Zdump-solver-proof-tree=on-error` and you'll only get proof trees you care about. --- r? `@lcnr` `@compiler-errors`
2023-07-04Rollup merge of #113192 - lcnr:add-comment, r=compiler-errorsMatthias Krüger-4/+13
`assemble_candidates_after_normalizing_self_ty` docs I already explained that in different places a few times, should have added that explanation as a doc comment the first time I did so :3 r? `@BoxyUwU`
2023-07-04add `ecx.probe_candidate`lcnr-298/+280
2023-07-04reviewsBoxy-90/+84
2023-07-04implement `ConstEvaluatable` goals in new solverlcnr-6/+42
we don't yet handle `generic_const_exprs`, someone else can do that :3
2023-07-04Replace `const_error` methods with `Const::new_error`Boxy-6/+5
2023-07-04Replace `mk_const` with `Const::new_x` methodsBoxy-34/+32
2023-07-04`TypeParameterDefinition` always require a `DefId`lcnr-2/+2
2023-07-04move logic for flags into separate functionBoxy-30/+35
2023-07-04extend commentlcnr-0/+5
2023-07-04change flag nameBoxy-1/+1
2023-07-04reviewsBoxy-3/+1
2023-07-04 -Ztrait-solver=next: stop depending on old solverlcnr-60/+69