Skip to content

Commit 42325c5

Browse files
committed
Auto merge of rust-lang#104293 - Manishearth:rollup-xj92d0k, r=Manishearth
Rollup of 8 pull requests Successful merges: - rust-lang#95292 (Allow specialized const trait impls.) - rust-lang#100386 (Make `Sized` coinductive, again) - rust-lang#102215 (Implement the `+whole-archive` modifier for `wasm-ld`) - rust-lang#103468 (Fix unused lint and parser caring about spaces to won't produce invalid code) - rust-lang#103531 (Suggest calling the instance method of the same name when method not found) - rust-lang#103960 (piece of diagnostic migrate) - rust-lang#104051 (update Miri) - rust-lang#104129 (rustdoc: use javascript to layout notable traits popups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7d85104 + b74d042 commit 42325c5

File tree

124 files changed

+2191
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2191
-521
lines changed

compiler/rustc_borrowck/src/borrow_set.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::nll::ToRegionVid;
24
use crate::path_utils::allow_two_phase_borrow;
35
use crate::place_ext::PlaceExt;

compiler/rustc_borrowck/src/borrowck_errors.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
88
pub(crate) fn cannot_move_when_borrowed(
99
&self,
1010
span: Span,
11-
desc: &str,
11+
borrow_span: Span,
12+
place: &str,
13+
borrow_place: &str,
14+
value_place: &str,
1215
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
13-
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
16+
self.infcx.tcx.sess.create_err(crate::session_diagnostics::MoveBorrow {
17+
place,
18+
span,
19+
borrow_place,
20+
value_place,
21+
borrow_span,
22+
})
1423
}
1524

1625
pub(crate) fn cannot_use_when_mutably_borrowed(

compiler/rustc_borrowck/src/constraint_generation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_infer::infer::InferCtxt;
24
use rustc_middle::mir::visit::TyContext;
35
use rustc_middle::mir::visit::Visitor;

compiler/rustc_borrowck/src/constraints/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use rustc_data_structures::graph::scc::Sccs;
25
use rustc_index::vec::IndexVec;
36
use rustc_middle::mir::ConstraintCategory;

compiler/rustc_borrowck/src/consumers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! This file provides API for compiler consumers.
24
35
use rustc_hir::def_id::LocalDefId;

compiler/rustc_borrowck/src/dataflow.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_data_structures::fx::FxHashMap;
24
use rustc_index::bit_set::BitSet;
35
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};

compiler/rustc_borrowck/src/def_use.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_middle::mir::visit::{
24
MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext,
35
};

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
25
use rustc_infer::infer::canonical::Canonical;
36
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+19-32
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
224224
}
225225
}
226226

227-
use_spans.var_span_label_path_only(
228-
&mut err,
229-
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
230-
);
227+
use_spans.var_path_only_subdiag(&mut err, desired_action);
231228

