Skip to content

Rustup to rustc-ap 658 #4177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 98 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions rustfmt-core/rustfmt-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,32 @@ env_logger = "0.7"

[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_ast_pretty]
package = "rustc-ap-rustc_ast_pretty"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_data_structures]
package = "rustc-ap-rustc_data_structures"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_errors]
package = "rustc-ap-rustc_errors"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_expand]
package = "rustc-ap-rustc_expand"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_parse]
package = "rustc-ap-rustc_parse"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_session]
package = "rustc-ap-rustc_session"
version = "656.0.0"
version = "658.0.0"

[dependencies.rustc_span]
package = "rustc-ap-rustc_span"
version = "656.0.0"
version = "658.0.0"
8 changes: 4 additions & 4 deletions rustfmt-core/rustfmt-lib/src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use std::borrow::Cow;
use std::cmp::min;

use rustc_ast::{ast, ptr};
use rustc_span::{BytePos, Span};
use rustc_span::{BytePos, Span, symbol};

use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
use crate::config::IndentStyle;
Expand Down Expand Up @@ -116,8 +116,8 @@ enum ChainItemKind {
Vec<ast::GenericArg>,
Vec<ptr::P<ast::Expr>>,
),
StructField(ast::Ident),
TupleField(ast::Ident, bool),
StructField(symbol::Ident),
TupleField(symbol::Ident, bool),
Await,
Comment(String, CommentPosition),
}
Expand Down Expand Up @@ -234,7 +234,7 @@ impl ChainItem {
}

