about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2022-07-15Propagate Expectation around binop typeck code to construct more precise ↵Will Crichton-3/+14
trait obligations for binops.
2022-07-15Revert "Highlight conflicting param-env candidates"Michael Goulet-71/+13
This reverts commit 08135254dcf22be0d5661ea8f75e703b29a83514.
2022-07-15hir typeck: `fulfillment_cx` ignore regionslcnr-0/+10
2022-07-15provide `generic_param_scope` for region errorslcnr-15/+23
2022-07-15try to avoid `FnCtxt` during wflcnr-2/+96
2022-07-15`QueryNormalizer` bug on ambiguitylcnr-2/+2
2022-07-15Remove some more usages of guess_head_spanMichael Goulet-8/+2
2022-07-15remove tcx from ObligationCauseCode::spanMichael Goulet-3/+3
2022-07-15Remove some more usages of guess_head_spanMichael Goulet-2/+2
2022-07-14Rollup merge of #99222 - atsuzaki:generic_const_err, r=lcnrDylan DPC-0/+27
Better error message for generic_const_exprs inference failure Fixes #90531 This code: ```rs #![feature(generic_const_exprs)] fn foo<const N: usize>(_arr: [u64; N + 1]) where [u64; N + 1]: {} fn main() { let arr = [5; 5]; foo(arr); } ``` Will now emit the following error: ```rs warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> test.rs:1:12 | 1 | #![feature(generic_const_exprs)] | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information error[E0284]: type annotations needed --> test.rs:8:7 | 8 | foo(arr); | ^^^ cannot infer the value of the const parameter `N` declared on the function `foo` | note: required by a bound in `foo` --> test.rs:3:56 | 3 | fn foo<const N: usize>(_arr: [u64; N + 1]) where [u64; N + 1]: {} | ^^^^^ required by this bound in `foo` help: consider specifying the generic argument | 8 | foo::<N>(arr); | +++++ error: aborting due to previous error; 1 warning emitted ``` cc: `@lcnr` thanks a lot again for the help on this
2022-07-14Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnrDylan DPC-667/+151
Move abstract const to middle Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`. This allows for const resolution in infer to use abstract consts to walk consts and check if they are resolvable. This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved. r? `@lcnr`
2022-07-14Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPCbors-3/+3
Rollup of 5 pull requests Successful merges: - #97720 (Always create elided lifetime parameters for functions) - #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`) - #98705 (Implement `for<>` lifetime binder for closures) - #99126 (remove allow(rustc::potential_query_instability) in rustc_span) - #99139 (Give a better error when `x dist` fails for an optional tool) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-14eagerly check for bound vars of predicateslcnr-0/+4
2022-07-14remove `ct.has_vars_bound_at_or_above` callslcnr-2/+1
`ty::Const` doesn't have precomputed type flags, so computing `has_vars_bound_at_or_above` for constants requires us to visit the const and its contained types and constants. A noop fold should be pretty much equally as fast so removing it prevents us from walking the constant twice in case it contains bound vars.
2022-07-14Fix overlapping implskadmin-30/+140
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-3/+3
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-13Remove predicate noteKatherine Philip-2/+1
2022-07-13Add checks & fallback branchKatherine Philip-1/+13
2022-07-13Use emit_inference_failure_err for ConstEvaluatable predicatesKatherine Philip-0/+16
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-3/+3
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-13Rollup merge of #98574 - dingxiangfei2009:let-else-thir, r=oli-obkDylan DPC-1/+1
Lower let-else in MIR This MR will switch to lower let-else statements in MIR building instead. To lower let-else in MIR, we build a mini-switch two branches. One branch leads to the matching case, and the other leads to the `else` block. This arrangement will allow temporary lifetime analysis running as-is so that the temporaries are properly extended according to the same rule applied to regular `let` statements. cc https://github.com/rust-lang/rust/issues/87335 Fix #98672
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-3/+3
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-12remove outdated commentlcnr-9/+9
2022-07-12arena > Rc for query resultslcnr-6/+7
2022-07-12Rollup merge of #99038 - jackh726:earlybinder-cleanup, r=lcnrDylan DPC-2/+2
Some more `EarlyBinder` cleanups First commit has a couple unrelated cleanups, but otherwise each commit is self-explanatory r? rust-lang/types
2022-07-12Move abstract const to rustc_middle::tykadmin-642/+16
2022-07-11move else block into the `Local` structDing Xiang Fei-1/+1
2022-07-11lower let-else in MIR insteadDing Xiang Fei-2/+2
2022-07-11Rollup merge of #99075 - danobi:dup_type_hint_sugg, r=petrochenkovMatthias Krüger-0/+3
Fix duplicated type annotation suggestion Before, there was more or less duplicated suggestions to add type hints. Fix by clearing more generic suggestions when a more specific suggestion is possible. This fixes #93506 .
2022-07-11cg_fulfill_obligation: expect erased regionslcnr-2/+0
2022-07-11Rollup merge of #99091 - compiler-errors:private-types-should-stay-private, ↵Dylan DPC-2/+22
r=lcnr Do not mention private types from other crates as impl candidates Fixes #99080
2022-07-11Rollup merge of #98907 - compiler-errors:plz-no-float, r=oli-obkDylan DPC-2/+20
Deny float const params even when `adt_const_params` is enabled Supersedes #98825 Fixes #98813 r? ``@oli-obk``
2022-07-11Use Visibility::is_accessible_from to make suggestion more specificMichael Goulet-5/+7
2022-07-11Do not mention private Self types from other cratesMichael Goulet-2/+20
2022-07-11Deny floats even when adt_const_params is enabledMichael Goulet-2/+20
2022-07-11Rollup merge of #99095 - rhysd:issue-99092, r=compiler-errorsMatthias Krüger-12/+12
Remove duplicate notes from error on inter-crate ambiguous impl of traits Fixes #99092
2022-07-10Don't pass InferCtxt to WfPredicatesJack Huey-23/+29
2022-07-10Don't try to resolve inference variables in WF computation, just registerJack Huey-35/+17
2022-07-10Rollup merge of #99103 - TaKO8Ki:avoid-&str-to-string-conversions, r=oli-obkMatthias Krüger-1/+1
Avoid some `&str` to `String` conversions This patch removes some `&str` to `String` conversions.
2022-07-10Remove duplicate notes from error on inter-crate ambiguous impl of traits ↵rhysd-12/+12
(fix #99092)
2022-07-10avoid some `&str` to `String` conversionsTakayuki Maeda-1/+1
2022-07-09don't allow ZST in ScalarIntRalf Jung-0/+4
There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So instead add new ZST variants to those types that did not have other variants which could be used for this purpose.
2022-07-08Fix duplicated type annotation suggestionDaniel Xu-0/+3
Before, there was more or less duplicated suggestions to add type hints. Fix by clearing more generic suggestions when a more specific suggestion is possible. This fixes #93506 .
2022-07-08Auto merge of #98816 - estebank:implicit-sized, r=oli-obkbors-6/+6
Track implicit `Sized` obligations in type params When we evaluate `ty::GenericPredicates` we introduce the implicit `Sized` predicate of type params, but we do so with only the `Predicate` its `Span` as context, we don't have an `Obligation` or `ObligationCauseCode` we could influence. To try and carry this information through, we add a new field to `ty::GenericPredicates` that tracks both which predicates come from a type param and whether that param has any bounds already (to use in suggestions). We also suggest adding a `?Sized` bound if appropriate on E0599. Address part of #98539.
2022-07-08Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiserbors-0/+5
don't succeed `evaluate_obligation` query if new opaque types were registered fixes #98608 fixes #98604 The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked. I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this. Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).
2022-07-08Rollup merge of #98794 - compiler-errors:conflicting-param-env, ↵Dylan DPC-13/+71
r=michaelwoerister Highlight conflicting param-env candidates This could probably be further improved by noting _why_ equivalent param-env candidates (modulo regions) leads to ambiguity. Fixes #98786
2022-07-08Rollup merge of #98654 - nnethercote:pest-2.1.3-opt, r=pnkfelixDylan DPC-17/+10
An optimization for `pest-2.1.3` An easy win I found while looking at a profile of `pest-2.1.3`. It's also a small code cleanup. r? `@pnkfelix`
2022-07-08Highlight conflicting param-env candidatesMichael Goulet-13/+71
2022-07-07Use map_boundJack Huey-2/+2
2022-07-07Move code from rustc_trait_selection/opaque_types to better placesJack Huey-547/+60