Skip to content

Commit dc44c57

Browse files
refactor: symb/source_map/syntax_pos to rustc_span
syntax_pos was renamed to rustc_span rust-lang/rust#67707 and modules like `symbol` and `source_map` are no longer re-exported in libsyanx so we also need to consume them directly from the rustc_span crate rust-lang/rust#67786
1 parent 900c527 commit dc44c57

30 files changed

+49
-61
lines changed

rustfmt-core/rustfmt-config/src/file_lines.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
1010
use serde_json as json;
1111
use thiserror::Error;
1212

13-
use syntax_pos::{self, SourceFile};
13+
use rustc_span::{self, SourceFile};
1414

1515
/// A range of lines in a file, inclusive of both ends.
1616
pub struct LineRange {
@@ -26,21 +26,21 @@ pub enum FileName {
2626
Stdin,
2727
}
2828

29-
impl From<syntax_pos::FileName> for FileName {
30-
fn from(name: syntax_pos::FileName) -> FileName {
29+
impl From<rustc_span::FileName> for FileName {
30+
fn from(name: rustc_span::FileName) -> FileName {
3131
match name {
32-
syntax_pos::FileName::Real(p) => FileName::Real(p),
33-
syntax_pos::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
32+
rustc_span::FileName::Real(p) => FileName::Real(p),
33+
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
3434
_ => unreachable!(),
3535
}
3636
}
3737
}
3838

39-
impl From<&FileName> for syntax_pos::FileName {
40-
fn from(filename: &FileName) -> syntax_pos::FileName {
39+
impl From<&FileName> for rustc_span::FileName {
40+
fn from(filename: &FileName) -> rustc_span::FileName {
4141
match filename {
42-
FileName::Real(path) => syntax_pos::FileName::Real(path.to_owned()),
43-
FileName::Stdin => syntax_pos::FileName::Custom("stdin".to_owned()),
42+
FileName::Real(path) => rustc_span::FileName::Real(path.to_owned()),
43+
FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()),
4444
}
4545
}
4646
}

rustfmt-core/rustfmt-config/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl Default for Edition {
374374
}
375375
}
376376

377-
impl From<Edition> for syntax_pos::edition::Edition {
377+
impl From<Edition> for rustc_span::edition::Edition {
378378
fn from(edition: Edition) -> Self {
379379
match edition {
380380
Edition::Edition2015 => Self::Edition2015,

rustfmt-core/rustfmt-lib/src/attr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Format attributes and meta items.
22
3+
use rustc_span::{BytePos, DUMMY_SP, Span, symbol::sym};
34
use syntax::ast;
4-
use syntax::source_map::{BytePos, Span, DUMMY_SP};
5-
use syntax::symbol::sym;
65

76
use self::doc_comment::DocCommentFormatter;
87
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};

rustfmt-core/rustfmt-lib/src/chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
use std::borrow::Cow;
5959
use std::cmp::min;
6060

61-
use syntax::source_map::{BytePos, Span};
61+
use rustc_span::{BytePos, Span};
6262
use syntax::{ast, ptr};
6363

6464
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};

rustfmt-core/rustfmt-lib/src/closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use syntax::source_map::Span;
1+
use rustc_span::Span;
22
use syntax::{ast, ptr};
33

44
use crate::attr::get_attrs_from_stmt;

rustfmt-core/rustfmt-lib/src/comment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{self, borrow::Cow, iter};
44

55
use itertools::{multipeek, MultiPeek};
6-
use syntax::source_map::Span;
6+
use rustc_span::Span;
77

88
use crate::config::Config;
99
use crate::rewrite::RewriteContext;

rustfmt-core/rustfmt-lib/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::borrow::Cow;
22
use std::cmp::min;
33

44
use itertools::Itertools;
5+
use rustc_span::{BytePos, Span};
56
use syntax::parse::token::{DelimToken, LitKind};
6-
use syntax::source_map::{BytePos, Span};
77
use syntax::{ast, ptr};
88

99
use crate::chains::rewrite_chain;

rustfmt-core/rustfmt-lib/src/formatting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::collections::HashMap;
44
use std::io::{self, Write};
55
use std::time::{Duration, Instant};
66

7+
use rustc_span::Span;
78
use syntax::ast;
8-
use syntax::source_map::Span;
99

1010
use self::newline_style::apply_newline_style;
1111
use crate::comment::{CharClasses, FullCodeCharKind};

rustfmt-core/rustfmt-lib/src/imports.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::borrow::Cow;
22
use std::cmp::Ordering;
33
use std::fmt;
44

5+
use rustc_span::{BytePos, DUMMY_SP, source_map, Span, symbol::sym};
56
use syntax::ast::{self, UseTreeKind};
6-
use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
7-
use syntax::symbol::sym;
87

98
use crate::comment::combine_strs_with_missing_comments;
109
use crate::config::lists::*;
@@ -854,7 +853,7 @@ impl Rewrite for UseTree {
854853
#[cfg(test)]
855854
mod test {
856855
use super::*;
857-
use syntax::source_map::DUMMY_SP;
856+
use rustc_span::DUMMY_SP;
858857

859858
// Parse the path part of an import. This parser is not robust and is only
860859
// suitable for use in a test harness.

rustfmt-core/rustfmt-lib/src/items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::borrow::Cow;
44
use std::cmp::{max, min, Ordering};
55

66
use regex::Regex;
7+
use rustc_span::{BytePos, DUMMY_SP, source_map, Span, symbol};
78
use rustc_target::spec::abi;
8-
use syntax::source_map::{self, BytePos, Span};
99
use syntax::visit;
10-
use syntax::{ast, ptr, symbol};
10+
use syntax::{ast, ptr};
1111

1212
use crate::attr::filter_inline_attrs;
1313
use crate::comment::{
@@ -35,7 +35,7 @@ use crate::visitor::FmtVisitor;
3535

3636
const DEFAULT_VISIBILITY: ast::Visibility = source_map::Spanned {
3737
node: ast::VisibilityKind::Inherited,
38-
span: source_map::DUMMY_SP,
38+
span: DUMMY_SP,
3939
};
4040

4141
fn type_annotation_separator(config: &Config) -> &str {

0 commit comments

Comments
 (0)