about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2023-04-03Never consider int and float vars for `FnPtr` candidatesNilstrieb-8/+14
This solves a regression where `0.0.cmp()` was ambiguous when a custom trait with a `cmp` method was in scope. FOr integers it shouldn't be a problem in practice so I wasn't able to add a test.
2023-04-02Rollup merge of #109846 - matthiaskrgr:clippy2023_04_III, r=NilstriebNilstrieb-3/+1
more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool)
2023-04-01use and_then/flat_map for map().flatten()Matthias Krüger-3/+1
2023-04-01a couple clippy::complexity fixesMatthias Krüger-3/+2
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-0/+1
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-29Inline and remove `SelectionContext::fast_reject_trait_refs`.Nicholas Nethercote-18/+4
Because it has a single call site, and it lets us move a small amount of the work outside the loop.
2023-03-29Introduce `DeepRejectCtxt::substs_refs_may_unify`.Nicholas Nethercote-4/+7
It factors out a repeated code pattern.
2023-03-28Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstriebbors-85/+93
Rollup of 8 pull requests Successful merges: - #91793 (socket ancillary data implementation for FreeBSD (from 13 and above).) - #92284 (Change advance(_back)_by to return the remainder instead of the number of processed elements) - #102472 (stop special-casing `'static` in evaluation) - #108480 (Use Rayon's TLV directly) - #109321 (Erase impl regions when checking for impossible to eagerly monomorphize items) - #109470 (Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`) - #109562 (Update ar_archive_writer to 0.1.3) - #109629 (remove obsolete `givens` from regionck) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-28Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnrbors-12/+162
Add a builtin `FnPtr` trait that is implemented for all function pointers r? `@ghost` Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR). If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
2023-03-28Rollup merge of #109629 - aliemjay:remove-givens, r=lcnrnils-7/+7
remove obsolete `givens` from regionck Revives #107376. The only change is the last commit (https://github.com/rust-lang/rust/pull/109629/commits/2a3177a8bcc4c5a5285dc2908a0f1ce98e9a6377) which should fix the regression. Fixes https://github.com/rust-lang/rust/issues/106567 r? `@lcnr`
2023-03-28Rollup merge of #102472 - lcnr:static-in-eval, r=jackh726nils-78/+86
stop special-casing `'static` in evaluation fixes #102360 I have no idea whether this actually removed all places where `'static` matters. Without canonicalization it's very easy to accidentally rely on `'static` again. Blocked on changing the `order_dependent_trait_objects` future-compat lint to a hard error r? `@nikomatsakis`
2023-03-27Some tracing/instrument cleanupsOli Scherer-6/+3
2023-03-27Add a builtin `FnPtr` traitlcnr-6/+159
2023-03-26Don't elaborate non-obligations into obligationsMichael Goulet-38/+33
2023-03-26resolve regions before implied boundsAli MJ Al-Nasrawy-5/+7
2023-03-26remove obsolete `givens` from regionckAli MJ Al-Nasrawy-2/+0
2023-03-24Auto merge of #109547 - matthiaskrgr:rollup-zczqgdk, r=matthiaskrgrbors-24/+27
Rollup of 9 pull requests Successful merges: - #108629 (rustdoc: add support for type filters in arguments and generics) - #108924 (panic_immediate_abort requires abort as a panic strategy) - #108961 (Refine error spans for const args in hir typeck) - #108986 (sync LVI tests) - #109142 (Add block-based mutex unlocking example) - #109368 (fix typo in the creation of OpenOption for RustyHermit) - #109493 (Return nested obligations from canonical response var unification) - #109515 (Add AixLinker to support linking on AIX) - #109536 (resolve: Rename some cstore methods to match queries and add comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-24Rollup merge of #109493 - compiler-errors:new-solver-vars-obligations, r=lcnrMatthias Krüger-22/+15
Return nested obligations from canonical response var unification Handle alias-eq obligations being emitted from `instantiate_and_apply_query_response` in: * `EvalCtxt` - by processing the nested obligations in the next loop by `new_goals` * `FulfillCtxt` - by adding the nested obligations to the fulfillment's pending obligations * `InferCtxt::evaluate_obligation` - ~~by returning `EvaluationResult::EvaluatedToAmbig` (boo :-1:, see the FIXME)~~ same behavior as above, since we use fulfillment and `select_where_possible` The only one that's truly sketchy is `evaluate_obligation`, but it's not hard to modify this behavior moving forward. From #109037, I think a smaller repro could be crafted if I were smarter, but I am not, so I just took this from #105878. r? `@lcnr` cc `@BoxyUwU`
2023-03-24Rollup merge of #108961 - compiler-errors:refine-ct-errors, r=BoxyUwUMatthias Krüger-2/+12
Refine error spans for const args in hir typeck Improve just a couple of error messages having to do with mismatched consts. r? `@ghost` i'll put this up when the dependent commits are merged
2023-03-23Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnrbors-19/+9
Don't pass `TreatProjections` separately to `fast_reject` Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417). Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
2023-03-23Use fulfillment in InferCtxt::evaluate_obligationMichael Goulet-30/+15
2023-03-23Note type mismatch on ConstArgHasTypeMichael Goulet-2/+12
2023-03-23Return nested obligations from canonical response var unificationMichael Goulet-1/+9
2023-03-23Don't split up TreatProjections and TreatParams anymoreMichael Goulet-19/+9
2023-03-23Rollup merge of #109472 - MU001999:patch-3, r=eholkMatthias Krüger-7/+25
Add parentheses properly for method calls Fixes #109436
2023-03-23Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgrbors-14/+19
Rollup of 7 pull requests Successful merges: - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs) - #109137 (resolve: Querify most cstore access methods (subset 2)) - #109380 (add `known-bug` test for unsoundness issue) - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate)) - #109475 (Simpler checked shifts in MIR building) - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.) - #109506 (make param bound vars visibly bound vars with -Zverbose) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23Rollup merge of #109462 - compiler-errors:alias-relate, r=BoxyUwU,lcnrMatthias Krüger-14/+19
Make alias-eq have a relation direction (and rename it to alias-relate) Emitting an "alias-eq" is too strict in some situations, since we don't always want strict equality between a projection and rigid ty. Adds a relation direction. * I could probably just reuse this [`RelationDir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/combine/enum.RelationDir.html) -- happy to uplift that struct into middle and use that instead, but I didn't feel compelled to... 🤷 * Some of the matching in `compute_alias_relate_goal` is a bit verbose -- I guess I could simplify it by using [`At::relate`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/at/struct.At.html#method.relate) and mapping the relation-dir to a variance. * Alternatively, I coulld simplify things by making more helper functions on `EvalCtxt` (e.g. `EvalCtxt::relate_with_direction(T, T)` that also does the nested goal registration). No preference. r? ```@lcnr``` cc ```@BoxyUwU``` though boxy can claim it if she wants NOTE: first commit is all the changes, the second is just renaming stuff
2023-03-23Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgrbors-5/+11
Rollup of 9 pull requests Successful merges: - #108954 (rustdoc: handle generics better when matching notable traits) - #109203 (refactor/feat: refactor identifier parsing a bit) - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions) - #109358 (rustc: Remove unused `Session` argument from some attribute functions) - #109359 (Update stdarch) - #109378 (Remove Ty::is_region_ptr) - #109423 (Use region-erased self type during IAT selection) - #109447 (new solver cleanup + implement coherence) - #109501 (make link clickable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-23Rename AliasEq -> AliasRelateMichael Goulet-14/+14
2023-03-23Include relation direction in AliasEq predicateMichael Goulet-0/+5
2023-03-23Use span_look_ahead instead of next_pointMu42-6/+3
2023-03-22Rollup merge of #109447 - lcnr:coherence, r=compiler-errorsMatthias Krüger-5/+11
new solver cleanup + implement coherence the cleanup: - change `Certainty::unify_and` to consider ambig + overflow to be ambig - rename `trait_candidate_should_be_dropped_in_favor_of` to `candidate_should_be_dropped_in_favor_of` - remove outdated fixme For coherence I mostly just add an ambiguous candidate if the current trait ref is unknowable. I am doing the same for reservation impl where I also just add an ambiguous candidate.
2023-03-22reviewlcnr-2/+1
2023-03-22stop special-casing `'static` in evaluatelcnr-78/+86
2023-03-22`HirId` to `LocalDefId` cleanuplcnr-5/+4
2023-03-22Fixes #109436: add parentheses properlyMu42-7/+28
2023-03-22Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errorsbors-195/+81
a general type system cleanup removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context. changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR. also removes some other small - and imo unnecessary - helpers. r? types
2023-03-21Rollup merge of #109446 - spastorino:new-rpitit-17, r=compiler-errorsMatthias Krüger-0/+1
Do not suggest bounds restrictions for synthesized RPITITs Before this PR we were getting ... ``` warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes --> tests/ui/async-await/in-trait/missing-send-bound.rs:5:12 | 5 | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ | = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information = note: `#[warn(incomplete_features)]` on by default error: future cannot be sent between threads safely --> tests/ui/async-await/in-trait/missing-send-bound.rs:17:20 | 17 | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` --> tests/ui/async-await/in-trait/missing-send-bound.rs:13:5 | 13 | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` --> tests/ui/async-await/in-trait/missing-send-bound.rs:21:27 | 21 | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` help: consider further restricting the associated type | 16 | fn test2<T: Foo>() where impl Future<Output = ()>: Send { | ++++++++++++++++++++++++++++++++++++ error: aborting due to previous error; 1 warning emitted ``` and we want this output ... ``` warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/missing-send-bound.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ | = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information = note: `#[warn(incomplete_features)]` on by default error: future cannot be sent between threads safely --> $DIR/missing-send-bound.rs:17:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` --> $DIR/missing-send-bound.rs:13:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` --> $DIR/missing-send-bound.rs:21:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` error: aborting due to previous error; 1 warning emitted ``` r? `@compiler-errors`
2023-03-21Rollup merge of #109441 - oli-obk:fn_trait_new_solver, r=compiler-errorsMatthias Krüger-20/+10
Only implement Fn* traits for extern "Rust" safe function pointers and items Since calling the function via an `Fn` trait will assume `extern "Rust"` ABI and not do any safety checks, only safe `extern "Rust"` function can implement the `Fn` traits. This syncs the logic between the old solver and the new solver. r? `@compiler-errors`
2023-03-21Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwUMatthias Krüger-1/+5
Constrain const vars to error if const types are mismatched When equating two consts of different types, if either are const variables, constrain them to the correct const error kind. This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection. Fixes #109296 The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message... r? `@BoxyUwU`
2023-03-21Do not suggest bounds restrictions for synthesized RPITITsSantiago Pastorino-0/+1
2023-03-21enable `intercrate` in the solver `InferCtxt`lcnr-4/+10
2023-03-21new solver cleanup + coherencelcnr-1/+1
2023-03-21Deduplicate fn trait compatibility checksOli Scherer-20/+7
2023-03-21Only implement Fn* traits for extern "Rust" safe function pointers.Oli Scherer-0/+3
2023-03-21evaluate: improve and fix recursion depth handlinglcnr-52/+19
2023-03-21remove some trait solver helperslcnr-143/+62
they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.
2023-03-20Enforce non-lifetime-binders in supertrait preds are not object safeMichael Goulet-1/+20
2023-03-19Delay overlap errors if errors are involvedMichael Goulet-1/+5
2023-03-17Fast path that skips over unchanged obligations in process_obligationsThe 8472-0/+23
- only borrow the refcell once per loop - avoid complex matches to reduce branch paths in the hot loop - use a by-ref fast path that avoids mutations at the expense of having false negatives