Update 'devise' to 0.3.

This transitively updates 'syn', 'proc-macro2', and 'quote' to 1.0.
This commit is contained in:
Sergio Benitez 2019-09-05 15:43:57 -07:00
parent dcea9563fc
commit 0b059e06e5
8 changed files with 29 additions and 27 deletions

View File

@ -19,8 +19,8 @@ database_attribute = []
proc-macro = true proc-macro = true
[dependencies] [dependencies]
devise = "0.2" quote = "1.0"
quote = "0.6" devise = { git = "https://github.com/SergioBenitez/Devise.git", rev = "e58b3ac9a" }
[build-dependencies] [build-dependencies]
yansi = "0.5" yansi = "0.5"

View File

@ -42,7 +42,7 @@ fn parse_invocation(attr: TokenStream, input: TokenStream) -> Result<DatabaseInv
let inner_type = match structure.fields { let inner_type = match structure.fields {
Fields::Unnamed(ref fields) if fields.unnamed.len() == 1 => { Fields::Unnamed(ref fields) if fields.unnamed.len() == 1 => {
let first = fields.unnamed.first().expect("checked length"); let first = fields.unnamed.first().expect("checked length");
first.value().ty.clone() first.ty.clone()
} }
_ => return Err(structure.fields.span().error(ONLY_UNNAMED_FIELDS).help(EXAMPLE)) _ => return Err(structure.fields.span().error(ONLY_UNNAMED_FIELDS).help(EXAMPLE))
}; };

View File

@ -17,9 +17,9 @@ proc-macro = true
[dependencies] [dependencies]
indexmap = "1.0" indexmap = "1.0"
quote = "0.6.1" quote = "1.0"
rocket_http = { version = "0.5.0-dev", path = "../http/" } rocket_http = { version = "0.5.0-dev", path = "../http/" }
devise = "0.2" devise = { git = "https://github.com/SergioBenitez/Devise.git", rev = "e58b3ac9a" }
[build-dependencies] [build-dependencies]
yansi = "0.5" yansi = "0.5"

View File

