prettyplease
Advanced tools
| { | ||
| "git": { | ||
| "sha1": "9ae9017fbc654311750b5c411c3e061e588f4964" | ||
| "sha1": "c971184fa8c5ef5a2828196e35bd99469455b46b" | ||
| }, | ||
| "path_in_vcs": "" | ||
| } |
+5
-5
@@ -13,3 +13,3 @@ # This file is automatically @generated by Cargo. | ||
| name = "prettyplease" | ||
| version = "0.2.36" | ||
| version = "0.2.37" | ||
| dependencies = [ | ||
@@ -24,5 +24,5 @@ "indoc", | ||
| name = "proc-macro2" | ||
| version = "1.0.95" | ||
| version = "1.0.101" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" | ||
| checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" | ||
| dependencies = [ | ||
@@ -43,5 +43,5 @@ "unicode-ident", | ||
| name = "syn" | ||
| version = "2.0.104" | ||
| version = "2.0.106" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" | ||
| checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" | ||
| dependencies = [ | ||
@@ -48,0 +48,0 @@ "proc-macro2", |
+3
-3
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "prettyplease" | ||
| version = "0.2.36" | ||
| version = "0.2.37" | ||
| authors = ["David Tolnay <dtolnay@gmail.com>"] | ||
@@ -67,3 +67,3 @@ build = "build.rs" | ||
| [dependencies.syn] | ||
| version = "2.0.104" | ||
| version = "2.0.105" | ||
| features = ["full"] | ||
@@ -84,3 +84,3 @@ default-features = false | ||
| [dev-dependencies.syn] | ||
| version = "2.0.104" | ||
| version = "2.0.105" | ||
| features = [ | ||
@@ -87,0 +87,0 @@ "clone-impls", |
+68
-25
@@ -108,4 +108,3 @@ use crate::algorithm::Printer; | ||
| TypeParamBound::Trait(trait_bound) => { | ||
| let tilde_const = false; | ||
| self.trait_bound(trait_bound, tilde_const); | ||
| self.trait_bound(trait_bound, TraitBoundConst::None); | ||
| } | ||
@@ -121,13 +120,17 @@ TypeParamBound::Lifetime(lifetime) => self.lifetime(lifetime), | ||
| fn trait_bound(&mut self, trait_bound: &TraitBound, tilde_const: bool) { | ||
| fn trait_bound(&mut self, trait_bound: &TraitBound, constness: TraitBoundConst) { | ||
| if trait_bound.paren_token.is_some() { | ||
| self.word("("); | ||
| } | ||
| if tilde_const { | ||
| self.word("~const "); | ||
| } | ||
| self.trait_bound_modifier(&trait_bound.modifier); | ||
| if let Some(bound_lifetimes) = &trait_bound.lifetimes { | ||
| self.bound_lifetimes(bound_lifetimes); | ||
| } | ||
| match constness { | ||
| TraitBoundConst::None => {} | ||
| #[cfg(feature = "verbatim")] | ||
| TraitBoundConst::Conditional => self.word("[const] "), | ||
| #[cfg(feature = "verbatim")] | ||
| TraitBoundConst::Unconditional => self.word("const "), | ||
| } | ||
| self.trait_bound_modifier(&trait_bound.modifier); | ||
| for segment in trait_bound.path.segments.iter().delimited() { | ||
@@ -159,7 +162,10 @@ if !segment.is_first || trait_bound.path.leading_colon.is_some() { | ||
| use syn::parse::{Parse, ParseStream, Result}; | ||
| use syn::{parenthesized, token, Token}; | ||
| use syn::{ | ||
| bracketed, parenthesized, token, ParenthesizedGenericArguments, Path, PathArguments, | ||
| Token, | ||
| }; | ||
| enum TypeParamBoundVerbatim { | ||
| Ellipsis, | ||
| TildeConst(TraitBound), | ||
| Const(TraitBound, TraitBoundConst), | ||
| } | ||
@@ -169,21 +175,51 @@ | ||
| fn parse(input: ParseStream) -> Result<Self> { | ||
| if input.peek(Token![...]) { | ||
| input.parse::<Token![...]>()?; | ||
| return Ok(TypeParamBoundVerbatim::Ellipsis); | ||
| } | ||
| let content; | ||
| let (paren_token, content) = if input.peek(token::Paren) { | ||
| (Some(parenthesized!(content in input)), &content) | ||
| let content = if input.peek(token::Paren) { | ||
| parenthesized!(content in input); | ||
| &content | ||
| } else { | ||
| (None, input) | ||
| input | ||
| }; | ||
| let lookahead = content.lookahead1(); | ||
| if lookahead.peek(Token![~]) { | ||
| content.parse::<Token![~]>()?; | ||
| let lifetimes: Option<BoundLifetimes> = content.parse()?; | ||
| let constness = if content.peek(token::Bracket) { | ||
| let conditionally_const; | ||
| bracketed!(conditionally_const in content); | ||
| conditionally_const.parse::<Token![const]>()?; | ||
| TraitBoundConst::Conditional | ||
| } else if content.peek(Token![const]) { | ||
| content.parse::<Token![const]>()?; | ||
| let mut bound: TraitBound = content.parse()?; | ||
| bound.paren_token = paren_token; | ||
| Ok(TypeParamBoundVerbatim::TildeConst(bound)) | ||
| } else if lookahead.peek(Token![...]) { | ||
| content.parse::<Token![...]>()?; | ||
| Ok(TypeParamBoundVerbatim::Ellipsis) | ||
| TraitBoundConst::Unconditional | ||
| } else { | ||
| Err(lookahead.error()) | ||
| TraitBoundConst::None | ||
| }; | ||
| let modifier: TraitBoundModifier = content.parse()?; | ||
| let mut path: Path = content.parse()?; | ||
| if path.segments.last().unwrap().arguments.is_empty() | ||
| && (content.peek(token::Paren) | ||
| || content.peek(Token![::]) && content.peek3(token::Paren)) | ||
| { | ||
| content.parse::<Option<Token![::]>>()?; | ||
| let args: ParenthesizedGenericArguments = content.parse()?; | ||
| let parenthesized = PathArguments::Parenthesized(args); | ||
| path.segments.last_mut().unwrap().arguments = parenthesized; | ||
| } | ||
| Ok(TypeParamBoundVerbatim::Const( | ||
| TraitBound { | ||
| paren_token: None, | ||
| modifier, | ||
| lifetimes, | ||
| path, | ||
| }, | ||
| constness, | ||
| )) | ||
| } | ||
@@ -201,5 +237,4 @@ } | ||
| } | ||
| TypeParamBoundVerbatim::TildeConst(trait_bound) => { | ||
| let tilde_const = true; | ||
| self.trait_bound(&trait_bound, tilde_const); | ||
| TypeParamBoundVerbatim::Const(trait_bound, constness) => { | ||
| self.trait_bound(&trait_bound, constness); | ||
| } | ||
@@ -389,1 +424,9 @@ } | ||
| } | ||
| enum TraitBoundConst { | ||
| None, | ||
| #[cfg(feature = "verbatim")] | ||
| Conditional, | ||
| #[cfg(feature = "verbatim")] | ||
| Unconditional, | ||
| } |
+1
-1
@@ -323,3 +323,3 @@ //! [![github]](https://github.com/dtolnay/prettyplease) [![crates-io]](https://crates.io/crates/prettyplease) [![docs-rs]](https://docs.rs/prettyplease) | ||
| #![doc(html_root_url = "https://docs.rs/prettyplease/0.2.36")] | ||
| #![doc(html_root_url = "https://docs.rs/prettyplease/0.2.37")] | ||
| #![allow( | ||
@@ -326,0 +326,0 @@ clippy::bool_to_int_with_if, |
+0
-13
@@ -183,3 +183,2 @@ use crate::algorithm::Printer; | ||
| MutSelf(MutSelf), | ||
| NotType(NotType), | ||
| } | ||
@@ -203,6 +202,2 @@ | ||
| struct NotType { | ||
| inner: Type, | ||
| } | ||
| impl Parse for TypeVerbatim { | ||
@@ -235,6 +230,2 @@ fn parse(input: ParseStream) -> Result<Self> { | ||
| Ok(TypeVerbatim::MutSelf(MutSelf { ty })) | ||
| } else if lookahead.peek(Token![!]) { | ||
| input.parse::<Token![!]>()?; | ||
| let inner: Type = input.parse()?; | ||
| Ok(TypeVerbatim::NotType(NotType { inner })) | ||
| } else if lookahead.peek(Token![...]) { | ||
@@ -300,6 +291,2 @@ input.parse::<Token![...]>()?; | ||
| } | ||
| TypeVerbatim::NotType(ty) => { | ||
| self.word("!"); | ||
| self.ty(&ty.inner); | ||
| } | ||
| } | ||
@@ -306,0 +293,0 @@ } |
Sorry, the diff of this file is not supported yet