8000 Merge pull request #5222 from youknowone/vm-build · RustPython/RustPython@940b879 · GitHub
[go: up one dir, main page]

Skip to content

Commit 940b879

Browse files
authored
Merge pull request #5222 from youknowone/vm-build
Fix rustpython-vm --no-default-features build
2 parents 6342f16 + ccf650d commit 940b879

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"]
1919
[dependencies]
2020
# rustpython crates
2121
rustpython-derive = { workspace = true }
22-
rustpython-vm = { workspace = true, features = ["compiler"] }
22+
rustpython-vm = { workspace = true }
2323
rustpython-common = { workspace = true }
2424

2525
ahash = { workspace = true }

vm/src/compiler.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use crate::{builtins::PyBaseExceptionRef, convert::ToPyException, VirtualMachine};
2-
31
#[cfg(feature = "rustpython-codegen")]
42
pub use rustpython_codegen::CompileOpts;
53
#[cfg(feature = "rustpython-compiler")]
64
pub use rustpython_compiler::*;
5+
#[cfg(not(feature = "rustpython-compiler"))]
6+
pub use rustpython_compiler_core::Mode;
77

88
#[cfg(not(feature = "rustpython-compiler"))]
99
pub use rustpython_compiler_core as core;
1010

11-
#[cfg(all(not(feature = "rustpython-compiler"), feature = "rustpython-parser"))]
11+
#[cfg(not(feature = "rustpython-compiler"))]
1212
pub use rustpython_parser_core as parser;
1313

1414
#[cfg(not(feature = "rustpython-compiler"))]
@@ -26,13 +26,14 @@ mod error {
2626
Parse(#[from] rustpython_parser::error::ParseErrorType),
2727
}
2828

29-
pub type CompileError = rustpython_compiler_core::CompileError<CompileErrorType>;
29+
pub type CompileError = rustpython_parser_core::source_code::LocatedError<CompileErrorType>;
3030
}
3131
#[cfg(not(feature = "rustpython-compiler"))]
3232
pub use error::{CompileError, CompileErrorType};
3333

34-
impl ToPyException for (CompileError, Option<&str>) {
35-
fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef {
34+
#[cfg(any(feature = "rustpython-parser", feature = "rustpython-codegen"))]
35+
impl crate::convert::ToPyException for (CompileError, Option<&str>) {
36+
fn to_pyexception(&self, vm: &crate::VirtualMachine) -> crate::builtins::PyBaseExceptionRef {
3637
vm.new_syntax_error(&self.0, self.1)
3738
}
3839
}

vm/src/stdlib/builtins.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mod builtins {
1717
PyByteArray, PyBytes, PyDictRef, PyStr, PyStrRef, PyTuple, PyTupleRef, PyType,
1818
},
1919
common::{hash::PyHash, str::to_ascii},
20-
convert::ToPyException,
2120
function::{
2221
ArgBytesLike, ArgCallable, ArgIndex, ArgIntoBool, ArgIterable, ArgMapping,
2322
ArgStrOrBytesLike, Either, FsPath, FuncArgs, KwArgs, OptionalArg, OptionalOption,
@@ -147,7 +146,7 @@ mod builtins {
147146
}
148147
#[cfg(feature = "rustpython-parser")]
149148
{
150-
use crate::builtins::PyBytesRef;
149+
use crate::{builtins::PyBytesRef, convert::ToPyException};
151150
use num_traits::Zero;
152151
use rustpython_parser as parser;
153152

vm/src/vm/vm_new.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use crate::{
88
convert::ToPyObject,
99
function::{IntoPyNativeFn, PyMethodFlags},
1010
scope::Scope,
11-
source::AtLocation,
12-
source_code::SourceLocation,
1311
vm::VirtualMachine,
1412
AsObject, Py, PyObject, PyObjectRef, PyRef,
1513
};
@@ -255,6 +253,9 @@ impl VirtualMachine {
255253
error: &crate::compiler::CompileError,
256254
source: Option<&str>,
257255
) -> PyBaseExceptionRef {
256+
use crate::source::AtLocation;
257+
use crate::source_code::SourceLocation;
258+
258259
let syntax_error_type = match &error.error {
259260
#[cfg(feature = "rustpython-parser")]
260261
crate::compiler::CompileErrorType::Parse(p) if p.is_indentation_error() => {

0 commit comments

Comments
 (0)
0