Skip to content

Commit 06fa27d

Browse files
committed
Auto merge of rust-lang#49561 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 3 pull requests - Successful merges: rust-lang#49451, rust-lang#49498, rust-lang#49549 - Failed merges:
2 parents d2235f2 + 36f9f76 commit 06fa27d

File tree

10 files changed

+103
-40
lines changed

10 files changed

+103
-40
lines changed

Diff for: src/Cargo.lock

+24-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ pub fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path, is_check: boo
11201120
let max = max.unwrap();
11211121
let max_path = max_path.unwrap();
11221122
if stamp_contents == new_contents && max <= stamp_mtime {
1123-
build.verbose(&format!("not updating {:?}; contents equal and {} <= {}",
1123+
build.verbose(&format!("not updating {:?}; contents equal and {:?} <= {:?}",
11241124
stamp, max, stamp_mtime));
11251125
return deps
11261126
}

Diff for: src/build_helper/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ authors = ["The Rust Project Developers"]
66
[lib]
77
name = "build_helper"
88
path = "lib.rs"
9-
10-
[dependencies]
11-
filetime = "0.1"

Diff for: src/build_helper/lib.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010

1111
#![deny(warnings)]
1212

13-
extern crate filetime;
14-
1513
use std::fs::File;
1614
use std::path::{Path, PathBuf};
1715
use std::process::{Command, Stdio};
1816
use std::{fs, env};
19-
20-
use filetime::FileTime;
17+
use std::time::{SystemTime, UNIX_EPOCH};
2118

2219
/// A helper macro to `unwrap` a result except also print out details like:
2320
///
@@ -137,10 +134,8 @@ pub fn rerun_if_changed_anything_in_dir(dir: &Path) {
137134
}
138135

139136
/// Returns the last-modified time for `path`, or zero if it doesn't exist.
140-
pub fn mtime(path: &Path) -> FileTime {
141-
fs::metadata(path).map(|f| {
142-
FileTime::from_last_modification_time(&f)
143-
}).unwrap_or(FileTime::zero())
137+
pub fn mtime(path: &Path) -> SystemTime {
138+
fs::metadata(path).and_then(|f| f.modified()).unwrap_or(UNIX_EPOCH)
144139
}
145140

146141
/// Returns whether `dst` is up to date given that the file or files in `src`
@@ -157,9 +152,9 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
157152
Err(e) => panic!("source {:?} failed to get metadata: {}", src, e),
158153
};
159154
if meta.is_dir() {
160-
dir_up_to_date(src, &threshold)
155+
dir_up_to_date(src, threshold)
161156
} else {
162-
FileTime::from_last_modification_time(&meta) <= threshold
157+
meta.modified().unwrap_or(UNIX_EPOCH) <= threshold
163158
}
164159
}
165160

@@ -226,13 +221,13 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoiler
226221
search_path)
227222
}
228223

229-
fn dir_up_to_date(src: &Path, threshold: &FileTime) -> bool {
224+
fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
230225
t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| {
231226
let meta = t!(e.metadata());
232227
if meta.is_dir() {
233228
dir_up_to_date(&e.path(), threshold)
234229
} else {
235-
FileTime::from_last_modification_time(&meta) < *threshold
230+
meta.modified().unwrap_or(UNIX_EPOCH) < threshold
236231
}
237232
})
238233
}

Diff for: src/doc/rustdoc/src/unstable-features.md

+13
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,19 @@ details.
348348

