Merge pull request #1887 from mgeisler/edition-2021

Require Rust 2021 edition
This commit is contained in:
Eric Huss 2022-09-09 13:14:33 -07:00 committed by GitHub
commit 8cdb8d0367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 32 additions and 24 deletions

View File

@ -32,7 +32,7 @@ jobs:
- build: msrv - build: msrv
os: ubuntu-latest os: ubuntu-latest
# sync MSRV with docs: guide/src/guide/installation.md # sync MSRV with docs: guide/src/guide/installation.md
rust: 1.54.0 rust: 1.56.0
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Install Rust - name: Install Rust

View File

@ -7,7 +7,7 @@ authors = [
"Matt Ickstadt <mattico8@gmail.com>" "Matt Ickstadt <mattico8@gmail.com>"
] ]
documentation = "http://rust-lang.github.io/mdBook/index.html" documentation = "http://rust-lang.github.io/mdBook/index.html"
edition = "2018" edition = "2021"
exclude = ["/guide/*"] exclude = ["/guide/*"]
keywords = ["book", "gitbook", "rustbook", "markdown"] keywords = ["book", "gitbook", "rustbook", "markdown"]
license = "MPL-2.0" license = "MPL-2.0"

View File

@ -8,7 +8,7 @@ use super::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem};
use crate::config::BuildConfig; use crate::config::BuildConfig;
use crate::errors::*; use crate::errors::*;
use crate::utils::bracket_escape; use crate::utils::bracket_escape;
use log::debug;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Load a book into memory from its `src/` directory. /// Load a book into memory from its `src/` directory.

View File

@ -6,6 +6,7 @@ use super::MDBook;
use crate::config::Config; use crate::config::Config;
use crate::errors::*; use crate::errors::*;
use crate::theme; use crate::theme;
use log::{debug, error, info, trace};
/// A helper for setting up a new book and its directory structure. /// A helper for setting up a new book and its directory structure.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]

View File

@ -14,6 +14,7 @@ pub use self::book::{load_book, Book, BookItem, BookItems, Chapter};
pub use self::init::BookBuilder; pub use self::init::BookBuilder;
pub use self::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem}; pub use self::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem};
use log::{debug, error, info, log_enabled, trace, warn};
use std::io::Write; use std::io::Write;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;

View File

