about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src/diagnostics
AgeCommit message (Collapse)AuthorLines
2023-11-25Remove HirId from QPath::LangItemMichael Goulet-8/+4
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-26/+26
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Rollup merge of #118035 - ouz-a:november_ice2, r=compiler-errorsNilstrieb-2/+9
Fix early param lifetimes in generic_const_exprs In cases like below, we never actually be able to capture region name for two reasons, first `'static` becomes anonymous lifetime and second we never capture region if it doesn't have a name so this results in ICE. ``` struct DataWrapper<'static> { data: &'a [u8; Self::SIZE], } impl DataWrapper<'a> { ``` Fixes https://github.com/rust-lang/rust/issues/118021
2023-11-20Fix early param lifetimes in generic_const_exprsouz-a-2/+9
2023-11-20Rollup merge of #117835 - Nilstrieb:note-object-lifetime-defaults, ↵Matthias Krüger-2/+60
r=compiler-errors Note about object lifetime defaults in does not live long enough error This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose. The implementation feels a bit questionable, I'm not sure whether there are better ways to do this. There probably are. fixes #117835 r? types
2023-11-17rename bound region instantiationlcnr-2/+3
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-16Auto merge of #116097 - jackh726:higher-ranked-lifetime-error-backup, ↵bors-12/+44
r=compiler-errors Try to use approximate placeholder regions when outputting an AscribeUserType error in borrowck Fixes #114866 Hi from GOSIM :)
2023-11-15Re-format code with new rustfmtMark Rousskov-1/+2
2023-11-14finish `RegionKind` renamelcnr-26/+29
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-13continue renaminglcnr-2/+2
- `RegionVariableOrigin::~~Late~~BoundRegion` - `~~Late~~BoundRegionConversionTime`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-3/+3
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-12Note about object lifetime defaults in does not live long enough errorNilstrieb-2/+60
This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose.
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-8/+7
also adds some comments
2023-11-07Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errorsbors-1/+19
Emit explanatory note for move errors in packed struct derives Derive expansions for packed structs with non-`Copy` fields cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access. This underlying cause of the errors, however, is not apparent to the user. This PR adds a diagnostic note to make it clear to the user (the new note is on the second last line): ``` tests/ui/derives/deriving-with-repr-packed-move-errors.rs:13:16 | 12 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)] | ----- in this derive macro expansion 13 | struct StructA(String); | ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait | = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Fixes #117406 Partially addresses #110777
2023-11-03Emit explanatory note for move errors in packed struct derivesGurinder Singh-1/+19
Derive expansions for packed structs cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access and therefore undefined behaviour. This underlying cause of the errors, however, is not apparent to the user. We add a diagnostic note here to remedy that.
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-27Handle `move` generatorsOli Scherer-5/+11
2023-10-26Add hir::GeneratorKind::GenOli Scherer-0/+19
2023-10-25Rename `AsyncCoroutineKind` to `CoroutineSource`Oli Scherer-6/+6
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-24Auto merge of #116300 - cjgillot:split-move, r=petrochenkovbors-69/+95
Separate move path tracking between borrowck and drop elaboration. The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration. The 2 first commits are cleanups. The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more. The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-23Rollup merge of #116859 - Nilstrieb:more-more-funny-pretty-printers, r=oli-obkMatthias Krüger-2/+4
Make `ty::print::Printer` take `&mut self` instead of `self` based on #116815 This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-21Stop computing error info in move path builder.Camille GILLOT-3/+22
2023-10-21Avoid using a magic value for untracked locals.Camille GILLOT-3/+4
2023-10-21Do not report errors from move path builder.Camille GILLOT-65/+71
2023-10-21Make `ty::print::Printer` take `&mut self` instead of `self`Nilstrieb-2/+4
This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-21Rollup merge of #116990 - estebank:issue-68445, r=cjgillotMatthias Krüger-0/+22
Mention `into_iter` on borrow errors suggestions when appropriate If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-20Rename `CoroutineKind::Gen` to `::Coroutine`Oli Scherer-2/+2
2023-10-20s/generator/coroutine/Oli Scherer-51/+51
2023-10-20s/Generator/Coroutine/Oli Scherer-36/+36
2023-10-20Mention `into_iter` on borrow errors suggestions when appropriateEsteban Küber-0/+22
If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-13Format all the let chains in compilerMichael Goulet-193/+177
2023-10-11Use structured suggestion for #113174Esteban Küber-23/+149
When encountering a for loop that is rejected by the borrow checker because it is being advanced within its body, provide a structured suggestion for `while let Some(pat) = iter.next()`.
2023-10-05Rollup merge of #116223 - catandcoder:master, r=cjgillotJubilee-3/+3
Fix misuses of a vs an Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/
2023-10-04Fix misuses of a vs ancui fliter-3/+3
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-02Add docs, remove code, change subtyper codeouz-a-2/+3
2023-10-02subtyping_projectionsouz-a-0/+4
2023-09-27fix clippy::{redundant_guards, useless_format}Matthias Krüger-2/+2
2023-09-27Auto merge of #116163 - compiler-errors:lazyness, r=oli-obkbors-1/+1
Don't store lazyness in `DefKind::TyAlias` 1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query. 2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase. r? `@oli-obk` cc `@fmease`
2023-09-26subst -> instantiatelcnr-2/+2
2023-09-26Don't store lazyness in DefKindMichael Goulet-1/+1
2023-09-24Remove span from BrAnon.Camille GILLOT-1/+1
2023-09-24Try to use approximate placeholder regions when outputting an ↵Jack Huey-12/+44
AscribeUserType error in borrowck
2023-09-21Record asyncness span in HIRMichael Goulet-1/+1
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-3/+3
2023-09-18Remove `RegionHighlightMode::tcx`.Nicholas Nethercote-4/+4
It's easier to pass it in to the one method that needs it (`highlighting_region_vid`) than to store it in the type. This means `RegionHighlightMode` can impl `Default`.
2023-09-11Auto merge of #115595 - surechen:114896, r=davidtwcobors-6/+78
Fix incorrect mutable suggestion information for binding in ref pattern like: `let &b = a;` fixes #114896 I find we have to get pat_span but not local_decl.source_info.span for suggestion. In `let &b = a;` pat_span is &b. I think check `let &b = a` in hir to make sure it is hir::Node::Local(hir::Local {pat: hir::Pat{kind: hir::PatKind::Ref(....... can distinguish it from other situation, but I'm not sure. If my processing method is not accurate, please guide me to modify it, thank you. r? `@davidtwco`
2023-09-11Auto merge of #115308 - chenyukang:yukang-fix-62387-iter-mut, r=davidtwcobors-1/+41
suggest iter_mut() where trying to modify elements from .iter() Fixes https://github.com/rust-lang/rust/issues/115259 Fixes https://github.com/rust-lang/rust/issues/62387
2023-09-07fixes #114896surechen-6/+78
2023-09-06Rollup merge of #114511 - chenyukang:yukang-fix-114374-fmt-args, r=b-naberMatthias Krüger-13/+37
Remove the unhelpful let binding diag comes from FormatArguments Fixes #114374
2023-09-07suggest iter_mut() where trying to modify elements from .iter()yukang-1/+41