1313//! [`Mode`]: crate::mode
1414
1515use crate :: {
16- ast:: { self } ,
16+ ast,
1717 lexer:: { self , LexResult , LexicalError , LexicalErrorType } ,
1818 mode:: Mode ,
1919 python,
20+ text_size:: TextSize ,
2021 token:: Tok ,
21- Location ,
2222} ;
2323use itertools:: Itertools ;
2424use std:: iter;
@@ -70,7 +70,7 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
7070///
7171/// ```
7272pub fn parse_expression ( source : & str , path : & str ) -> Result < ast:: Expr , ParseError > {
73- parse_expression_located ( source, path, Location :: default ( ) )
73+ parse_expression_located ( source, path, TextSize :: default ( ) )
7474}
7575
7676/// Parses a Python expression from a given location.
@@ -84,16 +84,15 @@ pub fn parse_expression(source: &str, path: &str) -> Result<ast::Expr, ParseErro
8484/// somewhat silly, location:
8585///
8686/// ```
87- /// use ruff_text_size::TextSize;
88- /// use rustpython_parser::{parse_expression_located};
87+ /// use rustpython_parser::{text_size::TextSize, parse_expression_located};
8988///
9089/// let expr = parse_expression_located("1 + 2", "<embedded>", TextSize::from(400));
9190/// assert!(expr.is_ok());
9291/// ```
9392pub fn parse_expression_located (
9493 source : & str ,
9594 path : & str ,
96- location : Location ,
95+ location : TextSize ,
9796) -> Result < ast:: Expr , ParseError > {
9897 parse_located ( source, Mode :: Expression , path, location) . map ( |top| match top {
9998 ast:: Mod :: Expression ( ast:: ModExpression { body } ) => * body,
@@ -133,7 +132,7 @@ pub fn parse_expression_located(
133132/// assert!(program.is_ok());
134133/// ```
135134pub fn parse ( source : & str , mode : Mode , source_path : & str ) -> Result < ast:: Mod , ParseError > {
136- parse_located ( source, mode, source_path, Location :: default ( ) )
135+ parse_located ( source, mode, source_path, TextSize :: default ( ) )
137136}
138137
139138/// Parse the given Python source code using the specified [`Mode`] and [`Location`].
@@ -144,8 +143,7 @@ pub fn parse(source: &str, mode: Mode, source_path: &str) -> Result<ast::Mod, Pa
144143/// # Example
145144///
146145/// ```
147- /// use ruff_text_size::TextSize;
148- /// use rustpython_parser::{Mode, parse_located};
146+ /// use rustpython_parser::{text_size::TextSize, Mode, parse_located};
149147///
150148/// let source = r#"
151149/// def fib(i):
@@ -163,7 +161,7 @@ pub fn parse_located(
163161 source : & str ,
164162 mode : Mode ,
165163 source_path : & str ,
166- location : Location ,
164+ location : TextSize ,
167165) -> Result < ast:: Mod , ParseError > {
168166 let lxr = lexer:: lex_located ( source, mode, location) ;
169167 parse_tokens ( lxr, mode, source_path)
@@ -226,7 +224,7 @@ impl std::error::Error for ParseErrorType {}
226224
227225// Convert `lalrpop_util::ParseError` to our internal type
228226fn parse_error_from_lalrpop (
229- err : LalrpopError < Location , Tok , LexicalError > ,
227+ err : LalrpopError < TextSize , Tok , LexicalError > ,
230228 source_path : & str ,
231229) -> ParseError {
232230 let source_path = source_path. to_owned ( ) ;
0 commit comments