Skip to content
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

derive(PartialBorrow) doesn't work if a field contains a reference #7

Open
lolbinarycat opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@lolbinarycat
Copy link

code:

use borrow::PartialBorrow;
#[derive(PartialBorrow)]
struct Foo<'a> {
 r: &'a u8
}

errors:

error: expected identifier, found `&`
 --> src/lib.rs:1:90
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                     -------------                                        ^ expected identifier
  |                                     |
  |                                     this macro call doesn't expand to a type
  |                                     in this macro invocation
  |
  = note: this error originates in the macro `$crate::Foo` which comes from the expansion of the macro `Foo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0726]: implicit elided lifetime not allowed here
 --> src/lib.rs:1:77
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                                                             ^^^ expected lifetime parameter
  |
help: indicate the anonymous lifetime
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'_><'a> { r: &'a u8 }
  |                                                                                ++++

error[E0261]: use of undeclared lifetime name `'a`
 --> src/lib.rs:1:91
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                     -------------                                         ^^ undeclared lifetime
  |                                     |
  |                                     lifetime `'a` is missing in item created through this procedural macro
  |
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html

error[E0261]: use of undeclared lifetime name `'a`
 --> src/lib.rs:1:91
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                                                                           ^^ undeclared lifetime

error[E0261]: use of undeclared lifetime name `'a`
 --> src/lib.rs:1:91
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                     -------------                                      -  ^^ undeclared lifetime
  |                                     |                                                  |
  |                                     |                                                  help: consider introducing lifetime `'a` here: `<'a>`
  |                                     lifetime `'a` is missing in item created through this procedural macro

error[E0277]: the trait bound `r: borrow::Acquire<()>` is not satisfied
 --> src/lib.rs:1:37
  |
1 | use borrow::PartialBorrow; #[derive(PartialBorrow)] #[module(crate)] struct Foo<'a> { r: &'a u8 }
  |                                     ^^^^^^^^^^^^^ the trait `borrow::Acquire<()>` is not implemented for `r`
  |
  = note: required for `Cons<r, Nil>` to implement `SplitFields<Cons<(), Nil>>`
  = note: required for `FooRef<r>` to implement `PartialBorrow<FooRef<()>>`
  = note: this error originates in the derive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant