about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
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
2022-05-11Gracefully fail to resolve associated items instead of `delay_span_bug`.Camille GILLOT-75/+16
2022-05-10Introduce EarlyBinderJack Huey-58/+62
2022-05-10Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwcobors-3/+71
Check hidden types for well formedness at the definition site instead of only at the opaque type itself work towards #90409 . We'll need to look into closure and generator bodies of closures and generators nested inside the hidden type in order to fix that. In hindsight this PR is not necessary for that, but it may be a bit easier with it and we'll get better diagnostics from it on its own.
2022-05-10Use InternedObligationCauseCode everywhereOli Scherer-11/+11
2022-05-10Make `FunctionArgumentObligation` also use the "no allocation for misc" trickOli Scherer-1/+1
2022-05-10Make the derived obligation cause parent privateOli Scherer-11/+10
2022-05-10Add a helper function for a common piece of codeOli Scherer-55/+17
2022-05-10Remove `clone_code` methodOli Scherer-23/+14
2022-05-10Remove another use of clone_codeOli Scherer-12/+10
2022-05-10only_local: always check for misuselcnr-6/+4
2022-05-10Move an extension trait method onto the type directly and reuse itOli Scherer-45/+4
2022-05-10Don't lose an obligation causeOli Scherer-2/+0
2022-05-10Remove some unnecessary clonesOli Scherer-19/+17
2022-05-10Simplify derived obligation peelingOli Scherer-15/+5
2022-05-10Check hidden types for well formedness at the definition site instead of ↵Oli Scherer-3/+71
only at the opaque type itself
2022-05-10update coherence docs, fix opaque type + generator icelcnr-22/+35
2022-05-10Auto merge of #96808 - cjgillot:impossible-trait, r=compiler-errorsbors-0/+14
Detect trait fulfillment in `subst_and_check_impossible_predicates` Split from https://github.com/rust-lang/rust/pull/91743 r? `@compiler-errors`
2022-05-10Auto merge of #96715 - cjgillot:trait-alias-loop, r=compiler-errorsbors-1/+2
Fortify handing of where bounds on trait & trait alias definitions Closes https://github.com/rust-lang/rust/issues/96664 Closes https://github.com/rust-lang/rust/issues/96665 Since https://github.com/rust-lang/rust/pull/93803, when listing all bounds and predicates we now need to account for the possible presence of predicates on any of the generic parameters. Both bugs were hidden by the special handling of bounds at the generic parameter declaration position. Trait alias expansion used to confuse predicates on `Self` and where predicates. Exiting too late when listing all the bounds caused a cycle error.
2022-05-08Rollup merge of #96617 - ↵Matthias Krüger-9/+19
ken-matsui:fix-incorrect-syntax-suggestion-with-pub-async-fn, r=cjgillot Fix incorrect syntax suggestion with `pub async fn` This PR closes: https://github.com/rust-lang/rust/issues/96555
2022-05-08Fix incorrect syntax suggestion with `pub async fn`Ken Matsui-9/+19
2022-05-07Do not report overflow error.Camille GILLOT-0/+3
2022-05-07Cleanup opaque type storage after checking impossible predicates.Camille GILLOT-0/+3
2022-05-07Also check TraitRef with impossible predicates.Camille GILLOT-0/+8
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-34/+34
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-05Don't cache results of coinductive cycleAaron Hill-59/+18
Fixes #96319 The logic around handling co-inductive cycles in the evaluation cache is confusing and error prone. Fortunately, a perf run showed that it doesn't actually appear to improve performance, so we can simplify this code (and eliminate a source of ICEs) by just skipping caching the evaluation results for co-inductive cycle participants. This commit makes no changes to any of the other logic around co-inductive cycle handling. Thus, while this commit could potentially expose latent bugs that were being hidden by caching, it should not introduce any new bugs.