Skip to content

Commit

Permalink
fail -> panic
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Oct 30, 2014
1 parent 4e8193b commit f966f1a
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 72 deletions.
32 changes: 16 additions & 16 deletions src/lib/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ impl RustType {
fn ref_str(&self, lt: &str) -> String {
match *self {
RustRef(ref param) => format!("&'{} {}", lt, *param),
_ => fail!("not a ref: {}", *self),
_ => panic!("not a ref: {}", *self),
}
}

fn mut_ref_str(&self, lt: &str) -> String {
match *self {
RustRef(ref param) => format!("&'{} mut {}", lt, *param),
_ => fail!("not a ref: {}", *self),
_ => panic!("not a ref: {}", *self),
}
}

Expand Down Expand Up @@ -106,7 +106,7 @@ impl RustType {
RustRef(box RustMessage(ref name)) => format!("{}::default_instance()", name),
// TODO: use proper constant
RustEnum(ref name) => format!("{}::new(0)", name),
_ => fail!("cannot create default value for: {}", *self),
_ => panic!("cannot create default value for: {}", *self),
}
}

Expand All @@ -116,7 +116,7 @@ impl RustType {
RustOption(..) => format!("Some({})", value),
RustSingularField(..) => format!("::protobuf::SingularField::some({})", value),
RustSingularPtrField(..) => format!("::protobuf::SingularPtrField::some({})", value),
_ => fail!("not a wrapper type: {}", *self),
_ => panic!("not a wrapper type: {}", *self),
}
}

Expand All @@ -131,7 +131,7 @@ impl RustType {
fn into(&self, target: &RustType, v: &str) -> String {
match (self, target) {
(x, y) if x == y => v.to_string(),
_ => fail!("internal error: cannot convert {} to {}", self, target),
_ => panic!("internal error: cannot convert {} to {}", self, target),
}
}

Expand All @@ -141,7 +141,7 @@ impl RustType {
&RustVec(ref p) |
&RustRepeatedField(ref p) => box RustSlice(p.clone()),
&RustMessage(ref p) => box RustMessage(p.clone()),
x => fail!("no ref type for {}", x),
x => panic!("no ref type for {}", x),
})
}
}
Expand All @@ -166,7 +166,7 @@ fn rust_name(field_type: FieldDescriptorProto_Type) -> RustType {
FieldDescriptorProto_TYPE_BYTES => RustVec(box RustUnsigned(8)),
FieldDescriptorProto_TYPE_ENUM |
FieldDescriptorProto_TYPE_GROUP |
FieldDescriptorProto_TYPE_MESSAGE => fail!()
FieldDescriptorProto_TYPE_MESSAGE => panic!()
}
}

Expand All @@ -190,7 +190,7 @@ fn protobuf_name(field_type: FieldDescriptorProto_Type) -> &'static str {
FieldDescriptorProto_TYPE_BYTES => "bytes",
FieldDescriptorProto_TYPE_ENUM |
FieldDescriptorProto_TYPE_GROUP |
FieldDescriptorProto_TYPE_MESSAGE => fail!()
FieldDescriptorProto_TYPE_MESSAGE => panic!()
}
}

Expand All @@ -214,7 +214,7 @@ fn field_type_wire_type(field_type: FieldDescriptorProto_Type) -> wire_format::W
FieldDescriptorProto_TYPE_STRING => WireTypeLengthDelimited,
FieldDescriptorProto_TYPE_BYTES => WireTypeLengthDelimited,
FieldDescriptorProto_TYPE_MESSAGE => WireTypeLengthDelimited,
FieldDescriptorProto_TYPE_GROUP => fail!()
FieldDescriptorProto_TYPE_GROUP => panic!()
}
}

Expand Down Expand Up @@ -243,12 +243,12 @@ fn field_type_name(field: &FieldDescriptorProto, pkg: &str) -> RustType {
match field.get_field_type() {
FieldDescriptorProto_TYPE_MESSAGE => RustMessage(name),
FieldDescriptorProto_TYPE_ENUM => RustEnum(name),
_ => fail!("unknown named type: {}", field.get_field_type()),
_ => panic!("unknown named type: {}", field.get_field_type()),
}
} else if field.has_field_type() {
rust_name(field.get_field_type())
} else {
fail!("neither type_name, nor field_type specified for field: {}", field.get_name());
panic!("neither type_name, nor field_type specified for field: {}", field.get_name());
}
}

