Skip to content

Commit

Permalink
rm redundant return_type_to_pretty_string
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Sep 15, 2023
1 parent 46822b2 commit 9214d8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
16 changes: 1 addition & 15 deletions src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use proc_macro2::{Delimiter, TokenTree};
use quote::ToTokens;
use syn::ReturnType;

/// Convert a TokenStream representing some code to a reasonably formatted
/// string of Rust code.
Expand Down Expand Up @@ -69,19 +68,6 @@ pub(crate) fn tokens_to_pretty_string<T: ToTokens>(t: T) -> String {
b
}

pub(crate) fn return_type_to_pretty_string(return_type: &ReturnType) -> String {
match return_type {
ReturnType::Default => String::new(),
ReturnType::Type(arrow, typ) => {
format!(
"{} {}",
arrow.to_token_stream(),
tokens_to_pretty_string(typ)
)
}
}
}

#[cfg(test)]
mod test {
use pretty_assertions::assert_eq;
Expand All @@ -90,7 +76,7 @@ mod test {
use super::tokens_to_pretty_string;

#[test]
fn pretty_format() {
fn pretty_format_examples() {
assert_eq!(
tokens_to_pretty_string(quote! {
<impl Iterator for MergeTrees < AE , BE , AIT , BIT > > :: next
Expand Down
4 changes: 2 additions & 2 deletions src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use syn::{Attribute, Expr, ItemFn, ReturnType};
use tracing::{debug, debug_span, trace, trace_span, warn};

use crate::fnvalue::return_type_replacements;
use crate::pretty::{return_type_to_pretty_string, tokens_to_pretty_string};
use crate::pretty::tokens_to_pretty_string;
use crate::source::SourceFile;
use crate::*;

Expand Down Expand Up @@ -135,7 +135,7 @@ struct DiscoveryVisitor<'o> {
impl<'o> DiscoveryVisitor<'o> {
fn collect_fn_mutants(&mut self, return_type: &ReturnType, span: &proc_macro2::Span) {
let full_function_name = Arc::new(self.namespace_stack.join("::"));
let return_type_str = Arc::new(return_type_to_pretty_string(return_type));
let return_type_str = Arc::new(tokens_to_pretty_string(return_type));
let mut new_mutants = return_type_replacements(return_type, self.error_exprs)
.map(|rep| Mutant {
source_file: Arc::clone(&self.source_file),
Expand Down

0 comments on commit 9214d8d

Please sign in to comment.