about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-0/+1
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-12extend assertlcnr-3/+3
2023-06-11Rollup merge of #112513 - compiler-errors:dont-compute-box-span-for-tait, ↵Matthias Krüger-1/+19
r=cjgillot Dont compute `opt_suggest_box_span` span for TAIT Fixes #112434 Also a couple more commits on top, pruning some dead code and fixing another weird suggestion encountered in the above issue.
2023-06-11Don't suggest boxing an empty if/else armMichael Goulet-1/+19
2023-06-09split opaque type handling in new solverlcnr-36/+47
be more explicit in where we only add new hidden types and where we also have to deal with item bounds.
2023-06-09recompute opaque type originlcnr-20/+11
2023-06-08Don't suggest cyclic associated type constraintMichael Goulet-0/+6
2023-06-08More robust as_ref/as_deref suggestionsMichael Goulet-52/+3
2023-06-07Rollup merge of #112122 - compiler-errors:next-coherence, r=lcnrDylan DPC-27/+43
Add `-Ztrait-solver=next-coherence` Flag that conditionally uses the trait solver *only* during coherence, for more testing and/or eventual partial-migration onto the trait solver (in the medium- to long-term). * This still uses the selection context in some of the coherence methods I think, so it's not "complete". Putting this up for review and/or for further work in-tree. * I probably need to spend a bit more time making sure that we don't sneakily create any other infcx's during coherence that also need the new solver enabled. r? `@lcnr`
2023-06-07Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorinobors-1/+0
Emit an error when return-type-notation is used with type/const params These are not intended to be supported initially, even though the compiler supports them internally...
2023-06-06Fix comment for `get_region_var_origins`Nilstrieb-5/+5
2023-06-06Make TraitEngine::new use the right solver, add compare modeMichael Goulet-11/+9
2023-06-06New trait solver is a property of inference contextMichael Goulet-27/+45
2023-06-05Remove redundant InferCtxtExt::fresh_item_substsMichael Goulet-1/+0
2023-06-02Normalize anon consts in new solverMichael Goulet-1/+1
2023-06-02No more TyCtxt::lazy_normalizationMichael Goulet-1/+1
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-1/+1
2023-05-30change redundant `clear()` to assertionlcnr-4/+2
2023-05-30rework the leak_check to take the outer_universelcnr-111/+106
clean up coherence to not rely on probes anymore
2023-05-30coherence: don't add hidden types for opaqueslcnr-10/+22
we can otherwise assign a hidden type to the opaque which causes ICE if we don't use `take_opaque_types` during coherence. This is annoying so I didn't bother. Added a test showing the behavior this prevents.
2023-05-30leak_check: remove unused codepathlcnr-26/+6
2023-05-29Rename `tcx.mk_re_*` => `Region::new_*`Maybe Waffle-25/+28
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-26/+30
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-28Make EarlyBinder's inner value private; and fix all of the resulting errorsKyle Matsuda-1/+1
2023-05-26Auto merge of #111918 - compiler-errors:custom-type-ops-err, r=lcnrbors-2/+2
Use `ErrorGuaranteed` more in MIR type ops Delay bugs more eagerly and pass them through type op infra instead of delaying them at all the usage-sites. Follow up to: https://github.com/rust-lang/rust/pull/111741#discussion_r1203840588 r? `@lcnr`
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-295/+296
2023-05-25Fallible<_> -> Result<_, NoSolution>Michael Goulet-2/+2
2023-05-25Add InferCtxt::register_hidden_type_in_new_solverMichael Goulet-0/+23
2023-05-25Move DefiningAnchorMichael Goulet-14/+3
2023-05-25Pull out logic from #111131, plus some new logic in ↵Michael Goulet-26/+57
EvalCtxt::normalize_opaque_type Co-authored-by: lcnr <rust@lcnr.de>
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-7/+7
2023-05-20Rollup merge of #111450 - compiler-errors:opaque-ty-key, r=oli-obkGuillaume Gomez-6/+22
Use `OpaqueTypeKey` in query response Makes it a bit clearer that at least one of the types being returned from a canonical query is an opaque.
2023-05-18do not overwrite obligationslcnr-7/+6
2023-05-16Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obkNilstrieb-1/+1
Suppress "erroneous constant used" for constants tainted by errors When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not. Fixes #110891.
2023-05-15Replace RelationDir with VarianceMichael Goulet-63/+29
2023-05-15Rename super_relate_* to structurally_relate_*Michael Goulet-7/+7
2023-05-15Tweaks and a testMichael Goulet-51/+52
2023-05-15yeet ConstInferUnifierMichael Goulet-180/+63
2023-05-15Simplify delegateMichael Goulet-69/+70
2023-05-15Combine TypeGeneralizer and GeneralizerMichael Goulet-588/+467
2023-05-15Auto merge of #111570 - compiler-errors:ct-err, r=BoxyUwUbors-2/+2
Rename const error methods for consistency renames `ty::Const`'s methods for creating a `ConstKind::Error` to be in the same naming style as `ty::Ty`'s equivalent methods. r? `@BoxyUwU`
2023-05-15Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko-1/+1
When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not.
2023-05-14Rename const error methods for consistencyMichael Goulet-2/+2
2023-05-13Rollup merge of #110454 - oli-obk:limited_impl_trait_in_assoc_type, ↵Dylan DPC-3/+17
r=compiler-errors Require impl Trait in associated types to appear in method signatures This implements the limited version of TAIT that was proposed in https://github.com/rust-lang/rust/issues/107645#issuecomment-1477899536 Similar to `impl Trait` in return types, `impl Trait` in associated types may only be used within the impl block which it is a part of. To make everything simpler and forward compatible to getting desugared to a plain type alias impl trait in the future, we're requiring that any associated functions or constants that want to register hidden types must be using the associated type in their signature (type of the constant or argument/return type of the associated method. Where bounds mentioning the associated type are ignored). We have preexisting tests checking that this works transitively across multiple associated types in situations like ```rust impl Foo for Bar { type A = impl Trait; type B = impl Iterator<Item = Self::A>; fn foo() -> Self::B { ...... } } ```
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-1/+1
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-12Use the opaque_types_defined_by query to cheaply check for whether a hidden ↵Oli Scherer-124/+13
type may be registered for an opaque type
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-10/+135
2023-05-10Use OpaqueTypeKey in query responseMichael Goulet-6/+22
2023-05-10Remove and fix useless drop of referenceUrgau-1/+1
2023-05-09add EarlyBinder to thir_abstract_const; remove tcx.bound_abstract_constKyle Matsuda-1/+1