Fix deprecation warnings in Rust 1.37

This commit is contained in:
Tad Hardesty 2019-08-17 12:54:07 -07:00
parent 574f1f780e
commit 2644479a93
8 changed files with 16 additions and 16 deletions

View file

@ -35,7 +35,7 @@ thread_local! {
static ALL_TYPE_NAMES: RefCell<BTreeSet<String>> = Default::default();
}
fn main() -> Result<(), Box<std::error::Error>> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
for arg in std::env::args() {
if arg == "-V" || arg == "--version" {
println!("{}", BUILD_INFO);

View file

@ -329,7 +329,7 @@ pub struct DMError {
component: Component,
description: String,
notes: Vec<DiagnosticNote>,
cause: Option<Box<error::Error + Send + Sync>>,
cause: Option<Box<dyn error::Error + Send + Sync>>,
}
/// An additional note attached to an error, at some other location.
@ -426,8 +426,8 @@ impl error::Error for DMError {
&self.description
}
fn cause(&self) -> Option<&error::Error> {
self.cause.as_ref().map(|x| &**x as &error::Error)
fn cause(&self) -> Option<&dyn error::Error> {
self.cause.as_ref().map(|x| &**x as &dyn error::Error)
}
}

View file

@ -1141,8 +1141,8 @@ impl<'ctx, I: Iterator<Item=io::Result<u8>>> Iterator for Lexer<'ctx, I> {
}
Some(v) => Some(locate(Punct(v))),
None => match first {
b'0'...b'9' => Some(locate(self.read_number(first))),
b'_' | b'a'...b'z' | b'A'...b'Z' => {
b'0'..=b'9' => Some(locate(self.read_number(first))),
b'_' | b'a'..=b'z' | b'A'..=b'Z' => {
let ident = self.read_ident(first);
let next = self.next();
self.put_back(next);

View file

@ -161,7 +161,7 @@ enum Include<'ctx> {
File {
path: PathBuf,
file: FileId,
lexer: Lexer<'ctx, io::Bytes<Box<io::Read>>>,
lexer: Lexer<'ctx, io::Bytes<Box<dyn io::Read>>>,
},
Expansion {
name: String,
@ -171,7 +171,7 @@ enum Include<'ctx> {
}
impl<'ctx> Include<'ctx> {
fn from_read(context: &'ctx Context, path: PathBuf, read: Box<io::Read>) -> Include {
fn from_read(context: &'ctx Context, path: PathBuf, read: Box<dyn io::Read>) -> Include {
let idx = context.register_file(&path);
Include::File {
file: idx,

View file

@ -88,14 +88,14 @@ impl DocumentStore {
format!("URL not opened and schema is not 'file': {}", url)));
}
pub fn read(&self, url: &Url) -> io::Result<Box<io::Read>> {
pub fn read(&self, url: &Url) -> io::Result<Box<dyn io::Read>> {
if let Some(document) = self.map.get(url) {
return Ok(Box::new(Cursor::new(document.text.clone())) as Box<io::Read>);
return Ok(Box::new(Cursor::new(document.text.clone())) as Box<dyn io::Read>);
}
if let Ok(path) = ::url_to_path(url) {
let file = ::std::fs::File::open(path)?;
return Ok(Box::new(file) as Box<io::Read>);
return Ok(Box::new(file) as Box<dyn io::Read>);
}
return Err(io::Error::new(io::ErrorKind::NotFound,

View file

@ -23,7 +23,7 @@ pub struct Context<'a> {
pub grid: Grid<'a>,
pub min: (usize, usize),
pub max: (usize, usize),
pub render_passes: &'a [Box<RenderPass>],
pub render_passes: &'a [Box<dyn RenderPass>],
pub errors: &'a RwLock<HashSet<String>>,
}
@ -268,7 +268,7 @@ pub fn get_atom_list<'a>(
objtree: &'a ObjectTree,
prefabs: &'a [Prefab],
loc: (u32, u32),
render_passes: &[Box<RenderPass>],
render_passes: &[Box<dyn RenderPass>],
errors: Option<&RwLock<HashSet<String>>>,
) -> Vec<Atom<'a>> {
let mut result = Vec::new();

View file

@ -62,7 +62,7 @@ pub struct RenderPassInfo {
pub name: &'static str,
pub desc: &'static str,
pub default: bool,
pub new: fn() -> Box<RenderPass>,
pub new: fn() -> Box<dyn RenderPass>,
}
macro_rules! pass {
@ -88,7 +88,7 @@ pub const RENDER_PASSES: &[RenderPassInfo] = &[
pass!(Pipes, "only-pipenet", "Render only atmospheric pipes.", false),
];
pub fn configure(include: &str, exclude: &str) -> Vec<Box<RenderPass>> {
pub fn configure(include: &str, exclude: &str) -> Vec<Box<dyn RenderPass>> {
let include: Vec<&str> = include.split(",").collect();
let exclude: Vec<&str> = exclude.split(",").collect();
let include_all = include.iter().any(|&name| name == "all");

View file

@ -49,7 +49,7 @@ impl<R: Read> Iterator for Chars<R> {
}
}
fn read_one_byte(reader: &mut Read) -> Option<io::Result<u8>> {
fn read_one_byte(reader: &mut dyn Read) -> Option<io::Result<u8>> {
let mut buf = [0];
loop {
return match reader.read(&mut buf) {