From 9b789629c9b4d6f61ee1179437ee69588a9f9ead Mon Sep 17 00:00:00 2001 From: Yu Ding Date: Wed, 9 Oct 2019 14:56:50 -0700 Subject: [PATCH] Fix some old Rust codes Done by cargo fix using nightly-2019-10-04 toolchain. Fixed ... to ..=, trait object to dyn trait object --- src/prolog/heap_print.rs | 2 +- src/prolog/iterators.rs | 4 ++-- src/prolog/machine/machine_errors.rs | 2 +- src/prolog/machine/machine_state.rs | 14 +++++++------- src/prolog/machine/machine_state_impl.rs | 16 ++++++++-------- src/prolog/machine/mod.rs | 6 +++--- src/prolog/machine/system_calls.rs | 4 ++-- src/prolog/read.rs | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/prolog/heap_print.rs b/src/prolog/heap_print.rs index 4609693b..37aef6c5 100644 --- a/src/prolog/heap_print.rs +++ b/src/prolog/heap_print.rs @@ -147,7 +147,7 @@ fn char_to_string(c: char) -> String { '\u{0c}' => "\\f".to_string(), // UTF-8 form feed '\u{08}' => "\\b".to_string(), // UTF-8 backspace '\u{07}' => "\\a".to_string(), // UTF-8 alert - '\x20'...'\x7e' => c.to_string(), + '\x20'..='\x7e' => c.to_string(), _ => format!("\\x{:x}\\", c as u32), } } diff --git a/src/prolog/iterators.rs b/src/prolog/iterators.rs index ddc77613..09ec2096 100644 --- a/src/prolog/iterators.rs +++ b/src/prolog/iterators.rs @@ -342,7 +342,7 @@ fn contains_cut_var<'a, Iter: Iterator>(terms: Iter) -> bool { pub struct ChunkedIterator<'a> { pub chunk_num: usize, - iter: Box> + 'a>, + iter: Box> + 'a>, deep_cut_encountered: bool, cut_var_in_head: bool, } @@ -351,7 +351,7 @@ type ChunkedIteratorItem<'a> = (usize, usize, Vec>); type RuleBodyIteratorItem<'a> = (usize, usize, Vec<&'a QueryTerm>); impl<'a> ChunkedIterator<'a> { - pub fn rule_body_iter(self) -> Box> + 'a> { + pub fn rule_body_iter(self) -> Box> + 'a> { Box::new(self.filter_map(|(cn, lt_arity, terms)| { let filtered_terms: Vec<_> = terms .into_iter() diff --git a/src/prolog/machine/machine_errors.rs b/src/prolog/machine/machine_errors.rs index ad0ff427..4646a4f7 100644 --- a/src/prolog/machine/machine_errors.rs +++ b/src/prolog/machine/machine_errors.rs @@ -250,7 +250,7 @@ impl MachineError { } } - fn into_iter(self, offset: usize) -> Box> { + fn into_iter(self, offset: usize) -> Box> { match self.from { ErrorProvenance::Constructed => { Box::new(self.stub.into_iter().map(move |hcv| match hcv { diff --git a/src/prolog/machine/machine_state.rs b/src/prolog/machine/machine_state.rs index 05ced12a..aae549db 100644 --- a/src/prolog/machine/machine_state.rs +++ b/src/prolog/machine/machine_state.rs @@ -943,22 +943,22 @@ impl CallPolicy for CWILCallPolicy { } } -downcast!(CallPolicy); +downcast!(dyn CallPolicy); pub(crate) struct DefaultCallPolicy {} impl CallPolicy for DefaultCallPolicy {} pub(crate) struct CWILCallPolicy { - pub(crate) prev_policy: Box, + pub(crate) prev_policy: Box, count: Integer, limits: Vec<(Integer, usize)>, inference_limit_exceeded: bool, } impl CWILCallPolicy { - pub(crate) fn new_in_place(policy: &mut Box) { - let mut prev_policy: Box = Box::new(DefaultCallPolicy {}); + pub(crate) fn new_in_place(policy: &mut Box) { + let mut prev_policy: Box = Box::new(DefaultCallPolicy {}); mem::swap(&mut prev_policy, policy); let new_policy = CWILCallPolicy { @@ -1016,8 +1016,8 @@ impl CWILCallPolicy { self.limits.is_empty() } - pub(crate) fn into_inner(&mut self) -> Box { - let mut new_inner: Box = Box::new(DefaultCallPolicy {}); + pub(crate) fn into_inner(&mut self) -> Box { + let mut new_inner: Box = Box::new(DefaultCallPolicy {}); mem::swap(&mut self.prev_policy, &mut new_inner); new_inner } @@ -1028,7 +1028,7 @@ pub(crate) trait CutPolicy: Any { fn cut(&mut self, &mut MachineState, RegType) -> bool; } -downcast!(CutPolicy); +downcast!(dyn CutPolicy); fn cut_body(machine_st: &mut MachineState, addr: Addr) -> bool { let b = machine_st.b; diff --git a/src/prolog/machine/machine_state_impl.rs b/src/prolog/machine/machine_state_impl.rs index e20a2d9d..6f6238a7 100644 --- a/src/prolog/machine/machine_state_impl.rs +++ b/src/prolog/machine/machine_state_impl.rs @@ -3151,8 +3151,8 @@ impl MachineState { &mut self, indices: &mut IndexStore, code_repo: &CodeRepo, - call_policy: &mut Box, - cut_policy: &mut Box, + call_policy: &mut Box, + cut_policy: &mut Box, parsing_stream: &mut PrologStream, ct: &ClauseType, arity: usize, @@ -3167,7 +3167,7 @@ impl MachineState { return; } - let mut default_call_policy: Box = Box::new(DefaultCallPolicy {}); + let mut default_call_policy: Box = Box::new(DefaultCallPolicy {}); let call_policy = if use_default_cp { &mut default_call_policy } else { @@ -3217,8 +3217,8 @@ impl MachineState { &mut self, indices: &mut IndexStore, code_repo: &CodeRepo, - call_policy: &mut Box, - cut_policy: &mut Box, + call_policy: &mut Box, + cut_policy: &mut Box, parsing_stream: &mut PrologStream, instr: &ControlInstruction, ) { @@ -3253,7 +3253,7 @@ impl MachineState { pub(super) fn execute_indexed_choice_instr( &mut self, instr: &IndexedChoiceInstruction, - call_policy: &mut Box, + call_policy: &mut Box, ) { match instr { &IndexedChoiceInstruction::Try(l) => { @@ -3292,7 +3292,7 @@ impl MachineState { pub(super) fn execute_choice_instr( &mut self, instr: &ChoiceInstruction, - call_policy: &mut Box, + call_policy: &mut Box, ) { match instr { &ChoiceInstruction::TryMeElse(offset) => { @@ -3341,7 +3341,7 @@ impl MachineState { pub(super) fn execute_cut_instr( &mut self, instr: &CutInstruction, - cut_policy: &mut Box, + cut_policy: &mut Box, ) { match instr { &CutInstruction::NeckCut => { diff --git a/src/prolog/machine/mod.rs b/src/prolog/machine/mod.rs index d5ae71ec..8e412f91 100644 --- a/src/prolog/machine/mod.rs +++ b/src/prolog/machine/mod.rs @@ -51,8 +51,8 @@ use std::sync::atomic::AtomicBool; use termion::raw::IntoRawMode; pub struct MachinePolicies { - call_policy: Box, - cut_policy: Box, + call_policy: Box, + cut_policy: Box, } lazy_static! { @@ -75,7 +75,7 @@ pub struct Machine { pub(super) indices: IndexStore, pub(super) code_repo: CodeRepo, pub(super) toplevel_idx: usize, - pub(super) prolog_stream: ParsingStream>, + pub(super) prolog_stream: ParsingStream>, } impl Index for CodeRepo { diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index ca2ac0d5..673dd42d 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -550,8 +550,8 @@ impl MachineState { ct: &SystemClauseType, code_repo: &CodeRepo, indices: &mut IndexStore, - call_policy: &mut Box, - cut_policy: &mut Box, + call_policy: &mut Box, + cut_policy: &mut Box, current_input_stream: &mut PrologStream, ) -> CallResult { match ct { diff --git a/src/prolog/read.rs b/src/prolog/read.rs index b003bdda..2cc94d76 100644 --- a/src/prolog/read.rs +++ b/src/prolog/read.rs @@ -23,7 +23,7 @@ impl<'a> TermRef<'a> { } } -pub type PrologStream = ParsingStream>; +pub type PrologStream = ParsingStream>; pub mod readline { use prolog_parser::ast::*; @@ -116,7 +116,7 @@ pub mod readline { #[inline] pub fn input_stream() -> ::PrologStream { - let reader: Box = Box::new(ReadlineStream::input_stream(String::from(""))); + let reader: Box = Box::new(ReadlineStream::input_stream(String::from(""))); parsing_stream(reader) } } -- 2.54.0