about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-11-18 16:15:12 -0700
committerMichael Howell <michael@notriddle.com>2021-11-18 16:23:18 -0700
commit214ad2f5b5ff529548ce13dabcda8d5841df0bd7 (patch)
treee3662f2f69eba4ec3e069e75357b08f1385d2e4b /compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs
parentb6f580acc0ce233d5c4d1f9680d354fded88b824 (diff)
downloadrust-214ad2f5b5ff529548ce13dabcda8d5841df0bd7.tar.gz
rust-214ad2f5b5ff529548ce13dabcda8d5841df0bd7.zip
rustdoc doctest: detect `fn main` after an unexpected semicolon
The basic problem with this is that rustdoc, when hunting for `fn main`, will stop
parsing after it reaches a fatal error. This unexpected semicolon was a fatal error,
so in `src/test/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs`, it would wrap
the doctest in an implied main function, turning it into this:

    fn main() {
        struct S {};
        fn main() {
            assert_eq!(0, 1);
        }
    }

This, as it turns out, is totally valid, and it executes no assertions, so *it passes,*
even though the user wanted it to execute the assertion.

The Rust parser already has the ability to recover from these unexpected semicolons,
but to do so, it needs to use the `parse_mod` function, so this commit changes it to do that.
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/subslice-patterns-const-eval.rs')
0 files changed, 0 insertions, 0 deletions