diff options
26 files changed, 133 insertions, 151 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 613266e07..43162797e 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -51,12 +51,14 @@ impl PathResolution { | |||
51 | PathResolution::Def(ModuleDef::BuiltinType(builtin)) => { | 51 | PathResolution::Def(ModuleDef::BuiltinType(builtin)) => { |
52 | Some(TypeNs::BuiltinType((*builtin).into())) | 52 | Some(TypeNs::BuiltinType((*builtin).into())) |
53 | } | 53 | } |
54 | PathResolution::Def(ModuleDef::Const(_)) | 54 | PathResolution::Def( |
55 | | PathResolution::Def(ModuleDef::Variant(_)) | 55 | ModuleDef::Const(_) |
56 | | PathResolution::Def(ModuleDef::Function(_)) | 56 | | ModuleDef::Variant(_) |
57 | | PathResolution::Def(ModuleDef::Module(_)) | 57 | | ModuleDef::Function(_) |
58 | | PathResolution::Def(ModuleDef::Static(_)) | 58 | | ModuleDef::Module(_) |
59 | | PathResolution::Def(ModuleDef::Trait(_)) => None, | 59 | | ModuleDef::Static(_) |
60 | | ModuleDef::Trait(_), | ||
61 | ) => None, | ||
60 | PathResolution::Def(ModuleDef::TypeAlias(alias)) => { | 62 | PathResolution::Def(ModuleDef::TypeAlias(alias)) => { |
61 | Some(TypeNs::TypeAliasId((*alias).into())) | 63 | Some(TypeNs::TypeAliasId((*alias).into())) |
62 | } | 64 | } |
@@ -65,8 +67,7 @@ impl PathResolution { | |||
65 | } | 67 | } |
66 | PathResolution::TypeParam(param) => Some(TypeNs::GenericParam((*param).into())), | 68 | PathResolution::TypeParam(param) => Some(TypeNs::GenericParam((*param).into())), |
67 | PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType((*impl_def).into())), | 69 | PathResolution::SelfType(impl_def) => Some(TypeNs::SelfType((*impl_def).into())), |
68 | PathResolution::AssocItem(AssocItem::Const(_)) | 70 | PathResolution::AssocItem(AssocItem::Const(_) | AssocItem::Function(_)) => None, |
69 | | PathResolution::AssocItem(AssocItem::Function(_)) => None, | ||
70 | PathResolution::AssocItem(AssocItem::TypeAlias(alias)) => { | 71 | PathResolution::AssocItem(AssocItem::TypeAlias(alias)) => { |
71 | Some(TypeNs::TypeAliasId((*alias).into())) | 72 | Some(TypeNs::TypeAliasId((*alias).into())) |
72 | } | 73 | } |
diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs index b1e1b70d0..e63bc8232 100644 --- a/crates/hir_def/src/item_tree/pretty.rs +++ b/crates/hir_def/src/item_tree/pretty.rs | |||
@@ -63,7 +63,7 @@ impl<'a> Printer<'a> { | |||
63 | fn blank(&mut self) { | 63 | fn blank(&mut self) { |
64 | let mut iter = self.buf.chars().rev().fuse(); | 64 | let mut iter = self.buf.chars().rev().fuse(); |
65 | match (iter.next(), iter.next()) { | 65 | match (iter.next(), iter.next()) { |
66 | (Some('\n'), Some('\n')) | (Some('\n'), None) | (None, None) => {} | 66 | (Some('\n'), Some('\n') | None) | (None, None) => {} |
67 | (Some('\n'), Some(_)) => { | 67 | (Some('\n'), Some(_)) => { |
68 | self.buf.push('\n'); | 68 | self.buf.push('\n'); |
69 | } | 69 | } |
@@ -77,7 +77,7 @@ impl<'a> Printer<'a> { | |||
77 | 77 | ||
78 | fn whitespace(&mut self) { | 78 | fn whitespace(&mut self) { |
79 | match self.buf.chars().next_back() { | 79 | match self.buf.chars().next_back() { |
80 | None | Some('\n') | Some(' ') => {} | 80 | None | Some('\n' | ' ') => {} |
81 | _ => self.buf.push(' '), | 81 | _ => self.buf.push(' '), |
82 | } | 82 | } |
83 | } | 83 | } |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index fc2c50fb8..927a7b6e8 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1260,7 +1260,7 @@ impl DefCollector<'_> { | |||
1260 | for directive in &self.unresolved_imports { | 1260 | for directive in &self.unresolved_imports { |
1261 | if let ImportSource::Import { id: import, use_tree } = &directive.import.source { | 1261 | if let ImportSource::Import { id: import, use_tree } = &directive.import.source { |
1262 | match (directive.import.path.segments().first(), &directive.import.path.kind) { | 1262 | match (directive.import.path.segments().first(), &directive.import.path.kind) { |
1263 | (Some(krate), PathKind::Plain) | (Some(krate), PathKind::Abs) => { | 1263 | (Some(krate), PathKind::Plain | PathKind::Abs) => { |
1264 | if diagnosed_extern_crates.contains(krate) { | 1264 | if diagnosed_extern_crates.contains(krate) { |
1265 | continue; | 1265 | continue; |
1266 | } | 1266 | } |
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index d4681fa3e..47e56259f 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -605,8 +605,7 @@ fn to_value_ns(per_ns: PerNs) -> Option<ValueNs> { | |||
605 | ModuleDefId::ConstId(it) => ValueNs::ConstId(it), | 605 | ModuleDefId::ConstId(it) => ValueNs::ConstId(it), |
606 | ModuleDefId::StaticId(it) => ValueNs::StaticId(it), | 606 | ModuleDefId::StaticId(it) => ValueNs::StaticId(it), |
607 | 607 | ||
608 | ModuleDefId::AdtId(AdtId::EnumId(_)) | 608 | ModuleDefId::AdtId(AdtId::EnumId(_) | AdtId::UnionId(_)) |
609 | | ModuleDefId::AdtId(AdtId::UnionId(_)) | ||
610 | | ModuleDefId::TraitId(_) | 609 | | ModuleDefId::TraitId(_) |
611 | | ModuleDefId::TypeAliasId(_) | 610 | | ModuleDefId::TypeAliasId(_) |
612 | | ModuleDefId::BuiltinType(_) | 611 | | ModuleDefId::BuiltinType(_) |
diff --git a/crates/hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs index 83500f54e..aeb1e7726 100644 --- a/crates/hir_def/src/visibility.rs +++ b/crates/hir_def/src/visibility.rs | |||
@@ -172,9 +172,8 @@ impl Visibility { | |||
172 | /// visible in unrelated modules). | 172 | /// visible in unrelated modules). |
173 | pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option<Visibility> { | 173 | pub(crate) fn max(self, other: Visibility, def_map: &DefMap) -> Option<Visibility> { |
174 | match (self, other) { | 174 | match (self, other) { |
175 | (Visibility::Module(_), Visibility::Public) | 175 | (Visibility::Module(_) | Visibility::Public, Visibility::Public) |
176 | | (Visibility::Public, Visibility::Module(_)) | 176 | | (Visibility::Public, Visibility::Module(_)) => Some(Visibility::Public), |
177 | | (Visibility::Public, Visibility::Public) => Some(Visibility::Public), | ||
178 | (Visibility::Module(mod_a), Visibility::Module(mod_b)) => { | 177 | (Visibility::Module(mod_a), Visibility::Module(mod_b)) => { |
179 | if mod_a.krate != mod_b.krate { | 178 | if mod_a.krate != mod_b.krate { |
180 | return None; | 179 | return None; |
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index 05c6c3fb1..848522411 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -146,10 +146,11 @@ impl HygieneInfo { | |||
146 | (&self.macro_arg.1, InFile::new(loc.kind.file_id(), arg_start)) | 146 | (&self.macro_arg.1, InFile::new(loc.kind.file_id(), arg_start)) |
147 | } | 147 | } |
148 | mbe::Origin::Def => match (&*self.macro_def, self.def_start) { | 148 | mbe::Origin::Def => match (&*self.macro_def, self.def_start) { |
149 | (TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt)) | 149 | ( |
150 | | (TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt)) => { | 150 | TokenExpander::MacroDef { def_site_token_map, .. } |
151 | (def_site_token_map, tt) | 151 | | TokenExpander::MacroRules { def_site_token_map, .. }, |
152 | } | 152 | Some(tt), |
153 | ) => (def_site_token_map, tt), | ||
153 | _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"), | 154 | _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"), |
154 | }, | 155 | }, |
155 | }; | 156 | }; |
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 33107aa24..c31426d7c 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -368,10 +368,11 @@ impl ExpansionInfo { | |||
368 | let (token_map, tt) = match origin { | 368 | let (token_map, tt) = match origin { |
369 | mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()), | 369 | mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()), |
370 | mbe::Origin::Def => match (&*self.macro_def, self.def.as_ref()) { | 370 | mbe::Origin::Def => match (&*self.macro_def, self.def.as_ref()) { |
371 | (db::TokenExpander::MacroRules { def_site_token_map, .. }, Some(tt)) | 371 | ( |
372 | | (db::TokenExpander::MacroDef { def_site_token_map, .. }, Some(tt)) => { | 372 | db::TokenExpander::MacroRules { def_site_token_map, .. } |
373 | (def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone())) | 373 | | db::TokenExpander::MacroDef { def_site_token_map, .. }, |
374 | } | 374 | Some(tt), |
375 | ) => (def_site_token_map, tt.as_ref().map(|tt| tt.syntax().clone())), | ||
375 | _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"), | 376 | _ => panic!("`Origin::Def` used with non-`macro_rules!` macro"), |
376 | }, | 377 | }, |
377 | }; | 378 | }; |
diff --git a/crates/hir_ty/src/consteval.rs b/crates/hir_ty/src/consteval.rs index 6f0bf8f8c..ab1afce08 100644 --- a/crates/hir_ty/src/consteval.rs +++ b/crates/hir_ty/src/consteval.rs | |||
@@ -38,8 +38,7 @@ impl ConstExt for Const { | |||
38 | // FIXME: support more than just evaluating literals | 38 | // FIXME: support more than just evaluating literals |
39 | pub fn eval_usize(expr: &Expr) -> Option<u64> { | 39 | pub fn eval_usize(expr: &Expr) -> Option<u64> { |
40 | match expr { | 40 | match expr { |
41 | Expr::Literal(Literal::Uint(v, None)) | 41 | Expr::Literal(Literal::Uint(v, None | Some(BuiltinUint::Usize))) => (*v).try_into().ok(), |
42 | | Expr::Literal(Literal::Uint(v, Some(BuiltinUint::Usize))) => (*v).try_into().ok(), | ||
43 | _ => None, | 42 | _ => None, |
44 | } | 43 | } |
45 | } | 44 | } |
diff --git a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs index 471cd4921..e3d640a79 100644 --- a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs +++ b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs | |||
@@ -84,10 +84,7 @@ impl IntRange { | |||
84 | #[inline] | 84 | #[inline] |
85 | fn is_integral(ty: &Ty) -> bool { | 85 | fn is_integral(ty: &Ty) -> bool { |
86 | match ty.kind(&Interner) { | 86 | match ty.kind(&Interner) { |
87 | TyKind::Scalar(Scalar::Char) | 87 | TyKind::Scalar(Scalar::Char | Scalar::Int(_) | Scalar::Uint(_) | Scalar::Bool) => true, |
88 | | TyKind::Scalar(Scalar::Int(_)) | ||
89 | | TyKind::Scalar(Scalar::Uint(_)) | ||
90 | | TyKind::Scalar(Scalar::Bool) => true, | ||
91 | _ => false, | 88 | _ => false, |
92 | } | 89 | } |
93 | } | 90 | } |
@@ -381,7 +378,7 @@ impl Constructor { | |||
381 | // Wildcards cover anything | 378 | // Wildcards cover anything |
382 | (_, Wildcard) => true, | 379 | (_, Wildcard) => true, |
383 | // The missing ctors are not covered by anything in the matrix except wildcards. | 380 | // The missing ctors are not covered by anything in the matrix except wildcards. |
384 | (Missing, _) | (Wildcard, _) => false, | 381 | (Missing | Wildcard, _) => false, |
385 | 382 | ||
386 | (Single, Single) => true, | 383 | (Single, Single) => true, |
387 | (Variant(self_id), Variant(other_id)) => self_id == other_id, | 384 | (Variant(self_id), Variant(other_id)) => self_id == other_id, |
@@ -523,7 +520,7 @@ impl SplitWildcard { | |||
523 | } | 520 | } |
524 | } | 521 | } |
525 | TyKind::Scalar(Scalar::Char) => unhandled(), | 522 | TyKind::Scalar(Scalar::Char) => unhandled(), |
526 | TyKind::Scalar(Scalar::Int(..)) | TyKind::Scalar(Scalar::Uint(..)) => unhandled(), | 523 | TyKind::Scalar(Scalar::Int(..) | Scalar::Uint(..)) => unhandled(), |
527 | TyKind::Never if !cx.feature_exhaustive_patterns() && !pcx.is_top_level => { | 524 | TyKind::Never if !cx.feature_exhaustive_patterns() && !pcx.is_top_level => { |
528 | smallvec![NonExhaustive] | 525 | smallvec![NonExhaustive] |
529 | } | 526 | } |
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 4b7f31521..7be914451 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -47,10 +47,7 @@ impl<'a> InferenceContext<'a> { | |||
47 | // pointers to have a chance at getting a match. See | 47 | // pointers to have a chance at getting a match. See |
48 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 | 48 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 |
49 | let sig = match (ty1.kind(&Interner), ty2.kind(&Interner)) { | 49 | let sig = match (ty1.kind(&Interner), ty2.kind(&Interner)) { |
50 | (TyKind::FnDef(..), TyKind::FnDef(..)) | 50 | (TyKind::FnDef(..) | TyKind::Closure(..), TyKind::FnDef(..) | TyKind::Closure(..)) => { |
51 | | (TyKind::Closure(..), TyKind::FnDef(..)) | ||
52 | | (TyKind::FnDef(..), TyKind::Closure(..)) | ||
53 | | (TyKind::Closure(..), TyKind::Closure(..)) => { | ||
54 | // FIXME: we're ignoring safety here. To be more correct, if we have one FnDef and one Closure, | 51 | // FIXME: we're ignoring safety here. To be more correct, if we have one FnDef and one Closure, |
55 | // we should be coercing the closure to a fn pointer of the safety of the FnDef | 52 | // we should be coercing the closure to a fn pointer of the safety of the FnDef |
56 | cov_mark::hit!(coerce_fn_reification); | 53 | cov_mark::hit!(coerce_fn_reification); |
@@ -448,8 +445,7 @@ fn safe_to_unsafe_fn_ty(fn_ty: FnPointer) -> FnPointer { | |||
448 | 445 | ||
449 | fn coerce_mutabilities(from: Mutability, to: Mutability) -> Result<(), TypeError> { | 446 | fn coerce_mutabilities(from: Mutability, to: Mutability) -> Result<(), TypeError> { |
450 | match (from, to) { | 447 | match (from, to) { |
451 | (Mutability::Mut, Mutability::Mut) | 448 | (Mutability::Mut, Mutability::Mut | Mutability::Not) |
452 | | (Mutability::Mut, Mutability::Not) | ||
453 | | (Mutability::Not, Mutability::Not) => Ok(()), | 449 | | (Mutability::Not, Mutability::Not) => Ok(()), |
454 | (Mutability::Not, Mutability::Mut) => Err(TypeError), | 450 | (Mutability::Not, Mutability::Mut) => Err(TypeError), |
455 | } | 451 | } |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 5ea2e5934..4e4f6e5a4 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -593,11 +593,11 @@ impl<'a> InferenceContext<'a> { | |||
593 | UnaryOp::Neg => { | 593 | UnaryOp::Neg => { |
594 | match inner_ty.kind(&Interner) { | 594 | match inner_ty.kind(&Interner) { |
595 | // Fast path for builtins | 595 | // Fast path for builtins |
596 | TyKind::Scalar(Scalar::Int(_)) | 596 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_)) |
597 | | TyKind::Scalar(Scalar::Uint(_)) | 597 | | TyKind::InferenceVar( |
598 | | TyKind::Scalar(Scalar::Float(_)) | 598 | _, |
599 | | TyKind::InferenceVar(_, TyVariableKind::Integer) | 599 | TyVariableKind::Integer | TyVariableKind::Float, |
600 | | TyKind::InferenceVar(_, TyVariableKind::Float) => inner_ty, | 600 | ) => inner_ty, |
601 | // Otherwise we resolve via the std::ops::Neg trait | 601 | // Otherwise we resolve via the std::ops::Neg trait |
602 | _ => self | 602 | _ => self |
603 | .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()), | 603 | .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()), |
@@ -606,9 +606,7 @@ impl<'a> InferenceContext<'a> { | |||
606 | UnaryOp::Not => { | 606 | UnaryOp::Not => { |
607 | match inner_ty.kind(&Interner) { | 607 | match inner_ty.kind(&Interner) { |
608 | // Fast path for builtins | 608 | // Fast path for builtins |
609 | TyKind::Scalar(Scalar::Bool) | 609 | TyKind::Scalar(Scalar::Bool | Scalar::Int(_) | Scalar::Uint(_)) |
610 | | TyKind::Scalar(Scalar::Int(_)) | ||
611 | | TyKind::Scalar(Scalar::Uint(_)) | ||
612 | | TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty, | 610 | | TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty, |
613 | // Otherwise we resolve via the std::ops::Not trait | 611 | // Otherwise we resolve via the std::ops::Not trait |
614 | _ => self | 612 | _ => self |
@@ -735,7 +733,7 @@ impl<'a> InferenceContext<'a> { | |||
735 | Expr::Array(array) => { | 733 | Expr::Array(array) => { |
736 | let elem_ty = | 734 | let elem_ty = |
737 | match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) { | 735 | match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) { |
738 | Some(TyKind::Array(st, _)) | Some(TyKind::Slice(st)) => st.clone(), | 736 | Some(TyKind::Array(st, _) | TyKind::Slice(st)) => st.clone(), |
739 | _ => self.table.new_type_var(), | 737 | _ => self.table.new_type_var(), |
740 | }; | 738 | }; |
741 | 739 | ||
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 035f4ded6..58cb23e9d 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -297,10 +297,11 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool { | |||
297 | Expr::Literal(Literal::String(..)) => false, | 297 | Expr::Literal(Literal::String(..)) => false, |
298 | _ => true, | 298 | _ => true, |
299 | }, | 299 | }, |
300 | Pat::Bind { mode: BindingAnnotation::Mutable, subpat: Some(subpat), .. } | 300 | Pat::Bind { |
301 | | Pat::Bind { mode: BindingAnnotation::Unannotated, subpat: Some(subpat), .. } => { | 301 | mode: BindingAnnotation::Mutable | BindingAnnotation::Unannotated, |
302 | is_non_ref_pat(body, *subpat) | 302 | subpat: Some(subpat), |
303 | } | 303 | .. |
304 | } => is_non_ref_pat(body, *subpat), | ||
304 | Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Box { .. } | Pat::Missing => false, | 305 | Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Box { .. } | Pat::Missing => false, |
305 | } | 306 | } |
306 | } | 307 | } |
diff --git a/crates/hir_ty/src/op.rs b/crates/hir_ty/src/op.rs index 0222de2bc..5ef6342d5 100644 --- a/crates/hir_ty/src/op.rs +++ b/crates/hir_ty/src/op.rs | |||
@@ -8,17 +8,15 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty { | |||
8 | match op { | 8 | match op { |
9 | BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => TyKind::Scalar(Scalar::Bool).intern(&Interner), | 9 | BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => TyKind::Scalar(Scalar::Bool).intern(&Interner), |
10 | BinaryOp::Assignment { .. } => TyBuilder::unit(), | 10 | BinaryOp::Assignment { .. } => TyBuilder::unit(), |
11 | BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => { | 11 | BinaryOp::ArithOp(ArithOp::Shl | ArithOp::Shr) => { |
12 | // all integer combinations are valid here | 12 | // all integer combinations are valid here |
13 | if matches!( | 13 | if matches!( |
14 | lhs_ty.kind(&Interner), | 14 | lhs_ty.kind(&Interner), |
15 | TyKind::Scalar(Scalar::Int(_)) | 15 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)) |
16 | | TyKind::Scalar(Scalar::Uint(_)) | ||
17 | | TyKind::InferenceVar(_, TyVariableKind::Integer) | 16 | | TyKind::InferenceVar(_, TyVariableKind::Integer) |
18 | ) && matches!( | 17 | ) && matches!( |
19 | rhs_ty.kind(&Interner), | 18 | rhs_ty.kind(&Interner), |
20 | TyKind::Scalar(Scalar::Int(_)) | 19 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)) |
21 | | TyKind::Scalar(Scalar::Uint(_)) | ||
22 | | TyKind::InferenceVar(_, TyVariableKind::Integer) | 20 | | TyKind::InferenceVar(_, TyVariableKind::Integer) |
23 | ) { | 21 | ) { |
24 | lhs_ty | 22 | lhs_ty |
@@ -32,15 +30,15 @@ pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty { | |||
32 | | (TyKind::Scalar(Scalar::Uint(_)), TyKind::Scalar(Scalar::Uint(_))) | 30 | | (TyKind::Scalar(Scalar::Uint(_)), TyKind::Scalar(Scalar::Uint(_))) |
33 | | (TyKind::Scalar(Scalar::Float(_)), TyKind::Scalar(Scalar::Float(_))) => rhs_ty, | 31 | | (TyKind::Scalar(Scalar::Float(_)), TyKind::Scalar(Scalar::Float(_))) => rhs_ty, |
34 | // ({int}, int) | ({int}, uint) | 32 | // ({int}, int) | ({int}, uint) |
35 | (TyKind::InferenceVar(_, TyVariableKind::Integer), TyKind::Scalar(Scalar::Int(_))) | 33 | ( |
36 | | (TyKind::InferenceVar(_, TyVariableKind::Integer), TyKind::Scalar(Scalar::Uint(_))) => { | 34 | TyKind::InferenceVar(_, TyVariableKind::Integer), |
37 | rhs_ty | 35 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)), |
38 | } | 36 | ) => rhs_ty, |
39 | // (int, {int}) | (uint, {int}) | 37 | // (int, {int}) | (uint, {int}) |
40 | (TyKind::Scalar(Scalar::Int(_)), TyKind::InferenceVar(_, TyVariableKind::Integer)) | 38 | ( |
41 | | (TyKind::Scalar(Scalar::Uint(_)), TyKind::InferenceVar(_, TyVariableKind::Integer)) => { | 39 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_)), |
42 | lhs_ty | 40 | TyKind::InferenceVar(_, TyVariableKind::Integer), |
43 | } | 41 | ) => lhs_ty, |
44 | // ({float} | float) | 42 | // ({float} | float) |
45 | (TyKind::InferenceVar(_, TyVariableKind::Float), TyKind::Scalar(Scalar::Float(_))) => { | 43 | (TyKind::InferenceVar(_, TyVariableKind::Float), TyKind::Scalar(Scalar::Float(_))) => { |
46 | rhs_ty | 44 | rhs_ty |
@@ -69,21 +67,15 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | |||
69 | BinaryOp::Assignment { op: None } => lhs_ty, | 67 | BinaryOp::Assignment { op: None } => lhs_ty, |
70 | BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty.kind(&Interner) { | 68 | BinaryOp::CmpOp(CmpOp::Eq { .. }) => match lhs_ty.kind(&Interner) { |
71 | TyKind::Scalar(_) | TyKind::Str => lhs_ty, | 69 | TyKind::Scalar(_) | TyKind::Str => lhs_ty, |
72 | TyKind::InferenceVar(_, TyVariableKind::Integer) | 70 | TyKind::InferenceVar(_, TyVariableKind::Integer | TyVariableKind::Float) => lhs_ty, |
73 | | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty, | ||
74 | _ => TyKind::Error.intern(&Interner), | 71 | _ => TyKind::Error.intern(&Interner), |
75 | }, | 72 | }, |
76 | BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => { | 73 | BinaryOp::ArithOp(ArithOp::Shl | ArithOp::Shr) => TyKind::Error.intern(&Interner), |
77 | TyKind::Error.intern(&Interner) | ||
78 | } | ||
79 | BinaryOp::CmpOp(CmpOp::Ord { .. }) | 74 | BinaryOp::CmpOp(CmpOp::Ord { .. }) |
80 | | BinaryOp::Assignment { op: Some(_) } | 75 | | BinaryOp::Assignment { op: Some(_) } |
81 | | BinaryOp::ArithOp(_) => match lhs_ty.kind(&Interner) { | 76 | | BinaryOp::ArithOp(_) => match lhs_ty.kind(&Interner) { |
82 | TyKind::Scalar(Scalar::Int(_)) | 77 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_)) => lhs_ty, |
83 | | TyKind::Scalar(Scalar::Uint(_)) | 78 | TyKind::InferenceVar(_, TyVariableKind::Integer | TyVariableKind::Float) => lhs_ty, |
84 | | TyKind::Scalar(Scalar::Float(_)) => lhs_ty, | ||
85 | TyKind::InferenceVar(_, TyVariableKind::Integer) | ||
86 | | TyKind::InferenceVar(_, TyVariableKind::Float) => lhs_ty, | ||
87 | _ => TyKind::Error.intern(&Interner), | 79 | _ => TyKind::Error.intern(&Interner), |
88 | }, | 80 | }, |
89 | } | 81 | } |
diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index 93d3760bf..ffa8bd182 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs | |||
@@ -197,7 +197,7 @@ fn join_single_use_tree(edit: &mut TextEditBuilder, token: &SyntaxToken) -> Opti | |||
197 | } | 197 | } |
198 | 198 | ||
199 | fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { | 199 | fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { |
200 | matches!((left, right), (T![,], T![')']) | (T![,], T![']'])) | 200 | matches!((left, right), (T![,], T![')'] | T![']'])) |
201 | } | 201 | } |
202 | 202 | ||
203 | fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { | 203 | fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 945c9b9e1..5808562a7 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -79,8 +79,7 @@ pub(crate) fn find_all_refs( | |||
79 | }); | 79 | }); |
80 | usages.references.retain(|_, it| !it.is_empty()); | 80 | usages.references.retain(|_, it| !it.is_empty()); |
81 | } | 81 | } |
82 | Definition::ModuleDef(hir::ModuleDef::Adt(_)) | 82 | Definition::ModuleDef(hir::ModuleDef::Adt(_) | hir::ModuleDef::Variant(_)) => { |
83 | | Definition::ModuleDef(hir::ModuleDef::Variant(_)) => { | ||
84 | refs.for_each(|it| { | 83 | refs.for_each(|it| { |
85 | it.retain(|reference| { | 84 | it.retain(|reference| { |
86 | reference.name.as_name_ref().map_or(false, is_lit_name_ref) | 85 | reference.name.as_name_ref().map_or(false, is_lit_name_ref) |
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index e186b82b7..d44a1b45f 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs | |||
@@ -294,7 +294,7 @@ fn traverse( | |||
294 | Some(parent) => { | 294 | Some(parent) => { |
295 | // We only care Name and Name_ref | 295 | // We only care Name and Name_ref |
296 | match (token.kind(), parent.kind()) { | 296 | match (token.kind(), parent.kind()) { |
297 | (IDENT, NAME) | (IDENT, NAME_REF) => parent.into(), | 297 | (IDENT, NAME | NAME_REF) => parent.into(), |
298 | _ => token.into(), | 298 | _ => token.into(), |
299 | } | 299 | } |
300 | } | 300 | } |
@@ -310,7 +310,7 @@ fn traverse( | |||
310 | Some(parent) => { | 310 | Some(parent) => { |
311 | // We only care Name and Name_ref | 311 | // We only care Name and Name_ref |
312 | match (token.kind(), parent.kind()) { | 312 | match (token.kind(), parent.kind()) { |
313 | (IDENT, NAME) | (IDENT, NAME_REF) => parent.into(), | 313 | (IDENT, NAME | NAME_REF) => parent.into(), |
314 | _ => token.into(), | 314 | _ => token.into(), |
315 | } | 315 | } |
316 | } | 316 | } |
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index f2be091f4..7085a0c48 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs | |||
@@ -1384,7 +1384,7 @@ fn fix_param_usages(ctx: &AssistContext, params: &[Param], syntax: &SyntaxNode) | |||
1384 | for (param, usages) in usages_for_param { | 1384 | for (param, usages) in usages_for_param { |
1385 | for usage in usages { | 1385 | for usage in usages { |
1386 | match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { | 1386 | match usage.syntax().ancestors().skip(1).find_map(ast::Expr::cast) { |
1387 | Some(ast::Expr::MethodCallExpr(_)) | Some(ast::Expr::FieldExpr(_)) => { | 1387 | Some(ast::Expr::MethodCallExpr(_) | ast::Expr::FieldExpr(_)) => { |
1388 | // do nothing | 1388 | // do nothing |
1389 | } | 1389 | } |
1390 | Some(ast::Expr::RefExpr(node)) | 1390 | Some(ast::Expr::RefExpr(node)) |
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index 2441dbb8b..bf4ba16f0 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs | |||
@@ -68,28 +68,33 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | |||
68 | 68 | ||
69 | Some(!matches!( | 69 | Some(!matches!( |
70 | (&initializer_expr, usage_parent), | 70 | (&initializer_expr, usage_parent), |
71 | (ast::Expr::CallExpr(_), _) | 71 | ( |
72 | | (ast::Expr::IndexExpr(_), _) | 72 | ast::Expr::CallExpr(_) |
73 | | (ast::Expr::MethodCallExpr(_), _) | 73 | | ast::Expr::IndexExpr(_) |
74 | | (ast::Expr::FieldExpr(_), _) | 74 | | ast::Expr::MethodCallExpr(_) |
75 | | (ast::Expr::TryExpr(_), _) | 75 | | ast::Expr::FieldExpr(_) |
76 | | (ast::Expr::RefExpr(_), _) | 76 | | ast::Expr::TryExpr(_) |
77 | | (ast::Expr::Literal(_), _) | 77 | | ast::Expr::RefExpr(_) |
78 | | (ast::Expr::TupleExpr(_), _) | 78 | | ast::Expr::Literal(_) |
79 | | (ast::Expr::ArrayExpr(_), _) | 79 | | ast::Expr::TupleExpr(_) |
80 | | (ast::Expr::ParenExpr(_), _) | 80 | | ast::Expr::ArrayExpr(_) |
81 | | (ast::Expr::PathExpr(_), _) | 81 | | ast::Expr::ParenExpr(_) |
82 | | (ast::Expr::BlockExpr(_), _) | 82 | | ast::Expr::PathExpr(_) |
83 | | (ast::Expr::EffectExpr(_), _) | 83 | | ast::Expr::BlockExpr(_) |
84 | | (_, ast::Expr::CallExpr(_)) | 84 | | ast::Expr::EffectExpr(_), |
85 | | (_, ast::Expr::TupleExpr(_)) | 85 | _ |
86 | | (_, ast::Expr::ArrayExpr(_)) | 86 | ) | ( |
87 | | (_, ast::Expr::ParenExpr(_)) | 87 | _, |
88 | | (_, ast::Expr::ForExpr(_)) | 88 | ast::Expr::CallExpr(_) |
89 | | (_, ast::Expr::WhileExpr(_)) | 89 | | ast::Expr::TupleExpr(_) |
90 | | (_, ast::Expr::BreakExpr(_)) | 90 | | ast::Expr::ArrayExpr(_) |
91 | | (_, ast::Expr::ReturnExpr(_)) | 91 | | ast::Expr::ParenExpr(_) |
92 | | (_, ast::Expr::MatchExpr(_)) | 92 | | ast::Expr::ForExpr(_) |
93 | | ast::Expr::WhileExpr(_) | ||
94 | | ast::Expr::BreakExpr(_) | ||
95 | | ast::Expr::ReturnExpr(_) | ||
96 | | ast::Expr::MatchExpr(_) | ||
97 | ) | ||
93 | )) | 98 | )) |
94 | }) | 99 | }) |
95 | .collect::<Option<_>>() | 100 | .collect::<Option<_>>() |
diff --git a/crates/ide_assists/src/tests.rs b/crates/ide_assists/src/tests.rs index 60cecd94c..29bd4a563 100644 --- a/crates/ide_assists/src/tests.rs +++ b/crates/ide_assists/src/tests.rs | |||
@@ -179,9 +179,10 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label: | |||
179 | "unresolved assist should not contain source changes" | 179 | "unresolved assist should not contain source changes" |
180 | ), | 180 | ), |
181 | (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), | 181 | (Some(_), ExpectedResult::NotApplicable) => panic!("assist should not be applicable!"), |
182 | (None, ExpectedResult::After(_)) | 182 | ( |
183 | | (None, ExpectedResult::Target(_)) | 183 | None, |
184 | | (None, ExpectedResult::Unresolved) => { | 184 | ExpectedResult::After(_) | ExpectedResult::Target(_) | ExpectedResult::Unresolved, |
185 | ) => { | ||
185 | panic!("code action is not applicable") | 186 | panic!("code action is not applicable") |
186 | } | 187 | } |
187 | (None, ExpectedResult::NotApplicable) => (), | 188 | (None, ExpectedResult::NotApplicable) => (), |
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 0597879ac..da3385bdc 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs | |||
@@ -65,9 +65,11 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
65 | // Don't suggest attribute macros and derives. | 65 | // Don't suggest attribute macros and derives. |
66 | hir::ScopeDef::MacroDef(mac) => mac.is_fn_like(), | 66 | hir::ScopeDef::MacroDef(mac) => mac.is_fn_like(), |
67 | // no values in type places | 67 | // no values in type places |
68 | hir::ScopeDef::ModuleDef(hir::ModuleDef::Function(_)) | 68 | hir::ScopeDef::ModuleDef( |
69 | | hir::ScopeDef::ModuleDef(hir::ModuleDef::Variant(_)) | 69 | hir::ModuleDef::Function(_) |
70 | | hir::ScopeDef::ModuleDef(hir::ModuleDef::Static(_)) | 70 | | hir::ModuleDef::Variant(_) |
71 | | hir::ModuleDef::Static(_), | ||
72 | ) | ||
71 | | hir::ScopeDef::Local(_) => !ctx.expects_type(), | 73 | | hir::ScopeDef::Local(_) => !ctx.expects_type(), |
72 | // unless its a constant in a generic arg list position | 74 | // unless its a constant in a generic arg list position |
73 | hir::ScopeDef::ModuleDef(hir::ModuleDef::Const(_)) => { | 75 | hir::ScopeDef::ModuleDef(hir::ModuleDef::Const(_)) => { |
@@ -81,9 +83,13 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
81 | } | 83 | } |
82 | } | 84 | } |
83 | } | 85 | } |
84 | hir::PathResolution::Def(def @ hir::ModuleDef::Adt(_)) | 86 | hir::PathResolution::Def( |
85 | | hir::PathResolution::Def(def @ hir::ModuleDef::TypeAlias(_)) | 87 | def |
86 | | hir::PathResolution::Def(def @ hir::ModuleDef::BuiltinType(_)) => { | 88 | @ |
89 | (hir::ModuleDef::Adt(_) | ||
90 | | hir::ModuleDef::TypeAlias(_) | ||
91 | | hir::ModuleDef::BuiltinType(_)), | ||
92 | ) => { | ||
87 | if let hir::ModuleDef::Adt(hir::Adt::Enum(e)) = def { | 93 | if let hir::ModuleDef::Adt(hir::Adt::Enum(e)) = def { |
88 | add_enum_variants(acc, ctx, e); | 94 | add_enum_variants(acc, ctx, e); |
89 | } | 95 | } |
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 6f96eceb9..77c6d706f 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs | |||
@@ -71,9 +71,11 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC | |||
71 | // Don't suggest attribute macros and derives. | 71 | // Don't suggest attribute macros and derives. |
72 | ScopeDef::MacroDef(mac) => mac.is_fn_like(), | 72 | ScopeDef::MacroDef(mac) => mac.is_fn_like(), |
73 | // no values in type places | 73 | // no values in type places |
74 | ScopeDef::ModuleDef(hir::ModuleDef::Function(_)) | 74 | ScopeDef::ModuleDef( |
75 | | ScopeDef::ModuleDef(hir::ModuleDef::Variant(_)) | 75 | hir::ModuleDef::Function(_) |
76 | | ScopeDef::ModuleDef(hir::ModuleDef::Static(_)) | 76 | | hir::ModuleDef::Variant(_) |
77 | | hir::ModuleDef::Static(_), | ||
78 | ) | ||
77 | | ScopeDef::Local(_) => !ctx.expects_type(), | 79 | | ScopeDef::Local(_) => !ctx.expects_type(), |
78 | // unless its a constant in a generic arg list position | 80 | // unless its a constant in a generic arg list position |
79 | ScopeDef::ModuleDef(hir::ModuleDef::Const(_)) | 81 | ScopeDef::ModuleDef(hir::ModuleDef::Const(_)) |
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 240cac1de..84b2bcf9f 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs | |||
@@ -242,24 +242,23 @@ impl<'a> CompletionContext<'a> { | |||
242 | } | 242 | } |
243 | 243 | ||
244 | pub(crate) fn expects_assoc_item(&self) -> bool { | 244 | pub(crate) fn expects_assoc_item(&self) -> bool { |
245 | matches!( | 245 | matches!(self.completion_location, Some(ImmediateLocation::Trait | ImmediateLocation::Impl)) |
246 | self.completion_location, | ||
247 | Some(ImmediateLocation::Trait) | Some(ImmediateLocation::Impl) | ||
248 | ) | ||
249 | } | 246 | } |
250 | 247 | ||
251 | pub(crate) fn has_dot_receiver(&self) -> bool { | 248 | pub(crate) fn has_dot_receiver(&self) -> bool { |
252 | matches!( | 249 | matches!( |
253 | &self.completion_location, | 250 | &self.completion_location, |
254 | Some(ImmediateLocation::FieldAccess { receiver, .. }) | Some(ImmediateLocation::MethodCall { receiver,.. }) | 251 | Some(ImmediateLocation::FieldAccess { receiver, .. } | ImmediateLocation::MethodCall { receiver,.. }) |
255 | if receiver.is_some() | 252 | if receiver.is_some() |
256 | ) | 253 | ) |
257 | } | 254 | } |
258 | 255 | ||
259 | pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> { | 256 | pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> { |
260 | match &self.completion_location { | 257 | match &self.completion_location { |
261 | Some(ImmediateLocation::MethodCall { receiver, .. }) | 258 | Some( |
262 | | Some(ImmediateLocation::FieldAccess { receiver, .. }) => receiver.as_ref(), | 259 | ImmediateLocation::MethodCall { receiver, .. } |
260 | | ImmediateLocation::FieldAccess { receiver, .. }, | ||
261 | ) => receiver.as_ref(), | ||
263 | _ => None, | 262 | _ => None, |
264 | } | 263 | } |
265 | } | 264 | } |
@@ -283,7 +282,7 @@ impl<'a> CompletionContext<'a> { | |||
283 | pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool { | 282 | pub(crate) fn expects_ident_pat_or_ref_expr(&self) -> bool { |
284 | matches!( | 283 | matches!( |
285 | self.completion_location, | 284 | self.completion_location, |
286 | Some(ImmediateLocation::IdentPat) | Some(ImmediateLocation::RefExpr) | 285 | Some(ImmediateLocation::IdentPat | ImmediateLocation::RefExpr) |
287 | ) | 286 | ) |
288 | } | 287 | } |
289 | 288 | ||
@@ -294,14 +293,14 @@ impl<'a> CompletionContext<'a> { | |||
294 | pub(crate) fn in_use_tree(&self) -> bool { | 293 | pub(crate) fn in_use_tree(&self) -> bool { |
295 | matches!( | 294 | matches!( |
296 | self.completion_location, | 295 | self.completion_location, |
297 | Some(ImmediateLocation::Use) | Some(ImmediateLocation::UseTree) | 296 | Some(ImmediateLocation::Use | ImmediateLocation::UseTree) |
298 | ) | 297 | ) |
299 | } | 298 | } |
300 | 299 | ||
301 | pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool { | 300 | pub(crate) fn has_impl_or_trait_prev_sibling(&self) -> bool { |
302 | matches!( | 301 | matches!( |
303 | self.prev_sibling, | 302 | self.prev_sibling, |
304 | Some(ImmediatePrevSibling::ImplDefType) | Some(ImmediatePrevSibling::TraitDefName) | 303 | Some(ImmediatePrevSibling::ImplDefType | ImmediatePrevSibling::TraitDefName) |
305 | ) | 304 | ) |
306 | } | 305 | } |
307 | 306 | ||
@@ -318,14 +317,16 @@ impl<'a> CompletionContext<'a> { | |||
318 | || self.previous_token_is(T![unsafe]) | 317 | || self.previous_token_is(T![unsafe]) |
319 | || matches!( | 318 | || matches!( |
320 | self.prev_sibling, | 319 | self.prev_sibling, |
321 | Some(ImmediatePrevSibling::Attribute) | Some(ImmediatePrevSibling::Visibility) | 320 | Some(ImmediatePrevSibling::Attribute | ImmediatePrevSibling::Visibility) |
322 | ) | 321 | ) |
323 | || matches!( | 322 | || matches!( |
324 | self.completion_location, | 323 | self.completion_location, |
325 | Some(ImmediateLocation::Attribute(_)) | 324 | Some( |
326 | | Some(ImmediateLocation::ModDeclaration(_)) | 325 | ImmediateLocation::Attribute(_) |
327 | | Some(ImmediateLocation::RecordPat(_)) | 326 | | ImmediateLocation::ModDeclaration(_) |
328 | | Some(ImmediateLocation::RecordExpr(_)) | 327 | | ImmediateLocation::RecordPat(_) |
328 | | ImmediateLocation::RecordExpr(_) | ||
329 | ) | ||
329 | ) | 330 | ) |
330 | } | 331 | } |
331 | 332 | ||
diff --git a/crates/ide_completion/src/render/builder_ext.rs b/crates/ide_completion/src/render/builder_ext.rs index 749dfc665..33d3a5ee1 100644 --- a/crates/ide_completion/src/render/builder_ext.rs +++ b/crates/ide_completion/src/render/builder_ext.rs | |||
@@ -32,7 +32,7 @@ impl Builder { | |||
32 | cov_mark::hit!(no_parens_in_use_item); | 32 | cov_mark::hit!(no_parens_in_use_item); |
33 | return false; | 33 | return false; |
34 | } | 34 | } |
35 | if matches!(ctx.path_call_kind(), Some(CallKind::Expr) | Some(CallKind::Pat)) | 35 | if matches!(ctx.path_call_kind(), Some(CallKind::Expr | CallKind::Pat)) |
36 | | matches!( | 36 | | matches!( |
37 | ctx.completion_location, | 37 | ctx.completion_location, |
38 | Some(ImmediateLocation::MethodCall { has_parens: true, .. }) | 38 | Some(ImmediateLocation::MethodCall { has_parens: true, .. }) |
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index c2a9a38c9..b4f2fe9a4 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs | |||
@@ -804,33 +804,17 @@ impl<'a> TtIter<'a> { | |||
804 | }; | 804 | }; |
805 | 805 | ||
806 | match (punct.char, second, third) { | 806 | match (punct.char, second, third) { |
807 | ('.', '.', Some('.')) | 807 | ('.', '.', Some('.' | '=')) | ('<', '<', Some('=')) | ('>', '>', Some('=')) => { |
808 | | ('.', '.', Some('=')) | ||
809 | | ('<', '<', Some('=')) | ||
810 | | ('>', '>', Some('=')) => { | ||
811 | let tt2 = self.next().unwrap().clone(); | 808 | let tt2 = self.next().unwrap().clone(); |
812 | let tt3 = self.next().unwrap().clone(); | 809 | let tt3 = self.next().unwrap().clone(); |
813 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into()) | 810 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into()) |
814 | } | 811 | } |
815 | ('-', '=', _) | 812 | ('-' | '!' | '*' | '/' | '&' | '%' | '^' | '+' | '<' | '=' | '>' | '|', '=', _) |
816 | | ('-', '>', _) | 813 | | ('-' | '=' | '>', '>', _) |
817 | | (':', ':', _) | 814 | | (':', ':', _) |
818 | | ('!', '=', _) | ||
819 | | ('.', '.', _) | 815 | | ('.', '.', _) |
820 | | ('*', '=', _) | ||
821 | | ('/', '=', _) | ||
822 | | ('&', '&', _) | 816 | | ('&', '&', _) |
823 | | ('&', '=', _) | ||
824 | | ('%', '=', _) | ||
825 | | ('^', '=', _) | ||
826 | | ('+', '=', _) | ||
827 | | ('<', '<', _) | 817 | | ('<', '<', _) |
828 | | ('<', '=', _) | ||
829 | | ('=', '=', _) | ||
830 | | ('=', '>', _) | ||
831 | | ('>', '=', _) | ||
832 | | ('>', '>', _) | ||
833 | | ('|', '=', _) | ||
834 | | ('|', '|', _) => { | 818 | | ('|', '|', _) => { |
835 | let tt2 = self.next().unwrap().clone(); | 819 | let tt2 = self.next().unwrap().clone(); |
836 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into()) | 820 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into()) |
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs index 2b3d7fd84..ef2d7657a 100644 --- a/crates/vfs/src/vfs_path.rs +++ b/crates/vfs/src/vfs_path.rs | |||
@@ -389,7 +389,7 @@ impl VirtualPath { | |||
389 | 389 | ||
390 | match (file_stem, extension) { | 390 | match (file_stem, extension) { |
391 | (None, None) => None, | 391 | (None, None) => None, |
392 | (None, Some(_)) | (Some(""), Some(_)) => Some((file_name, None)), | 392 | (None | Some(""), Some(_)) => Some((file_name, None)), |
393 | (Some(file_stem), extension) => Some((file_stem, extension)), | 393 | (Some(file_stem), extension) => Some((file_stem, extension)), |
394 | } | 394 | } |
395 | } | 395 | } |
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 7e2dccdfe..64ab12b42 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -8,7 +8,7 @@ use xshell::{cmd, pushd}; | |||
8 | use crate::flags; | 8 | use crate::flags; |
9 | 9 | ||
10 | // Latest stable, feel free to send a PR if this lags behind. | 10 | // Latest stable, feel free to send a PR if this lags behind. |
11 | const REQUIRED_RUST_VERSION: u32 = 52; | 11 | const REQUIRED_RUST_VERSION: u32 = 53; |
12 | 12 | ||
13 | impl flags::Install { | 13 | impl flags::Install { |
14 | pub(crate) fn run(self) -> Result<()> { | 14 | pub(crate) fn run(self) -> Result<()> { |