summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/diagnostics
AgeCommit message (Collapse)AuthorLines
2024-11-19Put `param_env` into `infcx`.Nicholas Nethercote-31/+34
Because they get passed around together a lot.
2024-11-18reviewlcnr-1/+3
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-7/+16
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-17`suggest_borrow_generic_arg`: instantiate clauses properlydianne-16/+10
Fixes issue 133118. This also modifies `tests/ui/moves/moved-value-on-as-ref-arg.rs` to have more useful bounds on the tests for suggestions to borrow `Borrow` and `BorrowMut` arguments. With its old tautological `T: BorrowMut<T>` bound, this fix would make it suggest a shared borrow for that argument.
2024-11-13Suggest borrowing arguments in generic positions when trait bounds are satisfieddianne-159/+157
This subsumes the suggestions to borrow arguments with `AsRef`/`Borrow` bounds and those to borrow arguments with `Fn` and `FnMut` bounds. It works for other traits implemented on references as well, such as `std::io::Read`, `std::io::Write`, and `core::fmt::Write`. Incidentally, by making the logic for suggesting borrowing closures general, this removes some spurious suggestions to mutably borrow `FnMut` closures in assignments, as well as an unhelpful suggestion to add a `Clone` constraint to an `impl Fn` argument.
2024-11-13Use a common subdiagnostic format for generic borrowsdianne-5/+10
This is setup for unifing the logic for suggestions to borrow arguments in generic positions. As of this commit, it's still special cases for `AsRef`/`Borrow`-like traits and `Fn`-like traits.
2024-11-13Provide borrow-instead-of-move suggestions for calls of fn-like items from ↵dianne-39/+40
other crates This also downgrades its applicability to MaybeIncorrect. Its suggestion can result in ill-typed code when the type parameter it suggests providing a different generic argument for appears elsewhere in the callee's signature or predicates.
2024-11-09Dont suggest use<APIT>Michael Goulet-26/+45
2024-11-05Auto merge of #132580 - compiler-errors:globs, r=Noratriebbors-5/+5
Remove unnecessary pub enum glob-imports from `rustc_middle::ty` We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly. `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`. This PR is a bit large, but it's just naming. The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine. r? `@noratrieb` or reassign
2024-11-04Rollup merge of #131153 - VulnBandit:copy_impl_vuln, r=compiler-errorsJubilee-0/+17
Improve duplicate derive Copy/Clone diagnostics Improve duplicate derive Copy/Clone diagnostics. Closes #131083
2024-11-04Remove `ToUniverseInfo` impl for `CanonicalQueryInput<CustomTypeOp>`.Nicholas Nethercote-9/+0
It's unused.
2024-11-04Merge `UniverseInfo` and `UniverseInfoInner`.Nicholas Nethercote-25/+13
It's strange to have a struct that contains a single anonymous field that is an enum. This commit merges them. This does require increasing the visibility of `TypeOfInfo` to `pub(crate)`, but that seems worthwhile.
2024-11-04Tidy up comments and some formatting.Nicholas Nethercote-38/+48
Mostly by wrapping overly long comment lines, plus a few other things.
2024-11-04ty::BrK -> ty::BoundRegionKind::KMichael Goulet-4/+4
2024-11-04Remove BorrowKind glob, make names longerMichael Goulet-1/+1
2024-11-04Reduce visibilities.Nicholas Nethercote-1/+1
2024-11-02compiler: Replace rustc_target with _abi in _borrowckJubilee Young-3/+3
2024-10-31Auto merge of #132301 - compiler-errors:adjust, r=lcnrbors-1/+0
Remove region from adjustments It's not necessary to store this region, because it's only used in THIR and MemCat/ExprUse, both of which already basically only deal with erased regions anyways.
2024-10-31Try to point out when edition 2024 lifetime capture rules cause borrowck issuesMichael Goulet-1/+232
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-1/+1
2024-10-29Remove region from adjustmentsMichael Goulet-1/+0
2024-10-24Rollup merge of #131756 - compiler-errors:deeply-normalize-type-err, r=lcnrStuart Cook-6/+6
Deeply normalize `TypeTrace` when reporting type error in new solver Normalize the values that come from the `TypeTrace` for various type mismatches. Side-note: We can't normalize the `TypeError` itself bc it may come from instantiated binders, so it may reference values from within the probe... r? lcnr
2024-10-24Plumb through param_env to note_type_errMichael Goulet-6/+6
2024-10-23fix some manual_mapMatthias Krüger-7/+3
2024-10-19Rollup merge of #127675 - chenyukang:yukang-fix-127562-addr, r=petrochenkovMatthias Krüger-12/+21
Remove invalid help diagnostics for const pointer Partially addresses #127562
2024-10-17move `defining_opaque_types` out of `Canonical`lcnr-15/+14
2024-10-16Improve duplicate derive Copy/Clone diagnosticsVulnBandit-0/+17
2024-10-14Move trait bound modifiers into hir::PolyTraitRefMichael Goulet-3/+3
2024-10-12remove a couple of redundant String to String conversionMatthias Krüger-1/+1
2024-10-07Rollup merge of #131225 - nnethercote:rustc_borrowck-mm, r=lqdJubilee-13/+12
`rustc_borrowck` memory management tweaks Minor cleanups in `rustc_borrowck` relating to memory management. r? `@lqd`
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-8/+2
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-04Remove unnecessary lifetime in `ConditionVisitor`.Nicholas Nethercote-10/+10
By making it own two of its fields.
2024-10-04Use `Rc` less in `MirBorrowckCtxt`.Nicholas Nethercote-3/+2
The `regioncx` and `borrow_set` fields can be references instead of `Rc`. They use the existing `'a` lifetime. This avoids some heap allocations and is a bit simpler.
2024-10-02Remove redundant in_trait from hir::TyKind::OpaqueDefMichael Goulet-1/+1
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-5/+7
2024-09-24replace "cast" with "coercion" where applicableLukas Markeffsky-2/+5
This changes the remaining span for the cast, because the new `Cast` category has a higher priority (lower `Ord`) than the old `Coercion` category, so we no longer report the region error for the "unsizing" coercion from `*const Trait` to itself.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-82/+78
2024-09-14Rollup merge of #130294 - nnethercote:more-lifetimes, r=lcnrLeón Orell Valerian Liehr-9/+9
Lifetime cleanups The last commit is very opinionated, let's see how we go. r? `@oli-obk`
2024-09-13Rename and reorder lots of lifetimes.Nicholas Nethercote-9/+9
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and 'me with vanilla 'a. These are cases where the original name isn't really any more informative than 'a. - Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime applies to multiple fields and so the original lifetime name isn't really accurate. - Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-13Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxubors-17/+122
Rescope temp lifetime in if-let into IfElse with migration lint Tracking issue #124085 This PR shortens the temporary lifetime to cover only the pattern matching and consequent branch of a `if let`. At the expression location, means that the lifetime is shortened from previously the deepest enclosing block or statement in Edition 2021. This warrants an Edition change. Coming with the Edition change, this patch also implements an edition lint to warn about the change and a safe rewrite suggestion to preserve the 2021 semantics in most cases. Related to #103108. Related crater runs: https://github.com/rust-lang/rust/pull/129466.
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-25/+22
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-11Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errorsJubilee-1/+1
Remove needless returns detected by clippy in the compiler
2024-09-11Simplify some nested if statementsMichael Goulet-25/+22
2024-09-11downgrade borrowck suggestion level due to possible span conflictDing Xiang Fei-14/+29
2024-09-11rescope temp lifetime in let-chain into IfElseDing Xiang Fei-17/+107
apply rules by span edition
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-1/+1
2024-09-09Remove unnecessary lifetimes in dataflow structs.Nicholas Nethercote-24/+20
There are four related dataflow structs: `MaybeInitializedPlaces`, `MaybeUninitializedPlaces`, and `EverInitializedPlaces`, `DefinitelyInitializedPlaces`. They all have a `&Body` and a `&MoveData<'tcx>` field. The first three use different lifetimes for the two fields, but the last one uses the same lifetime for both. This commit changes the first three to use the same lifetime, removing the need for one of the lifetimes. Other structs that also lose a lifetime as a result of this are `LivenessContext`, `LivenessResults`, `InitializationData`. It then does similar things in various other structs.
2024-09-06Make `Ty::boxed_ty` return an `Option`Pavel Grigorenko-3/+4
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-1/+1
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_borrowck`.Nicholas Nethercote-0/+10