232229
if !is_loop_move {
233230
err.span_label(
@@ -404,10 +401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
404401
let used = desired_action.as_general_verb_in_past_tense();
405402
let mut err =
406403
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
407-
use_spans.var_span_label_path_only(
408-
&mut err,
409-
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
410-
);
404+
use_spans.var_path_only_subdiag(&mut err, desired_action);
411405

412406
if let InitializationRequiringAction::PartialAssignment
413407
| InitializationRequiringAction::Assignment = desired_action
@@ -673,16 +667,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
673667
let move_spans = self.move_spans(place.as_ref(), location);
674668
let span = move_spans.args_or_use();
675669

676-
let mut err =
677-
self.cannot_move_when_borrowed(span, &self.describe_any_place(place.as_ref()));
678-
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
679-
err.span_label(span, format!("move out of {} occurs here", value_msg));
680-
681-
borrow_spans.var_span_label_path_only(
682-
&mut err,
683-
format!("borrow occurs due to use{}", borrow_spans.describe()),
670+
let mut err = self.cannot_move_when_borrowed(
671+
span,
672+
borrow_span,
673+
&self.describe_any_place(place.as_ref()),
674+
&borrow_msg,
675+
&value_msg,
684676
);
685677

678+
borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
679+
686680
move_spans.var_span_label(
687681
&mut err,
688682
format!("move occurs due to use{}", move_spans.describe()),
@@ -724,22 +718,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
724718
borrow_span,
725719
&self.describe_any_place(borrow.borrowed_place.as_ref()),
726720
);
727-
borrow_spans.var_subdiag(
728-
&mut err,
729-
|var_span| {
730-
use crate::session_diagnostics::CaptureVarCause::*;
731-
let place = &borrow.borrowed_place;
732-
let desc_place = self.describe_any_place(place.as_ref());
733-
match borrow_spans {
734-
UseSpans::ClosureUse { generator_kind, .. } => match generator_kind {
735-
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
736-
None => BorrowUsePlaceClosure { place: desc_place, var_span },
737-
},
738-
_ => BorrowUsePlace { place: desc_place, var_span },
739-
}
740-
},
741-
"mutable",
742-
);
721+
borrow_spans.var_subdiag(&mut err, Some(borrow.kind), |kind, var_span| {
722+
use crate::session_diagnostics::CaptureVarCause::*;
723+
let place = &borrow.borrowed_place;
724+
let desc_place = self.describe_any_place(place.as_ref());
725+
match kind {
726+
Some(_) => BorrowUsePlaceGenerator { place: desc_place, var_span },
727+
None => BorrowUsePlaceClosure { place: desc_place, var_span },
728+
}
729+
});
743730

744731
self.explain_why_borrow_contains_point(location, borrow, None)
745732
.add_explanation_to_diagnostic(

compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use std::collections::BTreeSet;
25

36
use rustc_middle::mir::visit::{PlaceContext, Visitor};

compiler/rustc_borrowck/src/diagnostics/find_use.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use std::collections::VecDeque;
25
use std::rc::Rc;
36

compiler/rustc_borrowck/src/diagnostics/mod.rs

+48-16
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,34 @@ impl UseSpans<'_> {
595595
}
596596
}
597597

598-
// Add a span label to the use of the captured variable, if it exists.
599-
// only adds label to the `path_span`
600-
pub(super) fn var_span_label_path_only(self, err: &mut Diagnostic, message: impl Into<String>) {
601-
if let UseSpans::ClosureUse { path_span, .. } = self {
602-
err.span_label(path_span, message);
598+
/// Add a span label to the use of the captured variable, if it exists.
599+
/// only adds label to the `path_span`
600+
pub(super) fn var_path_only_subdiag(
601+
self,
602+
err: &mut Diagnostic,
603+
action: crate::InitializationRequiringAction,
604+
) {
605+
use crate::session_diagnostics::CaptureVarPathUseCause::*;
606+
use crate::InitializationRequiringAction::*;
607+
if let UseSpans::ClosureUse { generator_kind, path_span, .. } = self {
608+
match generator_kind {
609+
Some(_) => {
610+
err.subdiagnostic(match action {
611+
Borrow => BorrowInGenerator { path_span },
612+
MatchOn | Use => UseInGenerator { path_span },
613+
Assignment => AssignInGenerator { path_span },
614+
PartialAssignment => AssignPartInGenerator { path_span },
615+
});
616+
}
617+
None => {
618+
err.subdiagnostic(match action {
619+
Borrow => BorrowInClosure { path_span },
620+
MatchOn | Use => UseInClosure { path_span },
621+
Assignment => AssignInClosure { path_span },
622+
PartialAssignment => AssignPartInClosure { path_span },
623+
});
624+
}
625+
}
603626
}
604627
}
605628

@@ -627,19 +650,28 @@ impl UseSpans<'_> {
627650
pub(super) fn var_subdiag(
628651
self,
629652
err: &mut Diagnostic,
630-
f: impl Fn(Span) -> crate::session_diagnostics::CaptureVarCause,
631-
kind_desc: impl Into<String>,
653+
kind: Option<rustc_middle::mir::BorrowKind>,
654+
f: impl Fn(Option<GeneratorKind>, Span) -> crate::session_diagnostics::CaptureVarCause,
632655
) {
633-
if let UseSpans::ClosureUse { capture_kind_span, path_span, .. } = self {
634-
if capture_kind_span == path_span {
635-
err.subdiagnostic(f(capture_kind_span));
636-
} else {
637-
err.subdiagnostic(crate::session_diagnostics::CaptureVarKind {
638-
kind_desc: kind_desc.into(),
639-
kind_span: capture_kind_span,
656+
use crate::session_diagnostics::CaptureVarKind::*;
657+
if let UseSpans::ClosureUse { generator_kind, capture_kind_span, path_span, .. } = self {
658+
if capture_kind_span != path_span {
659+
err.subdiagnostic(match kind {
660+
Some(kd) => match kd {
661+
rustc_middle::mir::BorrowKind::Shared
662+
| rustc_middle::mir::BorrowKind::Shallow
663+
| rustc_middle::mir::BorrowKind::Unique => {
664+
Immute { kind_span: capture_kind_span }
665+
}
666+
667+
rustc_middle::mir::BorrowKind::Mut { .. } => {
668+
Mut { kind_span: capture_kind_span }
669+
}
670+
},
671+
None => Move { kind_span: capture_kind_span },
640672
});
641-
err.subdiagnostic(f(path_span));
642-
}
673+
};
674+
err.subdiagnostic(f(generator_kind, path_span));
643675
}
644676
}
645677

compiler/rustc_borrowck/src/diagnostics/var_name.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
3+
14
use crate::Upvar;
25
use crate::{nll::ToRegionVid, region_infer::RegionInferenceContext};
36
use rustc_index::vec::{Idx, IndexVec};

compiler/rustc_borrowck/src/facts.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::location::{LocationIndex, LocationTable};
24
use crate::BorrowIndex;
35
use polonius_engine::AllFacts as PoloniusFacts;

compiler/rustc_borrowck/src/invalidation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_data_structures::graph::dominators::Dominators;
24
use rustc_middle::mir::visit::Visitor;
35
use rustc_middle::mir::{self, BasicBlock, Body, Location, NonDivergingIntrinsic, Place, Rvalue};

compiler/rustc_borrowck/src/location.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_index::vec::{Idx, IndexVec};
24
use rustc_middle::mir::{BasicBlock, Body, Location};
35

compiler/rustc_borrowck/src/member_constraints.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_data_structures::captures::Captures;
24
use rustc_data_structures::fx::FxHashMap;
35
use rustc_index::vec::IndexVec;

compiler/rustc_borrowck/src/nll.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! The entry point of the NLL borrow checker.
24
35
use rustc_data_structures::vec_map::VecMap;

compiler/rustc_borrowck/src/path_utils.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
24
use crate::places_conflict;
35
use crate::AccessDepth;

compiler/rustc_borrowck/src/place_ext.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::borrow_set::LocalsStateAtExit;
24
use rustc_hir as hir;
35
use rustc_middle::mir::ProjectionElem;

compiler/rustc_borrowck/src/places_conflict.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::ArtificialField;
24
use crate::Overlap;
35
use crate::{AccessDepth, Deep, Shallow};

compiler/rustc_borrowck/src/prefixes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! From the NLL RFC: "The deep [aka 'supporting'] prefixes for an
24
//! place are formed by stripping away fields and derefs, except that
35
//! we stop when we reach the deref of a shared reference. [...] "

compiler/rustc_borrowck/src/region_infer/dump_mir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! As part of generating the regions, if you enable `-Zdump-mir=nll`,
24
//! we will generate an annotated copy of the MIR that includes the
35
//! state of region inference. This code handles emitting the region

compiler/rustc_borrowck/src/region_infer/graphviz.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
//! This module provides linkage between RegionInferenceContext and
24
//! `rustc_graphviz` traits, specialized to attaching borrowck analysis
35
//! data to rendered labels.

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use crate::constraints::ConstraintSccIndex;
24
use crate::RegionInferenceContext;
35
use itertools::Itertools;

compiler/rustc_borrowck/src/region_infer/values.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_data_structures::fx::FxIndexSet;
24
use rustc_index::bit_set::SparseBitMatrix;
35
use rustc_index::interval::IntervalSet;

compiler/rustc_borrowck/src/renumber.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(rustc::untranslatable_diagnostic)]
2+
#![deny(rustc::diagnostic_outside_of_impl)]
13
use rustc_index::vec::IndexVec;
24
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
35
use rustc_middle::mir::visit::{MutVisitor, TyContext};

0 commit comments

Comments
 (0)