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

A bug with Identifiable: "use of undeclared lifetime name `'a`" #502

Closed
golddranks opened this Issue Nov 27, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@golddranks
Contributor

golddranks commented Nov 27, 2016

Demonstrated by https://github.com/golddranks/diesel_bug

Setup a database with diesel_cli, set the DATABASE_URL env var and try to compile:

error[E0261]: use of undeclared lifetime name `'a`
 --> <proc-macro source code>:1:73
  |
1 | _Identifiable ! { ( table_name = sessions , struct_ty = UpdateSession < 'a > , ) , fields = [ { field_name:  id ,  column_name:  id ,  field_ty:  i32 ,  field_kind:  regular ,  } { field_name:  sess_token ,  column_name:  sess_token ,  field_ty:  & 'a [ u8 ] ,  field_kind:  regular ,  } { field_name:  proposed_token ,  column_name:  proposed_token ,  field_ty:  Option < & 'a [ u8 ] > ,  field_kind:  option ,  } { field_name:  last_ip ,  column_name:  last_ip ,  field_ty:  Vec < u8 > ,  field_kind:  regular ,  } ] , }
  |                                                                         ^^ undeclared lifetime

Caused by the Identifiable derivation with this struct in models.rs:

#[derive(Identifiable, Debug, AsChangeset)]
#[table_name="sessions"]
#[changeset_options(treat_none_as_null = "true")]
pub struct UpdateSession<'a> {
    pub id: i32,
    pub sess_token: &'a [u8],
    pub proposed_token: Option<&'a [u8]>,
    pub user_id: i32,
    pub started: DateTime<UTC>,
    pub last_seen: DateTime<UTC>,
    pub last_ip: Vec<u8>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment