mirror of https://github.com/zkat/miette.git
Make rustfmt no longer complain over lines that are too long which it can't format
Signed-off-by: Justus Flügel <justusfluegel@gmail.com>
This commit is contained in:
parent
e42637d428
commit
a23114fffe
|
|
@ -56,13 +56,25 @@ impl Code {
|
|||
let code = &code.as_ref()?.0;
|
||||
Some(match fields {
|
||||
syn::Fields::Named(_) => {
|
||||
quote! { Self::#ident { .. } => std::option::Option::Some(std::boxed::Box::new(#code)), }
|
||||
quote! {
|
||||
Self::#ident { .. } => {
|
||||
std::option::Option::Some(std::boxed::Box::new(#code))
|
||||
},
|
||||
}
|
||||
}
|
||||
syn::Fields::Unnamed(_) => {
|
||||
quote! { Self::#ident(..) => std::option::Option::Some(std::boxed::Box::new(#code)), }
|
||||
quote! {
|
||||
Self::#ident(..) => {
|
||||
std::option::Option::Some(std::boxed::Box::new(#code))
|
||||
},
|
||||
}
|
||||
}
|
||||
syn::Fields::Unit => {
|
||||
quote! { Self::#ident => std::option::Option::Some(std::boxed::Box::new(#code)), }
|
||||
quote! {
|
||||
Self::#ident => {
|
||||
std::option::Option::Some(std::boxed::Box::new(#code))
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -312,7 +312,9 @@ impl Diagnostic {
|
|||
forward.gen_struct_method(WhichFn::DiagnosticSource);
|
||||
|
||||
quote! {
|
||||
impl #impl_generics miette::Diagnostic for #ident #ty_generics #where_clause {
|
||||
impl #impl_generics miette::Diagnostic
|
||||
for #ident #ty_generics
|
||||
#where_clause {
|
||||
#code_method
|
||||
#help_method
|
||||
#url_method
|
||||
|
|
@ -372,7 +374,9 @@ impl Diagnostic {
|
|||
.and_then(|x| x.gen_struct())
|
||||
.or_else(|| forward(WhichFn::DiagnosticSource));
|
||||
quote! {
|
||||
impl #impl_generics miette::Diagnostic for #ident #ty_generics #where_clause {
|
||||
impl #impl_generics miette::Diagnostic
|
||||
for #ident #ty_generics
|
||||
#where_clause {
|
||||
#code_body
|
||||
#help_body
|
||||
#sev_body
|
||||
|
|
|
|||
|
|
@ -72,10 +72,14 @@ impl WhichFn {
|
|||
fn severity(&self) -> std::option::Option<miette::Severity>
|
||||
},
|
||||
Self::Related => quote! {
|
||||
fn related(&self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = &dyn miette::Diagnostic> + '_>>
|
||||
fn related(&self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::iter::Iterator<Item = &dyn miette::Diagnostic> + '_>
|
||||
>
|
||||
},
|
||||
Self::Labels => quote! {
|
||||
fn labels(&self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = miette::LabeledSpan> + '_>>
|
||||
fn labels(&self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::iter::Iterator<Item = miette::LabeledSpan> + '_>
|
||||
>
|
||||
},
|
||||
Self::SourceCode => quote! {
|
||||
fn source_code(&self) -> std::option::Option<&dyn miette::SourceCode>
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ impl Help {
|
|||
Help::Display(display) => {
|
||||
let (fmt, args) = display.expand_shorthand_cloned(&display_members);
|
||||
Some(quote! {
|
||||
Self::#ident #display_pat => std::option::Option::Some(std::boxed::Box::new(format!(#fmt #args))),
|
||||
Self::#ident #display_pat => {
|
||||
std::option::Option::Some(std::boxed::Box::new(format!(#fmt #args)))
|
||||
},
|
||||
})
|
||||
}
|
||||
Help::Field(member, ty) => {
|
||||
|
|
@ -123,7 +125,9 @@ impl Help {
|
|||
Help::Display(display) => {
|
||||
let (fmt, args) = display.expand_shorthand_cloned(&display_members);
|
||||
Some(quote! {
|
||||
fn help(&self) -> std::option::Option<std::boxed::Box<dyn std::fmt::Display + '_>> {
|
||||
fn help(&self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::fmt::Display + '_>
|
||||
> {
|
||||
#[allow(unused_variables, deprecated)]
|
||||
let Self #display_pat = self;
|
||||
std::option::Option::Some(std::boxed::Box::new(format!(#fmt #args)))
|
||||
|
|
@ -133,7 +137,9 @@ impl Help {
|
|||
Help::Field(member, ty) => {
|
||||
let var = quote! { __miette_internal_var };
|
||||
Some(quote! {
|
||||
fn help(&self) -> std::option::Option<std::boxed::Box<dyn std::fmt::Display + '_>> {
|
||||
fn help(&self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::fmt::Display + '_>
|
||||
> {
|
||||
#[allow(unused_variables, deprecated)]
|
||||
let Self #display_pat = self;
|
||||
use miette::macro_helpers::ToOption;
|
||||
|
|
|
|||
|
|
@ -253,7 +253,9 @@ impl Labels {
|
|||
|
||||
Some(quote! {
|
||||
#[allow(unused_variables)]
|
||||
fn labels(&self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = miette::LabeledSpan> + '_>> {
|
||||
fn labels(&self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::iter::Iterator<Item = miette::LabeledSpan> + '_>
|
||||
> {
|
||||
use miette::macro_helpers::ToOption;
|
||||
let Self #display_pat = self;
|
||||
|
||||
|
|
@ -263,7 +265,10 @@ impl Labels {
|
|||
.into_iter()
|
||||
#(#collections_chain)*;
|
||||
|
||||
std::option::Option::Some(Box::new(labels_iter.filter(Option::is_some).map(Option::unwrap)))
|
||||
std::option::Option::Some(Box::new(
|
||||
labels_iter
|
||||
.filter_map(|x| x)
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -276,7 +281,12 @@ impl Labels {
|
|||
let (display_pat, display_members) = display_pat_members(fields);
|
||||
labels.as_ref().and_then(|labels| {
|
||||
let variant_labels = labels.0.iter().filter_map(|label| {
|
||||
let Label { span, label, ty, lbl_ty } = label;
|
||||
let Label {
|
||||
span,
|
||||
label,
|
||||
ty,
|
||||
lbl_ty,
|
||||
} = label;
|
||||
if *lbl_ty == LabelType::Collection {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -313,7 +323,12 @@ impl Labels {
|
|||
})
|
||||
});
|
||||
let collections_chain = labels.0.iter().filter_map(|label| {
|
||||
let Label { span, label, ty: _, lbl_ty } = label;
|
||||
let Label {
|
||||
span,
|
||||
label,
|
||||
ty: _,
|
||||
lbl_ty,
|
||||
} = label;
|
||||
if *lbl_ty != LabelType::Collection {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -357,7 +372,10 @@ impl Labels {
|
|||
]
|
||||
.into_iter()
|
||||
#(#collections_chain)*;
|
||||
std::option::Option::Some(std::boxed::Box::new(labels_iter.filter(Option::is_some).map(Option::unwrap)))
|
||||
std::option::Option::Some(std::boxed::Box::new(
|
||||
labels_iter
|
||||
.filter_map(|x| x)
|
||||
))
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ impl Related {
|
|||
pub(crate) fn gen_struct(&self) -> Option<TokenStream> {
|
||||
let rel = &self.0;
|
||||
Some(quote! {
|
||||
fn related<'a>(&'a self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = &'a dyn miette::Diagnostic> + 'a>> {
|
||||
fn related<'a>(&'a self) -> std::option::Option<
|
||||
std::boxed::Box<dyn std::iter::Iterator<Item = &'a dyn miette::Diagnostic> + 'a>
|
||||
> {
|
||||
use ::core::borrow::Borrow;
|
||||
std::option::Option::Some(std::boxed::Box::new(
|
||||
self.#rel.iter().map(|x| -> &(dyn miette::Diagnostic) { &*x.borrow() })
|
||||
|
|
|
|||
|
|
@ -71,9 +71,11 @@ impl Severity {
|
|||
syn::Fields::Unnamed(_) => quote! { (..) },
|
||||
syn::Fields::Unit => quote! {},
|
||||
};
|
||||
Some(
|
||||
quote! { Self::#ident #fields => std::option::Option::Some(miette::Severity::#severity), },
|
||||
)
|
||||
Some(quote! {
|
||||
Self::#ident #fields => {
|
||||
std::option::Option::Some(miette::Severity::#severity)
|
||||
},
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,8 +412,10 @@ impl TraitBoundStore {
|
|||
let type_opts_deref_item = self
|
||||
.0
|
||||
.entry((
|
||||
Some(syn::parse_quote!(for<'__miette_internal_lt>)),
|
||||
syn::parse_quote!(<<#ty as ::std::iter::IntoIterator>::Item as ::std::ops::Deref>::Target),
|
||||
Some(syn::parse_quote! {for<'__miette_internal_lt>}),
|
||||
syn::parse_quote! {
|
||||
<<#ty as ::std::iter::IntoIterator>::Item as ::std::ops::Deref>::Target
|
||||
},
|
||||
))
|
||||
.or_default();
|
||||
type_opts_deref_item.register_to_owned_usage();
|
||||
|
|
@ -421,8 +423,16 @@ impl TraitBoundStore {
|
|||
let type_opts_deref_to_owned_item = self
|
||||
.0
|
||||
.entry((
|
||||
Some(syn::parse_quote!(for<'__miette_internal_lt>)),
|
||||
syn::parse_quote!(<<<#ty as ::std::iter::IntoIterator>::Item as ::std::ops::Deref>::Target as ::std::borrow::ToOwned>::Owned),
|
||||
Some(syn::parse_quote! {for<'__miette_internal_lt>}),
|
||||
syn::parse_quote! {
|
||||
<
|
||||
<
|
||||
<#ty as ::std::iter::IntoIterator>::Item
|
||||
as ::std::ops::Deref
|
||||
>::Target
|
||||
as ::std::borrow::ToOwned
|
||||
>::Owned
|
||||
},
|
||||
))
|
||||
.or_default();
|
||||
type_opts_deref_to_owned_item.register_label_usage();
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ impl Url {
|
|||
}
|
||||
};
|
||||
Some(quote! {
|
||||
Self::#ident #pat => std::option::Option::Some(std::boxed::Box::new(format!(#fmt #args))),
|
||||
Self::#ident #pat => {
|
||||
std::option::Option::Some(std::boxed::Box::new(format!(#fmt #args)))
|
||||
},
|
||||
})
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1401,13 +1401,17 @@ impl Line {
|
|||
/// text on this line
|
||||
fn span_applies(&self, span: &FancySpan) -> bool {
|
||||
let spanlen = if span.len() == 0 { 1 } else { span.len() };
|
||||
// Span starts in this line
|
||||
|
||||
(span.offset() >= self.offset && span.offset() < self.offset + self.length)
|
||||
// Span passes through this line
|
||||
|| (span.offset() < self.offset && span.offset() + spanlen > self.offset + self.length) //todo
|
||||
// Span ends on this line
|
||||
|| (span.offset() + spanlen > self.offset && span.offset() + spanlen <= self.offset + self.length)
|
||||
let span_starts_this_line =
|
||||
span.offset() >= self.offset && span.offset() < self.offset + self.length;
|
||||
|
||||
let span_passes_through_this_line =
|
||||
span.offset() < self.offset && span.offset() + spanlen > self.offset + self.length;
|
||||
|
||||
let span_ends_on_this_line = span.offset() + spanlen > self.offset
|
||||
&& span.offset() + spanlen <= self.offset + self.length;
|
||||
|
||||
span_starts_this_line || span_passes_through_this_line || span_ends_on_this_line
|
||||
}
|
||||
|
||||
/// Returns whether `span` should be visible on this line in the gutter (so this excludes spans
|
||||
|
|
|
|||
Loading…
Reference in New Issue