-
-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Add an experimental internal attribute for limiting const evaluation to crate-local things #163092
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -695,6 +695,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| ty::TypingMode::Typeck { defining_opaque_types_and_generators } => { | ||
| defining_opaque_types_and_generators | ||
| } | ||
| ty::TypingMode::IsolatedConst => ty::List::empty(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what, why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. XD I was thinking I should add a comment here... typeck needs to know about IsolatedConst as well, but that would mean essentially adding a new dimension typing mode, where everything can be an isolated const, but also have the normal typingmode. Instead this MVP just forbids having opaque types at all, even if we could make RPITs work. TAITs won't work as they require access to other items from the current crate |
||
| ty::TypingMode::Coherence | ||
| | ty::TypingMode::Reflection | ||
| | ty::TypingMode::PostTypeckUntilBorrowck { .. } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4696,7 +4696,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| // Check if there's a negative impl of `candidate` for `rcvr_ty` | ||
| if self | ||
| .tcx | ||
| .all_impls(candidate.def_id) | ||
| .all_impls(candidate.def_id, self.typing_mode().include_local_impls()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when do we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should never use |
||
| .map(|imp_did| self.tcx.impl_trait_header(imp_did)) | ||
| .filter(|header| header.polarity != ty::ImplPolarity::Positive) | ||
| .any(|header| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually check that the functions invoked during CTFE are all from the current crate, does it?
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not important in practice for the end goal. Either the resolver doesn't even let you call that function, or you get a cycle error, or you can call that function. All the work here is to avoid cycle errors, and we'll see how far we can take this