Skip to content

Commit 6123df8

Browse files
committed
libgetopts: deny warnings in doctests
1 parent 623747a commit 6123df8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $(eval $(call RUST_CRATE,collectionstest))
2525
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system \
2626
alloc_jemalloc,$(TARGET_CRATES)) \
2727
collectionstest coretest
28-
TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros
28+
TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros getopts
2929
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve \
3030
rustc_trans rustc_lint,\
3131
$(HOST_CRATES))

src/libgetopts/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
//! file name following `-o`, and accepts both `-h` and `--help` as optional flags.
3131
//!
3232
//! ```{.rust}
33+
//! #![feature(rustc_private)]
34+
//!
3335
//! extern crate getopts;
3436
//! use getopts::{optopt,optflag,getopts,OptGroup,usage};
35-
//! use std::os;
37+
//! use std::env;
3638
//!
3739
//! fn do_work(inp: &str, out: Option<String>) {
3840
//! println!("{}", inp);
@@ -44,34 +46,34 @@
4446
//!
4547
//! fn print_usage(program: &str, opts: &[OptGroup]) {
4648
//! let brief = format!("Usage: {} [options]", program);
47-
//! print!("{}", usage(brief, opts));
49+
//! print!("{}", usage(&brief, opts));
4850
//! }
4951
//!
5052
//! fn main() {
51-
//! let args: Vec<String> = os::args();
53+
//! let args: Vec<String> = env::args().collect();
5254
//!
5355
//! let program = args[0].clone();
5456
//!
5557
//! let opts = &[
5658
//! optopt("o", "", "set output file name", "NAME"),
5759
//! optflag("h", "help", "print this help menu")
5860
//! ];
59-
//! let matches = match getopts(args[1..], opts) {
61+
//! let matches = match getopts(&args[1..], opts) {
6062
//! Ok(m) => { m }
6163
//! Err(f) => { panic!(f.to_string()) }
6264
//! };
6365
//! if matches.opt_present("h") {
64-
//! print_usage(program, opts);
66+
//! print_usage(&program, opts);
6567
//! return;
6668
//! }
6769
//! let output = matches.opt_str("o");
6870
//! let input = if !matches.free.is_empty() {
6971
//! matches.free[0].clone()
7072
//! } else {
71-
//! print_usage(program, opts);
73+
//! print_usage(&program, opts);
7274
//! return;
7375
//! };
74-
//! do_work(input, output);
76+
//! do_work(&input, output);
7577
//! }
7678
//! ```
7779
@@ -88,7 +90,8 @@
8890
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
8991
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
9092
html_root_url = "https://doc.rust-lang.org/nightly/",
91-
html_playground_url = "https://play.rust-lang.org/")]
93+
html_playground_url = "https://play.rust-lang.org/",
94+
test(attr(deny(warnings))))]
9295

9396
#![deny(missing_docs)]
9497
#![feature(staged_api)]

0 commit comments

Comments
 (0)