Skip to content

Commit 44be3ae

Browse files
committed
remove UnaryPlus trait; cleanup
1 parent 9095a46 commit 44be3ae

File tree

12 files changed

+17
-51
lines changed

12 files changed

+17
-51
lines changed

crates/hir-analysis/src/name_resolution/method_selection.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ impl<'db> TraitMethodCand<'db> {
4949
}
5050
}
5151

52-
// xxx #[salsa::tracked]
5352
pub(crate) fn select_method_candidate<'db>(
5453
db: &'db dyn HirAnalysisDb,
5554
receiver: Canonical<TyId<'db>>,

crates/hir-analysis/src/name_resolution/path_resolver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'db> PathResError<'db> {
172172
expected: ExpectedPathKind,
173173
) -> Option<PathResDiag<'db>> {
174174
let failed_at = self.failed_at;
175-
let ident = failed_at.ident(db).to_opt()?; // xxx PathKind::QualifiedType
175+
let ident = failed_at.ident(db).to_opt()?; // TODO: handle PathKind::QualifiedType
176176

177177
let diag = match self.kind {
178178
PathResErrorKind::ParseError => return None,
@@ -343,7 +343,7 @@ impl<'db> PathRes<'db> {
343343
PathRes::Func(ty) => PathRes::Func(f(ty)),
344344
PathRes::Const(ty) => PathRes::Const(f(ty)),
345345
PathRes::EnumVariant(v) => PathRes::EnumVariant(ResolvedVariant { ty: f(v.ty), ..v }),
346-
// xxx map over candidate ty?
346+
// TODO: map over candidate ty?
347347
PathRes::Method(ty, candidate) => PathRes::Method(f(ty), candidate),
348348
r @ (PathRes::Trait(_) | PathRes::Mod(_) | PathRes::FuncParam(..)) => r,
349349
}

crates/hir-analysis/src/ty/trait_resolution/proof_forest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl GeneratorNode {
361361
let mut table = g_node.table.clone();
362362
let gen_cand = table.instantiate_with_fresh_vars(cand);
363363

364-
// xxx require candidates to be pre-normalized
364+
// TODO: require candidates to be pre-normalized
365365
// Normalize trait instance arguments before unification
366366
let normalized_gen_cand = {
367367
let trait_inst = gen_cand.trait_(db);

crates/hir-analysis/src/ty/ty_check/expr.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ impl<'db> TyChecker<'db> {
111111
unreachable!()
112112
};
113113
let prop = self.check_expr_unknown(*lhs);
114+
if *op == UnOp::Plus {
115+
// TODO: remove support for unary plus? what should it do?
116+
return prop;
117+
}
114118
if prop.ty.has_invalid(self.db) {
115119
return ExprProp::invalid(self.db);
116120
}
@@ -155,7 +159,7 @@ impl<'db> TyChecker<'db> {
155159
}
156160

157161
if matches!(op, BinOp::Index) && lhs.ty.is_array(self.db) {
158-
// Built-in array indexing (xxx move to trait impl)
162+
// Built-in array indexing (TODO: move to trait impl)
159163
let args = lhs.ty.generic_args(self.db);
160164
let elem_ty = args[0];
161165
let index_ty = args[1].const_ty_ty(self.db).unwrap();
@@ -1335,13 +1339,8 @@ impl TraitOps for BinOp {
13351339
}
13361340
}
13371341

1338-
BinOp::Logical(logical_op) => {
1339-
use hir::hir_def::LogicalBinOp::*;
1340-
1341-
match logical_op {
1342-
And => ["And", "and", "&&"],
1343-
Or => ["Or", "or", "||"],
1344-
}
1342+
BinOp::Logical(_) => {
1343+
unreachable!()
13451344
}
13461345

13471346
BinOp::Index => ["Index", "index", "[]"],

crates/hir-analysis/src/ty/ty_lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub(crate) fn lower_generic_arg_list<'db>(
233233
}
234234

235235
GenericArg::AssocType(_assoc_type_arg) => {
236-
// xxx
236+
// TODO: ?
237237
TyId::invalid(db, InvalidCause::Other)
238238
}
239239
})

crates/parser/src/ast/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ ast_node! {
447447
ast_node! {
448448
pub struct ImplItemList,
449449
SK::ImplItemList,
450-
IntoIterator<Item=Func>, // xxx ImplTraitItem
450+
IntoIterator<Item=Func>, // TODO: ImplTraitItem
451451
}
452452

453453
ast_node! {

crates/uitest/fixtures/ty_check/generic_arg_path_resolution_fail.fe

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct S2<T> {
3636

3737
// Case 4: Associated type on concrete type that doesn't implement the trait
3838
struct Concrete {}
39-
// xxx this shouldn't be a conflicting trait impl!
4039
impl Tr1 for S1<Concrete> {
4140
type Foo = Concrete::Bar // Error: Concrete doesn't have associated type Bar
4241

crates/uitest/fixtures/ty_check/generic_arg_path_resolution_fail.snap

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: crates/uitest/tests/ty_check.rs
3-
assertion_line: 20
43
expression: diags
54
input_file: fixtures/ty_check/generic_arg_path_resolution_fail.fe
65
---
@@ -17,13 +16,13 @@ error[2-0002]: `NonExistent` is not found
1716
│ ^^^^^^^^^^^ `NonExistent` is not found
1817

1918
error[2-0002]: `Bar` is not found
20-
┌─ generic_arg_path_resolution_fail.fe:41:26
19+
┌─ generic_arg_path_resolution_fail.fe:40:26
2120
22-
41type Foo = Concrete::Bar // Error: Concrete doesn't have associated type Bar
21+
40type Foo = Concrete::Bar // Error: Concrete doesn't have associated type Bar
2322
│ ^^^ `Bar` is not found
2423

2524
error[2-0002]: `Missing` is not found
26-
┌─ generic_arg_path_resolution_fail.fe:54:26
25+
┌─ generic_arg_path_resolution_fail.fe:53:26
2726
28-
54type Foo = T::Inner::Missing // Error: T::Inner doesn't have associated type Missing
27+
53type Foo = T::Inner::Missing // Error: T::Inner doesn't have associated type Missing
2928
│ ^^^^^^^ `Missing` is not found

crates/uitest/fixtures/ty_check/unary.fe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ fn foo() {
55
+f
66
-f
77
!f
8-
}
8+
}

crates/uitest/fixtures/ty_check/unary.snap

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@ source: crates/uitest/tests/ty_check.rs
33
expression: diags
44
input_file: fixtures/ty_check/unary.fe
55
---
6-
error[8-0016]: `core::ops::UnaryPlus` trait is not implemented
7-
┌─ unary.fe:5:5
8-
9-
5+f
10-
^^
11-
│ │
12-
`+` can't be applied to `Foo`
13-
Try implementing `core::ops::UnaryPlus` for `Foo`
14-
156
error[8-0016]: `core::ops::Neg` trait is not implemented
167
┌─ unary.fe:6:5
178

0 commit comments

Comments
 (0)