- Notifications
You must be signed in to change notification settings - Fork 14k
generic_const_exprs: use thir for abstract consts instead of mir #88709
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
Merged
Changes from all commits
Commits
Show all changes
18 commits Select commit Hold shift + click to select a range
2987f4b WIP state
BoxyUwU 9b29138 as casts and block exprs
BoxyUwU 4483c2b dont support blocks
BoxyUwU 47b16f4 bless stderr
BoxyUwU c170dcf tidy
BoxyUwU 08e8644 move thir visitor to rustc_middle
BoxyUwU fc63e9a dont build abstract const for monomorphic consts
BoxyUwU 4cbcb09 handle `ExprKind::NeverToAny`
BoxyUwU 1f57f8b remove `WorkNode`
BoxyUwU 15101c8 remove debug stmts
BoxyUwU 406d2ab rename mir -> thir around abstract consts
BoxyUwU 79be080 remove comment
BoxyUwU 955e2b2 nits
BoxyUwU 8c7954d add a `CastKind` to `Node::Cast`
BoxyUwU 3212734 resolve `from_hir_call` FIXME
BoxyUwU cd2915e fmt
BoxyUwU fd9bb30 CI please
BoxyUwU 8295e4a add test for builtin types N + N unifying with fn call
BoxyUwU 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 was deleted.
Oops, something went wrong.
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,61 @@ | ||
| //! A subset of a mir body used for const evaluatability checking. | ||
| use crate::mir; | ||
| use crate::ty::{self, Ty, TyCtxt}; | ||
| use rustc_errors::ErrorReported; | ||
| | ||
| rustc_index::newtype_index! { | ||
| /// An index into an `AbstractConst`. | ||
| pub struct NodeId { | ||
| derive [HashStable] | ||
| DEBUG_FORMAT = "n{}", | ||
| } | ||
| } | ||
| | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] | ||
| pub enum CastKind { | ||
| /// thir::ExprKind::As | ||
| As, | ||
| /// thir::ExprKind::Use | ||
| Use, | ||
| } | ||
| | ||
| /// A node of an `AbstractConst`. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] | ||
| pub enum Node<'tcx> { | ||
| Leaf(&'tcx ty::Const<'tcx>), | ||
| Binop(mir::BinOp, NodeId, NodeId), | ||
| UnaryOp(mir::UnOp, NodeId), | ||
| FunctionCall(NodeId, &'tcx [NodeId]), | ||
| Cast(CastKind, NodeId, Ty<'tcx>), | ||
| } | ||
| | ||
| #[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] | ||
| pub enum NotConstEvaluatable { | ||
| Error(ErrorReported), | ||
| MentionsInfer, | ||
| MentionsParam, | ||
| } | ||
| | ||
| impl From<ErrorReported> for NotConstEvaluatable { | ||
| fn from(e: ErrorReported) -> NotConstEvaluatable { | ||
| NotConstEvaluatable::Error(e) | ||
| } | ||
| } | ||
| | ||
| TrivialTypeFoldableAndLiftImpls! { | ||
| NotConstEvaluatable, | ||
| } | ||
| | ||
| impl<'tcx> TyCtxt<'tcx> { | ||
| #[inline] | ||
| pub fn thir_abstract_const_opt_const_arg( | ||
| self, | ||
| def: ty::WithOptConstParam<rustc_hir::def_id::DefId>, | ||
| ) -> Result<Option<&'tcx [Node<'tcx>]>, ErrorReported> { | ||
| if let Some((did, param_did)) = def.as_const_arg() { | ||
| self.thir_abstract_const_of_const_arg((did, param_did)) | ||
| } else { | ||
| self.thir_abstract_const(def.did) | ||
| } | ||
| } | ||
| } |
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 |
|---|---|---|
| | @@ -11,4 +11,3 @@ crate mod cx; | |
| crate mod pattern; | ||
| | ||
| mod util; | ||
| pub mod visit; | ||
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
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.