summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2024-06-06Uplift TypeRelation and RelateMichael Goulet-11/+11
2024-06-05Add `Ty` to `mir::Const::Ty`Boxy-2/+2
2024-06-05Basic removal of `Ty` from places (boring)Boxy-2/+2
2024-06-04Rollup merge of #125667 - oli-obk:taintify, r=TaKO8KiMichael Goulet-5/+29
Silence follow-up errors directly based on error types and regions During type_of, we used to just return an error type if there were any errors encountered. This is problematic, because it means a struct declared as `struct Foo<'static>` will end up not finding any inherent or trait impls because those impl blocks' `Self` type will be `{type error}` instead of `Foo<'re_error>`. Now it's the latter, silencing nonsensical follow-up errors about `Foo` not having any methods. Unfortunately that now allows for new follow-up errors, because borrowck treats `'re_error` as `'static`, causing nonsensical errors about non-error lifetimes not outliving `'static`. So what I also did was to just strip all outlives bounds that borrowck found, thus never letting it check them. There are probably more nuanced ways to do this, but I worried there would be other nonsensical errors if some outlives bounds were missing. Also from the test changes, it looked like an improvement everywhere.
2024-06-03Nits and formattingMichael Goulet-3/+3
2024-06-03Add cycle errors to ScrubbedTraitError to remove a couple more calls to ↵Michael Goulet-1/+1
new_with_diagnostics
2024-06-03Move FulfillmentErrorCode to rustc_trait_selection tooMichael Goulet-3/+5
2024-06-03Use ScrubbedTraitError in more placesMichael Goulet-2/+2
2024-06-03Opt-in diagnostics reporting to avoid doing extra work in the new solverMichael Goulet-2/+2
2024-06-03Make TraitEngines generic over errorMichael Goulet-1/+2
2024-06-03Auto merge of #125778 - estebank:issue-67100, r=compiler-errorsbors-1/+1
Use parenthetical notation for `Fn` traits Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Address #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-06-01Uplift TypeRelation and RelateMichael Goulet-2/+3
2024-05-31Rollup merge of #125652 - amandasystems:you-dropped-something, r=oli-obkMatthias Krüger-35/+30
Revert propagation of drop-live information from Polonius #64749 introduced a flow of drop-use data from Polonius to `LivenessResults::add_extra_drop_facts()`, which makes `LivenessResults` agree with Polonius on liveness in the presence of free regions that may be dropped. Later changes accidentally removed this flow. This PR restores it.
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-8/+4
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-8/+4
2024-05-29Use parenthetical notation for `Fn` traitsEsteban Küber-1/+1
Always use the `Fn(T) -> R` format when printing closure traits instead of `Fn<(T,), Output = R>`. Fix #67100: ``` error[E0277]: expected a `Fn()` closure, found `F` --> file.rs:6:13 | 6 | call_fn(f) | ------- ^ expected an `Fn()` closure, found `F` | | | required by a bound introduced by this call | = note: wrap the `F` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `call_fn` --> file.rs:1:15 | 1 | fn call_fn<F: Fn() -> ()>(f: &F) { | ^^^^^^^^^^ required by this bound in `call_fn` help: consider further restricting this bound | 5 | fn call_any<F: std::any::Any + Fn()>(f: &F) { | ++++++ ```
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-19/+15
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29Stop proving outlives constraints on regions we already reported errors onOli Scherer-5/+29
2024-05-28Move the rest of the logic into `add_extra_drop_facts()`Amanda Stjerna-9/+7
2024-05-28Make drop-use fact collection simpler for `polonius`Amanda Stjerna-41/+34
This shunts all the complexity of siphoning off the drop-use facts into `LivenessResults::add_extra_drop_facts()`, which may or may not be a good approach.
2024-05-28Fix back-porting drop-livess from Polonius to tracingAmanda Stjerna-5/+9
2024-05-24Remove `DefId` from `EarlyParamRegion` (tedium/diagnostics)Boxy-32/+51
2024-05-21Uplift OutlivesPredicate, remove a bunch of unnecessary associated types ↵Michael Goulet-2/+2
from Interner
2024-05-21Auto merge of #123812 - compiler-errors:additional-fixes, r=fmeasebors-1/+1
Follow-up fixes to `report_return_mismatched_types` Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
2024-05-21Auto merge of #125284 - compiler-errors:uplift-misc, r=lcnrbors-21/+44
Uplift `RegionVid`, `TermKind` to `rustc_type_ir`, and `EagerResolver` to `rustc_next_trait_solver` - Uplift `RegionVid`. This was complicated due to the fact that we implement `polonius_engine::Atom` for `RegionVid` -- but I just separated that into `PoloniusRegionVid`, and added `From`/`Into` impls so it can be defined in `rustc_borrowck` separately. Coherence 😵 - Change `InferCtxtLike` to expose `opportunistically_resolve_{ty,ct,lt,int,float}_var` so that we can uplift `EagerResolver` for use in the canonicalization methods. - Uplift `TermKind` much like `GenericArgKind` All of this is miscellaneous dependencies for making more `EvalCtxt` methods generic.
2024-05-20Rename confusing function nameMichael Goulet-1/+1
2024-05-20Uplift RegionVidMichael Goulet-21/+44
2024-05-20Rollup merge of #125173 - scottmcm:never-checked, r=davidtwcoMatthias Krüger-7/+3
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
2024-05-19fix suggestion in E0373 for !Unpin coroutinesJoshua Wong-0/+4
Coroutines can be prefixed with the `static` keyword to make them `!Unpin`. However, given the following function: ```rust fn check() -> impl Sized { let x = 0; #[coroutine] static || { yield; x } } ``` We currently suggest prefixing `move` before `static`, which is syntactically incorrect: ``` error[E0373]: coroutine may outlive the current function, but it borrows ... --> src/main.rs:6:5 | 6 | static || { | ^^^^^^^^^ may outlive borrowed value `x` 7 | yield; 8 | x | - `x` is borrowed here | note: coroutine is returned here --> src/main.rs:6:5 | 6 | / static || { 7 | | yield; 8 | | x 9 | | } | |_____^ help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword | // this is syntactically incorrect, it should be `static move ||` 6 | move static || { | ++++ ``` This PR suggests adding `move` after `static` for these coroutines.
2024-05-19Rollup merge of #124948 - blyxyas:remove-repeated-words, r=compiler-errorsMatthias Krüger-1/+1
chore: Remove repeated words (extension of #124924) When I saw #124924 I thought "Hey, I'm sure that there are far more than just two typos of this nature in the codebase". So here's some more typo-fixing. Some found with regex, some found with a spellchecker. Every single one manually reviewed by me (along with hundreds of false negatives by the tools)
2024-05-18Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726bors-4/+4
Rename Unsafe to Safety Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18Fix typos (taking into account review comments)blyxyas-1/+1
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-7/+3
2024-05-17Rename Unsafe to SafetySantiago Pastorino-4/+4
2024-05-16Uplift Goal to rustc_type_irMichael Goulet-3/+3
2024-05-16Make P parameter explicitMichael Goulet-3/+6
2024-05-16Rename ToPredicate for UpcastMichael Goulet-10/+10
2024-05-13split out AliasTy -> AliasTermMichael Goulet-1/+2
2024-05-11Consolidate obligation cause codes for where clausesMichael Goulet-4/+1
2024-05-10Auto merge of #124982 - compiler-errors:uplift-trait-ref, r=lcnrbors-12/+25
Uplift `TraitRef` into `rustc_type_ir` Emotional rollercoaster r? lcnr
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-12/+25
2024-05-10Auto merge of #124952 - compiler-errors:no-error, r=lcnrbors-4/+4
Rename some `FulfillmentErrorCode`/`ObligationCauseCode` variants to be less redundant 1. Rename some `FulfillmentErrorCode` variants. 2. Always use `ObligationCauseCode::` to prefix a code, rather than using a glob import and naming them through `traits::`. 3. Rename some `ObligationCauseCode` variants -- I wasn't particularly thorough with thinking of a new names for these, so could workshop them if necessary. 4. Misc stuff from renaming. r? lcnr
2024-05-10Name tweaksMichael Goulet-1/+4
2024-05-10More rename falloutMichael Goulet-1/+1
2024-05-10Rename some ObligationCauseCode variantsMichael Goulet-5/+2
2024-05-10rename some variants in FulfillmentErrorCodeMichael Goulet-2/+2
2024-05-10Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoeristerMatthias Krüger-5/+4
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2024-05-10Auto merge of #124961 - matthiaskrgr:rollup-1jj65p6, r=matthiaskrgrbors-17/+4
Rollup of 7 pull requests Successful merges: - #124551 (Add benchmarks for `impl Debug for str`) - #124915 (`rustc_target` cleanups) - #124918 (Eliminate some `FIXME(lcnr)` comments) - #124927 (opt-dist: use xz2 instead of xz crate) - #124936 (analyse visitor: build proof tree in probe) - #124943 (always use `GenericArgsRef`) - #124955 (Use fewer origins when creating type variables.) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-10Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnrMatthias Krüger-14/+3
Use fewer origins when creating type variables. To reduce lots of repetitive boilerplate code. Details in the individual commit messages. r? ``@lcnr``
2024-05-10Rollup merge of #124918 - nnethercote:FIXME-lcnr, r=lcnrMatthias Krüger-3/+1
Eliminate some `FIXME(lcnr)` comments In some cases this involved changing code. In some cases the comment was able to removed or replaced. r? ``@lcnr``