Ensure deterministic ordering for diagnostics
This commit is contained in:
parent
8cbeaf7382
commit
08c616741c
3 changed files with 7 additions and 5 deletions
|
@ -96,7 +96,7 @@ type MigrationNeededForCapture = (Option<hir::HirId>, String, String);
|
|||
|
||||
/// Intermediate format to store the hir id of the root variable and a HashSet containing
|
||||
/// information on why the root variable should be fully captured
|
||||
type MigrationDiagnosticInfo = (hir::HirId, FxHashSet<MigrationNeededForCapture>);
|
||||
type MigrationDiagnosticInfo = (hir::HirId, Vec<MigrationNeededForCapture>);
|
||||
|
||||
struct InferBorrowKindVisitor<'a, 'tcx> {
|
||||
fcx: &'a FnCtxt<'a, 'tcx>,
|
||||
|
@ -861,7 +861,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
// Perform auto-trait analysis
|
||||
for (&var_hir_id, _) in upvars.iter() {
|
||||
let mut responsible_captured_hir_ids = FxHashSet::default();
|
||||
let mut responsible_captured_hir_ids = Vec::new();
|
||||
|
||||
let auto_trait_diagnostic = if let Some(diagnostics_info) =
|
||||
self.compute_2229_migrations_for_trait(min_captures, var_hir_id, closure_clause)
|
||||
|
@ -891,6 +891,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
capture_diagnostic.insert(key.clone());
|
||||
}
|
||||
|
||||
let mut capture_diagnostic = capture_diagnostic.into_iter().collect::<Vec<_>>();
|
||||
capture_diagnostic.sort();
|
||||
for captured_info in capture_diagnostic.iter() {
|
||||
// Get the auto trait reasons of why migration is needed because of that capture, if there are any
|
||||
let capture_trait_reasons =
|
||||
|
@ -907,7 +909,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// auto trait implementation issues
|
||||
auto_trait_migration_reasons.extend(capture_trait_reasons.clone());
|
||||
|
||||
responsible_captured_hir_ids.insert((
|
||||
responsible_captured_hir_ids.push((
|
||||
captured_info.0,
|
||||
captured_info.1.clone(),
|
||||
self.compute_2229_migrations_reasons(
|
||||
|
|
|
@ -90,8 +90,8 @@ LL | let _f_1 = f1.1;
|
|||
LL | }
|
||||
| -
|
||||
| |
|
||||
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.1` would be dropped here alongside the closure
|
||||
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.0` would be dropped here alongside the closure
|
||||
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.1` would be dropped here alongside the closure
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
|
||||
help: add a dummy let to cause `f1` to be fully captured
|
||||
|
|
|
@ -44,8 +44,8 @@ LL | let _x = u.1.0;
|
|||
LL | }
|
||||
| -
|
||||
| |
|
||||
| in Rust 2018, `u` would be dropped here, but in Rust 2021, only `u.0.1` would be dropped here alongside the closure
|
||||
| in Rust 2018, `u` would be dropped here, but in Rust 2021, only `u.0.0` would be dropped here alongside the closure
|
||||
| in Rust 2018, `u` would be dropped here, but in Rust 2021, only `u.0.1` would be dropped here alongside the closure
|
||||
| in Rust 2018, `u` would be dropped here, but in Rust 2021, only `u.1.0` would be dropped here alongside the closure
|
||||
|
|
||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
|
||||
|
|
Loading…
Reference in a new issue