Skip to content

Commit 6fe4d27

Browse files
upgrade to rustc-ap* v642 (#1091)
* deps: upgrade to rustc-ap* v642 * fix: ast::LitKind -> LitKind
1 parent c2b0080 commit 6fe4d27

File tree

6 files changed

+284
-137
lines changed

6 files changed

+284
-137
lines changed

Cargo.lock

Lines changed: 218 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,33 @@ version = "0.1"
3737
optional = true
3838
path = "metadata"
3939

40+
[dependencies.rustc_ast_pretty]
41+
package = "rustc-ap-rustc_ast_pretty"
42+
version = "642.0.0"
43+
44+
[dependencies.rustc_data_structures]
45+
package = "rustc-ap-rustc_data_structures"
46+
version = "642.0.0"
47+
48+
[dependencies.rustc_errors]
49+
package = "rustc-ap-rustc_errors"
50+
version = "642.0.0"
51+
52+
[dependencies.rustc_parse]
53+
package = "rustc-ap-rustc_parse"
54+
version = "642.0.0"
55+
56+
[dependencies.rustc_session]
57+
package = "rustc-ap-rustc_session"
58+
version = "642.0.0"
59+
60+
[dependencies.rustc_span]
61+
package = "rustc-ap-rustc_span"
62+
version = "642.0.0"
63+
4064
[dependencies.syntax]
4165
package = "rustc-ap-syntax"
42-
version = "610.0.0"
66+
version = "642.0.0"
4367

4468
[dev-dependencies.racer-testutils]
4569
version = "0.1"

src/racer/ast.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@ use crate::typeinf;
99
use std::path::Path;
1010
use std::rc::Rc;
1111

12+
use rustc_data_structures::sync::Lrc;
13+
use rustc_errors::emitter::Emitter;
14+
use rustc_errors::{Diagnostic, Handler};
15+
use rustc_parse::new_parser_from_source_str;
16+
use rustc_parse::parser::Parser;
17+
use rustc_session::parse::ParseSess;
18+
use rustc_span::edition::Edition;
19+
use rustc_span::Span;
20+
use rustc_span::source_map::{self, FileName, SourceMap};
1221
use syntax::ast::{self, ExprKind, FunctionRetTy, ItemKind, PatKind, UseTree, UseTreeKind};
13-
use syntax::edition::Edition;
14-
use syntax::errors::{emitter::Emitter, Diagnostic, Handler};
15-
use syntax::parse::parser::Parser;
16-
use syntax::parse::{self, ParseSess};
17-
use syntax::source_map::{self, FileName, SourceMap, Span};
1822
use syntax::{self, visit};
1923

2024
struct DummyEmitter;
2125

2226
impl Emitter for DummyEmitter {
2327
fn emit_diagnostic(&mut self, _db: &Diagnostic) {}
28+
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
29+
None
30+
}
2431
fn should_show_explain(&self) -> bool {
2532
false
2633
}
@@ -29,7 +36,7 @@ impl Emitter for DummyEmitter {
2936
/// construct parser from string
3037
// From syntax/util/parser_testing.rs
3138
pub fn string_to_parser(ps: &ParseSess, source_str: String) -> Parser<'_> {
32-
parse::new_parser_from_source_str(ps, FileName::Custom("racer-file".to_owned()), source_str)
39+
new_parser_from_source_str(ps, FileName::Custom("racer-file".to_owned()), source_str)
3340
}
3441

3542
/// Get parser from string s and then apply closure f to it
@@ -217,11 +224,14 @@ pub struct FnArgVisitor {
217224
impl<'ast> visit::Visitor<'ast> for FnArgVisitor {
218225
fn visit_fn(
219226
&mut self,
220-
_fk: visit::FnKind<'_>,
221-
fd: &ast::FnDecl,
227+
fk: visit::FnKind<'_>,
222228
_: source_map::Span,
223229
_: ast::NodeId,
224230
) {
231+
let fd = match fk {
232+
visit::FnKind::Fn(_, _, ref fn_sig, _, _) => &*fn_sig.decl,
233+
visit::FnKind::Closure(ref fn_decl, _) => fn_decl,
234+
};
225235
debug!("[FnArgVisitor::visit_fn] inputs: {:?}", fd.inputs);
226236
self.idents = fd
227237
.inputs
@@ -495,7 +505,7 @@ impl<'c, 's, 'ast> visit::Visitor<'ast> for ExprTypeVisitor<'c, 's> {
495505
);
496506
//walk_expr(self, ex, e)
497507
match expr.kind {
498-
ExprKind::Unary(_, ref expr) | ExprKind::AddrOf(_, ref expr) => {
508+
ExprKind::Unary(_, ref expr) | ExprKind::AddrOf(_, _, ref expr) => {
499509
self.visit_expr(expr);
500510
}
501511
ExprKind::Path(_, ref path) => {
@@ -924,13 +934,13 @@ impl<'p> ImplVisitor<'p> {
924934

925935
impl<'ast, 'p> visit::Visitor<'ast> for ImplVisitor<'p> {
926936
fn visit_item(&mut self, item: &ast::Item) {
927-
if let ItemKind::Impl(_, _, _, ref generics, ref otrait, ref self_typ, _) = item.kind {
937+
if let ItemKind::Impl { ref generics, ref of_trait, ref self_ty, .. } = item.kind {
928938
let impl_start = self.offset + get_span_start(item.span).into();
929939
self.result = ImplHeader::new(
930940
generics,
931941
self.filepath,
932-
otrait,
933-
self_typ,
942+
of_trait,
943+
self_ty,
934944
self.offset,
935945
self.local,
936946
impl_start,
@@ -1015,7 +1025,7 @@ impl<'ast> visit::Visitor<'ast> for StaticVisitor {
10151025
match i.kind {
10161026
ItemKind::Const(ref ty, ref _expr) => self.ty = Ty::from_ast(ty, &self.scope),
10171027
ItemKind::Static(ref ty, m, ref _expr) => {
1018-
self.is_mutable = m == ast::Mutability::Mutable;
1028+
self.is_mutable = m == ast::Mutability::Mut;
10191029
self.ty = Ty::from_ast(ty, &self.scope);
10201030
}
10211031
_ => {}
@@ -1229,10 +1239,13 @@ impl<'ast> visit::Visitor<'ast> for FnOutputVisitor {
12291239
fn visit_fn(
12301240
&mut self,
12311241
kind: visit::FnKind<'_>,
1232-
fd: &ast::FnDecl,
12331242
_: source_map::Span,
12341243
_: ast::NodeId,
12351244
) {
1245+
let fd = match kind {
1246+
visit::FnKind::Fn(_, _, ref fn_sig, _, _) => &*fn_sig.decl,
1247+
visit::FnKind::Closure(ref fn_decl, _) => fn_decl,
1248+
};
12361249
self.is_async = kind
12371250
.header()
12381251
.map(|header| header.asyncness.node.is_async())

src/racer/ast_types.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ use syntax::ast::{
1515
self, GenericBound, GenericBounds, GenericParamKind, LitKind, PatKind, TraitRef, TyKind,
1616
WherePredicate,
1717
};
18+
use rustc_span::source_map;
19+
use rustc_ast_pretty::pprust;
1820
// we can only re-export types without thread-local interned string
1921
pub use syntax::ast::{BindingMode, Mutability};
20-
use syntax::print::pprust;
21-
use syntax::source_map;
2222

2323
/// The leaf of a `use` statement.
2424
#[derive(Clone, Debug)]
@@ -102,7 +102,7 @@ impl Ty {
102102
let mut ty = self;
103103
// TODO: it's incorrect
104104
for _ in 0..count {
105-
ty = Ty::RefPtr(Box::new(ty), Mutability::Immutable);
105+
ty = Ty::RefPtr(Box::new(ty), Mutability::Not);
106106
}
107107
ty
108108
}
@@ -159,11 +159,11 @@ impl Ty {
159159
LitKind::Byte(_) => make_match(PrimKind::U8),
160160
LitKind::Char(_) => make_match(PrimKind::Char),
161161
LitKind::Int(_, int_ty) => make_match(PrimKind::from_litint(int_ty)),
162-
LitKind::Float(_, float_ty) => match float_ty {
162+
LitKind::Float(_, ast::LitFloatType::Unsuffixed) => make_match(PrimKind::F32),
163+
LitKind::Float(_, ast::LitFloatType::Suffixed(float_ty)) => match float_ty {
163164
ast::FloatTy::F32 => make_match(PrimKind::F32),
164165
ast::FloatTy::F64 => make_match(PrimKind::F64),
165166
},
166-
LitKind::FloatUnsuffixed(_) => make_match(PrimKind::F32),
167167
LitKind::Bool(_) => make_match(PrimKind::Bool),
168168
LitKind::Err(_) => None,
169169
}
@@ -232,12 +232,12 @@ impl fmt::Display for Ty {
232232
write!(f, "]")
233233
}
234234
Ty::RefPtr(ref ty, mutab) => match mutab {
235-
Mutability::Immutable => write!(f, "&{}", ty),
236-
Mutability::Mutable => write!(f, "&mut {}", ty),
235+
Mutability::Not => write!(f, "&{}", ty),
236+
Mutability::Mut => write!(f, "&mut {}", ty),
237237
},
238238
Ty::Ptr(ref ty, mutab) => match mutab {
239-
Mutability::Immutable => write!(f, "*const {}", ty),
240-
Mutability::Mutable => write!(f, "*mut {}", ty),
239+
Mutability::Not => write!(f, "*const {}", ty),
240+
Mutability::Mut => write!(f, "*mut {}", ty),
241241
},
242242
Ty::TraitObject(ref bounds) => {
243243
write!(f, "<")?;
@@ -449,7 +449,7 @@ impl Path {
449449
}
450450
// TODO: support inputs in GenericArgs::Parenthesized (A path like `Foo(A,B) -> C`)
451451
if let ast::GenericArgs::Parenthesized(ref paren_args) = **params {
452-
if let Some(ref ty) = paren_args.output {
452+
if let ast::FunctionRetTy::Ty(ref ty) = paren_args.output {
453453
output = Ty::from_ast(&*ty, scope);
454454
}
455455
}
@@ -867,7 +867,7 @@ impl GenericsArgs {
867867
WherePredicate::BoundPredicate(bound) => match bound.bounded_ty.kind {
868868
TyKind::Path(ref _qself, ref path) => {
869869
if let Some(seg) = path.segments.get(0) {
870-
let name = seg.ident.name.as_str();
870+
let name = pprust::path_segment_to_string(&seg);
871871
let bound =
872872
TraitBounds::from_generic_bounds(&bound.bounds, &filepath, offset);
873873
if let Some(tp) = args.iter_mut().find(|tp| tp.name == name) {

src/racer/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ops::{Deref, Range};
1515
use std::rc::Rc;
1616
use std::{fmt, vec};
1717
use std::{path, str};
18-
use syntax::source_map;
18+
use rustc_span::source_map;
1919

2020
use crate::ast;
2121
use crate::fileres;

src/racer/snippets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::ast::with_error_checking_parse;
22
use crate::core::{Match, Session};
33
use crate::typeinf::get_function_declaration;
44

5-
use syntax::ast::ImplItemKind;
5+
use syntax::ast::AssocItemKind;
66

77
/// Returns completion snippets usable by some editors
88
///
@@ -58,7 +58,7 @@ impl MethodInfo {
5858
with_error_checking_parse(decorated, |p| {
5959
let mut at_end = false;
6060
if let Ok(method) = p.parse_impl_item(&mut at_end) {
61-
if let ImplItemKind::Method(ref msig, _) = method.kind {
61+
if let AssocItemKind::Fn(ref msig, _) = method.kind {
6262
let decl = &msig.decl;
6363
return Some(MethodInfo {
6464
// ident.as_str calls Ident.name.as_str

0 commit comments

Comments
 (0)