Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crates/ra_assists/src/doc_tests/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ trait Trait<T> {
}

impl Trait<u32> for () {
fn foo(&self) -> u32 { unimplemented!() }
fn foo(&self) -> u32 { todo!() }

}
"#####,
Expand Down
34 changes: 17 additions & 17 deletions crates/ra_assists/src/handlers/add_missing_impl_members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum AddMissingImplMembersMode {
// }
//
// impl Trait<u32> for () {
// fn foo(&self) -> u32 { unimplemented!() }
// fn foo(&self) -> u32 { todo!() }
//
// }
// ```
Expand Down Expand Up @@ -165,7 +165,7 @@ fn add_missing_impl_members_inner(

fn add_body(fn_def: ast::FnDef) -> ast::FnDef {
if fn_def.body().is_none() {
fn_def.with_body(make::block_from_expr(make::expr_unimplemented()))
fn_def.with_body(make::block_from_expr(make::expr_todo()))
} else {
fn_def
}
Expand Down Expand Up @@ -215,8 +215,8 @@ impl Foo for S {
fn bar(&self) {}
<|>type Output;
const CONST: usize = 42;
fn foo(&self) { unimplemented!() }
fn baz(&self) { unimplemented!() }
fn foo(&self) { todo!() }
fn baz(&self) { todo!() }

}",
);
Expand Down Expand Up @@ -250,7 +250,7 @@ struct S;

impl Foo for S {
fn bar(&self) {}
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }

}",
);
Expand All @@ -268,7 +268,7 @@ impl Foo for S { <|> }",
trait Foo { fn foo(&self); }
struct S;
impl Foo for S {
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }
}",
);
}
Expand All @@ -285,7 +285,7 @@ impl Foo<u32> for S { <|> }",
trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S;
impl Foo<u32> for S {
<|>fn foo(&self, t: u32) -> &u32 { unimplemented!() }
<|>fn foo(&self, t: u32) -> &u32 { todo!() }
}",
);
}
Expand All @@ -302,7 +302,7 @@ impl<U> Foo<U> for S { <|> }",
trait Foo<T> { fn foo(&self, t: T) -> &T; }
struct S;
impl<U> Foo<U> for S {
<|>fn foo(&self, t: U) -> &U { unimplemented!() }
<|>fn foo(&self, t: U) -> &U { todo!() }
}",
);
}
Expand All @@ -319,7 +319,7 @@ impl Foo for S {}<|>",
trait Foo { fn foo(&self); }
struct S;
impl Foo for S {
<|>fn foo(&self) { unimplemented!() }
<|>fn foo(&self) { todo!() }
}",
)
}
Expand All @@ -342,7 +342,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar) { todo!() }
}",
);
}
Expand All @@ -365,7 +365,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<u32>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>) { todo!() }
}",
);
}
Expand All @@ -388,7 +388,7 @@ mod foo {
}
struct S;
impl foo::Foo<u32> for S {
<|>fn foo(&self, bar: foo::Bar<u32>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>) { todo!() }
}",
);
}
Expand All @@ -414,7 +414,7 @@ mod foo {
struct Param;
struct S;
impl foo::Foo<Param> for S {
<|>fn foo(&self, bar: Param) { unimplemented!() }
<|>fn foo(&self, bar: Param) { todo!() }
}",
);
}
Expand All @@ -439,7 +439,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<u32>::Assoc) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<u32>::Assoc) { todo!() }
}",
);
}
Expand All @@ -464,7 +464,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: foo::Bar<foo::Baz>) { unimplemented!() }
<|>fn foo(&self, bar: foo::Bar<foo::Baz>) { todo!() }
}",
);
}
Expand All @@ -487,7 +487,7 @@ mod foo {
}
struct S;
impl foo::Foo for S {
<|>fn foo(&self, bar: dyn Fn(u32) -> i32) { unimplemented!() }
<|>fn foo(&self, bar: dyn Fn(u32) -> i32) { todo!() }
}",
);
}
Expand Down Expand Up @@ -544,7 +544,7 @@ trait Foo {
struct S;
impl Foo for S {
<|>type Output;
fn foo(&self) { unimplemented!() }
fn foo(&self) { todo!() }
}"#,
)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/ra_syntax/src/ast/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ pub fn expr_empty_block() -> ast::Expr {
pub fn expr_unimplemented() -> ast::Expr {
expr_from_text("unimplemented!()")
}
pub fn expr_todo() -> ast::Expr {
expr_from_text("todo!()")
}
pub fn expr_path(path: ast::Path) -> ast::Expr {
expr_from_text(&path.to_string())
}
Expand Down
2 changes: 1 addition & 1 deletion docs/user/assists.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ trait Trait<T> {
}

impl Trait<u32> for () {
fn foo(&self) -> u32 { unimplemented!() }
fn foo(&self) -> u32 { todo!() }

}
```
Expand Down
11 changes: 10 additions & 1 deletion xtask/tests/tidy-tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ fn rust_files_are_tidy() {
}

fn check_todo(path: &Path, text: &str) {
if path.ends_with("tests/cli.rs") {
let whitelist = &[
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not particularly happy about this approach, but this isn't a particularly sophisticated check that would allow more fine grained configuration.

Might be reasonable to extend this to detect some marker in the file that allows more fine-grained ignoring, but idk.

Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think such whitelisting is the optimal solution, given the scale of the problem actually!

// This file itself is whitelisted since this test itself contains matches.
"tests/cli.rs",
// Some of our assists generate `todo!()` so those files are whitelisted.
"doc_tests/generated.rs",
"handlers/add_missing_impl_members.rs",
// To support generating `todo!()` in assists, we have `expr_todo()` in ast::make.
"ast/make.rs",
];
if whitelist.iter().any(|p| path.ends_with(p)) {
return;
}
if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") {
Expand Down