8000 Use ast::Suite::parse instead of deprecated parse_program. (#5186) · RustPython/RustPython@2f8e518 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f8e518

Browse files
authored
Use ast::Suite::parse instead of deprecated parse_program. (#5186)
1 parent 4c8cd67 commit 2f8e518

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/codegen/src/compile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,8 @@ impl ToU32 for usize {
29412941
#[cfg(test)]
29422942
mod tests {
29432943
use super::*;
2944-
use rustpython_parser as parser;
2944+
use rustpython_parser::ast::Suite;
2945+
use rustpython_parser::Parse;
29452946
use rustpython_parser_core::source_code::LinearLocator;
29462947

29472948
fn compile_exec(source: &str) -> CodeObject {
@@ -2952,7 +2953,7 @@ mod tests {
29522953
"source_path".to_owned(),
29532954
"<module>".to_owned(),
29542955
);
2955-
let ast = parser::parse_program(source, "<test>").unwrap();
2956+
let ast = Suite::parse(source, "<test>").unwrap();
29562957
let ast = locator.fold(ast).unwrap();
29572958
let symbol_scope = SymbolTable::scan_program(&ast).unwrap();
29582959
compiler.compile_program(&ast, symbol_scope).unwrap();

examples/parse_folder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate env_logger;
1212
extern crate log;
1313

1414
use clap::{App, Arg};
15-
use rustpython_parser::{self as parser, ast};
15+
use rustpython_parser::{self as parser, ast, Parse};
1616
use std::{
1717
path::Path,
1818
time::{Duration, Instant},
@@ -85,8 +85,8 @@ fn parse_python_file(filename: &Path) -> ParsedFile {
8585
},
8686
Ok(source) => {
8787
let num_lines = source.lines().count();
88-
let result = parser::parse_program(&source, &filename.to_string_lossy())
89-
.map_err(|e| e.to_string());
88+
let result =
89+
ast::Suite::parse(&source, &filename.to_string_lossy()).map_err(|e| e.to_string());
9090
ParsedFile {
9191
// filename: Box::new(filename.to_path_buf()),
9292
// code: source.to_string(),

0 commit comments

Comments
 (0)
0