Treat missing trait declaration as not builtin in trait_impl_is_builtin#1137
Treat missing trait declaration as not builtin in trait_impl_is_builtin#1137SAY-5 wants to merge 5 commits into
Conversation
Note: this PR doesn't close the linked issue. If the PR version of Aeneas is given one example from the issue: #[derive(serde::Serialize)]
pub struct Point {
pub x: u32,
pub y: u32,
}Aeneas still generates three warnings and an error. The Lean output is only partial. The root cause behind the behaviour seen in the issue is that Aeneas doesn't yet support recursive traits. What this PR does: This PR modifies the behaviour of one of the lookups in I would say the original behaviour was the correct one in this case, modified as per this PR would means that problems are silenced rather than communicated. Moreover the PR doesn't solve the underlying issue. I suspect extending Aeneas to support recursive traits is complex and will need to be done in-house since it will touch on lots of deep parts of the code base. |
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
bd2f9e3 to
2c25fd5
Compare
|
That's fair, the loud failure does communicate the missing recursive-trait support better than a silent false. I'll leave it to you whether to keep this as-is, swap it for a clearer diagnostic instead of Not_found, or close in favour of the #176 work. |
Thanks for your efforts with this PR! I'm trying to figure out what is best to do since there are multiple issues behind the scenes with #1102. A somewhat convoluted investigation! Do you have a particular minimal example in mind with this PR work? I've been using the following: pub trait Gat {
type Assoc<'a>;
}
pub struct S;
impl Gat for S {
type Assoc<'a> = &'a u32;
}
pub fn use_it(_s: &S) -> u32 {
0
}This has the behaviour described in title of #1102, namely an uncaught exception related to Using the version of Aeneas of this PR, this error is changed to a similar error but now at Indeed it would be desirable to avoid Aeneas having a hard crash in these cases, prior to the root cause being supported. Is it possible to do this for all the consumers that will be missing the relevant data? I.e., a modification like in this PR removes the hard error at Do you want to investigate if something complete is possible? |
|
You're right that this PR only relocates the crash: The clean fix is to replace each raw lookup on that data with a I'll map the full set of call sites that look up trait-impl data by id and see whether they can all be routed through |
If that works out, that would be great! It will be very useful to users who encounter such problems in the future so they know exactly what the problem is and can use a workaround until the full fix for the translation is available. The example can be included in the tests folder of the repo using the |
|
Sounds good, and thanks for mapping the call sites. Routing every trait-impl-by-id lookup through |
trait_impl_is_builtinlooks up the impl's trait declaration intrans_trait_declswith a bareMap.find. When a trait decl was dropped earlier but its impl is still exported (e.g. the mutually-recursive serdeSerialize/Serializercluster), the lookup raises an uncaughtNot_foundand aeneas exits after writing partial output. This switches tofind_optand treats an absent declaration as not builtin, as suggested in #1102.Closes #1102.