@ -44,7 +44,7 @@ pub fn _catch(args: TokenStream, input: TokenStream) -> Result<TokenStream> {
// Gather everything we'll need to generate the catcher. // Gather everything we'll need to generate the catcher.
let user_catcher_fn = &catch.function; let user_catcher_fn = &catch.function;
let mut user_catcher_fn_name = catch.function.ident.clone(); let mut user_catcher_fn_name = catch.function.sig.ident.clone();
let generated_struct_name = user_catcher_fn_name.prepend(CATCH_STRUCT_PREFIX); let generated_struct_name = user_catcher_fn_name.prepend(CATCH_STRUCT_PREFIX);
let generated_fn_name = user_catcher_fn_name.prepend(CATCH_FN_PREFIX); let generated_fn_name = user_catcher_fn_name.prepend(CATCH_FN_PREFIX);
let (vis, status) = (&catch.function.vis, &catch.status); let (vis, status) = (&catch.function.vis, &catch.status);
@ -54,20 +54,20 @@ pub fn _catch(args: TokenStream, input: TokenStream) -> Result<TokenStream> {
define_vars_and_mods!(req, catcher, response, Request, Response); define_vars_and_mods!(req, catcher, response, Request, Response);
// Determine the number of parameters that will be passed in. // Determine the number of parameters that will be passed in.
let (fn_sig, inputs) = match catch.function.decl.inputs.len() { let (fn_sig, inputs) = match catch.function.sig.inputs.len() {
0 => (quote!(fn() -> _), quote!()), 0 => (quote!(fn() -> _), quote!()),
1 => (quote!(fn(&#Request) -> _), quote!(#req)), 1 => (quote!(fn(&#Request) -> _), quote!(#req)),
_ => return Err(catch.function.decl.inputs.span() _ => return Err(catch.function.sig.inputs.span()
.error("invalid number of arguments: must be zero or one") .error("invalid number of arguments: must be zero or one")
.help("catchers may optionally take an argument of type `&Request`")) .help("catchers may optionally take an argument of type `&Request`"))
}; };
// Set the span of the function name to point to inputs so that a later type // Set the span of the function name to point to inputs so that a later type
// coercion failure points to the user's catcher's handler input. // coercion failure points to the user's catcher's handler input.
user_catcher_fn_name.set_span(catch.function.decl.inputs.span().into()); user_catcher_fn_name.set_span(catch.function.sig.inputs.span().into());
// This ensures that "Responder not implemented" points to the return type. // This ensures that "Responder not implemented" points to the return type.
let return_type_span = catch.function.decl.output.ty() let return_type_span = catch.function.sig.output.ty()
.map(|ty| ty.span().into()) .map(|ty| ty.span().into())
.unwrap_or(Span::call_site().into()); .unwrap_or(Span::call_site().into());

View File

@ -85,11 +85,11 @@ fn parse_route(attr: RouteAttribute, function: syn::ItemFn) -> Result<Route> {
// Check the validity of function arguments. // Check the validity of function arguments.
let mut inputs = vec![]; let mut inputs = vec![];
let mut fn_segments: IndexSet<Segment> = IndexSet::new(); let mut fn_segments: IndexSet<Segment> = IndexSet::new();
for input in &function.decl.inputs { for input in &function.sig.inputs {
let help = "all handler arguments must be of the form: `ident: Type`"; let help = "all handler arguments must be of the form: `ident: Type`";
let span = input.span(); let span = input.span();
let (ident, ty) = match input { let (ident, ty) = match input {
syn::FnArg::Captured(arg) => match arg.pat { syn::FnArg::Typed(arg) => match *arg.pat {
syn::Pat::Ident(ref pat) => (&pat.ident, &arg.ty), syn::Pat::Ident(ref pat) => (&pat.ident, &arg.ty),
syn::Pat::Wild(_) => { syn::Pat::Wild(_) => {
diags.push(span.error("handler arguments cannot be ignored").help(help)); diags.push(span.error("handler arguments cannot be ignored").help(help));
@ -113,8 +113,8 @@ fn parse_route(attr: RouteAttribute, function: syn::ItemFn) -> Result<Route> {
} }
// Check that all of the declared parameters are function inputs. // Check that all of the declared parameters are function inputs.
let span = match function.decl.inputs.is_empty() { let span = match function.sig.inputs.is_empty() {
false => function.decl.inputs.span(), false => function.sig.inputs.span(),
true => function.span() true => function.span()
}; };
@ -335,7 +335,7 @@ fn generate_internal_uri_macro(route: &Route) -> TokenStream2 {
line_column.line.hash(&mut hasher); line_column.line.hash(&mut hasher);
line_column.column.hash(&mut hasher); line_column.column.hash(&mut hasher);
let mut generated_macro_name = route.function.ident.prepend(URI_MACRO_PREFIX); let mut generated_macro_name = route.function.sig.ident.prepend(URI_MACRO_PREFIX);
generated_macro_name.set_span(Span::call_site().into()); generated_macro_name.set_span(Span::call_site().into());
let inner_generated_macro_name = generated_macro_name.append(&hasher.finish().to_string()); let inner_generated_macro_name = generated_macro_name.append(&hasher.finish().to_string());
let route_uri = route.attribute.path.origin.0.to_string(); let route_uri = route.attribute.path.origin.0.to_string();
@ -386,7 +386,7 @@ fn codegen_route(route: Route) -> Result<TokenStream> {
// Gather everything we need. // Gather everything we need.
define_vars_and_mods!(req, data, handler, Request, Data, StaticRouteInfo); define_vars_and_mods!(req, data, handler, Request, Data, StaticRouteInfo);
let (vis, user_handler_fn) = (&route.function.vis, &route.function); let (vis, user_handler_fn) = (&route.function.vis, &route.function);
let user_handler_fn_name = &user_handler_fn.ident; let user_handler_fn_name = &user_handler_fn.sig.ident;
let generated_fn_name = user_handler_fn_name.prepend(ROUTE_FN_PREFIX); let generated_fn_name = user_handler_fn_name.prepend(ROUTE_FN_PREFIX);
let generated_struct_name = user_handler_fn_name.prepend(ROUTE_STRUCT_PREFIX); let generated_struct_name = user_handler_fn_name.prepend(ROUTE_STRUCT_PREFIX);
let parameter_names = route.inputs.iter().map(|(_, rocket_ident, _)| rocket_ident); let parameter_names = route.inputs.iter().map(|(_, rocket_ident, _)| rocket_ident);

View File

@ -11,7 +11,7 @@ mod uri_parsing;
crate fn prefix_last_segment(path: &mut Path, prefix: &str) { crate fn prefix_last_segment(path: &mut Path, prefix: &str) {
let mut last_seg = path.segments.last_mut().expect("syn::Path has segments"); let mut last_seg = path.segments.last_mut().expect("syn::Path has segments");
last_seg.value_mut().ident = last_seg.value().ident.prepend(prefix); last_seg.ident = last_seg.ident.prepend(prefix);
} }
fn _prefixed_vec( fn _prefixed_vec(

View File

@ -1,6 +1,6 @@
use quote::ToTokens; use quote::ToTokens;
use crate::proc_macro2::TokenStream as TokenStream2; use crate::proc_macro2::TokenStream as TokenStream2;
use devise::{FromMeta, MetaItem, Result, ext::Split2}; use devise::{FromMeta, MetaItem, Result, ext::{Split2, PathExt}};
use crate::http::{self, ext::IntoOwned}; use crate::http::{self, ext::IntoOwned};
use crate::http::uri::{Path, Query}; use crate::http::uri::{Path, Query};
use crate::attribute::segments::{parse_segments, parse_data_segment, Segment, Kind}; use crate::attribute::segments::{parse_segments, parse_data_segment, Segment, Kind};
@ -130,16 +130,18 @@ impl FromMeta for Method {
let span = meta.value_span(); let span = meta.value_span();
let help_text = format!("method must be one of: {}", VALID_METHODS_STR); let help_text = format!("method must be one of: {}", VALID_METHODS_STR);
if let MetaItem::Ident(ident) = meta { if let MetaItem::Path(path) = meta {
let method = ident.to_string().parse() if let Some(ident) = path.last_ident() {
.map_err(|_| span.error("invalid HTTP method").help(&*help_text))?; let method = ident.to_string().parse()
.map_err(|_| span.error("invalid HTTP method").help(&*help_text))?;
if !VALID_METHODS.contains(&method) { if !VALID_METHODS.contains(&method) {
return Err(span.error("invalid HTTP method for route handlers") return Err(span.error("invalid HTTP method for route handlers")
.help(&*help_text)); .help(&*help_text));
} }
return Ok(Method(method)); return Ok(Method(method));
}
} }
Err(span.error(format!("expected identifier, found {}", meta.description())) Err(span.error(format!("expected identifier, found {}", meta.description()))

View File

@ -44,7 +44,7 @@ error[E0277]: the trait bound `i32: rocket::http::uri::FromUriParam<rocket::http
--> $DIR/typed-uri-bad-type.rs:62:26 --> $DIR/typed-uri-bad-type.rs:62:26
| |
62 | uri!(optionals: id = Some(10), name = Ok("bob".into())); 62 | uri!(optionals: id = Some(10), name = Ok("bob".into()));
| ^^^^ the trait `rocket::http::uri::FromUriParam<rocket::http::uri::Path, std::option::Option<{integer}>>` is not implemented for `i32` | ^^^^^^^^ the trait `rocket::http::uri::FromUriParam<rocket::http::uri::Path, std::option::Option<{integer}>>` is not implemented for `i32`
| |
= help: the following implementations were found: = help: the following implementations were found:
i32 as $TRAIT i32 as $TRAIT
@ -56,7 +56,7 @@ error[E0277]: the trait bound `std::string::String: rocket::http::uri::FromUriPa
--> $DIR/typed-uri-bad-type.rs:62:43 --> $DIR/typed-uri-bad-type.rs:62:43
| |
62 | uri!(optionals: id = Some(10), name = Ok("bob".into())); 62 | uri!(optionals: id = Some(10), name = Ok("bob".into()));
| ^^ the trait `rocket::http::uri::FromUriParam<rocket::http::uri::Path, std::result::Result<_, _>>` is not implemented for `std::string::String` | ^^^^^^^^^^^^^^^^ the trait `rocket::http::uri::FromUriParam<rocket::http::uri::Path, std::result::Result<_, _>>` is not implemented for `std::string::String`
| |
= help: the following implementations were found: = help: the following implementations were found:
std::string::String as $TRAIT std::string::String as $TRAIT