Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
321419e
Box::from(slice): Clarify that contents are copied
XrXr Jul 21, 2022
c1aae4d
std::io: migrate ReadBuf to BorrowBuf/BorrowCursor
nrc May 13, 2022
b56cf67
Add some docs for BorrowBuf
nrc May 23, 2022
1a2122f
non-linux platforms
nrc Jun 7, 2022
08c9732
Add standard C error function aliases
BlackHoleFox Aug 9, 2022
8509936
Add mention of `BufReader` in `Read::bytes` docs
jakubdabek Aug 14, 2022
ac70aea
Address reviewer comments
nrc Aug 11, 2022
85b3df2
Export Cancel from std::os::fortanix_sgx::usercalls::raw
mzohreva Aug 22, 2022
2a26987
Add GDB/LLDB pretty-printers for NonZero types
artemmukhin Jun 20, 2022
80442f3
error::Error: rename the chain method to sources
nrc Aug 24, 2022
b556a5b
error::Error: rename the Demand arguments from req to demand
nrc Aug 24, 2022
9372c4f
error::Error: remove some comments
nrc Aug 25, 2022
7529029
Provide structured suggestion for `hashmap[idx] = val`
estebank Aug 25, 2022
b85178a
no alignment check during interning
RalfJung Aug 26, 2022
468c617
add a test
RalfJung Aug 26, 2022
b33c3d6
use smaller span for suggestions
TaKO8Ki Aug 26, 2022
aa76e13
extend attrs if local_def_id exists
TaKO8Ki Aug 27, 2022
fc3f3c3
rustc_middle: Remove `Visibility::Invisible`
petrochenkov Aug 27, 2022
4a82c21
unstable-book-gen: use std::fs::write
est31 Aug 27, 2022
b9306c2
Rollup merge of #97015 - nrc:read-buf-cursor, r=Mark-Simulacrum
matthiaskrgr Aug 28, 2022
85916c7
Rollup merge of #98301 - ortem:pretty-printers-nonzero, r=wesleywiser
matthiaskrgr Aug 28, 2022
6582009
Rollup merge of #99570 - XrXr:box-from-slice-docs, r=thomcc
matthiaskrgr Aug 28, 2022
58174e3
Rollup merge of #100296 - BlackHoleFox:os-error-aliases, r=thomcc
matthiaskrgr Aug 28, 2022
83e8305
Rollup merge of #100520 - jakubdabek:patch-1, r=thomcc
matthiaskrgr Aug 28, 2022
1547638
Rollup merge of #100885 - mzohreva:mz/sgx-export-cancel-type, r=Mark-…
matthiaskrgr Aug 28, 2022
edd81d1
Rollup merge of #100955 - nrc:chain, r=joshtriplett
matthiaskrgr Aug 28, 2022
c577021
Rollup merge of #101002 - estebank:hashmap-idx, r=davidtwco
matthiaskrgr Aug 28, 2022
5b80814
Rollup merge of #101038 - RalfJung:interning-alignment, r=oli-obk
matthiaskrgr Aug 28, 2022
3142996
Rollup merge of #101055 - TaKO8Ki:use-smaller-span, r=compiler-errors
matthiaskrgr Aug 28, 2022
c2f294a
Rollup merge of #101091 - TaKO8Ki:fix-101076, r=notriddle
matthiaskrgr Aug 28, 2022
0335909
Rollup merge of #101098 - petrochenkov:noinvis, r=TaKO8Ki
matthiaskrgr Aug 28, 2022
b3a4bc5
Rollup merge of #101102 - est31:unstable_book_gen_write, r=Mark-Simul…
matthiaskrgr Aug 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unstable-book-gen: use std::fs::write
I wrote this code in 2017 back when std::fs::write wasn't available.
Also, use the t macro from tidy.
  • Loading branch information
est31 committed Aug 27, 2022
commit 4a82c2174a7e986f9a50d9ec806c4c47bd22eed8
33 changes: 10 additions & 23 deletions src/tools/unstable-book-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,23 @@

use std::collections::BTreeSet;
use std::env;
use std::fs::{self, File};
use std::io::Write;
use std::fs::{self, write};
use std::path::Path;
use tidy::features::{collect_lang_features, collect_lib_features, Features};
use tidy::t;
use tidy::unstable_book::{
collect_unstable_book_section_file_names, collect_unstable_feature_names, LANG_FEATURES_DIR,
LIB_FEATURES_DIR, PATH_STR,
};

/// A helper macro to `unwrap` a result except also print out details like:
///
/// * The file/line of the panic
/// * The expression that failed
/// * The error itself
macro_rules! t {
($e:expr) => {
match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {}", stringify!($e), e),
}
};
}

fn generate_stub_issue(path: &Path, name: &str, issue: u32) {
let mut file = t!(File::create(path));
t!(write!(file, include_str!("stub-issue.md"), name = name, issue = issue));
let content = format!(include_str!("stub-issue.md"), name = name, issue = issue);
t!(write(path, content), path);
}

fn generate_stub_no_issue(path: &Path, name: &str) {
let mut file = t!(File::create(path));
t!(write!(file, include_str!("stub-no-issue.md"), name = name));
let content = format!(include_str!("stub-no-issue.md"), name = name);
t!(write(path, content), path);
}

fn set_to_summary_str(set: &BTreeSet<String>, dir: &str) -> String {
Expand All @@ -52,13 +38,14 @@ fn generate_summary(path: &Path, lang_features: &Features, lib_features: &Featur
let lang_features_str = set_to_summary_str(&unstable_lang_features, "language-features");
let lib_features_str = set_to_summary_str(&unstable_lib_features, "library-features");

let mut file = t!(File::create(&path.join("src/SUMMARY.md")));
t!(file.write_fmt(format_args!(
let summary_path = path.join("src/SUMMARY.md");
let content = format!(
include_str!("SUMMARY.md"),
compiler_flags = compiler_flags_str,
language_features = lang_features_str,
library_features = lib_features_str
)));
);
t!(write(&summary_path, content), summary_path);
}

fn generate_unstable_book_files(src: &Path, out: &Path, features: &Features) {
Expand Down