Skip to content

Commit c049bae

Browse files
apply suggestions and fix bitset subtraction
1 parent 80c5c8f commit c049bae

File tree

9 files changed

+23
-13
lines changed

9 files changed

+23
-13
lines changed

compiler/rustc_codegen_ssa/src/mir/statement.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
9292
| mir::StatementKind::AscribeUserType(..)
9393
| mir::StatementKind::ConstEvalCounter
9494
| mir::StatementKind::PlaceMention(..)
95-
| mir::StatementKind::Nop
96-
| mir::StatementKind::BackwardIncompatibleDropHint { .. } => {}
95+
| mir::StatementKind::BackwardIncompatibleDropHint { .. }
96+
| mir::StatementKind::Nop => {}
9797
}
9898
}
9999
}

compiler/rustc_hir_analysis/src/check/region.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,10 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
178178
(lint::Level::Allow, _)
179179
)
180180
{
181-
// Note: we are unconditionally adding this information so that we can run
182-
// migration for Edition lower than 2024.
183-
// For future scope changes, we need to extend the mapping with edition information.
181+
// If this temporary scope will be changing once the codebase adopts Rust 2024,
182+
// and we are linting about possible semantic changes that would result,
183+
// then record this node-id in the field `backwards_incompatible_scope`
184+
// for future reference.
184185
visitor
185186
.scope_tree
186187
.backwards_incompatible_scope

compiler/rustc_index/src/bit_set.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,14 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
680680
for (mut self_chunk, other_chunk) in self.chunks.iter_mut().zip(other.chunks.iter()) {
681681
match (&mut self_chunk, &other_chunk) {
682682
(Zeros(..), _) | (_, Zeros(..)) => {}
683-
(Ones(self_chunk_domain_size), Ones(other_chunk_domain_size)) => {
683+
(
684+
Ones(self_chunk_domain_size) | Mixed(self_chunk_domain_size, _, _),
685+
Ones(other_chunk_domain_size),
686+
) => {
684687
debug_assert_eq!(self_chunk_domain_size, other_chunk_domain_size);
685688
changed = true;
686689
*self_chunk = Zeros(*self_chunk_domain_size);
687690
}
688-
(_, Ones(_)) => {}
689691
(
690692
Ones(self_chunk_domain_size),
691693
Mixed(other_chunk_domain_size, other_chunk_count, other_chunk_words),

compiler/rustc_middle/src/arena.rs

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ macro_rules! arena_types {
114114
[decode] specialization_graph: rustc_middle::traits::specialization_graph::Graph,
115115
[] crate_inherent_impls: rustc_middle::ty::CrateInherentImpls,
116116
[] hir_owner_nodes: rustc_hir::OwnerNodes<'tcx>,
117-
[] hir_id_set: rustc_hir::HirIdSet,
118117
]);
119118
)
120119
}

compiler/rustc_middle/src/mir/syntax.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,11 @@ pub enum StatementKind<'tcx> {
441441
/// No-op. Useful for deleting instructions without affecting statement indices.
442442
Nop,
443443

444-
/// Marker statement for backward-incompatible drops in incoming future editions
444+
/// Marker statement for backward-incompatible drops in incoming future editions.
445+
/// This is semantically equivalent to `Nop`, so codegen and MIRI should interpret this
446+
/// statement as such.
447+
/// The only use case of this statement is for linting in MIR to detect temporary lifetime
448+
/// changes.
445449
BackwardIncompatibleDropHint {
446450
/// Place to drop
447451
place: Box<Place<'tcx>>,

compiler/rustc_middle/src/thir.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ pub struct TempLifetime {
259259
/// Lifetime for temporaries as expected.
260260
/// This should be `None` in a constant context.
261261
pub temp_lifetime: Option<region::Scope>,
262-
/// Backward-incompatible lifetime for future editions
262+
/// If `Some(lt)`, indicates that the lifetime of this temporary will change to `lt` in a future edition.
263+
/// If `None`, then no changes are expected, or lints are disabled.
263264
pub backwards_incompatible: Option<region::Scope>,
264265
}
265266

compiler/rustc_middle/src/ty/rvalue_scopes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ impl RvalueScopes {
5353
| ScopeData::Arguments
5454
| ScopeData::IfThen
5555
| ScopeData::Remainder(_) => {
56+
// If we haven't already passed through a backwards-incompatible node,
57+
// then check if we are passing through one now and record it if so.
58+
// This is for now only working for cases where a temporary lifetime is
59+
// *shortened*.
5660
if backwards_incompatible.is_none() {
5761
backwards_incompatible = region_scope_tree
5862
.backwards_incompatible_scope

compiler/rustc_middle/src/ty/structural_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ TrivialTypeTraversalImpls! {
264264
// interners).
265265
TrivialTypeTraversalAndLiftImpls! {
266266
::rustc_hir::def_id::DefId,
267-
::rustc_hir::hir_id::ItemLocalId,
268267
::rustc_hir::Safety,
269268
::rustc_target::spec::abi::Abi,
270269
crate::ty::ClosureKind,

compiler/rustc_mir_dataflow/src/value_analysis.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pub trait ValueAnalysis<'tcx> {
9393
| StatementKind::FakeRead(..)
9494
| StatementKind::PlaceMention(..)
9595
| StatementKind::Coverage(..)
96-
| StatementKind::AscribeUserType(..)
97-
| StatementKind::BackwardIncompatibleDropHint { .. } => (),
96+
| StatementKind::BackwardIncompatibleDropHint { .. }
97+
| StatementKind::AscribeUserType(..) => {}
9898
}
9999
}
100100

0 commit comments

Comments
 (0)