about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2021-11-07more clippy fixesMatthias Krüger-1/+1
2021-11-07Rename functions reflect that inline const is also "typeck_child"Gary Guo-37/+27
2021-11-07Ensure closure requirements are proven for inline constGary Guo-5/+79
2021-11-07Implement type inference for inline constsGary Guo-13/+53
In most cases it is handled in the same way as closures.
2021-11-06use matches!() macro in more placesMatthias Krüger-19/+10
2021-11-03Optimize live point computationMark Rousskov-28/+40
This is just replicating the previous algorithm, but taking advantage of the bitset structures to optimize into tighter and better optimized loops. Particularly advantageous on enormous MIR blocks, which are relatively rare in practice.
2021-10-29Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnrbors-1/+0
Revert "Add rustc lint, warning when iterating over hashmaps" Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-28Auto merge of #90387 - matthiaskrgr:rollup-b2x8v0x, r=matthiaskrgrbors-1/+0
Rollup of 3 pull requests Successful merges: - #90082 (Fix minor typos) - #90336 (Remove extra lines in examples for `Duration::try_from_secs_*`) - #90376 (Various cleanups around opaque types) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-28Auto merge of #90281 - xldenis:public-borrow-set, r=nikomatsakisbors-14/+14
Add BorrowSet to public api This PR adds `BorrowSet` to the public api so that verification tools can obtain the activation and reservation points of two phase borrows without having to redo calculations themselves (and thus potentially differently from rustc). Turns out we already can obtain `MoveData` thanks to the public `HasMoveData` trait, so constructing a `BorrowSet` should not provide much of an issue. However, I can't speak to the soundness of this approach, is it safe to take an under-approximation of `MoveData`? r? `@nikomatsakis`
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-28Move instantiate_opaque_types to rustc_infer.Oli Scherer-1/+0
It does not depend on anything from rustc_trait_selection anymore.
2021-10-25Add BorrowSet to public apiXavier Denis-14/+14
2021-10-25Auto merge of #90042 - pietroalbini:1.56-master, r=Mark-Simulacrumbors-1/+0
Bump bootstrap compiler to 1.57 Fixes https://github.com/rust-lang/rust/issues/90152 r? `@Mark-Simulacrum`
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-23update cfg(bootstrap)Pietro Albini-1/+0
2021-10-23Auto merge of #90104 - spastorino:coherence-for-negative-trait, r=nikomatsakisbors-0/+1
Implement coherence checks for negative trait impls The main purpose of this PR is to be able to [move Error trait to core](https://github.com/rust-lang/project-error-handling/issues/3). This feature is necessary to handle the following from impl on box. ```rust impl From<&str> for Box<dyn Error> { ... } ``` Without having negative traits affect coherence moving the error trait into `core` and moving that `From` impl to `alloc` will cause the from impl to no longer compiler because of a potential future incompatibility. The compiler indicates that `&str` _could_ introduce an `Error` impl in the future, and thus prevents the `From` impl in `alloc` that would cause overlap with `From<E: Error> for Box<dyn Error>`. Adding `impl !Error for &str {}` with the negative trait coherence feature will disable this error by encoding a stability guarantee that `&str` will never implement `Error`, making the `From` impl compile. We would have this in `alloc`: ```rust impl From<&str> for Box<dyn Error> {} // A impl<E> From<E> for Box<dyn Error> where E: Error {} // B ``` and this in `core`: ```rust trait Error {} impl !Error for &str {} ``` r? `@nikomatsakis` This PR was built on top of `@yaahc` PR #85764. Language team proposal: to https://github.com/rust-lang/lang-team/issues/96
2021-10-22Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwcoYuki Okushi-40/+41
Don't mark for loop iter expression as desugared We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
2021-10-20Remove NullOp::BoxGary Guo-4/+0
2021-10-20Add polarity to TraitPredicateSantiago Pastorino-0/+1
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-6/+3
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-18Auto merge of #89229 - oli-obk:i_love_inferctxt, r=jackh726bors-45/+14
Remove redundant member-constraint check impl trait will, for each lifetime in the hidden type, register a "member constraint" that says the lifetime must be equal or outlive one of the lifetimes of the impl trait. These member constraints will be solved by borrowck But, as you can see in the big red block of removed code, there was an ad-hoc check for member constraints happening at the site where they get registered. This check had some minor effects on diagnostics, but will fall down on its feet with my big type alias impl trait refactor. So we removed it and I pulled the removal out into a (hopefully) reviewable PR that works on master directly.
2021-10-17Fix ICE with `let...else` and `ref mut`Yuki Okushi-8/+8
2021-10-16Adopt let_else across the compilerest31-6/+3
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-15Remove a now-unused traitOli Scherer-21/+1
2021-10-15simplify constrain_opaque_typesNiko Matsakis-24/+13
2021-10-15Don't mark for loop head span with desugaringCameron Steffen-40/+41
2021-10-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-14Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obkbors-16/+23
Add check that live_region is live in sanitize_promoted This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`. To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region: /// Returns an iterator of all the elements contained by the region `r` crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_ Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`. This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.
2021-10-11Rollup merge of #89675 - oli-obk:type_checker, r=davidtwcoMatthias Krüger-81/+53
Re-use TypeChecker instead of passing around some of its fields In the future (for lazy TAIT) we will need more of its fields, but even ignoring that, this change seems reasonable on its own to me.
2021-10-08Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514Guillaume Gomez-3/+2
clippy::complexity fixes
2021-10-08clippy::complexity fixesMatthias Krüger-3/+2
2021-10-08Directly call relate_types function instead of having a method wrapperOli Scherer-37/+26
2021-10-08Re-use TypeChecker instead of passing around some of its fieldsOli Scherer-48/+31
2021-10-07Add check that region is live in sanitize_promotedNoble-Mushtak-16/+23
2021-10-07Rollup merge of #89615 - willcrichton:fix-get-body-with-borrowck-facts, ↵Guillaume Gomez-1/+1
r=oli-obk Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts `mir_borrowck` uses `with_opaque_type_inference` before calling `do_mir_borrowck`: https://github.com/rust-lang/rust/blob/0eabf25b90396dead0b2a1aaa275af18a1ae6008/compiler/rustc_borrowck/src/lib.rs#L132 However `get_body_with_borrowck_facts` does not. Therefore I get an ICE eg when calling this function on the bodies of an async function as described here: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20ICE.20when.20using.20get_body_with_borrowck_facts.20with.20async This change fixes that bug. r? `@nikomatsakis`
2021-10-06Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_factsWill Crichton-1/+1
2021-10-05Note specific regions involved in 'borrowed data escapes' errorAaron Hill-0/+21
Fixes #67007 Currently, a 'borrowed data escapes' error does not mention the specific lifetime involved (except indirectly through a suggestion about adding a lifetime bound). We now explain the specific lifetime relationship that failed to hold, which improves otherwise vague error messages.
2021-10-04Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakisManish Goregaokar-3/+1
Don't suggest replacing region with 'static in NLL Fixes #73159 This is similar to #69350 - if the user didn't initially write out a 'static lifetime, adding 'static in response to a lifetime error is usually the wrong thing to do.
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-1/+1
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Stabilize `const_panic`Jacob Pratt-1/+1
2021-10-03Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillotManish Goregaokar-2/+2
Remove some feature gates The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.
2021-10-03Don't suggest replacing region with 'static in NLLAaron Hill-3/+1
Fixes #73159 This is similar to #69350 - if the user didn't initially write out a 'static lifetime, adding 'static in response to a lifetime error is usually the wrong thing to do.
2021-10-03Replace Fn impls with RPIT impls in rustc_indexbjorn3-2/+2
This is cleaner and removes an unstable feature usage
2021-10-02Make diangostic item names consistentCameron Steffen-4/+4
2021-10-01Fix clippy lintsGuillaume Gomez-12/+12
2021-09-30Rollup merge of #89327 - oli-obk:nll_diag_infer_vars, r=wesleywiserManish Goregaokar-1/+16
Pick one possible lifetime in case there are multiple choices In case a lifetime variable is created, but doesn't have an obvious lifetime in the list of named lifetimes that it should be inferred to, just pick the first one for the diagnostic. This happens e.g. in ```rust fn foo<'a, 'b>(a: Struct<'a>, b: Struct<'b>) -> impl Trait<'a, 'b> { if bar() { a } else { b } } ``` where we get a lifetime variable that combines the lifetimes of `a` and `b` creating a lifetime that is the intersection of both. Right now the type system cannot express this and thus we get an error, but that error also can't express this. I can also create an entirely new diagnostic that mentions all involved lifetimes, so it would actually mention `'a` and `'b` instead of just `'b`.
2021-09-30Auto merge of #87998 - nneonneo:master, r=oli-obkbors-28/+80
Avoid spurious "previous iteration of loop" errors Only follow backwards edges during `get_moved_indexes` if the move path is definitely initialized at loop entry. Otherwise, the error occurred prior to the loop, so we ignore the backwards edges to avoid generating misleading "value moved here, in previous iteration of loop" errors. This patch also slightly improves the analysis of inits, including `NonPanicPathOnly` initializations (which are ignored by `drop_flag_effects::for_location_inits`). This is required for the definite initialization analysis, but may also help find certain skipped reinits in rare cases. Patch passes all non-ignored src/test/ui testcases. Fixes #72649.
2021-09-28Pick one possible lifetime in case there are multiple choicesOli Scherer-1/+16
2021-09-28More tracing instrumentationOli Scherer-98/+78
2021-09-27Remove `DefId` from `ConstraintCategory::Predicate`Aaron Hill-8/+16
This shirnks the size of `ConstraintCategory`, hopefully fixing a performance regression.