Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 624ed6d

Browse files
Change layout of SwitchTargets
1 parent 60a5372 commit 624ed6d

File tree

14 files changed

+217
-139
lines changed

14 files changed

+217
-139
lines changed

‎compiler/rustc_borrowck/src/type_check/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20162016
}
20172017
TerminatorKind::SwitchInt { ref targets, .. } => {
20182018
for target in targets.all_targets() {
2019-
self.assert_iscleanup(block_data, *target, is_cleanup);
2019+
self.assert_iscleanup(block_data, target, is_cleanup);
20202020
}
20212021
}
20222022
TerminatorKind::UnwindResume => {

‎compiler/rustc_codegen_ssa/src/mir/block.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::cmp;
22

3+
use itertools::Itertools as _;
34
use rustc_abi::{Align, BackendRepr, ExternAbi, HasDataLayout, Reg, Size, WrappingRange};
45
use rustc_ast as ast;
56
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};

‎compiler/rustc_middle/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@
4848
#![feature(gen_blocks)]
4949
#![feature(if_let_guard)]
5050
#![feature(intra_doc_pointers)]
51+
#![feature(iter_advance_by)]
5152
#![feature(min_specialization)]
5253
#![feature(negative_impls)]
5354
#![feature(never_type)]
5455
#![feature(ptr_alignment_type)]
5556
#![feature(rustc_attrs)]
5657
#![feature(rustdoc_internals)]
5758
#![feature(sized_hierarchy)]
59+
#![feature(trusted_len)]
5860
#![feature(try_blocks)]
5961
#![feature(try_trait_v2)]
6062
#![feature(try_trait_v2_residual)]

‎compiler/rustc_middle/src/mir/pretty.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,9 +1004,8 @@ impl<'tcx> TerminatorKind<'tcx> {
10041004
| CoroutineDrop => vec![],
10051005
Goto { .. } => vec!["".into()],
10061006
SwitchInt { ref targets, .. } => targets
1007-
.values
1008-
.iter()
1009-
.map(|&u| Cow::Owned(u.to_string()))
1007+
.all_values()
1008+
.map(|u| Cow::Owned(u.to_string()))
10101009
.chain(iter::once("otherwise".into()))
10111010
.collect(),
10121011
Call { target: Some(_), unwind: UnwindAction::Cleanup(_), .. } => {

‎compiler/rustc_middle/src/mir/syntax.rs‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,31 +1004,8 @@ pub enum BackwardIncompatibleDropReason {
10041004

10051005
#[derive(Debug, Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq)]
10061006
pub struct SwitchTargets {
1007-
/// Possible values. For each value, the location to branch to is found in
1008-
/// the corresponding element in the `targets` vector.
1009-
pub(super) values: SmallVec<[Pu128; 1]>,
1010-
1011-
/// Possible branch targets. The last element of this vector is used for
1012-
/// the "otherwise" branch, so `targets.len() == values.len() + 1` always
1013-
/// holds.
1014-
//
1015-
// Note: This invariant is non-obvious and easy to violate. This would be a
1016-
// more rigorous representation:
1017-
//
1018-
// normal: SmallVec<[(Pu128, BasicBlock); 1]>,
1019-
// otherwise: BasicBlock,
1020-
//
1021-
// But it's important to have the targets in a sliceable type, because
1022-
// target slices show up elsewhere. E.g. `TerminatorKind::InlineAsm` has a
1023-
// boxed slice, and `TerminatorKind::FalseEdge` has a single target that
1024-
// can be converted to a slice with `slice::from_ref`.
1025-
//
1026-
// Why does this matter? In functions like `TerminatorKind::successors` we
1027-
// return `impl Iterator` and a non-slice-of-targets representation here
1028-
// causes problems because multiple different concrete iterator types would
1029-
// be involved and we would need a boxed trait object, which requires an
1030-
// allocation, which is expensive if done frequently.
1031-
pub(super) targets: SmallVec<[BasicBlock; 2]>,
1007+
pub(super) normal: SmallVec<[(Pu128, BasicBlock); 1]>,
1008+
pub(super) otherwise: BasicBlock,
10321009
}
10331010

10341011
/// Action to be taken when a stack unwind happens.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /