Open Ten0 opened 2 months ago
I believe I have an issue related to this as well where the following code
use std::collections::HashMap;
use ouroboros::self_referencing;
#[self_referencing]
struct MyStruct {
items: Vec<String>,
#[borrows(items)]
map: HashMap<(&'this String, &'this String), (&'this String, &'this String)>,
}
Expands out to something containing:
{
::core::compile_error!{
"Ouroboros cannot automatically determine if this type is covariant.\n\nAs an example, a Box<&'this ()> is covariant because it can be used as a\nBox<&'smaller ()> for any lifetime smaller than 'this. In contrast,\na Fn(&'this ()) is not covariant because it cannot be used as a\nFn(&'smaller ()). In general, values that are safe to use with smaller\nlifetimes than they were defined with are covariant, breaking this \nguarantee means the value is not covariant.\n\nTo resolve this error, add #[covariant] or #[not_covariant] to the field.\n"
};
}
The issue with my code being a missing `#[covariant]` but the error generated instead is a syntax error.
"error: expected item, found `{`"
ouroboros = "0.18.4"
e.g.
generates (notably):
(note the "block" open which is incorrect in item position, and the random
;
)Workaround: this does not happen if specifying
#[covariant]
.Version: 0.18.4