about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2024-06-14Rollup merge of #126320 - oli-obk:pat_ice, r=lcnrMatthias Krüger-5/+5
Avoid ICES after reporting errors on erroneous patterns fixes #109812 fixes #125914 fixes #124004
2024-06-13MIR visitor: constant -> const_operandRalf Jung-4/+4
2024-06-13Replace some `Option<Diag>` with `Result<(), Diag>`Oli Scherer-5/+5
2024-06-12Auto merge of #125069 - amandasystems:scc-refactor, r=nikomatsakisbors-201/+191
Extend SCC construction to enable extra functionality Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do *everything*! Well, almost. This patch has been extracted from #123720. It specifically enhances `Sccs` to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including - reachable values (max/min) - SCC-internal values (max/min) This helps with among other things universe computation. We can now identify SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch. It's also more or less zero-cost; don't use the new features, don't pay for them. This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else. I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.
2024-06-12Use Variance glob import everywhereMichael Goulet-31/+21
2024-06-12Address code review comments on the commentsAmanda Stjerna-29/+29
2024-06-12Move `RegionTracker` to `region_infer`Amanda Stjerna-95/+93
In terms of code organisation, this is a lot cleaner and allows tighter access modifiers.
2024-06-12Resurrect some comments, remove a `pub`Amanda Stjerna-1/+42
This commit addresses @lqd's code review and resurrects a lost comment and removes some dead code.
2024-06-12Roll back a few `#[instrument]`Amanda Stjerna-15/+12
Apparently this interferes with inlining and murders performance on `wg-grammar`.
2024-06-12Formatting, weird because I just did thatAmanda Stjerna-2/+2
2024-06-12Simplify path compression logicAmanda Stjerna-3/+12
2024-06-12Extend SCC construction to enable extra functionalityAmanda Stjerna-212/+157
This patch has been extracted from #123720. It specifically enhances `Sccs` to allow tracking arbitrary commutative properties of SCCs, including - reachable values (max/min) - SCC-internal values (max/min) This helps with among other things universe computation: we can now identify SCC universes as a straightforward "find max/min" operation during SCC construction. It's also more or less zero-cost; don't use the new features, don't pay for them. This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following.
2024-06-12Rollup merge of #126295 - linyihai:uninitalized-in-match-arm, r=pnkfelixGuillaume Gomez-4/+17
No uninitalized report in a pre-returned match arm This is a attemp to address https://github.com/rust-lang/rust/issues/126133
2024-06-12Rollup merge of #126301 - nnethercote:sort-crate-attributes, r=davidtwcoJubilee-1/+3
Use `tidy` to sort crate attributes for all compiler crates. We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`). r? `@davidtwco`
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-1/+3
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-12No uninitalized report in a pre-returned match armLin Yihai-4/+17
2024-06-11Try not to make obligations in handle_opaque_typeMichael Goulet-8/+1
2024-06-11Rename some thingsMichael Goulet-6/+6
2024-06-11Make ObligationEmittingRelation deal with Goals onlyMichael Goulet-11/+27
2024-06-11Get rid of PredicateObligationsMichael Goulet-2/+2
2024-06-10Make suggestion to change `Fn` to `FnMut` work with methods wellGurinder Singh-44/+69
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-05Remove confusing `use_polonius` flag and do less cloningAmanda Stjerna-51/+57
The `use_polonius` flag is both redundant and confusing since every function it's propagated to also checks if `all_facts` is `Some`, the true test of whether to generate Polonius facts for Polonius or for external consumers. This PR makes that path clearer by simply doing away with the argument and handling the logic in precisely two places: where facts are populated (check for `Some`), and where `all_facts` are initialised. It also delays some statements until after that check to avoid the miniscule performance penalty of executing them when Polonius is disabled. This also addresses @lqd's concern in #125652 by reducing the size of what is cloned out of Polonius facts to just the facts being added, as opposed to the entire vector of potential inputs, and added descriptive comments. *Reviewer note*: the comments in [add_extra_drop_facts](https://github.com/rust-lang/rust/blob/85f90a461262f7ca37a6e629933d455fa9c3ee48/compiler/rustc_borrowck/src/type_check/liveness/trace.rs#L219) should be inspected by a reviewer, in particular the one on L#259 in this PR, which should be trivial for someone with the right background knowledge. I also included some minor lints I found on the way there that I couldn't help myself from addressing.
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