-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Conversation
cd960d9
to
c548a27
Compare
src/librustdoc/html/markdown.rs
Outdated
@@ -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.
src/librustdoc/doctest/rust.rs
Outdated
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.
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.
Hum right, a Cell
might be enough. Force of habit...
c548a27
to
eecc07d
Compare
Added the builder type. For setters, I wondered if I should allow generics for |
This comment has been minimized.
This comment has been minimized.
eecc07d
to
d4bfa2f
Compare
Forgot to remove some imports... |
This comment has been minimized.
This comment has been minimized.
d4bfa2f
to
f4d41a5
Compare
And rebased on |
@notriddle: Is there anything else to be done here? |
Not AFAIK. @bors r+ |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 2cd3783 (parent) -> 1d67944 (this PR) Test differencesShow 33262 test diffsStage 1
Stage 2
(and 16558 additional test diffs) Additionally, 16604 doctest diffs were found. These are ignored, as they are noisy. Job group index Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 1d679446b01e65f9bc9ae609d0ae1e4a9c0ccaa3 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Finished benchmarking commit (1d67944): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 2.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -0.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 775.776s -> 777.175s (0.18%) |
This code is wrong: /// ```
/// struct Question;
///
/// fn main() {
/// assert!(false);
/// }
/// ```
pub struct Answer; Running this panics. What should be checked is if there is one non- |
Right it panics … but that's correct. I'm not sure what issue you're trying to point out here. Master doesn't emit a warning for this code (good), |
Nah all good. Just my brain at late times... |
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