-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add basic support for RPIT #1351
base: master
Are you sure you want to change the base?
Changes from 2 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 |
---|---|---|
|
@@ -444,7 +444,12 @@ impl<'tcx> TranslationCtx<'tcx> { | |
pub(crate) fn typing_env(&self, def_id: DefId) -> TypingEnv<'tcx> { | ||
// FIXME: is it correct to pretend we are doing a non-body analysis? | ||
let param_env = self.param_env(def_id); | ||
TypingEnv { typing_mode: TypingMode::non_body_analysis(), param_env } | ||
let mode = if self.is_mir_available(def_id) && def_id.is_local() { | ||
TypingMode::post_borrowck_analysis(self.tcx, def_id.as_local().unwrap()) | ||
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. I tried to use |
||
} else { | ||
TypingMode::non_body_analysis() | ||
}; | ||
TypingEnv { typing_mode: mode, param_env } | ||
} | ||
|
||
pub(crate) fn has_body(&mut self, def_id: DefId) -> bool { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,9 @@ impl<'tcx> BodyTranslator<'_, 'tcx> { | |
} | ||
Unreachable => term = Terminator::Abort(terminator.source_info.span), | ||
Call { func, args, destination, mut target, fn_span, .. } => { | ||
let (fun_def_id, subst) = func_defid(func).expect("expected call with function"); | ||
let Some((fun_def_id, subst)) = func_defid(func) else { | ||
self.ctx.fatal_error(*fn_span, "unsupported function call type").emit() | ||
}; | ||
if let Some((need, resolved)) = resolved_during.take() { | ||
self.resolve_before_assignment(need, &resolved, location, *destination) | ||
} | ||
|
@@ -436,7 +438,7 @@ fn resolve_function<'tcx>( | |
|
||
// Try to extract a function defid from an operand | ||
fn func_defid<'tcx>(op: &Operand<'tcx>) -> Option<(DefId, GenericArgsRef<'tcx>)> { | ||
let fun_ty = op.constant().unwrap().const_.ty(); | ||
let fun_ty = op.constant()?.const_.ty(); | ||
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. this just allows us to report a nicer error rather than panic. |
||
if let ty::TyKind::FnDef(def_id, subst) = fun_ty.kind() { | ||
Some((*def_id, subst)) | ||
} else { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extern crate creusot_contracts; | ||
|
||
use creusot_contracts::*; | ||
|
||
pub trait MyTrait { | ||
fn a(&self) -> bool; | ||
} | ||
|
||
impl MyTrait for () { | ||
fn a(&self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
pub fn returns_iterator() -> impl MyTrait { | ||
() | ||
} | ||
|
||
#[ensures(true)] | ||
pub fn main() { | ||
let x = returns_iterator().a(); | ||
|
||
proof_assert!(x); | ||
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. I guess I should move this to |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
I'm not sure how but I'm getting these new "synthetic" types in the code I'm looking at which I don't yet know how to handle cleanly here.