Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves migrations lint for RFC2229 #86965

Merged
merged 9 commits into from
Jul 11, 2021
Prev Previous commit
Next Next commit
Update comments
  • Loading branch information
roxelo committed Jul 9, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 59f634bc2d9188375ef51944b16e0450c638afdb
26 changes: 15 additions & 11 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
@@ -616,7 +616,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
reasons
}

/// Returns true if migration is needed for trait for the provided var_hir_id
/// Returns a tuple that contains the hir_id pointing to the use that resulted in the
/// corresponding place being captured and a String which contains the captured value's name
/// (i.e: a.b.c) if migration is needed for trait for the provided var_hir_id, otherwise returns None
fn need_2229_migrations_for_trait(
&self,
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
@@ -693,12 +695,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// captured by the closure when `capture_disjoint_fields` is enabled and auto-traits
/// differ between the root variable and the captured paths.
///
/// The output list would include a root variable if:
/// - It would have been captured into the closure when `capture_disjoint_fields` wasn't
/// enabled, **and**
/// - It wasn't completely captured by the closure, **and**
/// - One of the paths captured does not implement all the auto-traits its root variable
/// implements.
/// Returns a tuple containing a HashSet of traits that not implemented by the captured fields
/// of a root variables that has the provided var_hir_id and a HashSet of tuples that contains
/// the hir_id pointing to the use that resulted in the corresponding place being captured and
/// a String which contains the captured value's name (i.e: a.b.c) if migration is needed for
/// trait for the provided var_hir_id, otherwise returns None
fn compute_2229_migrations_for_trait(
&self,
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
@@ -788,8 +789,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// - It wasn't completely captured by the closure, **and**
/// - One of the paths starting at this root variable, that is not captured needs Drop.
///
/// This function only returns true for significant drops. A type is considerent to have a
/// significant drop if it's Drop implementation is not annotated by `rustc_insignificant_dtor`.
/// This function only returns a HashSet of tuples for significant drops. The returned HashSet
/// of tuples contains the hir_id pointing to the use that resulted in the corresponding place
/// being captured anda String which contains the captured value's name (i.e: a.b.c)
fn compute_2229_migrations_for_drop(
&self,
closure_def_id: DefId,
@@ -871,8 +873,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// - One of the paths captured does not implement all the auto-traits its root variable
/// implements.
///
/// Returns a tuple containing a vector of HirIds as well as a String containing the reason
/// why root variables whose HirId is contained in the vector should be fully captured.
/// Returns a tuple containing a vector of tuples of HirIds and a HashSet of tuples that contains
/// the hir_id pointing to the use that resulted in the corresponding place being captured and
/// a String which contains the captured value's name (i.e: a.b.c), as well as a String
/// containing the reason why root variables whose HirId is contained in the vector should
fn compute_2229_migrations(
&self,
closure_def_id: DefId,