Skip to content

Commit 8faaef6

Browse files
add test for parsing comments in doctest headers
1 parent ea3078d commit 8faaef6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags:--test
12+
13+
// comments, both doc comments and regular ones, used to trick rustdoc's doctest parser into
14+
// thinking that everything after it was part of the regular program. combined with the libsyntax
15+
// parser loop failing to detect the manual main function, it would wrap everything in `fn main`,
16+
// which would cause the doctest to fail as the "extern crate" declaration was no longer valid.
17+
// oddly enough, it would pass in 2018 if a crate was in the extern prelude. see
18+
// https://github.com/rust-lang/rust/issues/56727
19+
20+
//! ```
21+
//! // crate: proc-macro-test
22+
//! //! this is a test
23+
//!
24+
//! // used to pull in proc-macro specific items
25+
//! extern crate proc_macro;
26+
//!
27+
//! use proc_macro::TokenStream;
28+
//!
29+
//! # fn main() {}
30+
//! ```

0 commit comments

Comments
 (0)