Expand Down Expand Up @@ -420,7 +420,7 @@ impl Field {
FieldDescriptorProto_TYPE_ENUM => format!("{}", proto_default),
FieldDescriptorProto_TYPE_GROUP |
FieldDescriptorProto_TYPE_MESSAGE =>
fail!("default value is not implemented for type: {}", self.field_type)
panic!("default value is not implemented for type: {}", self.field_type)
})
} else {
None
Expand Down Expand Up @@ -838,7 +838,7 @@ impl<'a> IndentWriter<'a> {

#[allow(dead_code)]
fn fail<S : Str>(&self, reason: S) {
self.write_line(format!("fail!({});", reason.as_slice()));
self.write_line(format!("panic!({});", reason.as_slice()));
}

#[allow(dead_code)]
Expand Down Expand Up @@ -939,7 +939,7 @@ fn write_merge_from_field_message_string_bytes(w: &mut IndentWriter) {
FieldDescriptorProto_TYPE_BYTES =>
w.write_line(format!("try!(is.read_bytes_into(tmp))")),
_ =>
fail!(),
panic!(),
}
}

Expand Down Expand Up @@ -973,7 +973,7 @@ fn write_merge_from_field(w: &mut IndentWriter) {
match repeat_mode {
Single => w.self_field_assign_some("tmp"),
RepeatRegular => w.self_field_push("tmp"),
_ => fail!()
_ => panic!()
}
},
RepeatPacked => {
Expand Down Expand Up @@ -1548,7 +1548,7 @@ fn write_enum_impl(w: &mut IndentWriter) {
for value in w.en().values.iter() {
w.write_line(format!("{:d} => {:s},", value.number(), value.rust_name()));
}
w.write_line(format!("_ => fail!()"));
w.write_line(format!("_ => panic!()"));
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/lib/core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO: drop all fail!
// TODO: drop all panic!

use std::mem;
use std::raw;
Expand Down Expand Up @@ -99,11 +99,11 @@ pub trait Message : PartialEq + Clone + Default + fmt::Show + Clear {

// http://stackoverflow.com/q/20342436/15018
fn descriptor_static(_: Option<Self>) -> &'static MessageDescriptor {
fail!();
panic!();
}

fn type_id(&self) -> TypeId {
fail!();
panic!();
}

// Rust does not allow implementation of trait for trait:
Expand Down Expand Up @@ -142,7 +142,7 @@ pub trait ProtobufEnum : Eq {

// http://stackoverflow.com/q/20342436/15018
fn enum_descriptor_static(_: Option<Self>) -> &'static EnumDescriptor {
fail!();
panic!();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ impl FieldDescriptorProto_Type {
16 => FieldDescriptorProto_TYPE_SFIXED64,
17 => FieldDescriptorProto_TYPE_SINT32,
18 => FieldDescriptorProto_TYPE_SINT64,
_ => fail!()
_ => panic!()
}
}
}
Expand Down Expand Up @@ -2462,7 +2462,7 @@ impl FieldDescriptorProto_Label {
1 => FieldDescriptorProto_LABEL_OPTIONAL,
2 => FieldDescriptorProto_LABEL_REQUIRED,
3 => FieldDescriptorProto_LABEL_REPEATED,
_ => fail!()
_ => panic!()
}
}
}
Expand Down Expand Up @@ -4522,7 +4522,7 @@ impl FileOptions_OptimizeMode {
1 => FileOptions_SPEED,
2 => FileOptions_CODE_SIZE,
3 => FileOptions_LITE_RUNTIME,
_ => fail!()
_ => panic!()
}
}
}
Expand Down Expand Up @@ -5401,7 +5401,7 @@ impl FieldOptions_CType {
0 => FieldOptions_STRING,
1 => FieldOptions_CORD,
2 => FieldOptions_STRING_PIECE,
_ => fail!()
_ => panic!()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::char;
fn decode_hex_digit(digit: char) -> u8 {
match char::to_digit(digit, 16) {
Some(d) => d as u8,
_ => fail!()
_ => panic!()
}
}

Expand All @@ -26,15 +26,15 @@ pub fn decode_hex(hex: &str) -> Vec<u8> {
if pos == hex.char_len() {
break;
}
fail!("pos = {:u}d", pos);
panic!("pos = {:u}d", pos);
}
r
}

