about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-06-08Folding revamp.Nicholas Nethercote-20/+19
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
2022-06-08Rename `TypeVisitor::visit_unevaluated_const`.Nicholas Nethercote-4/+1
To match the corresponding type name.
2022-06-07Auto merge of #97081 - oli-obk:outlives_query_fast_path, r=jackh726bors-3/+10
Re-use the type op instead of calling the implied_outlives_bounds query directly r? `@ghost`
2022-06-06Add proper tracing spans to rustc_trait_selection::traits::error_reportingNoa-58/+36
2022-06-06Rollup merge of #97721 - compiler-errors:issue-97704, r=jackh726Matthias Krüger-30/+18
Do `suggest_await_before_try` with infer variables in self, and clean up binders Fixes #97704 Also cleans up binders in this fn, since everything is a `Poly*` and we really shouldn't have stray escaping late-bound regions everywhere. That's why the function changed so much. This isn't necessary, so I can revert if necessary.
2022-06-05Do suggest_await_before_try with infer in self, clean up bindersMichael Goulet-30/+18
2022-06-06Split `process_obligation` in two.Nicholas Nethercote-41/+30
Because it really has two halves: - A read-only part that checks if further work is needed. - The further work part, which is much less hot. This makes things a bit clearer and nicer.
2022-06-06Handle stalling within `ObligationForest`.Nicholas Nethercote-19/+8
It is simpler if `ObligationForest` does this itself, rather than the caller having to manage it.
2022-06-05get_vtable returns opt instd of unwrppingouz-a-6/+8
2022-06-05Auto merge of #97697 - WaffleLapkin:no_ref_vec, r=WaffleLapkinbors-5/+7
Replace `&Vec<_>`s with `&[_]`s It's generally preferable to use `&[_]` since it's one less indirection and it can be created from types other that `Vec`. I've left `&Vec` in some locals where it doesn't really matter, in cases where `TypeFoldable` is expected (`TypeFoldable: Clone` so slice can't implement it) and in cases where it's `&TypeAliasThatIsActiallyVec`. Nothing important, really, I was just a little annoyed by `visit_generic_param_vec` :D r? `@compiler-errors`
2022-06-03Tighten spans for bad fields in Copy structMichael Goulet-2/+2
2022-06-03Replace `&Vec<_>`s with `&[_]`sMaybe Waffle-5/+7
2022-06-02fix wrong suggestion for adding where clausesTakayuki Maeda-2/+16
2022-06-01Rollup merge of #97616 - TaKO8Ki:remove-unnecessary-option, r=Dylan-DPCYuki Okushi-3/+10
Remove an unnecessary `Option`
2022-06-01remove an unnecessary `Option`Takayuki Maeda-3/+10
2022-05-31Fix comment in poly_project_and_unify_typeMichael Goulet-14/+14
2022-05-29Auto merge of #97214 - Mark-Simulacrum:stage0-bump, r=pietroalbinibors-1/+0
Finish bumping stage0 It looks like the last time had left some remaining cfg's -- which made me think that the stage0 bump was actually successful. This brings us to a released 1.62 beta though. This now brings us to cfg-clean, with the exception of check-cfg-features in bootstrap; I'd prefer to leave that for a separate PR at this time since it's likely to be more tricky. cc https://github.com/rust-lang/rust/pull/97147#issuecomment-1132845061 r? `@pietroalbini`
2022-05-28Fix TyKind lint, make consts no longer fn, etcMichael Goulet-7/+5
2022-05-28Initial fixes on top of type interner commitMichael Goulet-4/+4
2022-05-27Finish bumping stage0Mark Rousskov-1/+0
It looks like the last time had left some remaining cfg's -- which made me think that the stage0 bump was actually successful. This brings us to a released 1.62 beta though.
2022-05-27Auto merge of #96046 - oli-obk:const_typeck, r=cjgillotbors-0/+1
Move various checks to typeck so them failing causes the typeck result to get tainted Fixes #69487 fixes #79047 cc `@RalfJung` this gets rid of the `Transmute` invalid program error variant
2022-05-25Rollup merge of #97351 - ↵Dylan DPC-10/+24
b-naber:adt-const-params-structural-match-violation, r=michaelwoerister Output correct type responsible for structural match violation Previously we included the outermost type that caused a structural match violation in the error message and stated that that type must be annotated with `#[derive(Eq, PartialEq)]` even if it already had that annotation. This PR outputs the correct type in the error message. Fixes https://github.com/rust-lang/rust/issues/97278
2022-05-25Auto merge of #97388 - Dylan-DPC:rollup-tfuc4tf, r=Dylan-DPCbors-9/+7
Rollup of 5 pull requests Successful merges: - #95953 (Modify MIR building to drop repeat expressions with length zero) - #96913 (RFC3239: Implement `cfg(target)` - Part 2) - #97233 ([RFC 2011] Library code) - #97370 (Minor improvement on else-no-if diagnostic) - #97384 (Fix metadata stats.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-25Rollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkovDylan DPC-9/+7
RFC3239: Implement `cfg(target)` - Part 2 This pull-request implements the compact `cfg(target(..))` part of [RFC 3239](https://github.com/rust-lang/rust/issues/96901). I recommend reviewing this PR on a per commit basics, because of some moving parts. cc `@GuillaumeGomez` r? `@petrochenkov`
2022-05-25Auto merge of #97345 - lcnr:fast_reject, r=nnethercotebors-66/+31
add a deep fast_reject routine continues the work on #97136. r? `@nnethercote` Actually agree with you on the match structure :laughing: let's see how that impacted perf :sweat_smile:
2022-05-25move fast reject test out of `SelectionContext::match_impl`.lcnr-11/+12
`match_impl` has two call sites. For one of them (within `rematch_impl`) the fast reject test isn't necessary, because any rejection would represent a compiler bug. This commit moves the fast reject test to the other `match_impl` call site, in `assemble_candidates_from_impls`. This lets us move the fast reject test outside the `probe` call in that function. This avoids the taking of useless snapshots when the fast reject test succeeds, which gives a performance win when compiling the `bitmaps` and `nalgebra` crates. Co-authored-by: name <n.nethercote@gmail.com>
2022-05-25add a deep fast_reject routinelcnr-55/+19
2022-05-25Rollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnrDylan DPC-134/+133
Add tests for lint on type dependent on consts r? `@lcnr`
2022-05-24trait selection errors should poison the typeck results, too, so that const ↵Oli Scherer-0/+1
eval can avoid running at all
2022-05-24Clean up condition evaluation systemLoïc BRANSTETT-9/+7
2022-05-24give correct error message on structural match violationb-naber-10/+24
2022-05-24Coalesce brancheskadmin-137/+133
Move a bunch of branches together into one if block, for easier reading. Resolve comments Attempt to make some branches unreachable [tmp] Revert unreachable branches
2022-05-22Lifetime variance fixes for rustcMichael Goulet-2/+2
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-7/+6
2022-05-19Auto merge of #97024 - lcnr:simplify_type-sus, r=<try>bors-14/+8
`simplify_type` improvements and cursed docs the existing `TreatParams` enum pretty much mixes everything up. Not sure why this looked right to me in #94057 This also includes two changes which impact perf: - `ty::Projection` with inference vars shouldn't be treated as a rigid type, even if fully normalized - `ty::Placeholder` only unifies with itself, so actually return `Some` for them r? `@nikomatsakis`
2022-05-18fix `simplify_type`lcnr-14/+8
2022-05-18Rollup merge of #97123 - ricked-twice:issue-96223-clean-fix, r=jackh726Dylan DPC-128/+130
Clean fix for #96223 Okay, so here we are (hopefully) :+1: Closes #96223 Thanks a lot to `@jackh726` for your help and explanation :pray: - Modified `InferCtxt::mk_trait_obligation_with_new_self_ty` to take as argument a `Binder<(TraitPredicate, Ty)>` instead of a `Binder<TraitPredicate>` and a separate `Ty` with no bound vars. - Modified all call places to avoid calling `Binder::no_bounds_var` or `Binder::skip_binder` when it is not safe. r? `@jackh726`
2022-05-18Rollup merge of #95979 - lcnr:coherence-docs, r=compiler-errorsDylan DPC-22/+35
update coherence docs, fix generator + opaque type ICE the world is confusing, this makes it slightly less so
2022-05-17Taking review into accountricked-twice-20/+16
2022-05-17Clean fix for #96223ricked-twice-115/+121
- Modified `InferCtxt::mk_trait_obligation_with_new_self_ty` to take as argument a `Binder<(TraitPredicate, Ty)>` instead of a `Binder<TraitPredicate>` and a separate `Ty` with no bound vars. - Modified all call places to avoid calling `Binder::no_bounds_var` or `Binder::skip_binder` when it is not safe.
2022-05-17Add tests for lint on type dependent on constskadmin-0/+3
2022-05-17Auto merge of #96892 - oli-obk:🐌_obligation_cause_code_🐌, r=estebankbors-161/+56
Clean up derived obligation creation r? `@estebank` working on fixing the perf regression from https://github.com/rust-lang/rust/pull/91030#issuecomment-1083360210
2022-05-16Don't go into the query for things that can't possibly have lifetimes.Oli Scherer-3/+10
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-36/+38
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-14Add bound_explicit_item_bounds and bound_item_boundsJack Huey-30/+29
2022-05-13Add bound_impl_trait_refJack Huey-11/+10
2022-05-13Add bound_type_ofJack Huey-11/+11
2022-05-13For non-defining opaque type usage errors, don't try to also prove all trait ↵Oli Scherer-0/+101
bounds
2022-05-13Check that closures satisfy their where boundsOli Scherer-8/+16
2022-05-12Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwcobors-6/+4
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289