-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Replace fragile erroneous const sys #70820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 11 commits into
rust-lang:master
from
spastorino:replace-fragile-erroneous-const-sys
Apr 24, 2020
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6807bb7
Make mir::Constant Copy
spastorino f8976e3
Add MirPass to collect Unevaluated consts in MIR body
spastorino db18b42
Evaluate unevaluated MIR constants in codegen_mir
spastorino 5313e2e
Make inlining carry over unevaluated consts
spastorino 0107cec
Visit unevaluated constants in super_body
spastorino f925a03
Make ConstPropagator only visit basic blocks when visiting body
spastorino 25e0be7
Clean up fragile checks of optimized away constants
spastorino 39be0b5
Bless mir-opt tests
spastorino da9aa2d
Adjust name of never typed const test
spastorino c1ed7cc
Rename uneval_consts to required_consts
spastorino 7bc45f6
Import RequiredConstsVisitor
spastorino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
use rustc_middle::mir::visit::Visitor; | ||
use rustc_middle::mir::{Constant, Location}; | ||
use rustc_middle::ty::ConstKind; | ||
|
||
pub struct RequiredConstsVisitor<'a, 'tcx> { | ||
required_consts: &'a mut Vec<Constant<'tcx>>, | ||
} | ||
|
||
impl<'a, 'tcx> RequiredConstsVisitor<'a, 'tcx> { | ||
pub fn new(required_consts: &'a mut Vec<Constant<'tcx>>) -> Self { | ||
RequiredConstsVisitor { required_consts } | ||
} | ||
} | ||
|
||
impl<'a, 'tcx> Visitor<'tcx> for RequiredConstsVisitor<'a, 'tcx> { | ||
fn visit_constant(&mut self, constant: &Constant<'tcx>, _: Location) { | ||
let const_kind = constant.literal.val; | ||
|
||
if let ConstKind::Unevaluated(_, _, _) = const_kind { | ||
self.required_consts.push(*constant); | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
5 changes: 3 additions & 2 deletions
5
src/test/mir-opt/retain-never-const.rs → src/test/mir-opt/remove-never-const.rs
This file contains hidden or 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
11 changes: 11 additions & 0 deletions
11
src/test/mir-opt/remove-never-const/rustc.no_codegen.PreCodegen.after.mir
This file contains hidden or 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,11 @@ | ||
// MIR for `no_codegen` after PreCodegen | ||
|
||
fn no_codegen() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/remove-never-const.rs:19:20: 19:20 | ||
scope 1 { | ||
} | ||
|
||
bb0: { | ||
unreachable; // bb0[0]: scope 0 at $DIR/remove-never-const.rs:20:13: 20:33 | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.