Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-def/src/expr_store.rs8
-rw-r--r--crates/hir-def/src/expr_store/expander.rs7
-rw-r--r--crates/hir-def/src/expr_store/lower.rs19
-rw-r--r--crates/hir-def/src/expr_store/lower/format_args.rs3
-rw-r--r--crates/hir-def/src/hir/generics.rs3
-rw-r--r--crates/hir-def/src/nameres/path_resolution.rs2
-rw-r--r--crates/hir-def/src/resolver.rs2
-rw-r--r--crates/hir/src/has_source.rs2
-rw-r--r--crates/rust-analyzer/src/lib.rs3
9 files changed, 22 insertions, 27 deletions
diff --git a/crates/hir-def/src/expr_store.rs b/crates/hir-def/src/expr_store.rs
index 66f7e25ffa..10cd460d1d 100644
--- a/crates/hir-def/src/expr_store.rs
+++ b/crates/hir-def/src/expr_store.rs
@@ -57,8 +57,7 @@ impl HygieneId {
Self(ctx)
}
- // FIXME: Inline this
- pub(crate) fn lookup(self) -> SyntaxContext {
+ pub(crate) fn syntax_context(self) -> SyntaxContext {
self.0
}
@@ -73,7 +72,8 @@ pub type ExprSource = InFile<ExprPtr>;
pub type PatPtr = AstPtr<ast::Pat>;
pub type PatSource = InFile<PatPtr>;
-pub type LabelPtr = AstPtr<ast::Label>;
+/// BlockExpr -> Desugared label from try block
+pub type LabelPtr = AstPtr<Either<ast::Label, ast::BlockExpr>>;
pub type LabelSource = InFile<LabelPtr>;
pub type FieldPtr = AstPtr<ast::RecordExprField>;
@@ -942,7 +942,7 @@ impl ExpressionStoreSourceMap {
}
pub fn node_label(&self, node: InFile<&ast::Label>) -> Option<LabelId> {
- let src = node.map(AstPtr::new);
+ let src = node.map(AstPtr::new).map(AstPtr::wrap_left);
self.expr_only()?.label_map.get(&src).cloned()
}
diff --git a/crates/hir-def/src/expr_store/expander.rs b/crates/hir-def/src/expr_store/expander.rs
index 6a2f06b0a6..de5974fff1 100644
--- a/crates/hir-def/src/expr_store/expander.rs
+++ b/crates/hir-def/src/expr_store/expander.rs
@@ -11,7 +11,7 @@ use hir_expand::{
ExpandError, ExpandErrorKind, ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
eager::EagerCallBackFn, mod_path::ModPath, span_map::SpanMap,
};
-use span::{AstIdMap, Edition, SyntaxContext};
+use span::{AstIdMap, SyntaxContext};
use syntax::ast::HasAttrs;
use syntax::{AstNode, Parse, ast};
use triomphe::Arc;
@@ -75,11 +75,6 @@ impl Expander {
AttrFlags::is_cfg_enabled_for(owner, cfg_options)
}
- pub(super) fn call_syntax_ctx(&self) -> SyntaxContext {
- // FIXME:
- SyntaxContext::root(Edition::CURRENT_FIXME)
- }
-
pub(super) fn enter_expand<T: ast::AstNode>(
&mut self,
db: &dyn DefDatabase,
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index 42b076abb2..af274f1a48 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -1096,7 +1096,7 @@ impl<'db> ExprCollector<'db> {
ast::Expr::WhileExpr(e) => self.collect_while_loop(syntax_ptr, e),
ast::Expr::ForExpr(e) => self.collect_for_loop(syntax_ptr, e),
ast::Expr::CallExpr(e) => {
- // FIXME: Remove this once we drop support for <1.86, https://github.com/rust-lang/rust/commit/ac9cb908ac4301dfc25e7a2edee574320022ae2c
+ // FIXME(MINIMUM_SUPPORTED_TOOLCHAIN_VERSION): Remove this once we drop support for <1.86, https://github.com/rust-lang/rust/commit/ac9cb908ac4301dfc25e7a2edee574320022ae2c
let is_rustc_box = {
let attrs = e.attrs();
attrs.filter_map(|it| it.as_simple_atom()).any(|it| it == "rustc_box")
@@ -1649,7 +1649,7 @@ impl<'db> ExprCollector<'db> {
fn desugar_try_block(&mut self, e: BlockExpr) -> ExprId {
let try_from_output = self.lang_path(self.lang_items().TryTraitFromOutput);
let label = self.generate_new_name();
- let label = self.alloc_label_desugared(Label { name: label });
+ let label = self.alloc_label_desugared(Label { name: label }, AstPtr::new(&e).wrap_right());
let old_label = self.current_try_block_label.replace(label);
let ptr = AstPtr::new(&e).upcast();
@@ -2399,7 +2399,6 @@ impl<'db> ExprCollector<'db> {
};
let start = range_part_lower(p.start());
let end = range_part_lower(p.end());
- // FIXME: Exclusive ended pattern range is stabilised
match p.op_kind() {
Some(range_type) => Pat::Range { start, end, range_type },
None => Pat::Missing,
@@ -2519,9 +2518,9 @@ impl<'db> ExprCollector<'db> {
let mut hygiene_info = if hygiene_id.is_root() {
None
} else {
- hygiene_id.lookup().outer_expn(self.db).map(|expansion| {
+ hygiene_id.syntax_context().outer_expn(self.db).map(|expansion| {
let expansion = self.db.lookup_intern_macro_call(expansion.into());
- (hygiene_id.lookup().parent(self.db), expansion.def)
+ (hygiene_id.syntax_context().parent(self.db), expansion.def)
})
};
let name = Name::new_lifetime(&lifetime.text());
@@ -2727,17 +2726,17 @@ impl ExprCollector<'_> {
self.store.pats.alloc(Pat::Missing)
}
- fn alloc_label(&mut self, label: Label, ptr: LabelPtr) -> LabelId {
+ fn alloc_label(&mut self, label: Label, ptr: AstPtr<ast::Label>) -> LabelId {
+ self.alloc_label_desugared(label, ptr.wrap_left())
+ }
+
+ fn alloc_label_desugared(&mut self, label: Label, ptr: LabelPtr) -> LabelId {
let src = self.expander.in_file(ptr);
let id = self.store.labels.alloc(label);
self.store.label_map_back.insert(id, src);
self.store.label_map.insert(src, id);
id
}
- // FIXME: desugared labels don't have ptr, that's wrong and should be fixed somehow.
- fn alloc_label_desugared(&mut self, label: Label) -> LabelId {
- self.store.labels.alloc(label)
- }
fn is_lowering_awaitable_block(&self) -> &Awaitable {
self.awaitable_context.as_ref().unwrap_or(&Awaitable::No("unknown"))
diff --git a/crates/hir-def/src/expr_store/lower/format_args.rs b/crates/hir-def/src/expr_store/lower/format_args.rs
index 32c9df3dfe..7ef84f27f6 100644
--- a/crates/hir-def/src/expr_store/lower/format_args.rs
+++ b/crates/hir-def/src/expr_store/lower/format_args.rs
@@ -3,6 +3,7 @@
use base_db::FxIndexSet;
use hir_expand::name::Name;
use intern::{Symbol, sym};
+use span::SyntaxContext;
use syntax::{AstPtr, AstToken as _, ast};
use crate::{
@@ -49,7 +50,7 @@ impl<'db> ExprCollector<'db> {
self.expand_macros_to_string(template.clone()).map(|it| (it, template))
}) {
Some(((s, is_direct_literal), template)) => {
- let call_ctx = self.expander.call_syntax_ctx();
+ let call_ctx = SyntaxContext::root(self.def_map.edition());
let hygiene = self.hygiene_id_for(s.syntax().text_range());
let fmt = format_args::parse(
&s,
diff --git a/crates/hir-def/src/hir/generics.rs b/crates/hir-def/src/hir/generics.rs
index 1a2d5ebba4..482cf36f95 100644
--- a/crates/hir-def/src/hir/generics.rs
+++ b/crates/hir-def/src/hir/generics.rs
@@ -20,8 +20,7 @@ pub type LocalLifetimeParamId = Idx<LifetimeParamData>;
/// Data about a generic type parameter (to a function, struct, impl, ...).
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct TypeParamData {
- /// [`None`] only if the type ref is an [`crate::type_ref::TypeRef::ImplTrait`]. FIXME: Might be better to just
- /// make it always be a value, giving impl trait a special name.
+ /// [`None`] only if the type ref is an [`crate::type_ref::TypeRef::ImplTrait`].
pub name: Option<Name>,
pub default: Option<TypeRefId>,
pub provenance: TypeParamProvenance,
diff --git a/crates/hir-def/src/nameres/path_resolution.rs b/crates/hir-def/src/nameres/path_resolution.rs
index e4b1d2a987..cf33cecf5f 100644
--- a/crates/hir-def/src/nameres/path_resolution.rs
+++ b/crates/hir-def/src/nameres/path_resolution.rs
@@ -267,7 +267,6 @@ impl DefMap {
// plain import or absolute path in 2015: crate-relative with
// fallback to extern prelude (with the simplification in
// rust-lang/rust#57745)
- // FIXME there must be a nicer way to write this condition
PathKind::Plain | PathKind::Abs
if self.data.edition == Edition::Edition2015
&& (path.kind == PathKind::Abs || mode == ResolveMode::Import) =>
@@ -383,7 +382,6 @@ impl DefMap {
// plain import or absolute path in 2015: crate-relative with
// fallback to extern prelude (with the simplification in
// rust-lang/rust#57745)
- // FIXME there must be a nicer way to write this condition
PathKind::Plain | PathKind::Abs
if self.data.edition == Edition::Edition2015
&& (path.kind == PathKind::Abs || mode == ResolveMode::Import) =>
diff --git a/crates/hir-def/src/resolver.rs b/crates/hir-def/src/resolver.rs
index 263f603a0b..f643ed31ad 100644
--- a/crates/hir-def/src/resolver.rs
+++ b/crates/hir-def/src/resolver.rs
@@ -950,7 +950,7 @@ fn hygiene_info(
hygiene_id: HygieneId,
) -> Option<(SyntaxContext, MacroDefId)> {
if !hygiene_id.is_root() {
- let ctx = hygiene_id.lookup();
+ let ctx = hygiene_id.syntax_context();
ctx.outer_expn(db).map(|expansion| {
let expansion = db.lookup_intern_macro_call(expansion.into());
(ctx.parent(db), expansion.def)
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index 09c5b1cca7..e032a16989 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -330,7 +330,7 @@ impl HasSource for Label {
let (_body, source_map) = db.body_with_source_map(self.parent);
let src = source_map.label_syntax(self.label_id);
let root = src.file_syntax(db);
- Some(src.map(|ast| ast.to_node(&root)))
+ src.map(|ast| ast.to_node(&root).left()).transpose()
}
}
diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs
index 971ae2a601..4a37bb34ab 100644
--- a/crates/rust-analyzer/src/lib.rs
+++ b/crates/rust-analyzer/src/lib.rs
@@ -16,6 +16,9 @@ extern crate rustc_driver as _;
extern crate ra_ap_rustc_type_ir as rustc_type_ir;
+/*
+ If you bump this, grep for `FIXME(MINIMUM_SUPPORTED_TOOLCHAIN_VERSION)` to check for old support code we can drop
+*/
/// Any toolchain less than this version will likely not work with rust-analyzer built from this revision.
pub const MINIMUM_SUPPORTED_TOOLCHAIN_VERSION: semver::Version = semver::Version {
major: 1,