-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #109938 - oli-obk:try_norm, r=compiler-errors
Move a const-prop-lint specific hack from mir interpret to const-prop-lint and make it fallible fixes #109743 This hack didn't need to live in the mir interpreter. For const-prop-lint it is entirely correct to avoid doing any const prop if normalization fails at this stage. Most likely we couldn't const propagate anything anyway, and if revealing was needed (so opaque types were involved), we wouldn't want to be too smart and leak the hidden type anyway.
- Loading branch information
Showing
4 changed files
with
64 additions
and
12 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
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,51 @@ | ||
// build-pass | ||
// compile-flags: --crate-type=lib | ||
|
||
use std::marker::PhantomData; | ||
|
||
pub trait StreamOnce { | ||
type Token; | ||
} | ||
|
||
impl StreamOnce for &str { | ||
type Token = (); | ||
} | ||
|
||
pub trait Parser<Input: StreamOnce> { | ||
type PartialState: Default; | ||
fn parse_mode(&self, _state: &Self::PartialState) {} | ||
fn parse_mode_impl() {} | ||
} | ||
|
||
pub fn parse_bool<'a>() -> impl Parser<&'a str> { | ||
pub struct TokensCmp<C, Input> | ||
where | ||
Input: StreamOnce, | ||
{ | ||
_cmp: C, | ||
_marker: PhantomData<Input>, | ||
} | ||
|
||
impl<Input, C> Parser<Input> for TokensCmp<C, Input> | ||
where | ||
C: FnMut(Input::Token), | ||
Input: StreamOnce, | ||
{ | ||
type PartialState = (); | ||
} | ||
|
||
TokensCmp { _cmp: |_| (), _marker: PhantomData } | ||
} | ||
|
||
pub struct ParseBool; | ||
|
||
impl<'a> Parser<&'a str> for ParseBool | ||
where | ||
&'a str: StreamOnce, | ||
{ | ||
type PartialState = (); | ||
|
||
fn parse_mode_impl() { | ||
parse_bool().parse_mode(&Default::default()) | ||
} | ||
} |