-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Emit a warning if the doctest main
function will not be run
#140527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cd960d9
to
c548a27
Compare
@@ -303,7 +303,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> { | |||
attrs: vec![], | |||
args_file: PathBuf::new(), | |||
}; | |||
let doctest = doctest::DocTestBuilder::new(&test, krate, edition, false, None, None); | |||
let doctest = doctest::DocTestBuilder::new( | |||
&test, krate, edition, false, None, None, None, DUMMY_SP, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a builder pattern, badly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Do you want it in this PR or in a follow-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way is fine, as long as it actually gets done.
let line = self.get_base_line() + rel_line.offset(); | ||
let base_line = self.get_base_line(); | ||
let line = base_line + rel_line.offset(); | ||
let count = AtomicUsize::new(base_line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is an atomic needed here? This code isn't multithreaded.
Fixes #140310.
I think we could try to go much further like adding a "link" (ie UI annotations) on the
main
function in the doctest. However that will require some more computation, not sure if it's worth it or not. Can still be done in a follow-up if we want it.For now, this PR does two things:
DiagCtxt
to the doctest parser to emit the warning.Span
to where the doctest is starting (I hope the way I did it isn't too bad either...).cc @fmease
r? @notriddle