Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd todo!() macro #56348
Conversation
rust-highfive
assigned
dtolnay
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
internals discussion: https://internals.rust-lang.org/t/micro-pre-rfc-todo-macro/8925 |
This comment has been minimized.
This comment has been minimized.
|
Example where Lines 89 to 95 in 3dde9e1 |
This comment has been minimized.
This comment has been minimized.
|
I like that this distinguishes intent -- |
This comment was marked as outdated.
This comment was marked as outdated.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
Oups, was meant to add that to commit message. That obviously should be done, but only when/if we stabilize the |
matklad
force-pushed the
matklad:todo-macro
branch
from
269d0a8
to
7ffa157
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
Centril
reviewed
Nov 29, 2018
| @@ -553,6 +553,64 @@ macro_rules! unimplemented { | |||
| ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*))); | |||
| } | |||
|
|
|||
| /// A standardized placeholder for marking unfinished code. | |||
This comment has been minimized.
This comment has been minimized.
Centril
Nov 29, 2018
Contributor
The unimplemented macro also has this sentence in the docs so you probably want to re-frame that documentation.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
yoshuawuyts
Nov 29, 2018
Member
@steveklabnik I believe not necessarily. The dbg!() macro went through nightly first, and is only now landing on stable.
This comment has been minimized.
This comment has been minimized.
|
I think relegating Prior art: |
This comment has been minimized.
This comment has been minimized.
|
@scottmcm not sure I entirely understand what you are trying to say, so let me to elaborate on my goals here: The single reason is that I want to shorten unimplemented to todo. Ideally, I wish it was named todo from the start. However, we already have unimplemented, so we need to do something about it. One choice is to deprecate, another choice is to repurpose. The PR description went with repurposing, because, after grepping rust-lang/rust, I’ve noticed that it already is being used in the C#’s not supported sense. |
This comment has been minimized.
This comment has been minimized.
|
I'm entirely in favor of this. |
kennytm
added
the
T-libs
label
Nov 30, 2018
This comment has been minimized.
This comment has been minimized.
|
|
Thomasdezeeuw
reviewed
Dec 4, 2018
| /// | ||
| /// # Panics | ||
| /// | ||
| /// This will always [panic!](macro.panic.html) |
This comment has been minimized.
This comment has been minimized.
| /// | ||
| /// We want to implement `Foo` on one of our types, but we also want to work on | ||
| /// just `bar()` first. In order for our code to compile, we need to implement | ||
| /// `baz()`, so we can use `unimplemented!`: |
This comment has been minimized.
This comment has been minimized.
matklad
force-pushed the
matklad:todo-macro
branch
from
73adb97
to
44d4ddc
Dec 5, 2018
This comment has been minimized.
This comment has been minimized.
|
Renamed to |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure |
This comment was marked as outdated.
This comment was marked as outdated.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
An all-caps macro strikes me as a large enough digression from Rust style conventions to be immediately confusing to a reader. |
This comment has been minimized.
This comment has been minimized.
|
Don't have an opinion about which capitalization is better, will leave that to libs team to decide. Both Kotlin & Go decided to change naming convention for this macro though. |
This comment has been minimized.
This comment has been minimized.
|
There is some precedent: TODO in comments tends to be all caps. |
This comment has been minimized.
This comment has been minimized.
|
TODO in comments is not a macro invocation. |
This comment has been minimized.
This comment has been minimized.
|
I know, but it is related to TODOs... |
This comment was marked as outdated.
This comment was marked as outdated.
|
|
This comment has been minimized.
This comment has been minimized.
|
I am sympathetic to At the same time I agree with @scottmcm in #56348 (comment) and would prefer not to see I am pretty ambivalent but probably leaning against making this change -- meaning I would continue to use Regarding capitalization, I would advise against weighing Go as precedent. They were hamstrung by requiring a capital first letter on public functions, at which point |
rust-highfive
assigned
withoutboats
and unassigned
dtolnay
Dec 16, 2018
matklad
force-pushed the
matklad:todo-macro
branch
from
c57dc56
to
5350fe1
Mar 18, 2019
matklad
force-pushed the
matklad:todo-macro
branch
2 times, most recently
from
fb0aa26
to
9482cb7
Mar 18, 2019
This comment has been minimized.
This comment has been minimized.
|
rebased and created&filled the tracking issue |
This comment has been minimized.
This comment has been minimized.
|
@matklad This looks good and I'd like to request just one more change: add a sentence to the docs of both |
matklad
force-pushed the
matklad:todo-macro
branch
from
9482cb7
to
c11b37a
Mar 18, 2019
This comment has been minimized.
This comment has been minimized.
|
I think we should only change |
This comment has been minimized.
This comment has been minimized.
|
that makes sense to me @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Mar 18, 2019
This comment has been minimized.
This comment has been minimized.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
matklad
force-pushed the
matklad:todo-macro
branch
from
c11b37a
to
9d408d9
Mar 18, 2019
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors rollup |
Centril
added a commit
to Centril/rust
that referenced
this pull request
Mar 19, 2019
bors
added a commit
that referenced
this pull request
Mar 19, 2019
Centril
added a commit
to Centril/rust
that referenced
this pull request
Mar 19, 2019
bors
added a commit
that referenced
this pull request
Mar 19, 2019
bors
merged commit 9d408d9
into
rust-lang:master
Mar 19, 2019
This comment has been minimized.
This comment has been minimized.
|
Just going to leave a link to #39930 and rust-lang/rfcs#1911 here so that we maintain the breadcrumbs for people digging later on. |
This comment has been minimized.
This comment has been minimized.
mikhail-krainik
commented
Mar 28, 2019
•
|
I cannot understand why people think that “todo” is “panic”. Historically //TODO is a note that does not violate your program. But this discussion said todo! have to break your program. #[macro_export]
#[unstable(feature = "todo_macro", issue = "59277")]
macro_rules! todo {
() => (panic!("not yet implemented"));
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
}We have a lot of important RFC. Let's leave the |
This comment has been minimized.
This comment has been minimized.
|
The convention that this is making easier is not unprecedented. A lot of development flows say that In addition, this makes no change to The purpose of this is more to provide |
This comment has been minimized.
This comment has been minimized.
mikhail-krainik
commented
Mar 28, 2019
•
easy shouldn't be confusing
A lot of people say that earth is flat. But https://en.wikipedia.org/wiki/Comment_(computer_programming) says "TODO – something to be done."
todo! mustn't raise an error.
If you want to see a shorter version than |
matklad commentedNov 29, 2018
•
edited
The primary use-case of
todo!()macro is to be a much easier to typealternative to
unimplemented!()macro.EDIT: hide unpopular proposal about re-purposing unimplemented
With the addition of TODO, you have three nuanced choices for a
!-returning macro (in addition to a good-old panic we all love):Here's a rough guideline what each one means:
todo: use it during development, as a "hole" or placeholder. Itmight be a good idea to add a pre-commit hook which checks that
todois not accidentally committed.unreachable!(): use it when your code can statically guaranteethat some situation can not happen. If you use a library and hit
unreachable!()in the library's code, it's definitely a bug in thelibrary. It's OK to have
unreachable!()in the code base,although, if possible, it's better to replace it with
compiler-verified exhaustive checks.
unimplemented!(): use it when the type checker forces you tohandle some situation, but there's a contract that a callee must not
actually call the code. If you use a library and hit
unimplemented!(), it's probably a bug in your code, thoughit could be a bug in the library (or library docs) as well. It is
ok-ish to see an
unimplemented!()in real code, but it usuallysignifies a clunky, eyebrow-rising API.