fn encode_hex_digit(digit: u8) -> char {
match char::from_digit(digit as uint, 16) {
Some(c) => c,
_ => fail!()
_ => panic!()
}
}

Expand Down
48 changes: 24 additions & 24 deletions src/lib/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,99 +18,99 @@ pub trait FieldAccessor<M : Message> {
fn name(&self) -> &'static str;

fn has_field(&self, _m: &M) -> bool {
fail!();
panic!();
}

fn len_field(&self, _m: &M) -> uint {
fail!();
panic!();
}

fn get_message<'a>(&self, _m: &'a M) -> &'a Message {
fail!();
panic!();
}

fn get_rep_message_item<'a>(&self, _m: &'a M, _index: uint) -> &'a Message {
fail!();
panic!();
}

fn get_enum(&self, _m: &M) -> &'static EnumValueDescriptor {
fail!();
panic!();
}

fn get_rep_enum_item(&self, _m: &M, _index: uint) -> &'static EnumValueDescriptor {
fail!();
panic!();
}

fn get_str<'a>(&self, _m: &'a M) -> &'a str {
fail!();
panic!();
}

fn get_rep_str<'a>(&self, _m: &'a M) -> &'a [String] {
fail!();
panic!();
}

fn get_bytes<'a>(&self, _m: &'a M) -> &'a [u8] {
fail!();
panic!();
}

fn get_rep_bytes<'a>(&self, _m: &'a M) -> &'a [Vec<u8>] {
fail!();
panic!();
}

fn get_u32(&self, _m: &M) -> u32 {
fail!();
panic!();
}

fn get_rep_u32<'a>(&self, _m: &'a M) -> &'a [u32] {
fail!();
panic!();
}

fn get_u64(&self, _m: &M) -> u64 {
fail!();
panic!();
}

fn get_rep_u64<'a>(&self, _m: &'a M) -> &'a [u64] {
fail!();
panic!();
}

fn get_i32(&self, _m: &M) -> i32 {
fail!();
panic!();
}

fn get_rep_i32<'a>(&self, _m: &'a M) -> &'a [i32] {
fail!();
panic!();
}

fn get_i64(&self, _m: &M) -> i64 {
fail!();
panic!();
}

fn get_rep_i64<'a>(&self, _m: &'a M) -> &'a [i64] {
fail!();
panic!();
}

fn get_bool(&self, _m: &M) -> bool {
fail!();
panic!();
}

fn get_rep_bool<'a>(&self, _m: &'a M) -> &'a [bool] {
fail!();
panic!();
}

fn get_f32(&self, _m: &M) -> f32 {
fail!();
panic!();
}

fn get_rep_f32<'a>(&self, _m: &'a M) -> &'a [f32] {
fail!();
panic!();
}

fn get_f64(&self, _m: &M) -> f64 {
fail!();
panic!();
}

fn get_rep_f64<'a>(&self, _m: &'a M) -> &'a [f64] {
fail!();
panic!();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn value_size_no_tag<T : ProtobufVarint>(value: T, wt: wire_format::WireType
wire_format::WireTypeFixed64 => 8,
wire_format::WireTypeFixed32 => 4,
wire_format::WireTypeVarint => value.len_varint(),
_ => fail!()
_ => panic!()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/shrug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6595,7 +6595,7 @@ impl TestEnumDescriptor {
1 => RED,
2 => BLUE,
3 => GREEN,
_ => fail!()
_ => panic!()
}
}
}
Expand Down Expand Up @@ -6628,7 +6628,7 @@ impl EnumForDefaultValue {
1 => ONE,
2 => TWO,
3 => THREE,
_ => fail!()
_ => panic!()
}
}
}
Expand Down
Loading

0 comments on commit f966f1a

Please sign in to comment.