-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #70820 - spastorino:replace-fragile-erroneous-const-sys…
- Loading branch information
Showing
13 changed files
with
133 additions
and
82 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
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,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 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
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 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 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.