Skip to content
This repository was archived by the owner on May 11, 2023. It is now read-only.

Commit b86d171

Browse files
committed
Remove ast::Location export
1 parent ab6e9d1 commit b86d171

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

compiler/ast/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ mod impls;
66

77
pub use ast_gen::*;
88

9-
pub use ruff_text_size::TextSize as Location;
10-
119
pub type Suite<U = ()> = Vec<Stmt<U>>;

compiler/parser/python.lalrpop

+2-2
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ ArgumentList: ArgumentList = {
17211721
}
17221722
};
17231723

1724-
FunctionArgument: (Option<(ast::Location, ast::Location, Option<String>)>, ast::Expr) = {
1724+
FunctionArgument: (Option<(crate::Location, crate::Location, Option<String>)>, ast::Expr) = {
17251725
<location:@L> <e:NamedExpressionTest> <c:CompFor?> <end_location:@R> => {
17261726
let expr = match c {
17271727
Some(c) => ast::Expr::new(
@@ -1776,7 +1776,7 @@ Identifier: String = <s:name> => s;
17761776

17771777
// Hook external lexer:
17781778
extern {
1779-
type Location = ast::Location;
1779+
type Location = crate::Location;
17801780
type Error = LexicalError;
17811781

17821782
enum token::Tok {

compiler/parser/src/function.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
ast,
55
lexer::{LexicalError, LexicalErrorType},
66
};
7+
use ruff_text_size::TextSize;
78
use rustc_hash::FxHashSet;
89

910
pub(crate) struct ArgumentList {
@@ -83,10 +84,7 @@ pub(crate) fn parse_params(
8384
Ok((pos_only, names, defaults))
8485
}
8586

86-
type FunctionArgument = (
87-
Option<(ast::Location, ast::Location, Option<String>)>,
88-
ast::Expr,
89-
);
87+
type FunctionArgument = (Option<(TextSize, TextSize, Option<String>)>, ast::Expr);
9088

9189
// Parse arguments as supplied during a function/lambda *call*.
9290
pub(crate) fn parse_args(func_args: Vec<FunctionArgument>) -> Result<ArgumentList, LexicalError> {

compiler/parser/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ mod context;
127127
mod soft_keywords;
128128
mod token;
129129

130+
type Location = TextSize;
131+
130132
pub use mode::Mode;
131133
pub use parser::{
132134
parse, parse_expression, parse_expression_located, parse_located, parse_program, parse_tokens,
133135
ParseError, ParseErrorType,
134136
};
137+
use ruff_text_size::TextSize;
135138
pub use string::FStringErrorType;
136139
pub use token::{StringKind, Tok};

compiler/parser/src/parser.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
//! [`Mode`]: crate::mode
1414
1515
use crate::{
16-
ast::{self, Location},
16+
ast::{self},
1717
lexer::{self, LexResult, LexicalError, LexicalErrorType},
1818
mode::Mode,
1919
python,
2020
token::Tok,
21+
Location,
2122
};
2223
use itertools::Itertools;
2324
use std::iter;
@@ -224,6 +225,7 @@ fn parse_error_from_lalrpop(
224225
source_path: &str,
225226
) -> ParseError {
226227
let source_path = source_path.to_owned();
228+
227229
match err {
228230
// TODO: Are there cases where this isn't an EOF?
229231
LalrpopError::InvalidToken { location } => ParseError {

compiler/parser/src/string.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
// regular strings. Since the parser has no definition of f-string formats (Pending PEP 701)
55
// we have to do the parsing here, manually.
66
use crate::{
7-
ast::{Constant, Expr, ExprKind, Location},
7+
ast::{Constant, Expr, ExprKind},
88
lexer::{LexicalError, LexicalErrorType},
99
parser::{parse_expression_located, LalrpopError, ParseError, ParseErrorType},
1010
token::{StringKind, Tok},
11+
Location,
1112
};
1213
use itertools::Itertools;
1314
use ruff_text_size::{TextLen, TextSize};

ruff_text_size/src/size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl TextSize {
4242
/// assert_eq!(TextSize::from(4), TextSize::new(4));
4343
/// ```
4444
pub const fn new(offset: u32) -> Self {
45-
Self { raw: offset}
45+
Self { raw: offset }
4646
}
4747

4848
/// The text size of some primitive text-like object.

0 commit comments

Comments
 (0)