Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 72d7897

Browse files
committedMar 15, 2024
Auto merge of #122555 - GuillaumeGomez:rollup-tr6wu54, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #114651 (rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests) - #122468 (Cleanup `MirBorrowckCtxt::prefixes`) - #122496 (Greatly reduce GCC build logs) - #122512 (Cursor.rs documentation fix) - #122513 (hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`) - #122530 (less symbol interner locks) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c5b5713 + 6ec4092 commit 72d7897

File tree

50 files changed

+248
-303
lines changed

Some content is hidden

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

50 files changed

+248
-303
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
3939
use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt};
4040
use crate::{
4141
borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
42-
InitializationRequiringAction, MirBorrowckCtxt, PrefixSet, WriteKind,
42+
InitializationRequiringAction, MirBorrowckCtxt, WriteKind,
4343
};
4444

4545
use super::{
@@ -114,7 +114,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
114114
self.buffer_error(err);
115115
} else {
116116
if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
117-
if self.prefixes(*reported_place, PrefixSet::All).any(|p| p == used_place) {
117+
if used_place.is_prefix_of(*reported_place) {
118118
debug!(
119119
"report_use_of_moved_or_uninitialized place: error suppressed mois={:?}",
120120
move_out_indices
@@ -422,8 +422,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
422422
(None, &[][..], 0)
423423
};
424424
if let Some(def_id) = def_id
425-
&& let node =
426-
self.infcx.tcx.hir_node(self.infcx.tcx.local_def_id_to_hir_id(def_id))
425+
&& let node = self.infcx.tcx.hir_node_by_def_id(def_id)
427426
&& let Some(fn_sig) = node.fn_sig()
428427
&& let Some(ident) = node.ident()
429428
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
@@ -1995,34 +1994,23 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19951994
kind: Option<WriteKind>,
19961995
) {
19971996
let drop_span = place_span.1;
1998-
let root_place =
1999-
self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap();
1997+
let borrowed_local = borrow.borrowed_place.local;
20001998

20011999
let borrow_spans = self.retrieve_borrow_spans(borrow);
20022000
let borrow_span = borrow_spans.var_or_use_path_span();
20032001

2004-
assert!(root_place.projection.is_empty());
2005-
let proper_span = self.body.local_decls[root_place.local].source_info.span;
2006-
2007-
let root_place_projection = self.infcx.tcx.mk_place_elems(root_place.projection);
2002+
let proper_span = self.body.local_decls[borrowed_local].source_info.span;
20082003

2009-
if self.access_place_error_reported.contains(&(
2010-
Place { local: root_place.local, projection: root_place_projection },
2011-
borrow_span,
2012-
)) {
2004+
if self.access_place_error_reported.contains(&(Place::from(borrowed_local), borrow_span)) {
20132005
debug!(
20142006
"suppressing access_place error when borrow doesn't live long enough for {:?}",
20152007
borrow_span
20162008
);
20172009
return;
20182010
}
20192011

2020-
self.access_place_error_reported.insert((
2021-
Place { local: root_place.local, projection: root_place_projection },
2022-
borrow_span,
2023-
));
2012+
self.access_place_error_reported.insert((Place::from(borrowed_local), borrow_span));
20242013

2025-
let borrowed_local = borrow.borrowed_place.local;
20262014
if self.body.local_decls[borrowed_local].is_ref_to_thread_local() {
20272015
let err =
20282016
self.report_thread_local_value_does_not_live_long_enough(drop_span, borrow_span);
@@ -2544,9 +2532,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25442532
};
25452533
(format!("{local_kind}`{place_desc}`"), format!("`{place_desc}` is borrowed here"))
25462534
} else {
2547-
let root_place =
2548-
self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap();
2549-
let local = root_place.local;
2535+
let local = borrow.borrowed_place.local;
25502536
match self.body.local_kind(local) {
25512537
LocalKind::Arg => (
25522538
"function parameter".to_string(),

‎compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
672672
};
673673
(
674674
true,
675-
td.as_local().and_then(|tld| match self.infcx.tcx.opt_hir_node_by_def_id(tld) {
676-
Some(Node::Item(hir::Item {
677-
kind: hir::ItemKind::Trait(_, _, _, _, items),
678-
..
679-
})) => {
675+
td.as_local().and_then(|tld| match self.infcx.tcx.hir_node_by_def_id(tld) {
676+
Node::Item(hir::Item { kind: hir::ItemKind::Trait(_, _, _, _, items), .. }) => {
680677
let mut f_in_trait_opt = None;
681678
for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
682679
let hi = fi.hir_id();
@@ -1475,11 +1472,9 @@ fn get_mut_span_in_struct_field<'tcx>(
14751472
if let ty::Ref(_, ty, _) = ty.kind()
14761473
&& let ty::Adt(def, _) = ty.kind()
14771474
&& let field = def.all_fields().nth(field.index())?
1478-
// Use the HIR types to construct the diagnostic message.
1479-
&& let node = tcx.opt_hir_node_by_def_id(field.did.as_local()?)?
14801475
// Now we're dealing with the actual struct that we're going to suggest a change to,
14811476
// we can expect a field that is an immutable reference to a type.
1482-
&& let hir::Node::Field(field) = node
1477+
&& let hir::Node::Field(field) = tcx.hir_node_by_def_id(field.did.as_local()?)
14831478
&& let hir::TyKind::Ref(lt, hir::MutTy { mutbl: hir::Mutability::Not, ty }) = field.ty.kind
14841479
{
14851480
return Some(lt.ident.span.between(ty.span));

0 commit comments

Comments
 (0)
Please sign in to comment.