about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
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
2022-04-15Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwcoDylan DPC-1/+1
Stabilize `derive_default_enum` This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility). ```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-14Auto merge of #95315 - compiler-errors:pointee-fix, r=pnkfelixbors-1/+11
when checking pointee metadata, canonicalize the `Sized` check Use `infcx.predicate_must_hold_modulo_regions` with a `Sized` obligation instead of just calling `ty.is_sized`, because the latter does not canonicalize region and type vars (and in the test case I added in this PR, there's a region var in the `ParamEnv`). Fixes #95311
2022-04-13couple of clippy::complexity fixesMatthias Krüger-1/+1
2022-04-13couple of clippy::perf fixesMatthias Krüger-2/+2
2022-04-13Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obkbors-0/+1
Use mir constant in thir instead of ty::Const This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary). This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`. Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented. r? `@oli-obk`
2022-04-11Auto merge of #95931 - matthiaskrgr:rollup-1c5zhit, r=matthiaskrgrbors-0/+7
Rollup of 7 pull requests Successful merges: - #95743 (Update binary_search example to instead redirect to partition_point) - #95771 (Update linker-plugin-lto.md to 1.60) - #95861 (Note that CI tests Windows 10) - #95875 (bootstrap: show available paths help text for aliased subcommands) - #95876 (Add a note for unsatisfied `~const Drop` bounds) - #95907 (address fixme for diagnostic variable name) - #95917 (thin_box test: import from std, not alloc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-11Rollup merge of #95876 - fee1-dead:note-const-drop, r=oli-obkMatthias Krüger-0/+7
Add a note for unsatisfied `~const Drop` bounds r? ``@oli-obk``
2022-04-11Add a note for unsatisfied `~const Drop` boundsDeadbeef-0/+7
2022-04-10only suggest removing semicolon when expr implements traitMichael Goulet-10/+21
2022-04-09Auto merge of #95435 - cjgillot:one-name, r=oli-obkbors-5/+5
Make def names and HIR names consistent. The name in the `DefKey` is interned to create the `DefId`, so it does not require any query to access. This can be leveraged to avoid a few useless HIR accesses for names. ~In order to achieve that, generic parameters created from universal impl-trait are given the pretty-printed ast as a name, instead of `{{opaque}}`.~ ~Drive-by: the `TyCtxt::opt_item_name` used a dummy span for non-local definitions. We have access to `def_ident_span`, so we use it.~
2022-04-09Use def_key in `tcx.item_name` when possible.Camille GILLOT-5/+5
2022-04-09Auto merge of #95835 - Dylan-DPC:rollup-l5mf2ad, r=Dylan-DPCbors-3/+19
Rollup of 8 pull requests Successful merges: - #90066 (Add new ThinBox type for 1 stack pointer wide heap allocated trait objects) - #95374 (assert_uninit_valid: ensure we detect at least arrays of uninhabited types) - #95599 (Strict provenance lints) - #95751 (Don't report numeric inference ambiguity when we have previous errors) - #95764 ([macro_metavar_expr] Add tests to ensure the feature requirement) - #95787 (reword panic vs result section to remove recoverable vs unrecoverable framing) - #95797 (Remove explicit delimiter token trees from `Delimited`.) - #95804 (rustdoc: Fix empty doc comment with backline ICE) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-09Rollup merge of #95751 - compiler-errors:ambig-int, r=jackh726Dylan DPC-3/+19
Don't report numeric inference ambiguity when we have previous errors Fixes #95648
2022-04-09Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercotebors-9/+6
Cached stable hash cleanups r? `@nnethercote` Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time. Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
2022-04-08Avoid looking at the internals of Interned directlyOli Scherer-9/+6
2022-04-07Stabilize `derive_default_enum`Jacob Pratt-1/+1
2022-04-07Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrumbors-18/+0
Bump bootstrap compiler to 1.61.0 beta This PR bumps the bootstrap compiler to the 1.61.0 beta. The first commit changes the stage0 compiler, the second commit applies the "mechanical" changes and the third and fourth commits apply changes explained in the relevant comments. r? `@Mark-Simulacrum`
2022-04-06don't report int/float ambiguity when we have previous errorsMichael Goulet-3/+19
2022-04-06only downgrade Error -> Ambiguous if type error is in predicateMichael Goulet-2/+2
2022-04-06get rid of visit_constant in thir visitorb-naber-4/+0
2022-04-05rustc_trait_selection changesPietro Albini-18/+0
2022-04-05Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, ↵Dylan DPC-0/+9
r=compiler-errors diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut Fixes #90073