fn rewrite_method_call(
method_name: ast::Ident,
method_name: symbol::Ident,
types: &[ast::GenericArg],
args: &[ptr::P<ast::Expr>],
span: Span,
Expand Down
4 changes: 2 additions & 2 deletions rustfmt-core/rustfmt-lib/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::cmp::Ordering;
use std::fmt;

use rustc_ast::ast::{self, UseTreeKind};
use rustc_span::{source_map, symbol::sym, BytePos, Span, DUMMY_SP};
use rustc_span::{source_map, symbol::{self, sym}, BytePos, Span, DUMMY_SP};

use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;
Expand All @@ -21,7 +21,7 @@ use crate::visitor::FmtVisitor;

/// Returns a name imported by a `use` declaration.
/// E.g., returns `Ordering` for `std::cmp::Ordering` and `self` for `std::cmp::self`.
pub(crate) fn path_to_imported_ident(path: &ast::Path) -> ast::Ident {
pub(crate) fn path_to_imported_ident(path: &ast::Path) -> symbol::Ident {
path.segments.last().unwrap().ident
}

Expand Down
26 changes: 13 additions & 13 deletions rustfmt-core/rustfmt-lib/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a> FmtVisitor<'a> {
pub(crate) fn rewrite_fn_before_block(
&mut self,
indent: Indent,
ident: ast::Ident,
ident: symbol::Ident,
fn_sig: &FnSig<'_>,
span: Span,
) -> Option<(String, FnBraceStyle)> {
Expand All @@ -394,7 +394,7 @@ impl<'a> FmtVisitor<'a> {
pub(crate) fn rewrite_required_fn(
&mut self,
indent: Indent,
ident: ast::Ident,
ident: symbol::Ident,
sig: &ast::FnSig,
generics: &ast::Generics,
span: Span,
Expand Down Expand Up @@ -470,7 +470,7 @@ impl<'a> FmtVisitor<'a> {

pub(crate) fn visit_enum(
&mut self,
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
enum_def: &ast::EnumDef,
generics: &ast::Generics,
Expand Down Expand Up @@ -1012,7 +1012,7 @@ fn rewrite_trait_ref(

pub(crate) struct StructParts<'a> {
prefix: &'a str,
ident: ast::Ident,
ident: symbol::Ident,
vis: &'a ast::Visibility,
def: &'a ast::VariantData,
generics: Option<&'a ast::Generics>,
Expand Down Expand Up @@ -1279,7 +1279,7 @@ impl<'a> Rewrite for TraitAliasBounds<'a> {

pub(crate) fn format_trait_alias(
context: &RewriteContext<'_>,
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
generics: &ast::Generics,
generic_bounds: &ast::GenericBounds,
Expand Down Expand Up @@ -1559,7 +1559,7 @@ fn format_tuple_struct(
fn rewrite_type<R: Rewrite>(
context: &RewriteContext<'_>,
indent: Indent,
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
generics: &ast::Generics,
generic_bounds_opt: Option<&ast::GenericBounds>,
Expand Down Expand Up @@ -1628,7 +1628,7 @@ fn rewrite_type<R: Rewrite>(
pub(crate) fn rewrite_opaque_type(
context: &RewriteContext<'_>,
indent: Indent,
ident: ast::Ident,
ident: symbol::Ident,
generic_bounds: &ast::GenericBounds,
generics: &ast::Generics,
vis: &ast::Visibility,
Expand Down Expand Up @@ -1742,7 +1742,7 @@ pub(crate) fn rewrite_struct_field(
pub(crate) struct StaticParts<'a> {
prefix: &'a str,
vis: &'a ast::Visibility,
ident: ast::Ident,
ident: symbol::Ident,
ty: &'a ast::Ty,
mutability: ast::Mutability,
expr_opt: Option<&'a ptr::P<ast::Expr>>,
Expand Down Expand Up @@ -1884,7 +1884,7 @@ fn rewrite_static(
}

pub(crate) fn rewrite_type_alias(
ident: ast::Ident,
ident: symbol::Ident,
ty_opt: Option<&ptr::P<ast::Ty>>,
generics: &ast::Generics,
generic_bounds_opt: Option<&ast::GenericBounds>,
Expand Down Expand Up @@ -1918,7 +1918,7 @@ impl<'a> Rewrite for OpaqueType<'a> {

pub(crate) fn rewrite_opaque_impl_type(
context: &RewriteContext<'_>,
ident: ast::Ident,
ident: symbol::Ident,
generics: &ast::Generics,
generic_bounds: &ast::GenericBounds,
indent: Indent,
Expand All @@ -1942,7 +1942,7 @@ pub(crate) fn rewrite_opaque_impl_type(
}

pub(crate) fn rewrite_associated_impl_type(
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
defaultness: ast::Defaultness,
ty_opt: Option<&ptr::P<ast::Ty>>,
Expand Down Expand Up @@ -2178,7 +2178,7 @@ pub(crate) enum FnBraceStyle {
fn rewrite_fn_base(
context: &RewriteContext<'_>,
indent: Indent,
ident: ast::Ident,
ident: symbol::Ident,
fn_sig: &FnSig<'_>,
span: Span,
fn_brace_style: FnBraceStyle,
Expand Down Expand Up @@ -2979,7 +2979,7 @@ fn rewrite_comments_before_after_where(
fn format_header(
context: &RewriteContext<'_>,
item_name: &str,
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
) -> String {
format!(
Expand Down
3 changes: 2 additions & 1 deletion rustfmt-core/rustfmt-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::PathBuf;
use std::rc::Rc;

use rustc_ast::ast;
use rustc_span::symbol;
use thiserror::Error;

pub use crate::config::{
Expand Down Expand Up @@ -508,7 +509,7 @@ impl Input {
let file_stem = file.file_stem()?;
if file.parent()?.to_path_buf().join(file_stem).is_dir() {
Some(DirectoryOwnership::Owned {
relative: file_stem.to_str().map(ast::Ident::from_str),
relative: file_stem.to_str().map(symbol::Ident::from_str),
})
} else {
None
Expand Down
16 changes: 8 additions & 8 deletions rustfmt-core/rustfmt-lib/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc_ast::tokenstream::{Cursor, TokenStream, TokenTree};
use rustc_ast::{ast, ptr};
use rustc_ast_pretty::pprust;
use rustc_parse::{new_parser_from_tts, parser::Parser};
use rustc_span::{symbol::kw, BytePos, Span, Symbol, DUMMY_SP};
use rustc_span::{symbol::{self, kw}, BytePos, Span, Symbol, DUMMY_SP};

use crate::comment::{
contains_comment, CharClasses, FindUncommented, FullCodeCharKind, LineClasses,
Expand Down Expand Up @@ -52,7 +52,7 @@ pub(crate) enum MacroArg {
Ty(ptr::P<ast::Ty>),
Pat(ptr::P<ast::Pat>),
Item(ptr::P<ast::Item>),
Keyword(ast::Ident, Span),
Keyword(symbol::Ident, Span),
}

impl MacroArg {
Expand Down Expand Up @@ -137,7 +137,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
fn rewrite_macro_name(
context: &RewriteContext<'_>,
path: &ast::Path,
extra_ident: Option<ast::Ident>,
extra_ident: Option<symbol::Ident>,
) -> String {
let name = if path.segments.len() == 1 {
// Avoid using pretty-printer in the common case.
Expand Down Expand Up @@ -188,7 +188,7 @@ fn return_macro_parse_failure_fallback(

pub(crate) fn rewrite_macro(
mac: &ast::MacCall,
extra_ident: Option<ast::Ident>,
extra_ident: Option<symbol::Ident>,
context: &RewriteContext<'_>,
shape: Shape,
position: MacroPosition,
Expand Down Expand Up @@ -229,7 +229,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
if parser.token.is_keyword(keyword) && parser.look_ahead(1, |t| is_delim(t.kind.clone())) {
parser.bump();
return Some(MacroArg::Keyword(
ast::Ident::with_dummy_span(keyword),
symbol::Ident::with_dummy_span(keyword),
parser.prev_token.span,
));
}
Expand All @@ -239,7 +239,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {

fn rewrite_macro_inner(
mac: &ast::MacCall,
extra_ident: Option<ast::Ident>,
extra_ident: Option<symbol::Ident>,
context: &RewriteContext<'_>,
shape: Shape,
position: MacroPosition,
Expand Down Expand Up @@ -478,7 +478,7 @@ pub(crate) fn rewrite_macro_def(
shape: Shape,
indent: Indent,
def: &ast::MacroDef,
ident: ast::Ident,
ident: symbol::Ident,
vis: &ast::Visibility,
span: Span,
) -> Option<String> {
Expand Down Expand Up @@ -618,7 +618,7 @@ fn replace_names(input: &str) -> Option<(String, HashMap<String, String>)> {
#[derive(Debug, Clone)]
enum MacroArgKind {
/// e.g., `$x: expr`.
MetaVariable(ast::Name, String),
MetaVariable(Symbol, String),
/// e.g., `$($foo: expr),*`
Repeat(
/// `()`, `[]` or `{}`.
Expand Down
6 changes: 3 additions & 3 deletions rustfmt-core/rustfmt-lib/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};

use rustc_ast::ast;
use rustc_ast::visit::Visitor;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::symbol::{sym, Symbol, self};

use crate::attr::MetaVisitor;
use crate::config::FileName;
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
/// Find a file path in the filesystem which corresponds to the given module.
fn find_external_module(
&self,
mod_name: ast::Ident,
mod_name: symbol::Ident,
attrs: &[ast::Attribute],
sub_mod: &Cow<'ast, ast::Mod>,
) -> Result<Option<SubModKind<'c, 'ast>>, String> {
Expand Down Expand Up @@ -326,7 +326,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
}
}

fn push_inline_mod_directory(&mut self, id: ast::Ident, attrs: &[ast::Attribute]) {
fn push_inline_mod_directory(&mut self, id: symbol::Ident, attrs: &[ast::Attribute]) {
if let Some(path) = find_path_value(attrs) {
self.directory.path.push(&*path.as_str());
self.directory.ownership = DirectoryOwnership::Owned { relative: None };
Expand Down
7 changes: 3 additions & 4 deletions rustfmt-core/rustfmt-lib/src/syntux/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use std::cell::RefCell;
use std::path::Path;
use std::rc::Rc;

use rustc_ast::ast;
use rustc_data_structures::sync::{Lrc, Send};
use rustc_errors::emitter::{Emitter, EmitterWriter};
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
use rustc_session::parse::ParseSess as RawParseSess;
use rustc_span::{
source_map::{FilePathMapping, SourceMap},
BytePos, Span,
BytePos, Span, symbol,
};

use crate::config::file_lines::LineRange;
Expand Down Expand Up @@ -147,8 +146,8 @@ impl ParseSess {

pub(crate) fn default_submod_path(
&self,
id: ast::Ident,
relative: Option<ast::Ident>,
id: symbol::Ident,
relative: Option<symbol::Ident>,
dir_path: &Path,
) -> rustc_expand::module::ModulePath<'_> {
rustc_expand::module::default_submod_path(
Expand Down
4 changes: 2 additions & 2 deletions rustfmt-core/rustfmt-lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::ast::{
};
use rustc_ast::ptr;
use rustc_ast_pretty::pprust;
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext, symbol};
use unicode_width::UnicodeWidthStr;

use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
Expand All @@ -24,7 +24,7 @@ pub(crate) fn skip_annotation() -> Symbol {
Symbol::intern("rustfmt::skip")
}

pub(crate) fn rewrite_ident<'a>(context: &'a RewriteContext<'_>, ident: ast::Ident) -> &'a str {
pub(crate) fn rewrite_ident<'a>(context: &'a RewriteContext<'_>, ident: symbol::Ident) -> &'a str {
context.snippet(ident.span)
}

Expand Down
6 changes: 3 additions & 3 deletions rustfmt-core/rustfmt-lib/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cell::{Cell, RefCell};
use std::rc::Rc;

use rustc_ast::{ast, token::DelimToken, visit};
use rustc_span::{BytePos, Pos, Span};
use rustc_span::{BytePos, Pos, Span, symbol};

use crate::attr::*;
use crate::comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};
Expand Down Expand Up @@ -686,7 +686,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
}
}

fn visit_mac(&mut self, mac: &ast::MacCall, ident: Option<ast::Ident>, pos: MacroPosition) {
fn visit_mac(&mut self, mac: &ast::MacCall, ident: Option<symbol::Ident>, pos: MacroPosition) {
skip_out_of_file_lines_range_visitor!(self, mac.span());

// 1 = ;
Expand Down Expand Up @@ -896,7 +896,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
m: &ast::Mod,
vis: &ast::Visibility,
s: Span,
ident: ast::Ident,
ident: symbol::Ident,
attrs: &[ast::Attribute],
is_internal: bool,
) {
Expand Down