2,903 matches across 25 files for TODO
snippet_mode: auto · sorted by relevance
34// fn handle(action: Action) {
35// match action {
36▶// Action::Move { distance } => ${1:todo!()},
37// Action::Stop => ${2:todo!()},$0
38// }
· · ·
37▶// Action::Stop => ${2:todo!()},$0
38// }
39// }
· · ·
742fn foo(a: bool) {
743 match a {
744▶ true => ${1:todo!()},
745 false => ${2:todo!()},$0
746 }
· · ·
745▶ false => ${2:todo!()},$0
746 }
747}
· · ·
765 match a {
766 true => {}
767▶ false => ${1:todo!()},$0
768 }
769}
+ 131 more matches in this file
48//
49// fn bar(arg: &'static str, baz: Baz) ${0:-> _} {
50▶// todo!()
51// }
52//
· · ·
419/// the correct return type).
420/// * If we could infer the return type, don't focus it (and thus focus the function body) so the
421▶/// user can change the `todo!` function body.
422fn make_return_type(
423 ctx: &AssistContext<'_>,
· · ·
1325
1326fn bar() ${0:-> _} {
1327▶ todo!()
1328}
1329",
· · ·
1352
1353fn bar() ${0:-> _} {
1354▶ todo!()
1355}
1356",
· · ·
1376
1377fn bar() ${0:-> _} {
1378▶ todo!()
1379}
1380
+ 72 more matches in this file
15
16pub(crate) struct ConstantCx {
17▶ todo: Vec<TodoItem>,
18 anon_allocs: FxHashMap<AllocId, DataId>,
19}
· · ·
20
21#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
22▶enum TodoItem {
23 Alloc(AllocId),
24 Static(DefId),
· · ·
27impl ConstantCx {
28 pub(crate) fn new() -> Self {
29▶ ConstantCx { todo: vec![], anon_allocs: FxHashMap::default() }
30 }
31
· · ·
37pub(crate) fn codegen_static(tcx: TyCtxt<'_>, module: &mut dyn Module, def_id: DefId) -> DataId {
38 let mut constants_cx = ConstantCx::new();
39▶ constants_cx.todo.push(TodoItem::Static(def_id));
40 constants_cx.finalize(tcx, module);
41
· · ·
247 mutability: rustc_hir::Mutability,
248) -> DataId {
249▶ cx.todo.push(TodoItem::Alloc(alloc_id));
250 *cx.anon_allocs
251 .entry(alloc_id)
+ 7 more matches in this file
8//! * No trailing whitespace.
9//! * No CR characters.
10▶//! * No `TODO` or `XXX` directives.
11//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests.
12//!
· · ·
541 err("Unrecognized tidy directive")
542 }
543▶ // Allow using TODO in diagnostic suggestions by marking the
544 // relevant line with `// ignore-tidy-todo`.
545 if trimmed.contains("TODO") && !trimmed.contains("ignore-tidy-todo") {
· · ·
544▶ // relevant line with `// ignore-tidy-todo`.
545 if trimmed.contains("TODO") && !trimmed.contains("ignore-tidy-todo") {
546 err(
· · ·
545▶ if trimmed.contains("TODO") && !trimmed.contains("ignore-tidy-todo") {
546 err(
547 "TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME",
· · ·
547▶ "TODO is used for tasks that should be done before merging a PR; If you want to leave a message in the codebase use FIXME",
548 )
549 }
15 (Some(simd), None) => format!("{prefix}{bit_len}x{simd}_t"),
16 (Some(simd), Some(vec)) => format!("{prefix}{bit_len}x{simd}x{vec}_t"),
17▶ (None, Some(_)) => todo!("{self:#?}"), // Likely an invalid case
18 }
19 } else {
· · ·
20▶ todo!("{self:#?}")
21 }
22 }
· · ·
59 // if armv7 and bl == 64, use "s", else "p"
60 TypeKind::Poly => if choose_workaround && *bl == 64 {"s"} else {"p"},
61▶ x => todo!("get_load_function TypeKind: {x:#?}"),
62 },
63 size = bl,
· · ·
66 )
67 } else {
68▶ todo!("get_load_function IntrinsicType: {self:#?}")
69 }
70 }
· · ·
91 TypeKind::Float => "f",
92 TypeKind::Poly => "p",
93▶ x => todo!("get_load_function TypeKind: {x:#?}"),
94 },
95 size = bl,
+ 2 more matches in this file
143}
144
145▶/// Checks if the given expression is a macro call to `todo!()` or `unimplemented!()`.
146pub fn is_todo_unimplemented_macro(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
147 root_macro_call_first_node(cx, expr)
· · ·
146▶pub fn is_todo_unimplemented_macro(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
147 root_macro_call_first_node(cx, expr)
148 .and_then(|macro_call| cx.tcx.get_diagnostic_name(macro_call.def_id))
· · ·
149▶ .is_some_and(|macro_name| matches!(macro_name, sym::todo_macro | sym::unimplemented_macro))
150}
151
· · ·
152▶/// Checks if the given expression is a stub, i.e., a `todo!()` or `unimplemented!()` expression,
153/// or a block whose last expression is a `todo!()` or `unimplemented!()`.
154pub fn is_todo_unimplemented_stub(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
· · ·
153▶/// or a block whose last expression is a `todo!()` or `unimplemented!()`.
154pub fn is_todo_unimplemented_stub(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
155 if let ExprKind::Block(block, _) = expr.kind {
+ 7 more matches in this file
218 r#"
219
220▶ // TODO: set xx to the version one below the MSRV used by the lint, and yy to
221 // the version used by the lint
222 #[clippy::msrv = "1.xx"]
· · ·
320 impl {pass_type}{pass_lifetimes} for {name_camel} {{{extract_msrv}}}
321
322▶ // TODO: Add MSRV level to `clippy_utils/src/msrvs.rs` if needed.
323 // TODO: Update msrv config comment in `clippy_config/src/conf.rs`
324 "
· · ·
323▶ // TODO: Update msrv config comment in `clippy_config/src/conf.rs`
324 "
325 );
· · ·
411 use super::{name_upper};
412
413▶ // TODO: Adjust the parameters as necessary
414 pub(super) fn check(cx: &{context_import}{pass_lifetimes}, msrv: {msrv_ref}{msrv_ty}) {{
415 if !msrv.meets({msrv_cx}todo!("Add a new entry in `clippy_utils/src/msrvs`")) {{
· · ·
415▶ if !msrv.meets({msrv_cx}todo!("Add a new entry in `clippy_utils/src/msrvs`")) {{
416 return;
417 }}
+ 3 more matches in this file
53// {
54// fn foo(&self) -> T {
55▶// todo!()
56// }
57// }
· · ·
112 let item = match item {
113 ast::AssocItem::Fn(method) if method.body().is_none() => {
114▶ todo_fn(make, &method, ctx.config).into()
115 }
116 ast::AssocItem::Const(_) | ast::AssocItem::TypeAlias(_) => item,
· · ·
264}
265
266▶fn todo_fn(make: &SyntaxFactory, f: &ast::Fn, config: &AssistConfig) -> ast::Fn {
267 let params = f.param_list().unwrap_or_else(|| make.param_list(None, None));
268 make.fn_(
· · ·
325{
326 fn foo(&self) -> T {
327▶ todo!()
328 }
329}
· · ·
368impl<I: Iterator> Foo for $0I {
369 fn foo(self) -> Self::Item {
370▶ todo!()
371 }
372}
+ 34 more matches in this file
27 ///
28 /// impl Clone for Thing {
29▶ /// fn clone(&self) -> Self { todo!() }
30 /// fn clone_from(&mut self, other: &Self) { todo!() }
31 /// }
· · ·
30▶ /// fn clone_from(&mut self, other: &Self) { todo!() }
31 /// }
32 ///
· · ·
40 ///
41 /// impl Clone for Thing {
42▶ /// fn clone(&self) -> Self { todo!() }
43 /// fn clone_from(&mut self, other: &Self) { todo!() }
44 /// }
· · ·
43▶ /// fn clone_from(&mut self, other: &Self) { todo!() }
44 /// }
45 ///
· · ·
96 }
97 && let Ok(Some(resolved_fn)) = Instance::try_resolve(cx.tcx, cx.typing_env(), fn_def.1, fn_gen_args)
98▶ // TODO: This check currently bails if the local variable has no initializer.
99 // That is overly conservative - the lint should fire even if there was no initializer,
100 // but the variable has been initialized before `lhs` was evaluated.
42//
43// fn foo(&self) -> u32 {
44▶// todo!()
45// }
46// }
· · ·
206 && let Some(ast::AssocItem::Fn(func)) = &first_new_item
207 && let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast)
208▶ && m.syntax().text() == "todo!()"
209 {
210 placeholder = Some(m);
· · ·
288
289 fn foo(&self) {
290▶ todo!()
291 }
292
· · ·
293 fn baz(&self) {
294▶ todo!()
295 }
296
· · ·
329
330 fn foo(&self) {
331▶ ${0:todo!()}
332 }
333
+ 61 more matches in this file
1use clippy_utils::diagnostics::span_lint_hir_and_then;
2use clippy_utils::is_def_id_trait_method;
3▶use clippy_utils::usage::is_todo_unimplemented_stub;
4use rustc_hir::def::DefKind;
5use rustc_hir::intravisit::{FnKind, Visitor, walk_expr, walk_fn};
· · ·
122 && !is_def_id_trait_method(cx, def_id)
123 && !is_default_trait_impl(cx, def_id)
124▶ && !async_fn_contains_todo_unimplemented_macro(cx, body)
125 {
126 let mut visitor = AsyncFnVisitor {
· · ·
207}
208
209▶fn async_fn_contains_todo_unimplemented_macro(cx: &LateContext<'_>, body: &Body<'_>) -> bool {
210 if let ExprKind::Closure(closure) = body.value.kind
211 && let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) = closure.kind
· · ·
215 && let ExprKind::DropTemps(inner) = expr.kind
216 {
217▶ return is_todo_unimplemented_stub(cx, inner);
218 }
219
327 },
328 PatKind::Expr(e) => match &e.kind {
329▶ // TODO: Handle negative integers. They're currently treated as a wild match.
330 PatExprKind::Lit { lit, negated: false } => match lit.node {
331 LitKind::Str(sym, _) => Self::LitStr(sym),
· · ·
341 },
342 PatKind::Range(start, end, bounds) => {
343▶ // TODO: Handle negative integers. They're currently treated as a wild match.
344 let start = match start {
345 None => 0,
· · ·
427 // Tuples can be matched like a struct.
428 (Self::Tuple(x, _), Self::Struct(y, _)) | (Self::Struct(x, _), Self::Tuple(y, _)) => {
429▶ // TODO: check fields here.
430 x == y
431 },
· · ·
432
433▶ // TODO: Lit* with Path, Range with Path, LitBytes with Slice
434 _ => true,
435 }
114
115 let generate_fill_expr = |ty: &Type<'_>| match ctx.config.expr_fill_default {
116▶ ExprFillDefaultMode::Todo => make::ext::expr_todo(),
117 ExprFillDefaultMode::Underscore => make::ext::expr_underscore(),
118 ExprFillDefaultMode::Default => {
· · ·
119▶ get_default_constructor(ctx, d, ty).unwrap_or_else(make::ext::expr_todo)
120 }
121 };
· · ·
465
466fn test_fn() {
467▶ let s = TestStruct { one: 0, two: todo!() };
468}
469"#,
· · ·
485
486fn test_fn() {
487▶ let s = TestStruct { one: 0, two: todo!() };
488}
489"#,
· · ·
690fn f() {
691 S {
692▶ a: todo!(),
693 b: todo!(),
694 };
+ 1 more matches in this file
196 use core::future::Future;
197 fn foo() -> impl F$0uture<Output = ()> {
198▶ todo!()
199 }
200 "#,
· · ·
202 use core::future::Future;
203 async fn foo() {
204▶ todo!()
205 }
206 "#,
· · ·
213 use core::future::Future;
214 fn foo() -> impl F$0uture<Output = usize> {
215▶ todo!()
216 }
217 "#,
· · ·
219 use core::future::Future;
220 async fn foo() -> usize {
221▶ todo!()
222 }
223 "#,
· · ·
233 use core::future::Future;
234 as$0ync fn foo() {
235▶ todo!()
236 }
237 "#,
+ 19 more matches in this file
485 };
486
487▶ // TODO(calebcartwright): consider enabling box_patterns feature gate
488 if should_visit_node_again {
489 match item.kind {
· · ·
620 }
621 ast::ItemKind::Delegation(..) | ast::ItemKind::DelegationMac(..) => {
622▶ // TODO: rewrite delegation items once syntax is established.
623 // For now, leave the contents of the Span unformatted.
624 self.push_rewrite(item.span, None)
· · ·
656 _ => unreachable!(),
657 };
658▶ // TODO(calebcartwright): Not sure the skip spans are correct
659 let skip_span = ai.span;
660 skip_out_of_file_lines_range_visitor!(self, ai.span);
· · ·
665 }
666
667▶ // TODO(calebcartwright): consider enabling box_patterns feature gate
668 match (&ai.kind, assoc_ctxt) {
669 (ast::AssocItemKind::Const(c), visit::AssocCtxt::Trait) => {
· · ·
716 }
717 (ast::AssocItemKind::Delegation(_) | ast::AssocItemKind::DelegationMac(_), _) => {
718▶ // TODO(ytmimi) #![feature(fn_delegation)]
719 // add formatting for `AssocItemKind::Delegation` and `AssocItemKind::DelegationMac`
720 self.push_rewrite(ai.span, None);
+ 1 more matches in this file
75 /// fn cmp(&self, other: &Self) -> Ordering {
76 /// // ...
77▶ /// # todo!();
78 /// }
79 /// }
· · ·
82 /// fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
83 /// // ...
84▶ /// # todo!();
85 /// }
86 /// }
· · ·
95 /// fn cmp(&self, other: &Self) -> Ordering {
96 /// // ...
97▶ /// # todo!();
98 /// }
99 /// }
39declare_clippy_lint! {
40 /// ### What it does
41▶ /// Checks for usage of `todo!`.
42 ///
43 /// ### Why restrict this?
· · ·
44▶ /// The `todo!` macro indicates the presence of unfinished code,
45 /// so it should not be present in production code.
46 ///
· · ·
47 /// ### Example
48 /// ```no_run
49▶ /// todo!();
50 /// ```
51 /// Finish the implementation, or consider marking it as explicitly unimplemented.
· · ·
54 /// ```
55 #[clippy::version = "1.40.0"]
56▶ pub TODO,
57 restriction,
58 "`todo!` should not be present in production code"
· · ·
58▶ "`todo!` should not be present in production code"
59}
60
+ 4 more matches in this file
18mod shared_utils;
19mod tests;
20▶mod todo;
21mod utils;
22
· · ·
40 AbiCafe,
41 Bench,
42▶ CheckTodo,
43}
44
· · ·
69 Some("abi-cafe") => Command::AbiCafe,
70 Some("bench") => Command::Bench,
71▶ Some("check-todo") => Command::CheckTodo,
72 Some(flag) if flag.starts_with('-') => arg_error!("Expected command found flag {}", flag),
73 Some(command) => arg_error!("Unknown command {}", command),
· · ·
143 }
144
145▶ if command == Command::CheckTodo {
146 todo::run();
147 }
· · ·
146▶ todo::run();
147 }
148
+ 1 more matches in this file
1100 ) -> InterpResult<'tcx> {
1101 let mut done = FxHashSet::default();
1102▶ let mut todo = start;
1103 while let Some(id) = todo.pop() {
1104 if !done.insert(id) {
· · ·
1103▶ while let Some(id) = todo.pop() {
1104 if !done.insert(id) {
1105 // We already saw this allocation before, don't process it again.
· · ·
1115 for prov in alloc.provenance().provenances() {
1116 if let Some(id) = prov.get_alloc_id() {
1117▶ todo.push(id);
1118 }
1119 }
· · ·
1171 let mut reachable = FxHashSet::default();
1172 let global_kind = M::GLOBAL_KIND.map(MemoryKind::Machine);
1173▶ let mut todo: Vec<_> =
1174 self.memory.alloc_map.filter_map_collect(move |&id, &(kind, _)| {
1175 if Some(kind) == global_kind { Some(id) } else { None }
· · ·
1176 });
1177▶ todo.extend(static_roots(self));
1178 while let Some(id) = todo.pop() {
1179 if reachable.insert(id) {
+ 3 more matches in this file
31 krate_json: Value,
32 /// Worklist of Ids to check.
33▶ todo: HashSet<&'a Id>,
34 /// Ids that have already been visited, so don't need to be checked again.
35 seen_ids: HashSet<&'a Id>,
· · ·
53 errs: Vec::new(),
54 seen_ids: HashSet::new(),
55▶ todo: HashSet::new(),
56 missing_ids: HashSet::new(),
57 }
· · ·
62 let root = &self.krate.root;
63 self.add_mod_id(root);
64▶ while let Some(id) = set_remove(&mut self.todo) {
65 self.seen_ids.insert(id);
66 self.check_item(id);
· · ·
417 if valid(kind) {
418 if !self.seen_ids.contains(id) {
419▶ self.todo.insert(id);
420 }
421 } else {
117/// enum variants without nested patterns or bindings.
118///
119▶/// TODO: Support more complex patterns.
120fn is_arms_disjointed(cx: &LateContext<'_>, arm1: &Arm<'_>, arm2: &Arm<'_>) -> bool {
121 if arm1.guard.is_some() || arm2.guard.is_some() {
· · ·
293 let (sn_fld_name, _) = snippet_with_context(cx, fld.ident.span, span.ctxt(), "", app);
294 let (sn_ptp, _) = snippet_with_context(cx, pat_to_put.span, span.ctxt(), "", app);
295▶ // TODO: this is a bit of a hack, but it does its job. Ideally, we'd check if pat_to_put is
296 // a PatKind::Binding but that is also hard to get right.
297 if sn_fld_name == sn_ptp {
· · ·
345 // Check whether the pattern contains any bindings, as the
346 // binding might potentially be used in the body.
347▶ // TODO: only look for *used* bindings.
348 let mut has_bindings = false;
349 pat.each_binding_or_first(&mut |_, _, _, _| has_bindings = true);
290pub struct RefTracking<T, PATH = ()> {
291 seen: FxHashSet<T>,
292▶ todo: Vec<(T, PATH)>,
293}
294
· · ·
295impl<T: Clone + Eq + Hash + std::fmt::Debug, PATH> RefTracking<T, PATH> {
296 pub fn empty() -> Self {
297▶ RefTracking { seen: FxHashSet::default(), todo: vec![] }
298 }
299 pub fn next(&mut self) -> Option<(T, PATH)> {
· · ·
300▶ self.todo.pop()
301 }
302
· · ·
306 let path = path();
307 // Remember to come back to this later.
308▶ self.todo.push((val, path));
309 }
310 }
· · ·
314 pub fn new(val: T, ty: Ty<'tcx>) -> Self {
315 let mut ref_tracking_for_consts =
316▶ RefTracking { seen: FxHashSet::default(), todo: vec![(val.clone(), Path::new(ty))] };
317 ref_tracking_for_consts.seen.insert(val);
318 ref_tracking_for_consts
+ 2 more matches in this file
455 }
456 // FIXME(unsafe_binders):
457▶ ty::UnsafeBinder(_) => todo!(),
458 ty::Dynamic(existential_predicates, region) => TyKind::RigidTy(RigidTy::Dynamic(
459 existential_predicates
· · ·
467 generic_args.stable(tables, cx),
468 )),
469▶ ty::CoroutineClosure(..) => todo!("FIXME(async_closures): Lower these to SMIR"),
470 ty::Coroutine(def_id, generic_args) => TyKind::RigidTy(RigidTy::Coroutine(
471 tables.coroutine_def(*def_id),
· · ·
477 )),
478 ty::Alias(_alias_ty) => {
479▶ todo!()
480 }
481 ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables, cx)),
· · ·
780 }
781 ClauseKind::HostEffect(..) => {
782▶ todo!()
783 }
784 ClauseKind::UnstableFeature(_) => {
· · ·
90 let captures = can_move_expr_to_closure(cx, some_expr.expr)?;
91 // Check if captures the closure will need conflict with borrows made in the scrutinee.
92▶ // TODO: check all the references made in the scrutinee expression. This will require interacting
93 // with the borrow checker. Currently only `<local>[.<field>]*` is checked for.
94 if let Some(binding_ref_mutability) = binding_ref {
· · ·
151 }
152 } else if !is_wild_none && explicit_ref.is_none() {
153▶ // TODO: handle explicit reference annotations.
154 let pat_snip = snippet_with_context(cx, some_pat.span, expr_ctxt, "..", &mut app).0;
155 format!("|{pat_snip}| {closure_body}")