diff --git a/mutest-emit/src/codegen/ast.rs b/mutest-emit/src/codegen/ast.rs index ebd657f0..03f09089 100644 --- a/mutest-emit/src/codegen/ast.rs +++ b/mutest-emit/src/codegen/ast.rs @@ -656,7 +656,10 @@ pub mod mk { } pub fn expr_str(sp: Span, str: &str) -> Box { - 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 { diff --git a/mutest-emit/src/codegen/harness.rs b/mutest-emit/src/codegen/harness.rs index b9544f57..3f3a8f6d 100644 --- a/mutest-emit/src/codegen/harness.rs +++ b/mutest-emit/src/codegen/harness.rs @@ -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; @@ -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), { @@ -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)) }), ]) }