@ -1,4 +1,5 @@
use crate::errors::*; use crate::errors::*;
use log::{debug, trace, warn};
use memchr::{self, Memchr}; use memchr::{self, Memchr};
use pulldown_cmark::{self, Event, HeadingLevel, Tag}; use pulldown_cmark::{self, Event, HeadingLevel, Tag};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -49,6 +49,7 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use log::{debug, trace, warn};
use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
@ -295,7 +296,7 @@ impl Default for Config {
} }
} }
impl<'de> Deserialize<'de> for Config { impl<'de> serde::Deserialize<'de> for Config {
fn deserialize<D: Deserializer<'de>>(de: D) -> std::result::Result<Self, D::Error> { fn deserialize<D: Deserializer<'de>>(de: D) -> std::result::Result<Self, D::Error> {
let raw = Value::deserialize(de)?; let raw = Value::deserialize(de)?;
@ -717,6 +718,7 @@ impl<'de, T> Updateable<'de> for T where T: Serialize + Deserialize<'de> {}
mod tests { mod tests {
use super::*; use super::*;
use crate::utils::fs::get_404_output_file; use crate::utils::fs::get_404_output_file;
use serde_json::json;
const COMPLEX_CONFIG: &str = r#" const COMPLEX_CONFIG: &str = r#"
[book] [book]

View File

@ -83,17 +83,6 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![deny(rust_2018_idioms)] #![deny(rust_2018_idioms)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_json;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
pub mod book; pub mod book;
pub mod config; pub mod config;
pub mod preprocess; pub mod preprocess;

View File

@ -1,6 +1,7 @@
use super::{Preprocessor, PreprocessorContext}; use super::{Preprocessor, PreprocessorContext};
use crate::book::Book; use crate::book::Book;
use crate::errors::*; use crate::errors::*;
use log::{debug, trace, warn};
use shlex::Shlex; use shlex::Shlex;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::process::{Child, Command, Stdio}; use std::process::{Child, Command, Stdio};

View File

@ -1,10 +1,11 @@
use regex::Regex; use regex::Regex;
use std::path::Path; use std::path::Path;
use crate::errors::*;
use super::{Preprocessor, PreprocessorContext}; use super::{Preprocessor, PreprocessorContext};
use crate::book::{Book, BookItem}; use crate::book::{Book, BookItem};
use crate::errors::*;
use lazy_static::lazy_static;
use log::warn;
/// A preprocessor for converting file name `README.md` to `index.md` since /// A preprocessor for converting file name `README.md` to `index.md` since
/// `README.md` is the de facto index file in markdown-based documentation. /// `README.md` is the de facto index file in markdown-based documentation.

View File

@ -10,6 +10,8 @@ use std::path::{Path, PathBuf};
use super::{Preprocessor, PreprocessorContext}; use super::{Preprocessor, PreprocessorContext};
use crate::book::{Book, BookItem}; use crate::book::{Book, BookItem};
use lazy_static::lazy_static;
use log::{error, warn};
const ESCAPE_CHAR: char = '\\'; const ESCAPE_CHAR: char = '\\';
const MAX_LINK_NESTED_DEPTH: usize = 10; const MAX_LINK_NESTED_DEPTH: usize = 10;

View File

@ -12,12 +12,11 @@ use crate::book::Book;
use crate::config::Config; use crate::config::Config;
use crate::errors::*; use crate::errors::*;
use serde::{Deserialize, Serialize};
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::PathBuf; use std::path::PathBuf;
use serde::{Deserialize, Serialize};
/// Extra information for a `Preprocessor` to give them more context when /// Extra information for a `Preprocessor` to give them more context when
/// processing a book. /// processing a book.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]

View File

@ -14,7 +14,10 @@ use std::path::{Path, PathBuf};
use crate::utils::fs::get_404_output_file; use crate::utils::fs::get_404_output_file;
use handlebars::Handlebars; use handlebars::Handlebars;
use lazy_static::lazy_static;
use log::{debug, trace, warn};
use regex::{Captures, Regex}; use regex::{Captures, Regex};
use serde_json::json;
#[derive(Default)] #[derive(Default)]
pub struct HtmlHandlebars; pub struct HtmlHandlebars;

View File

@ -4,6 +4,8 @@ use std::path::Path;
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError, Renderable}; use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError, Renderable};
use crate::utils; use crate::utils;
use log::{debug, trace};
use serde_json::json;
type StringMap = BTreeMap<String, String>; type StringMap = BTreeMap<String, String>;

View File

@ -1,4 +1,5 @@
use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError}; use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError};
use log::trace;
pub fn theme_option( pub fn theme_option(
h: &Helper<'_, '_>, h: &Helper<'_, '_>,

View File

@ -10,7 +10,8 @@ use crate::config::Search;
use crate::errors::*; use crate::errors::*;
use crate::theme::searcher; use crate::theme::searcher;
use crate::utils; use crate::utils;
use lazy_static::lazy_static;
use log::{debug, warn};
use serde::Serialize; use serde::Serialize;
const MAX_WORD_LENGTH_TO_INDEX: usize = 80; const MAX_WORD_LENGTH_TO_INDEX: usize = 80;

View File

@ -2,7 +2,7 @@ use crate::book::BookItem;
use crate::errors::*; use crate::errors::*;
use crate::renderer::{RenderContext, Renderer}; use crate::renderer::{RenderContext, Renderer};
use crate::utils; use crate::utils;
use log::trace;
use std::fs; use std::fs;
#[derive(Default)] #[derive(Default)]

View File

@ -27,6 +27,7 @@ use std::process::{Command, Stdio};
use crate::book::Book; use crate::book::Book;
use crate::config::Config; use crate::config::Config;
use crate::errors::*; use crate::errors::*;
use log::{error, info, trace, warn};
use toml::Value; use toml::Value;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -12,7 +12,7 @@ use std::io::Read;
use std::path::Path; use std::path::Path;
use crate::errors::*; use crate::errors::*;
use log::warn;
pub static INDEX: &[u8] = include_bytes!("index.hbs"); pub static INDEX: &[u8] = include_bytes!("index.hbs");
pub static HEAD: &[u8] = include_bytes!("head.hbs"); pub static HEAD: &[u8] = include_bytes!("head.hbs");
pub static REDIRECT: &[u8] = include_bytes!("redirect.hbs"); pub static REDIRECT: &[u8] = include_bytes!("redirect.hbs");

View File

@ -1,4 +1,5 @@
use crate::errors::*; use crate::errors::*;
use log::{debug, trace};
use std::convert::Into; use std::convert::Into;
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::Write; use std::io::Write;

View File

@ -4,9 +4,10 @@ pub mod fs;
mod string; mod string;
pub(crate) mod toml_ext; pub(crate) mod toml_ext;
use crate::errors::Error; use crate::errors::Error;
use regex::Regex; use lazy_static::lazy_static;
use log::error;
use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag}; use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag};
use regex::Regex;
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;

View File

@ -1,3 +1,4 @@
use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use std::ops::Bound::{Excluded, Included, Unbounded}; use std::ops::Bound::{Excluded, Included, Unbounded};
use std::ops::RangeBounds; use std::ops::RangeBounds;