Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mutest-emit/src/codegen/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ pub mod mk {
}

pub fn expr_str(sp: Span, str: &str) -> Box<ast::Expr> {
self::expr_lit(sp, ast::token::LitKind::Str, Symbol::intern(str), None)
// Escape the string, since the literal's symbol is unescaped by rustc
// (e.g. backslashes in Windows paths would otherwise be invalid escapes).
let escaped = crate::analysis::diagnostic::escape_literal(str);
self::expr_lit(sp, ast::token::LitKind::Str, Symbol::intern(&escaped), None)
}

pub fn expr_tuple(sp: Span, exprs: ThinVec<Box<ast::Expr>>) -> Box<ast::Expr> {
Expand Down
5 changes: 2 additions & 3 deletions mutest-emit/src/codegen/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc_middle::ty::TyCtxt;
use thin_vec::{ThinVec, thin_vec};

use crate::analysis::call_graph::{EntryPoints, TargetReachability, Unsafety};
use crate::analysis::diagnostic;
use crate::analysis::hir;
use crate::codegen::ast;
use crate::codegen::expansion::TcxExpansionExt;
Expand Down Expand Up @@ -76,7 +75,7 @@ pub fn bake_mutation<'tcx, 'ent>(sp: Span, tcx: TyCtxt<'tcx>, entry_points: Entr
ast::mk::expr_str(sp, &mutation.display_name())
}),
ast::mk::expr_struct_field(sp, Ident::new(sym::display_location, sp), {
ast::mk::expr_str(sp, &diagnostic::escape_literal(&mutation.display_location(tcx.sess)))
ast::mk::expr_str(sp, &mutation.display_location(tcx.sess))
}),

ast::mk::expr_struct_field(sp, Ident::new(sym::reachable_from, sp), {
Expand All @@ -102,7 +101,7 @@ pub fn bake_mutation<'tcx, 'ent>(sp: Span, tcx: TyCtxt<'tcx>, entry_points: Entr
}),

ast::mk::expr_struct_field(sp, Ident::new(sym::undetected_diagnostic, sp), {
ast::mk::expr_str(sp, &diagnostic::escape_literal(&mutation.undetected_diagnostic(tcx.sess)))
ast::mk::expr_str(sp, &mutation.undetected_diagnostic(tcx.sess))
}),
])
}
Expand Down