diff options
| author | Axary <bastian_kauschke@hotmail.de> | 2018-11-11 10:41:49 +0100 |
|---|---|---|
| committer | Axary <bastian_kauschke@hotmail.de> | 2018-11-11 10:41:49 +0100 |
| commit | 50307942481ffd95e9eb616463363542bc79b14b (patch) | |
| tree | 4088a496090b024effdae0ed3beb24791225be46 /src/librustc_codegen_llvm/back/bytecode.rs | |
| parent | 852ff1fc7d74a7668441e0f354f8c477c95b676d (diff) | |
| parent | b76ee83254ec0398da554f25c2168d917ba60f1c (diff) | |
| download | rust-50307942481ffd95e9eb616463363542bc79b14b.tar.gz rust-50307942481ffd95e9eb616463363542bc79b14b.zip | |
Merge branch 'master' of https://github.com/rust-lang/rust
Diffstat (limited to 'src/librustc_codegen_llvm/back/bytecode.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/back/bytecode.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/librustc_codegen_llvm/back/bytecode.rs b/src/librustc_codegen_llvm/back/bytecode.rs index 9a3dd9d2f88..0b264de18c1 100644 --- a/src/librustc_codegen_llvm/back/bytecode.rs +++ b/src/librustc_codegen_llvm/back/bytecode.rs @@ -42,7 +42,7 @@ use flate2::write::DeflateEncoder; // This is the "magic number" expected at the beginning of a LLVM bytecode // object in an rlib. -pub const RLIB_BYTECODE_OBJECT_MAGIC: &'static [u8] = b"RUST_OBJECT"; +pub const RLIB_BYTECODE_OBJECT_MAGIC: &[u8] = b"RUST_OBJECT"; // The version number this compiler will write to bytecode objects in rlibs pub const RLIB_BYTECODE_OBJECT_VERSION: u8 = 2; @@ -106,39 +106,39 @@ pub struct DecodedBytecode<'a> { } impl<'a> DecodedBytecode<'a> { - pub fn new(data: &'a [u8]) -> Result<DecodedBytecode<'a>, String> { + pub fn new(data: &'a [u8]) -> Result<DecodedBytecode<'a>, &'static str> { if !data.starts_with(RLIB_BYTECODE_OBJECT_MAGIC) { - return Err("magic bytecode prefix not found".to_string()) + return Err("magic bytecode prefix not found") } let data = &data[RLIB_BYTECODE_OBJECT_MAGIC.len()..]; if !data.starts_with(&[RLIB_BYTECODE_OBJECT_VERSION, 0, 0, 0]) { - return Err("wrong version prefix found in bytecode".to_string()) + return Err("wrong version prefix found in bytecode") } let data = &data[4..]; if data.len() < 4 { - return Err("bytecode corrupted".to_string()) + return Err("bytecode corrupted") } let identifier_len = unsafe { u32::from_le(ptr::read_unaligned(data.as_ptr() as *const u32)) as usize }; let data = &data[4..]; if data.len() < identifier_len { - return Err("bytecode corrupted".to_string()) + return Err("bytecode corrupted") } let identifier = match str::from_utf8(&data[..identifier_len]) { Ok(s) => s, - Err(_) => return Err("bytecode corrupted".to_string()) + Err(_) => return Err("bytecode corrupted") }; let data = &data[identifier_len..]; if data.len() < 8 { - return Err("bytecode corrupted".to_string()) + return Err("bytecode corrupted") } let bytecode_len = unsafe { u64::from_le(ptr::read_unaligned(data.as_ptr() as *const u64)) as usize }; let data = &data[8..]; if data.len() < bytecode_len { - return Err("bytecode corrupted".to_string()) + return Err("bytecode corrupted") } let encoded_bytecode = &data[..bytecode_len]; |
