mirror of https://github.com/rwf2/Rocket.git
parent
fa3e0334c1
commit
6784ebc097
|
@ -17,8 +17,10 @@ proc-macro = true
|
|||
[dependencies]
|
||||
indexmap = "1.0"
|
||||
quote = "1.0"
|
||||
rocket_http = { version = "0.5.0-dev", path = "../http/" }
|
||||
syn = { version = "1.0.72", features = ["full", "visit", "visit-mut", "extra-traits"] }
|
||||
proc-macro2 = "1.0.27"
|
||||
devise = { git = "https://github.com/SergioBenitez/Devise.git", rev = "df00b5" }
|
||||
rocket_http = { version = "0.5.0-dev", path = "../http/" }
|
||||
unicode-xid = "0.2"
|
||||
glob = "0.3"
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
mod parse;
|
||||
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::{syn, Spanned, Result};
|
||||
use devise::{Spanned, Result};
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
use crate::http_codegen::Optional;
|
||||
use crate::proc_macro2::{TokenStream, Span};
|
||||
use crate::syn_ext::ReturnTypeExt;
|
||||
use crate::exports::*;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::{syn, MetaItem, Spanned, Result, FromMeta, Diagnostic};
|
||||
use devise::{MetaItem, Spanned, Result, FromMeta, Diagnostic};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
use crate::{http, http_codegen};
|
||||
use crate::proc_macro2::TokenStream;
|
||||
|
||||
/// This structure represents the parsed `catch` attribute and associated items.
|
||||
pub struct Attribute {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use super::EntryAttr;
|
||||
|
||||
use devise::{syn, Spanned, Result};
|
||||
use devise::{Spanned, Result};
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::proc_macro2::{TokenStream, Span};
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
/// `#[rocket::launch]`: generates a `main` function that calls the attributed
|
||||
/// function to generate a `Rocket` instance. Then calls `.launch()` on the
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use super::EntryAttr;
|
||||
|
||||
use devise::{syn, Spanned, Result};
|
||||
use devise::{Spanned, Result};
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::proc_macro2::{TokenStream, Span};
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
/// `#[rocket::async_main]`: calls the attributed fn inside `rocket::async_main`
|
||||
pub struct Main;
|
||||
|
|
|
@ -2,9 +2,9 @@ mod main;
|
|||
mod launch;
|
||||
mod test;
|
||||
|
||||
use devise::{syn, Diagnostic, Spanned, Result};
|
||||
use devise::{Diagnostic, Spanned, Result};
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::proc_macro2::{TokenStream, Span};
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
// Common trait implemented by `async` entry generating attributes.
|
||||
trait EntryAttr {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::EntryAttr;
|
||||
|
||||
use devise::{syn, Spanned, Result};
|
||||
use devise::proc_macro2::TokenStream;
|
||||
use devise::{Spanned, Result};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
/// `#[rocket::async_test]`: calls the attributed fn inside `rocket::async_test`
|
||||
pub struct Test;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use devise::{syn, FromMeta, MetaItem, Result};
|
||||
use devise::{FromMeta, MetaItem, Result};
|
||||
use proc_macro2::Span;
|
||||
|
||||
use crate::name::Name;
|
||||
use crate::proc_macro2::Span;
|
||||
use crate::proc_macro_ext::StringLit;
|
||||
use crate::http::uri;
|
||||
|
||||
|
||||
impl Dynamic {
|
||||
pub fn is_wild(&self) -> bool {
|
||||
self.value == "_"
|
||||
|
|
|
@ -3,7 +3,6 @@ mod parse;
|
|||
use std::ops::Deref;
|
||||
use std::hash::Hash;
|
||||
|
||||
use crate::syn;
|
||||
use crate::name::Name;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use unicode_xid::UnicodeXID;
|
||||
use devise::{Diagnostic, ext::SpanDiagnosticExt};
|
||||
use proc_macro2::Span;
|
||||
|
||||
use crate::name::Name;
|
||||
use crate::proc_macro_ext::StringLit;
|
||||
use crate::proc_macro2::Span;
|
||||
use crate::attribute::param::{Parameter, Dynamic};
|
||||
use crate::http::uri::fmt::{Part, Kind, Path};
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@ mod parse;
|
|||
|
||||
use std::hash::Hash;
|
||||
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
use devise::{Spanned, SpanWrapped, Result, FromMeta, Diagnostic};
|
||||
use devise::ext::TypeExt as _;
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
use crate::{proc_macro2, syn};
|
||||
use crate::proc_macro_ext::StringLit;
|
||||
use crate::syn_ext::{IdentExt, TypeExt as _};
|
||||
use crate::http_codegen::{Method, Optional};
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use devise::{syn, Spanned, SpanWrapped, Result, FromMeta};
|
||||
use devise::{Spanned, SpanWrapped, Result, FromMeta};
|
||||
use devise::ext::{SpanDiagnosticExt, TypeExt};
|
||||
use indexmap::{IndexSet, IndexMap};
|
||||
use proc_macro2::Span;
|
||||
|
||||
use crate::proc_macro_ext::Diagnostics;
|
||||
use crate::http_codegen::{Method, MediaType};
|
||||
use crate::attribute::param::{Parameter, Dynamic, Guard};
|
||||
use crate::syn_ext::FnArgExt;
|
||||
|
||||
use crate::name::Name;
|
||||
use crate::proc_macro2::Span;
|
||||
use crate::http::ext::IntoOwned;
|
||||
use crate::http::uri::{Origin, fmt};
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ use std::hash::Hash;
|
|||
|
||||
use devise::Spanned;
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::proc_macro2::{TokenStream, TokenTree, Punct};
|
||||
use devise::syn;
|
||||
use proc_macro2::{TokenStream, TokenTree, Punct};
|
||||
|
||||
use crate::syn_ext::IdentExt;
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use devise::Result;
|
||||
|
||||
use crate::syn::{Path, punctuated::Punctuated, parse::Parser, Token};
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::syn::spanned::Spanned;
|
||||
use syn::{Path, punctuated::Punctuated, parse::Parser, Token};
|
||||
use syn::spanned::Spanned;
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
mod uri;
|
||||
mod uri_parsing;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::path::Path;
|
||||
use std::error::Error;
|
||||
|
||||
use syn::{self, Ident, LitStr};
|
||||
use devise::ext::SpanDiagnosticExt;
|
||||
use devise::syn::{self, Ident, LitStr};
|
||||
use devise::proc_macro2::TokenStream;
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
pub fn _macro(input: proc_macro::TokenStream) -> devise::Result<TokenStream> {
|
||||
let root_glob = syn::parse::<LitStr>(input.into())?;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use devise::{syn, Result};
|
||||
use devise::ext::{SpanDiagnosticExt, quote_respanned};
|
||||
use devise::{Result, ext::{SpanDiagnosticExt, quote_respanned}};
|
||||
use syn::{Expr, Ident, Type, spanned::Spanned};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
use crate::http::uri::fmt;
|
||||
use crate::http_codegen::Optional;
|
||||
use crate::syn::{Expr, Ident, Type, spanned::Spanned};
|
||||
use crate::syn_ext::IdentExt;
|
||||
use crate::bang::uri_parsing::*;
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::attribute::param::Parameter;
|
||||
use crate::exports::*;
|
||||
use crate::URI_MACRO_PREFIX;
|
||||
|
|
|
@ -3,15 +3,14 @@ use std::ops::Deref;
|
|||
use indexmap::IndexMap;
|
||||
use devise::{Spanned, ext::TypeExt};
|
||||
use quote::{ToTokens, TokenStreamExt};
|
||||
use syn::{Expr, Ident, LitStr, Path, Token, Type};
|
||||
use syn::parse::{self, Parse, ParseStream, Parser};
|
||||
use syn::punctuated::Punctuated;
|
||||
use proc_macro2::{TokenStream, TokenTree, Span};
|
||||
use rocket_http::uri::{Error, Reference};
|
||||
|
||||
use crate::{http_codegen, syn::{self, Expr, Ident, LitStr, Path, Token, Type}};
|
||||
use crate::syn::parse::{self, Parse, ParseStream, Parser};
|
||||
use crate::syn::punctuated::Punctuated;
|
||||
|
||||
use crate::http::uri::{Uri, Origin, Absolute, fmt};
|
||||
use crate::http::ext::IntoOwned;
|
||||
use crate::proc_macro2::{TokenStream, TokenTree, Span};
|
||||
use crate::proc_macro_ext::StringLit;
|
||||
use crate::attribute::param::{Parameter, Dynamic};
|
||||
use crate::name::Name;
|
||||
|
@ -549,7 +548,7 @@ impl Deref for UriLit {
|
|||
|
||||
impl ToTokens for UriLit {
|
||||
fn to_tokens(&self, t: &mut TokenStream) {
|
||||
use http_codegen::*;
|
||||
use crate::http_codegen::*;
|
||||
|
||||
let (uri, span) = (&self.0, self.1);
|
||||
match uri {
|
||||
|
|
|
@ -2,8 +2,8 @@ use devise::{*, ext::{TypeExt, SpanDiagnosticExt}};
|
|||
|
||||
use syn::visit_mut::VisitMut;
|
||||
use syn::visit::Visit;
|
||||
use proc_macro2::{TokenStream, TokenTree, Span};
|
||||
|
||||
use crate::proc_macro2::{TokenStream, TokenTree, Span};
|
||||
use crate::syn_ext::IdentExt;
|
||||
use crate::name::Name;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use devise::{*, ext::{TypeExt, SpanDiagnosticExt, GenericsExt, Split2, quote_respanned}};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
use crate::exports::*;
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::derive::form_field::{*, FieldName::*};
|
||||
|
||||
// F: fn(field_ty: Ty, field_context: Expr)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use devise::{*, ext::SpanDiagnosticExt};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
use crate::exports::*;
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::derive::form_field::{VariantExt, first_duplicate};
|
||||
|
||||
pub fn derive_from_form_field(input: proc_macro::TokenStream) -> TokenStream {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use quote::ToTokens;
|
||||
use devise::{*, ext::{TypeExt, SpanDiagnosticExt}};
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
use crate::exports::*;
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::http_codegen::{ContentType, Status};
|
||||
|
||||
#[derive(Debug, Default, FromMeta)]
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
use proc_macro2::TokenStream;
|
||||
use devise::{*, ext::SpanDiagnosticExt};
|
||||
|
||||
use crate::exports::*;
|
||||
use crate::derive::form_field::{FieldExt, VariantExt};
|
||||
use crate::proc_macro2::TokenStream;
|
||||
use crate::http::uri::fmt;
|
||||
|
||||
const NO_EMPTY_FIELDS: &str = "fieldless structs are not supported";
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::syn;
|
||||
use crate::proc_macro2::{Span, TokenStream};
|
||||
use crate::quote::{ToTokens, TokenStreamExt};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use quote::{ToTokens, TokenStreamExt};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StaticPath(pub Option<Span>, pub &'static str);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use quote::ToTokens;
|
||||
use devise::{FromMeta, MetaItem, Result, ext::{Split2, PathExt, SpanDiagnosticExt}};
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
|
||||
use crate::http;
|
||||
use crate::proc_macro2::{TokenStream, Span};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ContentType(pub http::ContentType);
|
||||
|
|
|
@ -70,7 +70,6 @@ mod name;
|
|||
|
||||
use crate::http::Method;
|
||||
use proc_macro::TokenStream;
|
||||
use devise::{proc_macro2, syn};
|
||||
|
||||
static URI_MACRO_PREFIX: &str = "rocket_uri_macro_";
|
||||
static ROCKET_IDENT_PREFIX: &str = "__rocket_";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::syn::{self, Ident, ext::IdentExt};
|
||||
use crate::http::uncased::UncasedStr;
|
||||
use crate::proc_macro2::Span;
|
||||
|
||||
use syn::{self, Ident, ext::IdentExt};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
|
||||
/// A "name" read by codegen, which may or may not be an identifier. A `Name` is
|
||||
/// typically constructed indirectly via FromMeta, or From<Ident> or directly
|
||||
|
@ -55,7 +56,7 @@ impl devise::FromMeta for Name {
|
|||
}
|
||||
|
||||
impl quote::ToTokens for Name {
|
||||
fn to_tokens(&self, tokens: &mut devise::proc_macro2::TokenStream) {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
syn::LitStr::new(self.as_str(), self.span()).to_tokens(tokens)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use std::ops::RangeBounds;
|
||||
|
||||
use devise::Diagnostic;
|
||||
|
||||
use crate::proc_macro2::{Span, Literal};
|
||||
use proc_macro2::{Span, Literal};
|
||||
|
||||
// An experiment.
|
||||
pub struct Diagnostics(Vec<Diagnostic>);
|
||||
|
@ -70,9 +69,9 @@ impl StringLit {
|
|||
}
|
||||
}
|
||||
|
||||
impl crate::syn::parse::Parse for StringLit {
|
||||
fn parse(input: devise::syn::parse::ParseStream<'_>) -> devise::syn::Result<Self> {
|
||||
let lit = input.parse::<crate::syn::LitStr>()?;
|
||||
impl syn::parse::Parse for StringLit {
|
||||
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
|
||||
let lit = input.parse::<syn::LitStr>()?;
|
||||
Ok(StringLit::new(lit.value(), lit.span()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
use std::ops::Deref;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use crate::syn::{self, Ident, ext::IdentExt as _, visit::Visit};
|
||||
use crate::proc_macro2::Span;
|
||||
use syn::{self, Ident, ext::IdentExt as _, visit::Visit};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
|
||||
pub trait IdentExt {
|
||||
fn prepend(&self, string: &str) -> syn::Ident;
|
||||
|
@ -19,7 +19,7 @@ pub trait ReturnTypeExt {
|
|||
}
|
||||
|
||||
pub trait TokenStreamExt {
|
||||
fn respanned(&self, span: crate::proc_macro2::Span) -> Self;
|
||||
fn respanned(&self, span: Span) -> Self;
|
||||
}
|
||||
|
||||
pub trait FnArgExt {
|
||||
|
@ -91,8 +91,8 @@ impl ReturnTypeExt for syn::ReturnType {
|
|||
}
|
||||
}
|
||||
|
||||
impl TokenStreamExt for crate::proc_macro2::TokenStream {
|
||||
fn respanned(&self, span: crate::proc_macro2::Span) -> Self {
|
||||
impl TokenStreamExt for TokenStream {
|
||||
fn respanned(&self, span: Span) -> Self {
|
||||
self.clone().into_iter().map(|mut token| {
|
||||
token.set_span(span);
|
||||
token
|
||||
|
|
Loading…
Reference in New Issue