Skip to content
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

Subtree update of rust-analyzer #132594

Merged
merged 43 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2dfbcb6
docs: create setup documentation
davidkurilla Oct 15, 2024
be7865e
style: fix typos
davidkurilla Oct 15, 2024
32b05c1
docs: remove unnecessary prerequisites setup.md
davidkurilla Oct 22, 2024
3bb20dd
fix: auto-complete import for aliased function and module
dqkqd Oct 23, 2024
af3f990
Add assist to generate a type alias for a function
Giga-Bowser Oct 23, 2024
0ac5c8a
Fix alphabetical order of handlers
Giga-Bowser Oct 23, 2024
75a659e
refactor: separate function for getting import name
dqkqd Oct 24, 2024
1b699b5
fix: handle aliased pattern and simplify testcase
dqkqd Oct 24, 2024
a00b4c2
Add `ty_fn_ptr` function to create function pointer type
Giga-Bowser Oct 24, 2024
d0de3fa
Rework `generate_fn_type_alias`
Giga-Bowser Oct 24, 2024
d7615a9
Cleanup TypeRef lowering
ChayimFriedman2 Oct 28, 2024
a1eb6b3
Merge pull request #18427 from ChayimFriedman2/cleanup-ty
Veykril Oct 29, 2024
1407065
fix: Fix the server not honoring diagnostic refresh support
Veykril Oct 29, 2024
c21de28
Merge pull request #18432 from Veykril/lw-yptzmuxyvxxt
Veykril Oct 29, 2024
d8f6538
Do not render meta info when hovering usages
Veykril Oct 29, 2024
711961d
Publish test-fixture => ra_ap_test_fixture
sam-mccall Oct 29, 2024
8a51cbf
Style hover messages a bit differently
Veykril Oct 29, 2024
3ab7a69
Merge pull request #18436 from Veykril/lw-yvkqwpnwsouo
Veykril Oct 30, 2024
5fe280e
Merge pull request #18385 from Giga-Bowser/master
Veykril Oct 30, 2024
482e63d
Merge pull request #18382 from dqkqd/issue-17042
Veykril Oct 30, 2024
cee3257
Merge pull request #18304 from davidkurilla/docs-create-setup-document
Veykril Oct 30, 2024
6a6b61a
Only parse `safe` as contextual kw in extern blocks
ChayimFriedman2 Oct 30, 2024
2d5b758
Merge pull request #18446 from ChayimFriedman2/safe-statement
Veykril Oct 30, 2024
5aff110
Avoid interior mutability in `TyLoweringContext`
ChayimFriedman2 Oct 30, 2024
7ca05b5
Merge pull request #18437 from sam-mccall/publish_fixture
Veykril Oct 31, 2024
bc862b8
Move child_by_source from hir-def to hir
Veykril Oct 31, 2024
2a9b851
Merge pull request #18448 from Veykril/push-zwuuoytnmnqz
Veykril Oct 31, 2024
b25a3de
Merge pull request #18447 from ChayimFriedman2/cleanup-tylowerctx
Veykril Oct 31, 2024
f0bf75d
Parse patterns with leading pipe properly in all places
ChayimFriedman2 Oct 31, 2024
a5b5b46
Merge pull request #18453 from ChayimFriedman2/leading-or
Veykril Oct 31, 2024
21544d8
Preparing for merge from rust-lang/rust
lnicola Nov 1, 2024
d94c49c
Merge from rust-lang/rust
lnicola Nov 1, 2024
7303227
Bump rustc crates
lnicola Nov 1, 2024
9acf57c
Format code
lnicola Nov 1, 2024
cf6bc48
Merge pull request #18457 from lnicola/sync-from-rust
lnicola Nov 1, 2024
b431237
Allow static initializers to be const evaluated
Veykril Nov 2, 2024
f5e1dce
Improve error message for too new proc-macro server
benluiwj Nov 2, 2024
db29fd3
Merge pull request #18463 from benluiwj/fix/proc-macro-server-msg-imp…
lnicola Nov 2, 2024
72d9929
Merge pull request #18469 from Veykril/push-zwnywqmvtuts
Veykril Nov 3, 2024
56e89bc
Allow interpreting consts and statics with interpret function command
Veykril Nov 3, 2024
43c20c2
Merge pull request #18470 from Veykril/push-rxmtkvpulotn
Veykril Nov 3, 2024
9f4e719
Fix feature name casing
lnicola Nov 4, 2024
0cd3fb2
Merge pull request #18472 from lnicola/reinterpret-function-casing
lnicola Nov 4, 2024
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
Prev Previous commit
Next Next commit
Cleanup TypeRef lowering
By removing interior mutability from it.
ChayimFriedman2 committed Oct 28, 2024
commit d7615a985417c9ef8994745f58c75de9f0fa5399
16 changes: 9 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
@@ -407,7 +407,7 @@ impl ExprCollector<'_> {
let method_name = e.name_ref().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
let generic_args = e
.generic_arg_list()
.and_then(|it| GenericArgs::from_ast(&self.ctx(), it))
.and_then(|it| GenericArgs::from_ast(&mut self.ctx(), it))
.map(Box::new);
self.alloc_expr(
Expr::MethodCall { receiver, method_name, args, generic_args },
@@ -533,7 +533,7 @@ impl ExprCollector<'_> {
ast::Expr::TryExpr(e) => self.collect_try_operator(syntax_ptr, e),
ast::Expr::CastExpr(e) => {
let expr = self.collect_expr_opt(e.expr());
let type_ref = TypeRef::from_ast_opt(&self.ctx(), e.ty());
let type_ref = TypeRef::from_ast_opt(&mut self.ctx(), e.ty());
self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr)
}
ast::Expr::RefExpr(e) => {
@@ -572,13 +572,15 @@ impl ExprCollector<'_> {
arg_types.reserve_exact(num_params);
for param in pl.params() {
let pat = this.collect_pat_top(param.pat());
let type_ref = param.ty().map(|it| TypeRef::from_ast(&this.ctx(), it));
let type_ref = param.ty().map(|it| TypeRef::from_ast(&mut this.ctx(), it));
args.push(pat);
arg_types.push(type_ref);
}
}
let ret_type =
e.ret_type().and_then(|r| r.ty()).map(|it| TypeRef::from_ast(&this.ctx(), it));
let ret_type = e
.ret_type()
.and_then(|r| r.ty())
.map(|it| TypeRef::from_ast(&mut this.ctx(), it));

