GeezerVison is showing github.com — Use ast::Suite::parse instead of deprecated parse_program. (#5186) · RustPython/RustPython@2f8e518
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: compiler/codegen/src/compile.rs +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2941,7 +2941,8 @@ impl ToU32 for usize { |
2941 | 2941 | #[cfg(test)] |
2942 | 2942 | mod tests { |
2943 | 2943 | use super::*; |
2944 | | - use rustpython_parser as parser; |
| 2944 | + use rustpython_parser::ast::Suite; |
| 2945 | + use rustpython_parser::Parse; |
2945 | 2946 | use rustpython_parser_core::source_code::LinearLocator; |
2946 | 2947 |
|
2947 | 2948 | fn compile_exec(source: &str) -> CodeObject { |
@@ -2952,7 +2953,7 @@ mod tests { |
2952 | 2953 | "source_path".to_owned(), |
2953 | 2954 | "<module>".to_owned(), |
2954 | 2955 | ); |
2955 | | - let ast = parser::parse_program(source, "<test>").unwrap(); |
| 2956 | + let ast = Suite::parse(source, "<test>").unwrap(); |
2956 | 2957 | let ast = locator.fold(ast).unwrap(); |
2957 | 2958 | let symbol_scope = SymbolTable::scan_program(&ast).unwrap(); |
2958 | 2959 | compiler.compile_program(&ast, symbol_scope).unwrap(); |
|
Collapse file
Copy file name to clipboardExpand all lines: examples/parse_folder.rs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ extern crate env_logger; |
12 | 12 | extern crate log; |
13 | 13 |
|
14 | 14 | use clap::{App, Arg}; |
15 | | -use rustpython_parser::{self as parser, ast}; |
| 15 | +use rustpython_parser::{self as parser, ast, Parse}; |
16 | 16 | use std::{ |
17 | 17 | path::Path, |
18 | 18 | time::{Duration, Instant}, |
@@ -85,8 +85,8 @@ fn parse_python_file(filename: &Path) -> ParsedFile { |
85 | 85 | }, |
86 | 86 | Ok(source) => { |
87 | 87 | 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()); |
90 | 90 | ParsedFile { |
91 | 91 | // filename: Box::new(filename.to_path_buf()), |
92 | 92 | // code: source.to_string(), |
|