about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
AgeCommit message (Collapse)AuthorLines
2023-05-24Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiaskobors-8/+3
Preprocess and cache dominator tree Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344. That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree). This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache. Rebase of https://github.com/rust-lang/rust/pull/107157 cc `@tmiasko`
2023-05-24Use ObligationCtxt in custom type opsMichael Goulet-33/+39
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-10/+5
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-4/+4
2023-05-23Add RegionInferenceContext::outlives_constraintsDominik Stolz-1/+7
2023-05-23Move BodyWithBorrowckFacts to consumersDominik Stolz-31/+34
2023-05-23Make place helpers accessibleDominik Stolz-0/+2
2023-05-23Return promoteds in BodyWithBorrowckFactsDominik Stolz-0/+3
2023-05-23Allow consumers to retrieve borrowck outputJonáš Fiala-48/+111
2023-05-22Check opaques for mismatch during writebackMichael Goulet-0/+2
2023-05-19Leverage the interval property to precompute borrow kill points.Camille GILLOT-50/+77
2023-05-18Take MIR dataflow analyses by mutable reference.Jason Newcomb-12/+15
2023-05-17Compute dominators on demand for borrowck.Camille GILLOT-8/+8
2023-05-17Cache dominators.Camille GILLOT-12/+7
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-4/+4
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-05-13Rollup merge of #110454 - oli-obk:limited_impl_trait_in_assoc_type, ↵Dylan DPC-2/+2
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 #111396 - vlad20012:reduce-Borrows-dataflow-bitset-size, ↵bors-1/+1
r=cjgillot Reduce BitSet size used in `Borrows` dataflow analysis It looks like it is not needed to multiply the number of borrows by 2. Bits greater than `self.borrow_set.len()` are never set in this bitset. This should decrease the memory usage by an epsilon.
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-2/+2
2023-05-11Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnrMichael Goulet-2/+2
Make `NonUseContext::AscribeUserTy` carry `ty::Variance` Close #108267
2023-05-10Make `NonUseContext::AscribeUserTy` carry `ty::Variance`Obei Sideg-2/+2
2023-05-09Reduce BitSet size used in `Borrows` dataflow analysisvlad20012-1/+1
2023-05-09Rollup merge of #110583 - Ezrashaw:tweak-make-mut-spans, r=estebankDylan DPC-245/+264
tweak "make mut" spans when assigning to locals Work towards fixing #106857 This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit. r? `@estebank`
2023-05-08Rollup merge of #110827 - compiler-errors:issue-110761-followup, r=cjgillotDylan DPC-3/+13
Fix lifetime suggestion for type aliases with objects in them Fixes an issue identified in https://github.com/rust-lang/rust/issues/110761#issuecomment-1520678479 This suggestion, like many other borrowck suggestions, are very fragile and there are other ways to trigger strange behavior even after this PR, so this is just a small improvement and not a total rework :skull:
2023-05-05fix trait definition spans in "make mut" suggestionEzra Shaw-196/+197
2023-05-05implement review commentEzra Shaw-2/+2
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2023-05-05tweak spans for `ref mut` suggestionEzra Shaw-7/+9
2023-05-05tweak "make mut" spans (No. 4)Ezra Shaw-6/+6
2023-05-05tweak "make mut" spans (No. 3)Ezra Shaw-0/+4
2023-05-05tweak "make mut" spans (No. 2)Ezra Shaw-21/+27
2023-05-05tweak "make mut" spans when assigning to localsEzra Shaw-25/+31
2023-05-05Rollup merge of #111132 - lcnr:nll-generalize, r=b-naberYuki Okushi-8/+13
cleanup nll generalizer followup to #108861
2023-05-04Auto merge of #111014 - klensy:no-rc, r=WaffleLapkinbors-11/+8
try to downgrade Arc -> Lrc -> Rc -> no-Rc in few places Expecting this be not slower on non-parallel compiler and probably faster on parallel (checked that this PR builds on it).
2023-05-04Rollup merge of #111100 - BoxyUwU:array_repeat_expr_wf, r=compiler-errorsMatthias Krüger-0/+15
check array type of repeat exprs is wf Fixes #111091 Also makes sure that we actually renumber regions in the length of repeat exprs which we previously weren't doing and would cause ICEs in `adt_const_params` + `generic_const_exprs` from attempting to prove the wf goals when the length was an unevaluated constant with `'erased` in the `ty` field of `Const` The duplicate errors are caused by the fact that `const_arg_to_const`/`array_len_to_const` in `FnCtxt` adds a `WellFormed` goal for the created `Const` which is also checked by the added `WellFormed(array_ty)`. I don't want to change this to just emit a `T: Sized` goal for the element type since that would ignore `ConstArgHasType` wf requirements and generally uncomfortable with the idea of trying to sync up `wf::obligations` for arrays and the code in hir typeck for repeat exprs. r? `@compiler-errors`
2023-05-04Rollup merge of #110826 - cjgillot:place-mention-use, r=JakobDegen,lcnrMatthias Krüger-6/+4
Make PlaceMention a non-mutating use. Fixes https://github.com/rust-lang/rust/issues/110781 r? `@JakobDegen` I don't agree with your statement in https://github.com/rust-lang/rust/issues/110781#issuecomment-1520841434. I suggest that we start fixing `PlaceContext` to be accurate enough for optimizations to use it. This structure is very convenient to use in visitors, and we perhaps have an opportunity to make it less of a footgun.
2023-05-04check array type of repeat exprs is wfBoxy-0/+15
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-10/+19
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-03remove `inside_canonicalization_ctxt` flaglcnr-8/+13
we never reach the code checking for this flag while the flag is enabled, so it does not change the behavior of the code.
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-49/+49
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-01Box AssertKindBen Kimock-3/+3
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-6/+32
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-30Lrc -> Rcklensy-1/+1
2023-04-30RegionInferenceContext: remove Rc from rev_scc_graph fieldklensy-11/+8
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-6/+4
2023-04-28Rollup merge of #110960 - lukas-code:unused-mut, r=compiler-errorsMatthias Krüger-6/+7
fix false negative for `unused_mut` fixes https://github.com/rust-lang/rust/issues/110849 We want to avoid double diagnostics for code like this, but only if an error actually occurs: ```rust fn main() { let mut x: (i32, i32); x.0 = 1; } ``` The first commit fixes the lint and the second one removes all the unused `mut`s it found.
2023-04-28remove unused `mut`sLukas Markeffsky-1/+1
2023-04-28Fix an ICE in conflict errors diagnosticsMaybe Waffle-1/+1
2023-04-28fix false negative for `unused_mut`Lukas Markeffsky-5/+6
2023-04-27Don't call await a methodMichael Goulet-6/+32
2023-04-26Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle-6/+8
a `Span`