summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2022-06-13Revert "Check that closures satisfy their where bounds"Oli Scherer-3/+5
This reverts commit 253408b4090bc15b88bb5faecaf1e9765be80587.
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-10only_local: always check for misuselcnr-6/+4
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-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.
2022-05-05Auto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitorbors-1/+0
Rollup of 7 pull requests Successful merges: - #96603 (Enable full revision in const generics ui tests) - #96616 (Relax memory ordering used in `min_stack`) - #96619 (Relax memory ordering used in SameMutexCheck) - #96628 (Stabilize `bool::then_some`) - #96658 (Move callback to the () => {} syntax.) - #96677 (Add more tests for label-break-value) - #96697 (Enable tracing for all queries) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-05Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-seYuki Okushi-1/+0
Stabilize `bool::then_some` FCP completed in https://github.com/rust-lang/rust/issues/80967
2022-05-05Auto merge of #96593 - jackh726:issue-93262, r=compiler-errorsbors-16/+8
Revert "Prefer projection candidates instead of param_env candidates for Sized predicates" Fixes #93262 Reopens #89352 This was a hack that seemed to have no negative side-effects at the time. Given that the latter has a workaround and likely less common than the former, it makes sense to revert this change. r? `@compiler-errors`
2022-05-04Add debug statements.Camille GILLOT-1/+2
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-04Rollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726Yuki Okushi-1/+7
Quick fix for #96223. This PR is a quick fix regarding #96223. As mentioned in the issue, others modification could be added to not elide types with bound vars from suggestions. Special thanks to ``@jackh726`` for mentoring and ``@Manishearth`` for minimal test case. r? ``@jackh726``
2022-05-04Revert #92191 Prefer projection candidates instead of param_env candidates ↵Jack Huey-16/+8
for Sized predicates
2022-05-03Taking review hints into account.ricked-twice-1/+1
2022-05-03Auto merge of #96558 - bjorn3:librarify_parse_format, r=davidtwcobors-60/+61
Make rustc_parse_format compile on stable This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-05-03Quick fix for #96223.ricked-twice-1/+7
2022-05-03Make rustc_parse_format compile on stablebjorn3-60/+61
This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-05-02fix most compiler/ doctestsElliot Roberts-34/+34
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-36/+16
2022-04-30Inline WhereClause into Generics.Camille GILLOT-12/+7
2022-04-29Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebankbors-1/+1
Enforce Copy bounds for repeat elements while considering lifetimes fixes https://github.com/rust-lang/rust/issues/95477 this is a breaking change in order to fix a soundness bug. Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't. r? `@lcnr`
2022-04-28Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obkbors-12/+16
Implement Valtree to ConstValue conversion Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction. r? `@oli-obk` cc `@RalfJung`
2022-04-28Update the diagnostic message to match the new spanOli Scherer-1/+1
2022-04-26Better error messages when collecting into `[T; n]`Michael Goulet-11/+31
2022-04-26add hacky closure to struct_tail_with_normalize in order to allow us to walk ↵b-naber-12/+16
valtrees in lockstep with the type
2022-04-25do not consider two extern types to be similarlcnr-0/+1
2022-04-19Rollup merge of #94493 - ↵Dylan DPC-40/+160
oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_diag_2, r=davidtwco Improved diagnostic on failure to meet send bound on future in a foreign crate Provide a better diagnostic on failure to meet send bound on futures in a foreign crate. fixes #78543
2022-04-16Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnrDylan DPC-2/+2
couple of clippy::perf fixes
2022-04-16Provide a better diagnostic on failure to meet send bound on futures in a ↵oribenshir-40/+160
foreign crate Adding diagnostic data on generators to the crate metadata and using it to provide a better diagnostic on failure to meet send bound on futures originated from a foreign crate
2022-04-16Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, ↵bors-1/+9
r=estebank Better method call error messages Rebase/continuation of #71827 ~Based on #92360~ ~Based on #93118~ There's a decent description in #71827 that I won't copy here (for now at least) In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now. I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given. ~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~ r? `@estebank` as the original reviewer of #71827
2022-04-16Implementation for 65853Jack Huey-1/+9
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-15Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPCDylan DPC-1/+1
couple of clippy::complexity fixes
2022-04-15Rollup merge of #95749 - compiler-errors:ambig, r=oli-obkDylan DPC-2/+2
only downgrade selection Error -> Ambiguous if type error is in predicate That is, we don't care if there's a TypeError type in the ParamEnv. Fixes #95408