about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-7/+7
2024-08-16Add `warn(unreachable_pub)` to `rustc_borrowck`.Nicholas Nethercote-68/+74
2024-08-14Rollup merge of #129059 - compiler-errors:subtyping-correct-type, r=lcnr许杰友 Jieyou Xu (Joe)-4/+4
Record the correct target type when coercing fn items/closures to pointers Self-explanatory. We were previously not recording the *target* type of a coercion as the output of an adjustment. This should remedy that. We must also modify the function pointer casts in MIR typeck to use subtyping, since those broke since #118247. r? lcnr
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-5/+5
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-13Use the right type when coercing fn items to pointersMichael Goulet-4/+4
2024-08-12Rollup merge of #128712 - compiler-errors:normalize-borrowck, r=lcnrMatthias Krüger-11/+49
Normalize struct tail properly for `dyn` ptr-to-ptr casting in new solver Realized that the new solver didn't handle ptr-to-ptr casting correctly. r? lcnr Built on #128694
2024-08-12Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxuGuillaume Gomez-2/+4
Use `assert_matches` around the compiler more It's a useful assertion, especially since it actually prints out the LHS.
2024-08-12Rollup merge of #128886 - GrigorenkoPV:untranslatable-diagnostic, r=nnethercoteGuillaume Gomez-33/+31
Get rid of some `#[allow(rustc::untranslatable_diagnostic)]` `@rustbot` label +A-translation cc https://github.com/rust-lang/rust/issues/100717
2024-08-11Rename normalization functions to rawMichael Goulet-2/+2
2024-08-11Normalize struct tail properly in borrowck and hir typeckMichael Goulet-11/+49
2024-08-11Use assert_matches around the compilerMichael Goulet-2/+4
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-2/+2
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
2024-08-10rustc_borrowck: fmtPavel Grigorenko-29/+31
2024-08-10rustc_borrowck: make "implicit static" suff translatablePavel Grigorenko-4/+3
2024-08-10rustc_borrowck: make some suggestion about static lifetimes translatablePavel Grigorenko-3/+2
2024-08-10rustc_borrowck: make suggestion to move closure translatablePavel Grigorenko-2/+1
2024-08-10rustc_borrowck: make dereference suggestion translatablePavel Grigorenko-3/+2
2024-08-09use stable sort to sort multipart diagnosticsFolkert-1/+1
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-5/+5
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-2/+2
2024-08-06Don't arbitrarily choose one upper bound for hidden captured regionMichael Goulet-15/+20
2024-08-05Normalize when equating dyn tails in MIR borrowckMichael Goulet-0/+6
2024-07-31Rollup merge of #128244 - compiler-errors:move-clone-sugg, r=estebankMatthias Krüger-80/+28
Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks Also remove a heck of a lot of weird hacks in `suggest_cloning` that I don't think we should have around. I know this regresses tests, but I don't believe most of these suggestions were accurate, b/c: 1. They either produced type errors (e.g. turning `&x` into `x.clone()`) 2. They don't fix the issue 3. They fix the issue ostensibly, but introduce logic errors (e.g. cloning a `&mut Option<T>` to then `Option::take` out...) Most of the suggestions are still wrong, but they're not particularly *less* wrong IMO. Stacked on top of #128241, which is an "obviously worth landing" subset of this PR. r? estebank
2024-07-29Stop using MoveDataParamEnv for places that don't need a param-envMichael Goulet-9/+7
2024-07-29Reformat `use` declarations.Nicholas Nethercote-312/+273
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-27Rollup merge of #128241 - compiler-errors:clone-sugg, r=jieyouxuTrevor Gross-31/+0
Remove logic to suggest clone of function output I can't exactly tell, but I believe that this suggestion is operating off of a heuristic that the lifetime of a function's input is correlated with the lifetime of a function's output in such a way that cloning would fix an error. I don't think that actually manages to hit the bar of "actually provides useful suggestions" most of the time. Specifically, I've hit false-positives due to this suggestion *twice* when fixing ICEs in the compiler, so I don't think it's worthwhile having this logic around. Neither of the two affected UI tests are actually fixed by the suggestion.
2024-07-26Peel off explicit (or implicit) deref before suggesting clone on move error ↵Michael Goulet-80/+28
in borrowck
2024-07-26Remove logic to suggest clone of function outputMichael Goulet-31/+0
2024-07-26Suppress useless clone suggestionMichael Goulet-0/+5
2024-07-24Don't ICE if HIR and middle types disagree in borrowck error reportingMichael Goulet-8/+26
2024-07-23Rollup merge of #128049 - compiler-errors:E0626, r=petrochenkovMatthias Krüger-3/+27
Reword E0626 to mention static coroutine, add structured suggestion for adding `static` Not certain how to make the example feel less artificial. 🤷 My main point though is that we should probably emphasize that the first solution to making a coroutine allow a borrow across an await is making it `static`. Also adds a structured suggestion.
2024-07-21Move all error reporting into rustc_trait_selectionMichael Goulet-11/+14
2024-07-21Move some stuff to TypeErrCtxtMichael Goulet-4/+10
2024-07-21Explain that coroutine can be marked staticMichael Goulet-3/+27
And also point out the def span of the coroutine
2024-07-20Rollup merge of #127948 - surechen:fix_127915, r=compiler-errorsMatthias Krüger-4/+9
fixes panic error `index out of bounds` in conflicting error fixes #127915
2024-07-19fixes panic errorsurechen-4/+9
fixes #127915
2024-07-18Remove tag field from relationsMichael Goulet-4/+0
2024-07-18Rollup merge of #127810 - compiler-errors:less-tcx, r=lcnrMatthias Krüger-4/+4
Rename `tcx` to `cx` in `rustc_type_ir` Self-explanatory. Forgot that we had to do this in type_ir too, and not just the new solver crate lol. r? lcnr
2024-07-17Fix relationsMichael Goulet-4/+4
2024-07-17If the moved value is a mut reference, it is used in a generic function and ↵surechen-29/+73
it's type is a generic param, it can be reborrowed to avoid moving. for example: ```rust struct Y(u32); // x's type is '& mut Y' and it is used in `fn generic<T>(x: T) {}`. fn generic<T>(x: T) {} ``` fixes #127285
2024-07-16Rollup merge of #127501 - compiler-errors:invert-infer-error-mod-struture, ↵Trevor Gross-3/+3
r=lcnr Invert infer `error_reporting` mod struture Parallel change to #127493, which moves `rustc_infer::infer::error_reporting` to `rustc_infer::error_reporting::infer`. After this, we should just be able to merge this into `rustc_trait_selection::error_reporting::infer`, and pull down `TypeErrCtxt` into that crate. 👍 r? lcnr
2024-07-16Rollup merge of #120990 - chenyukang:yukang-fix-120327-dbg, r=oli-obkTrevor Gross-2/+63
Suggest a borrow when using dbg Fixes #120327 r? ````@estebank````
2024-07-15Move rustc_infer::infer::error_reporting to rustc_infer::error_reporting::inferMichael Goulet-3/+3
2024-07-16Suggest a borrow when using dbgyukang-2/+63
2024-07-16Remove invalid help diagnostics for const pointeryukang-12/+21
2024-07-14Stop using the gen keyword in the compilerMichael Goulet-1/+1
2024-07-12Rollup merge of #127625 - SkiFire13:revert-comment-deletion, r=workingjubileeMatthias Krüger-0/+2
Revert accidental comment deletion This reverts an accidental comment deletion made in #113128 See also https://github.com/rust-lang/rust/pull/113128#discussion_r1674614882
2024-07-11Revert accidental comment deletionGiacomo Stevanato-0/+2
2024-07-11Rollup merge of #124599 - estebank:issue-41708, r=wesleywiserMatthias Krüger-19/+70
Suggest borrowing on fn argument that is `impl AsRef` When encountering a move conflict, on an expression that is `!Copy` passed as an argument to an `fn` that is `impl AsRef`, suggest borrowing the expression. ``` error[E0382]: use of moved value: `bar` --> f204.rs:14:15 | 12 | let bar = Bar; | --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait 13 | foo(bar); | --- value moved here 14 | let baa = bar; | ^^^ value used here after move | help: borrow the value to avoid moving it | 13 | foo(&bar); | + ``` Fix #41708
2024-07-09Auto merge of #127500 - compiler-errors:consolidate-region-errors, r=lcnrbors-7/+5
Consolidate region error reporting in `rustc_infer` More work on https://github.com/rust-lang/rust/issues/127492. Separate but important step, since I'm gonna likely pull everything else here into another module. I don't think I'm confident whether `nice_region_error` should be a submodule of the new `rustc_infer::infer::error_reporting::region` module, so I left it alone for now. r? lcnr