From: Nicolas Luck Date: Tue, 17 Oct 2023 20:07:38 +0000 (+0200) Subject: Fix wasm warnings X-Git-Tag: remove^2~3 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=0c9740fe52319aa4d593eccea0cf0bc690203e0d;p=scryer-prolog.git Fix wasm warnings --- diff --git a/src/lib.rs b/src/lib.rs index 87a0f8ad..3579fcf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,7 +49,6 @@ use wasm_bindgen::prelude::*; #[cfg(target_arch = "wasm32")] #[wasm_bindgen] pub fn eval_code(s: &str) -> String { - use web_sys::console; use machine::mock_wam::*; let mut wam = Machine::with_test_streams(); diff --git a/src/machine/streams.rs b/src/machine/streams.rs index 1dfbfaa9..4f955050 100644 --- a/src/machine/streams.rs +++ b/src/machine/streams.rs @@ -21,7 +21,9 @@ use std::fmt::Debug; use std::fs::{File, OpenOptions}; use std::hash::Hash; use std::io; -use std::io::{BufRead, Cursor, ErrorKind, Read, Seek, SeekFrom, Write}; +use std::io::{Cursor, ErrorKind, Read, Seek, SeekFrom, Write}; +#[cfg(feature = "http")] +use std::io::BufRead; use std::mem; use std::net::{Shutdown, TcpStream}; use std::ops::{Deref, DerefMut}; diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 17a86e98..61df25e7 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -51,14 +51,20 @@ use std::env; use std::ffi::CString; use std::fs; use std::hash::{BuildHasher, BuildHasherDefault}; -use std::io::{ErrorKind, Read, BufRead, Write}; +use std::io::{ErrorKind, Read, Write}; +#[cfg(feature = "http")] +use std::io::BufRead; use std::iter::{once, FromIterator}; use std::mem; -use std::net::{SocketAddr, TcpListener, TcpStream, ToSocketAddrs}; +use std::net::{TcpListener, TcpStream}; +#[cfg(feature = "http")] +use std::net::{SocketAddr, ToSocketAddrs}; use std::num::NonZeroU32; use std::ops::Sub; use std::process; +#[cfg(feature = "http")] use std::str::FromStr; +#[cfg(feature = "http")] use std::sync::{Mutex, Arc, Condvar}; use chrono::{offset::Local, DateTime}; @@ -100,7 +106,7 @@ use warp::hyper::{HeaderMap, Method}; use warp::{Buf, Filter}; #[cfg(feature = "http")] use reqwest::Url; -//use hyper_util::rt::TokioIo; +#[cfg(feature = "http")] use futures::future; #[cfg(feature = "repl")] diff --git a/src/read.rs b/src/read.rs index 1baf8720..4955c670 100644 --- a/src/read.rs +++ b/src/read.rs @@ -24,7 +24,9 @@ use rustyline::history::DefaultHistory; use rustyline::{Config, Editor}; use std::collections::VecDeque; -use std::io::{Cursor, Error, ErrorKind, Read}; +use std::io::{Cursor, Read}; +#[cfg(feature = "repl")] +use std::io::{Error, ErrorKind}; use std::sync::Arc; type SubtermDeque = VecDeque<(usize, usize)>; @@ -83,6 +85,7 @@ impl MachineState { } static mut PROMPT: bool = false; +#[cfg(feature = "repl")] const HISTORY_FILE: &'static str = ".scryer_history"; pub(crate) fn set_prompt(value: bool) { @@ -91,6 +94,7 @@ pub(crate) fn set_prompt(value: bool) { } } +#[cfg(feature = "repl")] #[inline] fn get_prompt() -> &'static str { unsafe { @@ -107,6 +111,7 @@ pub struct ReadlineStream { #[cfg(feature = "repl")] rl: Editor, pending_input: CharReader>, + #[allow(dead_code)] add_history: bool, } @@ -145,6 +150,7 @@ impl ReadlineStream { } } + #[allow(unused_variables)] pub fn set_atoms_for_completion(&mut self, atoms: &Arc) { #[cfg(feature = "repl")] { @@ -215,6 +221,7 @@ impl ReadlineStream { } } + #[allow(dead_code)] #[cfg(not(feature = "repl"))] fn save_history(&mut self) {}