let prev_is_lowering_coroutine = mem::take(&mut this.is_lowering_coroutine);
let prev_try_block_label = this.current_try_block_label.take();
@@ -705,7 +707,7 @@ impl ExprCollector<'_> {
ast::Expr::UnderscoreExpr(_) => self.alloc_expr(Expr::Underscore, syntax_ptr),
ast::Expr::AsmExpr(e) => self.lower_inline_asm(e, syntax_ptr),
ast::Expr::OffsetOfExpr(e) => {
let container = TypeRef::from_ast_opt(&self.ctx(), e.ty());
let container = TypeRef::from_ast_opt(&mut self.ctx(), e.ty());
let fields = e.fields().map(|it| it.as_name()).collect();
self.alloc_expr(Expr::OffsetOf(OffsetOf { container, fields }), syntax_ptr)
}
@@ -1317,7 +1319,7 @@ impl ExprCollector<'_> {
return;
}
let pat = self.collect_pat_top(stmt.pat());
let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it));
let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&mut self.ctx(), it));
let initializer = stmt.initializer().map(|e| self.collect_expr(e));
let else_branch = stmt
.let_else()
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/expander.rs
Original file line number Diff line number Diff line change
@@ -161,14 +161,14 @@ impl Expander {
types_map: &mut TypesMap,
types_source_map: &mut TypesSourceMap,
) -> Option<Path> {
let ctx = LowerCtx::with_span_map_cell(
let mut ctx = LowerCtx::with_span_map_cell(
db,
self.current_file_id,
self.span_map.clone(),
types_map,
types_source_map,
);
Path::from_src(&ctx, path)
Path::from_src(&mut ctx, path)
}

fn within_limit<F, T: ast::AstNode>(
19 changes: 12 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/generics.rs
Original file line number Diff line number Diff line change
@@ -451,7 +451,7 @@ pub(crate) struct GenericParamsCollector {
impl GenericParamsCollector {
pub(crate) fn fill(
&mut self,
lower_ctx: &LowerCtx<'_>,
lower_ctx: &mut LowerCtx<'_>,
node: &dyn HasGenericParams,
add_param_attrs: impl FnMut(
Either<LocalTypeOrConstParamId, LocalLifetimeParamId>,
@@ -468,7 +468,7 @@ impl GenericParamsCollector {

pub(crate) fn fill_bounds(
&mut self,
lower_ctx: &LowerCtx<'_>,
lower_ctx: &mut LowerCtx<'_>,
type_bounds: Option<ast::TypeBoundList>,
target: Either<TypeRefId, LifetimeRef>,
) {
@@ -479,7 +479,7 @@ impl GenericParamsCollector {

fn fill_params(
&mut self,
lower_ctx: &LowerCtx<'_>,
lower_ctx: &mut LowerCtx<'_>,
params: ast::GenericParamList,
mut add_param_attrs: impl FnMut(
Either<LocalTypeOrConstParamId, LocalLifetimeParamId>,
@@ -535,7 +535,11 @@ impl GenericParamsCollector {
}
}

fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx<'_>, where_clause: ast::WhereClause) {
fn fill_where_predicates(
&mut self,
lower_ctx: &mut LowerCtx<'_>,
where_clause: ast::WhereClause,
) {
for pred in where_clause.predicates() {
let target = if let Some(type_ref) = pred.ty() {
Either::Left(TypeRef::from_ast(lower_ctx, type_ref))
@@ -569,7 +573,7 @@ impl GenericParamsCollector {

fn add_where_predicate_from_bound(
&mut self,
lower_ctx: &LowerCtx<'_>,
lower_ctx: &mut LowerCtx<'_>,
bound: ast::TypeBound,
hrtb_lifetimes: Option<&[Name]>,
target: Either<TypeRefId, LifetimeRef>,
@@ -670,8 +674,9 @@ impl GenericParamsCollector {
{
let (mut macro_types_map, mut macro_types_source_map) =
(TypesMap::default(), TypesSourceMap::default());
let ctx = expander.ctx(db, &mut macro_types_map, &mut macro_types_source_map);
let type_ref = TypeRef::from_ast(&ctx, expanded.tree());
let mut ctx =
expander.ctx(db, &mut macro_types_map, &mut macro_types_source_map);
let type_ref = TypeRef::from_ast(&mut ctx, expanded.tree());
self.fill_implicit_impl_trait_args(
db,
generics_types_map,
17 changes: 9 additions & 8 deletions src/tools/rust-analyzer/crates/hir-def/src/hir/type_ref.rs
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ pub struct TraitRef {

impl TraitRef {
/// Converts an `ast::PathType` to a `hir::TraitRef`.
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> Option<Self> {
pub(crate) fn from_ast(ctx: &mut LowerCtx<'_>, node: ast::Type) -> Option<Self> {
// FIXME: Use `Path::from_src`
match node {
ast::Type::PathType(path) => {
@@ -240,7 +240,7 @@ pub enum TraitBoundModifier {

impl TypeRef {
/// Converts an `ast::TypeRef` to a `hir::TypeRef`.
pub fn from_ast(ctx: &LowerCtx<'_>, node: ast::Type) -> TypeRefId {
pub fn from_ast(ctx: &mut LowerCtx<'_>, node: ast::Type) -> TypeRefId {
let ty = match &node {
ast::Type::ParenType(inner) => return TypeRef::from_ast_opt(ctx, inner.ty()),
ast::Type::TupleType(inner) => TypeRef::Tuple(EmptyOptimizedThinVec::from_iter(
@@ -321,8 +321,9 @@ impl TypeRef {
// Disallow nested impl traits
TypeRef::Error
} else {
let _guard = ctx.outer_impl_trait_scope(true);
TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
ctx.with_outer_impl_trait_scope(true, |ctx| {
TypeRef::ImplTrait(type_bounds_from_ast(ctx, inner.type_bound_list()))
})
}
}
ast::Type::DynTraitType(inner) => {
@@ -336,7 +337,7 @@ impl TypeRef {
ctx.alloc_type_ref(ty, AstPtr::new(&node))
}

pub(crate) fn from_ast_opt(ctx: &LowerCtx<'_>, node: Option<ast::Type>) -> TypeRefId {
pub(crate) fn from_ast_opt(ctx: &mut LowerCtx<'_>, node: Option<ast::Type>) -> TypeRefId {
match node {
Some(node) => TypeRef::from_ast(ctx, node),
None => ctx.alloc_error_type(),
@@ -410,7 +411,7 @@ impl TypeRef {
}

pub(crate) fn type_bounds_from_ast(
lower_ctx: &LowerCtx<'_>,
lower_ctx: &mut LowerCtx<'_>,
type_bounds_opt: Option<ast::TypeBoundList>,
) -> ThinVec<TypeBound> {
if let Some(type_bounds) = type_bounds_opt {
@@ -423,8 +424,8 @@ pub(crate) fn type_bounds_from_ast(
}

impl TypeBound {
pub(crate) fn from_ast(ctx: &LowerCtx<'_>, node: ast::TypeBound) -> Self {
let lower_path_type = |path_type: ast::PathType| ctx.lower_path(path_type.path()?);
pub(crate) fn from_ast(ctx: &mut LowerCtx<'_>, node: ast::TypeBound) -> Self {
let mut lower_path_type = |path_type: ast::PathType| ctx.lower_path(path_type.path()?);

match node.kind() {
ast::TypeBoundKind::PathType(path_type) => {
Loading