Skip to content

Commit 09a9c83

Browse files
committed
fix format string escaping
see rust-lang/rust#14810
1 parent f3e39d9 commit 09a9c83

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/lib/codegen.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,15 +659,15 @@ impl<'a> IndentWriter<'a> {
659659
}
660660

661661
fn lazy_static<S1 : Str, S2 : Str>(&mut self, name: S1, ty: S2) {
662-
self.write_line(format!("static mut {:s}: ::protobuf::lazy::Lazy<{:s}> = ::protobuf::lazy::Lazy \\{ lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *{:s} \\};", name, ty, ty));
662+
self.write_line(format!("static mut {:s}: ::protobuf::lazy::Lazy<{:s}> = ::protobuf::lazy::Lazy {{ lock: ::protobuf::lazy::ONCE_INIT, ptr: 0 as *{:s} }};", name, ty, ty));
663663
}
664664

665665
fn lazy_static_decl_get<S1 : Str, S2 : Str>(&mut self, name: S1, ty: S2, init: |&mut IndentWriter|) {
666666
self.lazy_static(name.as_slice(), ty);
667667
self.unsafe_expr(|w| {
668-
w.write_line(format!("{:s}.get(|| \\{", name));
668+
w.write_line(format!("{:s}.get(|| {{", name));
669669
w.indented(|w| init(w));
670-
w.write_line(format!("\\})"));
670+
w.write_line(format!("}})"));
671671
});
672672
}
673673

@@ -678,11 +678,11 @@ impl<'a> IndentWriter<'a> {
678678
}
679679

680680
fn expr_block<S : Str>(&self, prefix: S, cb: |&mut IndentWriter|) {
681-
self.block(format!("{:s} \\{", prefix), "}", cb);
681+
self.block(format!("{:s} {{", prefix), "}", cb);
682682
}
683683

684684
fn stmt_block<S : Str>(&self, prefix: S, cb: |&mut IndentWriter|) {
685-
self.block(format!("{:s} \\{", prefix), "};", cb);
685+
self.block(format!("{:s} {{", prefix), "};", cb);
686686
}
687687

688688
fn unsafe_expr(&self, cb: |&mut IndentWriter|) {
@@ -766,7 +766,7 @@ impl<'a> IndentWriter<'a> {
766766
}
767767

768768
fn case_block<S : Str>(&self, cond: S, cb: |&mut IndentWriter|) {
769-
self.block(format!("{:s} => \\{", cond), "},", cb);
769+
self.block(format!("{:s} => {{", cond), "},", cb);
770770
}
771771

772772
fn case_expr<S1 : Str, S2 : Str>(&self, cond: S1, body: S2) {
@@ -833,7 +833,7 @@ fn write_merge_from_field(w: &mut IndentWriter) {
833833
}
834834
},
835835
RepeatPacked => {
836-
w.write_line(format!("if wire_type == ::protobuf::wire_format::{:?} \\{", wire_format::WireTypeLengthDelimited));
836+
w.write_line(format!("if wire_type == ::protobuf::wire_format::{:?} {{", wire_format::WireTypeLengthDelimited));
837837
w.indented(|w| {
838838
w.write_line("let len = is.read_raw_varint32();");
839839
w.write_line("let old_limit = is.push_limit(len);");
@@ -1240,7 +1240,7 @@ fn write_message_impl_message(w: &mut IndentWriter) {
12401240
for field in msg.fields.iter() {
12411241
let acc_name = format!("{}_{}_acc", msg.type_name, field.name);
12421242
// TODO: transmute is because of https://github.com/mozilla/rust/issues/13887
1243-
w.write_line(format!("fields.push(unsafe \\{ ::std::mem::transmute(&'static {} as &::protobuf::reflect::FieldAccessor<{}>) \\});",
1243+
w.write_line(format!("fields.push(unsafe {{ ::std::mem::transmute(&'static {} as &::protobuf::reflect::FieldAccessor<{}>) }});",
12441244
acc_name, msg.type_name));
12451245
}
12461246
w.write_line(format!("::protobuf::reflect::MessageDescriptor::new::<{}>(", msg.type_name));
@@ -1423,11 +1423,11 @@ fn write_message(msg: &Message, w: &mut IndentWriter) {
14231423

14241424
fn write_enum_struct(w: &mut IndentWriter) {
14251425
w.deriving(["Clone", "PartialEq", "Eq", "Show"]);
1426-
w.write_line(format!("pub enum {:s} \\{", w.en().type_name));
1426+
w.write_line(format!("pub enum {:s} {{", w.en().type_name));
14271427
for value in w.en().values.iter() {
14281428
w.write_line(format!(" {:s} = {:i},", value.rust_name(), value.number()));
14291429
}
1430-
w.write_line(format!("\\}"));
1430+
w.write_line(format!("}}"));
14311431
}
14321432

14331433
fn write_enum_impl(w: &mut IndentWriter) {

0 commit comments

Comments
 (0)