Skip to content

Commit 2dd40fd

Browse files
committed
[Rust] use core:error:Error unconditionally
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent bd1b2d0 commit 2dd40fd

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

rust/flatbuffers/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ homepage = "https://google.github.io/flatbuffers/"
99
repository = "https://github.com/google/flatbuffers"
1010
keywords = ["flatbuffers", "serialization", "zero-copy"]
1111
categories = ["encoding", "data-structures", "memory-management"]
12-
rust = "1.51"
12+
rust-version = "1.81"
1313

1414
[features]
1515
default = ["std"]

rust/flatbuffers/src/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#[cfg(not(feature = "std"))]
1817
use alloc::{vec, vec::Vec};
1918
use core::cmp::max;
2019
use core::convert::Infallible;

rust/flatbuffers/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
//! At this time, to generate Rust code, you will need the latest `master` version of `flatc`, available from here: <https://github.com/google/flatbuffers>
2929
//! (On OSX, you can install FlatBuffers from `HEAD` with the Homebrew package manager.)
3030
31-
#![cfg_attr(not(feature = "std"), no_std)]
32-
#![cfg_attr(all(nightly, not(feature = "std")), feature(error_in_core))]
33-
34-
#[cfg(not(feature = "std"))]
3531
extern crate alloc;
3632

3733
mod array;
@@ -56,8 +52,8 @@ pub use crate::push::{Push, PushAlignment};
5652
pub use crate::table::{buffer_has_identifier, Table};
5753
pub use crate::vector::{follow_cast_ref, Vector, VectorIter};
5854
pub use crate::verifier::{
59-
ErrorTraceDetail, InvalidFlatbuffer, SimpleToVerifyInSlice, TableVerifier, Verifiable, Verifier,
60-
VerifierOptions,
55+
ErrorTraceDetail, InvalidFlatbuffer, SimpleToVerifyInSlice, TableVerifier, Verifiable,
56+
Verifier, VerifierOptions,
6157
};
6258
pub use crate::vtable::field_index_to_field_offset;
6359
pub use bitflags;

rust/flatbuffers/src/verifier.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
use crate::follow::Follow;
22
use crate::{ForwardsUOffset, SOffsetT, SkipSizePrefix, UOffsetT, VOffsetT, Vector, SIZE_UOFFSET};
3-
#[cfg(not(feature = "std"))]
3+
use alloc::borrow::Cow;
44
use alloc::vec::Vec;
5+
use core::error::Error;
56
use core::ops::Range;
67
use core::option::Option;
78

8-
#[cfg(not(feature = "std"))]
9-
use alloc::borrow::Cow;
10-
#[cfg(feature = "std")]
11-
use std::borrow::Cow;
12-
13-
#[cfg(all(nightly, not(feature = "std")))]
14-
use core::error::Error;
15-
#[cfg(feature = "std")]
16-
use std::error::Error;
17-
189
/// Traces the location of data errors. Not populated for Dos detecting errors.
1910
/// Useful for MissingRequiredField and Utf8Error in particular, though
2011
/// the other errors should not be producible by correct flatbuffers implementations.
@@ -86,7 +77,6 @@ pub enum InvalidFlatbuffer {
8677
DepthLimitReached,
8778
}
8879

89-
#[cfg(any(nightly, feature = "std"))]
9080
impl Error for InvalidFlatbuffer {
9181
fn source(&self) -> Option<&(dyn Error + 'static)> {
9282
if let InvalidFlatbuffer::Utf8Error { error: source, .. } = self {
@@ -560,7 +550,7 @@ impl<'ver, 'opts, 'buf> TableVerifier<'ver, 'opts, 'buf> {
560550
)?;
561551
Ok(self)
562552
}
563-
_ => InvalidFlatbuffer::new_inconsistent_union(key_field_name.into(), val_field_name.into()),
553+
_ => InvalidFlatbuffer::new_inconsistent_union(key_field_name.into(),val_field_name.into()),
564554
}
565555
}
566556
pub fn finish(self) -> &'ver mut Verifier<'opts, 'buf> {

0 commit comments

Comments
 (0)