add #[non_exhaustive] · mode9/RustPython@9377134 · GitHub
Skip to content

Commit 9377134

Browse files
committed
add #[non_exhaustive]
1 parent 0040d4e commit 9377134

8 files changed

Lines changed: 22 additions & 15 deletions

File tree

ast/src/constant.rs

Lines changed: 3 additions & 4 deletions

jit/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use instructions::FunctionCompiler;
1313
use std::mem::ManuallyDrop;
1414

1515
#[derive(Debug, thiserror::Error)]
16+
#[non_exhaustive]
1617
pub enum JitCompileError {
1718
#[error("function can't be jitted")]
1819
NotSupported,
@@ -23,6 +24,7 @@ pub enum JitCompileError {
2324
}
2425

2526
#[derive(Debug, thiserror::Error, Eq, PartialEq)]
27+
#[non_exhaustive]
2628
pub enum JitArgumentError {
2729
#[error("argument is of wrong type")]
2830
ArgumentTypeMismatch,
@@ -167,6 +169,7 @@ impl JitSig {
167169
}
168170

169171
#[derive(Debug, Clone, PartialEq)]
172+
#[non_exhaustive]
170173
pub enum JitType {
171174
Int,
172175
Float,
@@ -192,6 +195,7 @@ impl JitType {
192195
}
193196

194197
#[derive(Debug, Clone, PartialEq)]
198+
#[non_exhaustive]
195199
pub enum AbiValue {
196200
Float(f64),
197201
Int(i64),

src/lib.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,15 @@ fn add_stdlib(vm: &mut VirtualMachine) {
310310
/// Create settings by examining command line arguments and environment
311311
/// variables.
312312
fn create_settings(matches: &ArgMatches) -> PySettings {
313-
let mut settings = PySettings {
314-
isolated: matches.is_present("isolate"),
315-
ignore_environment: matches.is_present("ignore-environment"),
316-
interactive: !matches.is_present("c")
317-
&& !matches.is_present("m")
318-
&& (!matches.is_present("script") || matches.is_present("inspect")),
319-
bytes_warning: matches.occurrences_of("bytes-warning"),
320-
no_site: matches.is_present("no-site"),
321-
..Default::default()
322-
};
313+
let mut settings = PySettings::default();
314+
settings.isolated = matches.is_present("isolate");
315+
settings.ignore_environment = matches.is_present("ignore-environment");
316+
settings.interactive = !matches.is_present("c")
317+
&& !matches.is_present("m")
318+
&& (!matches.is_present("script") || matches.is_present("inspect"));
319+
settings.bytes_warning = matches.occurrences_of("bytes-warning");
320+
settings.no_site = matches.is_present("no-site");
321+
323322
let ignore_environment = settings.ignore_environment || settings.isolated;
324323

325324
// when rustpython-vm/pylib is enabled, PySettings::default().path_list has pylib::LIB_PATH

vm/src/builtins/function/jitfunc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl IntoPyObject for AbiValue {
3131
AbiValue::Int(i) => i.into_pyobject(vm),
3232
AbiValue::Float(f) => f.into_pyobject(vm),
3333
AbiValue::Bool(b) => b.into_pyobject(vm),
34+
_ => unimplemented!(),
3435
}
3536
}
3637
}

vm/src/stdlib/posix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub mod module {
160160

161161
// Flags for os_access
162162
bitflags! {
163-
pub struct AccessFlags: u8{
163+
pub struct AccessFlags: u8 {
164164
const F_OK = _os::F_OK;
165165
const R_OK = _os::R_OK;
166166
const W_OK = _os::W_OK;

vm/src/types/slot.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::cmp::Ordering;
1414
// The corresponding field in CPython is `tp_` prefixed.
1515
// e.g. name -> tp_name
1616
#[derive(Default)]
17+
#[non_exhaustive]
1718
pub struct PyTypeSlots {
1819
pub name: PyRwLock<Option<String>>, // tp_name, not class name
1920
// tp_basicsize, tp_itemsize
@@ -84,6 +85,7 @@ impl std::fmt::Debug for PyTypeSlots {
8485
}
8586

8687
bitflags! {
88+
#[non_exhaustive]
8789
pub struct PyTypeFlags: u64 {
8890
const HEAPTYPE = 1 << 9;
8991
const BASETYPE = 1 << 10;

vm/src/types/zoo.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{PyContext, StaticType};
99

1010
/// Holder of references to builtin types.
1111
#[derive(Debug, Clone)]
12+
#[non_exhaustive]
1213
pub struct TypeZoo {
1314
pub async_generator: PyTypeRef,
1415
pub async_generator_asend: PyTypeRef,

vm/src/vm.rs

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)