349349
[issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574
350350

351+
### `--edition`: control the edition of docs and doctests
352+
353+
Using this flag looks like this:
354+
355+
```bash
356+
$ rustdoc src/lib.rs -Z unstable-options --edition 2018
357+
$ rustdoc --test src/lib.rs -Z unstable-options --edition 2018
358+
```
359+
360+
This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with
361+
the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015`
362+
(the first edition).
363+
351364
### `-Z force-unstable-if-unmarked`
352365

353366
Using this flag looks like this:

Diff for: src/librustdoc/core.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc_back::target::TargetTriple;
2626

2727
use syntax::ast::NodeId;
2828
use syntax::codemap;
29+
use syntax::edition::Edition;
2930
use syntax::feature_gate::UnstableFeatures;
3031
use errors;
3132
use errors::emitter::ColorConfig;
@@ -123,7 +124,8 @@ pub fn run_core(search_paths: SearchPaths,
123124
maybe_sysroot: Option<PathBuf>,
124125
allow_warnings: bool,
125126
crate_name: Option<String>,
126-
force_unstable_if_unmarked: bool) -> (clean::Crate, RenderInfo)
127+
force_unstable_if_unmarked: bool,
128+
edition: Edition) -> (clean::Crate, RenderInfo)
127129
{
128130
// Parse, resolve, and typecheck the given crate.
129131

@@ -148,6 +150,7 @@ pub fn run_core(search_paths: SearchPaths,
148150
actually_rustdoc: true,
149151
debugging_opts: config::DebuggingOptions {
150152
force_unstable_if_unmarked,
153+
edition,
151154
..config::basic_debugging_options()
152155
},
153156
..config::basic_options().clone()

Diff for: src/librustdoc/lib.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use std::path::{Path, PathBuf};
6161
use std::process;
6262
use std::sync::mpsc::channel;
6363

64+
use syntax::edition::Edition;
6465
use externalfiles::ExternalHtml;
6566
use rustc::session::search_paths::SearchPaths;
6667
use rustc::session::config::{ErrorOutputType, RustcOptGroup, nightly_options, Externs};
@@ -271,6 +272,11 @@ pub fn opts() -> Vec<RustcOptGroup> {
271272
\"light-suffix.css\"",
272273
"PATH")
273274
}),
275+
unstable("edition", |o| {
276+
o.optopt("", "edition",
277+
"edition to use when compiling rust code (default: 2015)",
278+
"EDITION")
279+
}),
274280
]
275281
}
276282

@@ -429,14 +435,23 @@ pub fn main_args(args: &[String]) -> isize {
429435
let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
430436
let resource_suffix = matches.opt_str("resource-suffix");
431437

438+
let edition = matches.opt_str("edition").unwrap_or("2015".to_string());
439+
let edition = match edition.parse() {
440+
Ok(e) => e,
441+
Err(_) => {
442+
print_error("could not parse edition");
443+
return 1;
444+
}
445+
};
446+
432447
match (should_test, markdown_input) {
433448
(true, true) => {
434449
return markdown::test(input, cfgs, libs, externs, test_args, maybe_sysroot,
435-
display_warnings, linker)
450+
display_warnings, linker, edition)
436451
}
437452
(true, false) => {
438453
return test::run(Path::new(input), cfgs, libs, externs, test_args, crate_name,
439-
maybe_sysroot, display_warnings, linker)
454+
maybe_sysroot, display_warnings, linker, edition)
440455
}
441456
(false, true) => return markdown::render(Path::new(input),
442457
output.unwrap_or(PathBuf::from("doc")),
@@ -446,7 +461,7 @@ pub fn main_args(args: &[String]) -> isize {
446461
}
447462

448463
let output_format = matches.opt_str("w");
449-
let res = acquire_input(PathBuf::from(input), externs, &matches, move |out| {
464+
let res = acquire_input(PathBuf::from(input), externs, edition, &matches, move |out| {
450465
let Output { krate, passes, renderinfo } = out;
451466
info!("going to format");
452467
match output_format.as_ref().map(|s| &**s) {
@@ -487,14 +502,15 @@ fn print_error<T>(error_message: T) where T: Display {
487502
/// and files and then generates the necessary rustdoc output for formatting.
488503
fn acquire_input<R, F>(input: PathBuf,
489504
externs: Externs,
505+
edition: Edition,
490506
matches: &getopts::Matches,
491507
f: F)
492508
-> Result<R, String>
493509
where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
494510
match matches.opt_str("r").as_ref().map(|s| &**s) {
495-
Some("rust") => Ok(rust_input(input, externs, matches, f)),
511+
Some("rust") => Ok(rust_input(input, externs, edition, matches, f)),
496512
Some(s) => Err(format!("unknown input format: {}", s)),
497-
None => Ok(rust_input(input, externs, matches, f))
513+
None => Ok(rust_input(input, externs, edition, matches, f))
498514
}
499515
}
500516

@@ -520,8 +536,14 @@ fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
520536
/// generated from the cleaned AST of the crate.
521537
///
522538
/// This form of input will run all of the plug/cleaning passes
523-
fn rust_input<R, F>(cratefile: PathBuf, externs: Externs, matches: &getopts::Matches, f: F) -> R
524-
where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
539+
fn rust_input<R, F>(cratefile: PathBuf,
540+
externs: Externs,
541+
edition: Edition,
542+
matches: &getopts::Matches,
543+
f: F) -> R
544+
where R: 'static + Send,
545+
F: 'static + Send + FnOnce(Output) -> R
546+
{
525547
let mut default_passes = !matches.opt_present("no-defaults");
526548
let mut passes = matches.opt_strs("passes");
527549
let mut plugins = matches.opt_strs("plugins");
@@ -570,7 +592,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
570592
let (mut krate, renderinfo) =
571593
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
572594
display_warnings, crate_name.clone(),
573-
force_unstable_if_unmarked);
595+
force_unstable_if_unmarked, edition);
574596

575597
info!("finished with rustc");
576598

Diff for: src/librustdoc/markdown.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use testing;
1818
use rustc::session::search_paths::SearchPaths;
1919
use rustc::session::config::Externs;
2020
use syntax::codemap::DUMMY_SP;
21+
use syntax::edition::Edition;
2122

2223
use externalfiles::{ExternalHtml, LoadStringError, load_string};
2324

@@ -139,7 +140,7 @@ pub fn render(input: &Path, mut output: PathBuf, matches: &getopts::Matches,
139140
/// Run any tests/code examples in the markdown file `input`.
140141
pub fn test(input: &str, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
141142
mut test_args: Vec<String>, maybe_sysroot: Option<PathBuf>,
142-
display_warnings: bool, linker: Option<PathBuf>) -> isize {
143+
display_warnings: bool, linker: Option<PathBuf>, edition: Edition) -> isize {
143144
let input_str = match load_string(input) {
144145
Ok(s) => s,
145146
Err(LoadStringError::ReadFail) => return 1,
@@ -151,7 +152,7 @@ pub fn test(input: &str, cfgs: Vec<String>, libs: SearchPaths, externs: Externs,
151152
let mut collector = Collector::new(input.to_owned(), cfgs, libs, externs,
152153
true, opts, maybe_sysroot, None,
153154
Some(PathBuf::from(input)),
154-
linker);
155+
linker, edition);
155156
find_testable_code(&input_str, &mut collector, DUMMY_SP, None);
156157
test_args.insert(0, "rustdoctest".to_string());
157158
testing::test_main(&test_args, collector.tests,

0 commit comments

Comments
 (0)