forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#95382 - Dylan-DPC:rollup-bebyfd1, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#94939 (diagnostics: suggest missing comma in bad FRU syntax) - rust-lang#95120 (Implement `apply_switch_int_edge_effects` for backward analyses) - rust-lang#95364 (Add long error explanation for E0667) - rust-lang#95366 (Remove test files with duplicated checksums) - rust-lang#95368 (Fix typo in `String::try_reserve_exact` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
23 changed files
with
287 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
`impl Trait` is not allowed in path parameters. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0667 | ||
fn some_fn(mut x: impl Iterator) -> <impl Iterator>::Item { // error! | ||
x.next().unwrap() | ||
} | ||
``` | ||
|
||
You cannot use `impl Trait` in path parameters. If you want something | ||
equivalent, you can do this instead: | ||
|
||
``` | ||
fn some_fn<T: Iterator>(mut x: T) -> T::Item { // ok! | ||
x.next().unwrap() | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//! Lazily compute the inverse of each `SwitchInt`'s switch targets. Modeled after | ||
//! `Predecessors`/`PredecessorCache`. | ||
|
||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | ||
use rustc_data_structures::sync::OnceCell; | ||
use rustc_index::vec::IndexVec; | ||
use rustc_serialize as serialize; | ||
use smallvec::SmallVec; | ||
|
||
use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind}; | ||
|
||
pub type SwitchSources = IndexVec<BasicBlock, IndexVec<BasicBlock, SmallVec<[Option<u128>; 1]>>>; | ||
|
||
#[derive(Clone, Debug)] | ||
pub(super) struct SwitchSourceCache { | ||
cache: OnceCell<SwitchSources>, | ||
} | ||
|
||
impl SwitchSourceCache { | ||
#[inline] | ||
pub(super) fn new() -> Self { | ||
SwitchSourceCache { cache: OnceCell::new() } | ||
} | ||
|
||
/// Invalidates the switch source cache. | ||
#[inline] | ||
pub(super) fn invalidate(&mut self) { | ||
self.cache = OnceCell::new(); | ||
} | ||
|
||
/// Returns the switch sources for this MIR. | ||
#[inline] | ||
pub(super) fn compute( | ||
&self, | ||
basic_blocks: &IndexVec<BasicBlock, BasicBlockData<'_>>, | ||
) -> &SwitchSources { | ||
self.cache.get_or_init(|| { | ||
let mut switch_sources = IndexVec::from_elem( | ||
IndexVec::from_elem(SmallVec::new(), basic_blocks), | ||
basic_blocks, | ||
); | ||
for (bb, data) in basic_blocks.iter_enumerated() { | ||
if let Some(Terminator { | ||
kind: TerminatorKind::SwitchInt { targets, .. }, .. | ||
}) = &data.terminator | ||
{ | ||
for (value, target) in targets.iter() { | ||
switch_sources[target][bb].push(Some(value)); | ||
} | ||
switch_sources[targets.otherwise()][bb].push(None); | ||
} | ||
} | ||
|
||
switch_sources | ||
}) | ||
} | ||
} | ||
|
||
impl<S: serialize::Encoder> serialize::Encodable<S> for SwitchSourceCache { | ||
#[inline] | ||
fn encode(&self, s: &mut S) -> Result<(), S::Error> { | ||
s.emit_unit() | ||
} | ||
} | ||
|
||
impl<D: serialize::Decoder> serialize::Decodable<D> for SwitchSourceCache { | ||
#[inline] | ||
fn decode(_: &mut D) -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl<CTX> HashStable<CTX> for SwitchSourceCache { | ||
#[inline] | ||
fn hash_stable(&self, _: &mut CTX, _: &mut StableHasher) { | ||
// do nothing | ||
} | ||
} | ||
|
||
TrivialTypeFoldableAndLiftImpls! { | ||
SwitchSourceCache, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.