fix 'edition="2018"' module import errors

- ref: <https://users.rust-lang.org/t/imports-can-only-refer-to-extern-crate-names/24388> @@ <https://archive.is/iCaXp>
This commit is contained in:
Roy Ivy III 2020-05-25 11:48:39 -05:00
parent 9f585f5426
commit d4aa3a2231
35 changed files with 112 additions and 90 deletions

View file

@ -12,8 +12,8 @@ use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, Read, Stdout, Write};
use std::path::Path;
use ranges::Range;
use searcher::Searcher;
use self::ranges::Range;
use self::searcher::Searcher;
mod buffer;
mod ranges;
@ -130,8 +130,8 @@ fn list_to_ranges(list: &str, complement: bool) -> Result<Vec<Range>, String> {
}
fn cut_bytes<R: Read>(reader: R, ranges: &[Range], opts: &Options) -> i32 {
use buffer::Bytes::Select;
use buffer::Bytes::Selected::*;
use self::buffer::Bytes::Select;
use self::buffer::Bytes::Selected::*;
let newline_char = if opts.zero_terminated { b'\0' } else { b'\n' };
let mut buf_read = buffer::ByteReader::new(reader, newline_char);

View file

@ -24,7 +24,7 @@ static LONG_HELP: &str = "
";
mod colors;
use colors::INTERNAL_DB;
use self::colors::INTERNAL_DB;
#[derive(PartialEq, Debug)]
pub enum OutputFmt {

View file

@ -11,7 +11,8 @@
//!
use onig::{Regex, RegexOptions, Syntax};
use tokens::Token;
use crate::tokens::Token;
type TokenStack = Vec<(usize, Token)>;
pub type OperandsList = Vec<Box<ASTNode>>;

View file

@ -15,7 +15,6 @@
#![cfg_attr(test, allow(dead_code))]
use sieve::Sieve;
use std::env::{self, args};
use std::fs::File;
use std::io::Write;
@ -23,6 +22,8 @@ use std::num::Wrapping;
use std::path::Path;
use std::u64::MAX as MAX_U64;
use self::sieve::Sieve;
#[cfg(test)]
use miller_rabin::is_prime;

View file

@ -1,11 +1,12 @@
use crate::miller_rabin::Result::*;
use crate::{miller_rabin, Factors};
use numeric::*;
use rand::distributions::{Distribution, Uniform};
use rand::rngs::SmallRng;
use rand::{thread_rng, SeedableRng};
use std::cmp::{max, min};
use crate::miller_rabin::Result::*;
use crate::numeric::*;
use crate::{miller_rabin, Factors};
fn find_divisor<A: Arithmetic>(n: u64) -> u64 {
#![allow(clippy::many_single_char_names)]
let mut rand = {

View file

@ -1,6 +1,7 @@
use crate::Factors;
use std::num::Wrapping;
use crate::Factors;
include!(concat!(env!("OUT_DIR"), "/prime_table.rs"));
pub(crate) fn factor(mut num: u64) -> (Factors, u64) {

View file

@ -10,13 +10,14 @@ extern crate unicode_width;
#[macro_use]
extern crate uucore;
use linebreak::break_lines;
use parasplit::ParagraphStream;
use std::cmp;
use std::fs::File;
use std::io::{stdin, stdout, Write};
use std::io::{BufReader, BufWriter, Read};
use self::linebreak::break_lines;
use self::parasplit::ParagraphStream;
macro_rules! silent_unwrap(
($exp:expr) => (
match $exp {

View file

@ -5,12 +5,13 @@
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
use parasplit::{ParaWords, Paragraph, WordInfo};
use std::cmp;
use std::i64;
use std::io::{BufWriter, Stdout, Write};
use std::mem;
use FmtOptions;
use crate::parasplit::{ParaWords, Paragraph, WordInfo};
use crate::FmtOptions;
struct BreakArgs<'a> {
opts: &'a FmtOptions,

View file

@ -9,8 +9,9 @@ use std::io::{BufRead, Lines};
use std::iter::Peekable;
use std::slice::Iter;
use unicode_width::UnicodeWidthChar;
use FileOrStdReader;
use FmtOptions;
use crate::FileOrStdReader;
use crate::FmtOptions;
fn char_width(c: char) -> usize {
if (c as usize) < 0xA0 {

View file

@ -4,9 +4,10 @@ extern crate sha1;
extern crate sha2;
extern crate sha3;
use digest::digest::{ExtendableOutput, Input, XofReader};
use hex::ToHex;
use crate::digest::digest::{ExtendableOutput, Input, XofReader};
pub trait Digest {
fn new() -> Self
where

View file

@ -21,7 +21,8 @@ extern crate uucore;
mod digest;
use digest::Digest;
use self::digest::Digest;
use hex::ToHex;
use md5::Context as Md5;
use regex::Regex;

View file

@ -17,7 +17,7 @@ path = "src/mkdir.rs"
[dependencies]
getopts = "0.2.18"
libc = "0.2.42"
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["mode"] }
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["fs", "mode"] }
uucore_procs = { version="0.0.3", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
[[bin]]

View file

@ -6,7 +6,6 @@
// * file that was distributed with this source code.
extern crate getopts;
extern crate libc;
#[macro_use]
extern crate uucore;
@ -124,7 +123,7 @@ fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> i32 {
#[cfg(any(unix, target_os = "redox"))]
fn chmod(path: &Path, mode: u16) -> i32 {
use fs::{set_permissions, Permissions};
use std::fs::{set_permissions, Permissions};
use std::os::unix::fs::PermissionsExt;
let mode = Permissions::from_mode(u32::from(mode));

View file

@ -2,17 +2,17 @@ extern crate getopts;
extern crate regex;
// parse_style parses a style string into a NumberingStyle.
fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
fn parse_style(chars: &[char]) -> Result<crate::NumberingStyle, String> {
if chars.len() == 1 && chars[0] == 'a' {
Ok(::NumberingStyle::NumberForAll)
Ok(crate::NumberingStyle::NumberForAll)
} else if chars.len() == 1 && chars[0] == 't' {
Ok(::NumberingStyle::NumberForNonEmpty)
Ok(crate::NumberingStyle::NumberForNonEmpty)
} else if chars.len() == 1 && chars[0] == 'n' {
Ok(::NumberingStyle::NumberForNone)
Ok(crate::NumberingStyle::NumberForNone)
} else if chars.len() > 1 && chars[0] == 'p' {
let s: String = chars[1..].iter().cloned().collect();
match regex::Regex::new(&s) {
Ok(re) => Ok(::NumberingStyle::NumberForRegularExpression(re)),
Ok(re) => Ok(crate::NumberingStyle::NumberForRegularExpression(re)),
Err(_) => Err(String::from("Illegal regular expression")),
}
} else {
@ -22,7 +22,7 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> {
// parse_options loads the options into the settings, returning an array of
// error messages.
pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<String> {
pub fn parse_options(settings: &mut crate::Settings, opts: &getopts::Matches) -> Vec<String> {
// This vector holds error messages encountered.
let mut errs: Vec<String> = vec![];
settings.renumber = !opts.opt_present("p");
@ -36,13 +36,13 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec<
None => {}
Some(val) => match val.as_ref() {
"ln" => {
settings.number_format = ::NumberFormat::Left;
settings.number_format = crate::NumberFormat::Left;
}
"rn" => {
settings.number_format = ::NumberFormat::Right;
settings.number_format = crate::NumberFormat::Right;
}
"rz" => {
settings.number_format = ::NumberFormat::RightZero;
settings.number_format = crate::NumberFormat::RightZero;
}
_ => {
errs.push(String::from("Illegal value for -n"));

View file

@ -16,7 +16,7 @@ impl Clone for FormatWriter {
impl PartialEq for FormatWriter {
fn eq(&self, other: &FormatWriter) -> bool {
use formatteriteminfo::FormatWriter::*;
use crate::formatteriteminfo::FormatWriter::*;
match (self, other) {
(&IntWriter(ref a), &IntWriter(ref b)) => a == b,

View file

@ -1,9 +1,10 @@
use byteorder_io::ByteOrder;
use half::f16;
use multifilereader::HasError;
use peekreader::PeekRead;
use std::io;
use crate::byteorder_io::ByteOrder;
use crate::multifilereader::HasError;
use crate::peekreader::PeekRead;
/// Processes an input and provides access to the data read in various formats
///
/// Currently only useful if the input implements `PeekRead`.

View file

@ -29,20 +29,21 @@ mod prn_char;
mod prn_float;
mod prn_int;
use byteorder_io::*;
use formatteriteminfo::*;
use inputdecoder::{InputDecoder, MemoryDecoder};
use inputoffset::{InputOffset, Radix};
use multifilereader::*;
use output_info::OutputInfo;
use parse_formats::{parse_format_flags, ParsedFormatterItemInfo};
use parse_inputs::{parse_inputs, CommandLineInputs};
use parse_nrofbytes::parse_number_of_bytes;
use partialreader::*;
use peekreader::*;
use prn_char::format_ascii_dump;
use std::cmp;
use crate::byteorder_io::*;
use crate::formatteriteminfo::*;
use crate::inputdecoder::{InputDecoder, MemoryDecoder};
use crate::inputoffset::{InputOffset, Radix};
use crate::multifilereader::*;
use crate::output_info::OutputInfo;
use crate::parse_formats::{parse_format_flags, ParsedFormatterItemInfo};
use crate::parse_inputs::{parse_inputs, CommandLineInputs};
use crate::parse_nrofbytes::parse_number_of_bytes;
use crate::partialreader::*;
use crate::peekreader::*;
use crate::prn_char::format_ascii_dump;
static VERSION: &str = env!("CARGO_PKG_VERSION");
const PEEK_BUFFER_SIZE: usize = 4; // utf-8 can be 4 bytes

View file

@ -1,8 +1,9 @@
use formatteriteminfo::FormatterItemInfo;
use parse_formats::ParsedFormatterItemInfo;
use std::cmp;
use std::slice::Iter;
use crate::formatteriteminfo::FormatterItemInfo;
use crate::parse_formats::ParsedFormatterItemInfo;
/// Size in bytes of the max datatype. ie set to 16 for 128-bit numbers.
const MAX_BYTES_PER_UNIT: usize = 8;

View file

@ -1,7 +1,7 @@
use formatteriteminfo::FormatterItemInfo;
use prn_char::*;
use prn_float::*;
use prn_int::*;
use crate::formatteriteminfo::FormatterItemInfo;
use crate::prn_char::*;
use crate::prn_float::*;
use crate::prn_int::*;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct ParsedFormatterItemInfo {

View file

@ -1,8 +1,9 @@
use multifilereader::HasError;
use std::cmp;
use std::io;
use std::io::Read;
use crate::multifilereader::HasError;
/// When a large number of bytes must be skipped, it will be read into a
/// dynamically allocated buffer. The buffer will be limited to this size.
const MAX_SKIP_BUFFER: usize = 64 * 1024;

View file

@ -1,9 +1,10 @@
//! Contains the trait `PeekRead` and type `PeekReader` implementing it.
use multifilereader::HasError;
use std::io;
use std::io::{Read, Write};
use crate::multifilereader::HasError;
/// A trait which supplies a function to peek into a stream without
/// actually reading it.
///

View file

@ -1,6 +1,7 @@
use formatteriteminfo::*;
use std::str::from_utf8;
use crate::formatteriteminfo::*;
pub static FORMAT_ITEM_A: FormatterItemInfo = FormatterItemInfo {
byte_size: 1,
print_width: 4,

View file

@ -1,9 +1,10 @@
use formatteriteminfo::*;
use half::f16;
use std::f32;
use std::f64;
use std::num::FpCategory;
use crate::formatteriteminfo::*;
pub static FORMAT_ITEM_F16: FormatterItemInfo = FormatterItemInfo {
byte_size: 2,
print_width: 10,

View file

@ -1,4 +1,4 @@
use formatteriteminfo::*;
use crate::formatteriteminfo::*;
/// format string to print octal using `int_writer_unsigned`
macro_rules! OCT {

View file

@ -5,13 +5,14 @@
//! 2. feeds remaining arguments into function
//! that prints tokens.
use cli;
use itertools::put_back_n;
use std::iter::Peekable;
use std::slice::Iter;
use tokenize::sub::Sub;
use tokenize::token::{Token, Tokenizer};
use tokenize::unescaped_text::UnescapedText;
use crate::cli;
use crate::tokenize::sub::Sub;
use crate::tokenize::token::{Token, Tokenizer};
use crate::tokenize::unescaped_text::UnescapedText;
pub struct Memo {
tokens: Vec<Box<dyn Token>>,

View file

@ -1,11 +1,13 @@
//! Primitives used by num_format and sub_modules.
//! never dealt with above (e.g. Sub Tokenizer never uses these)
use super::format_field::FormatField;
use cli;
use itertools::{put_back_n, PutBackN};
use std::str::Chars;
use super::format_field::FormatField;
use crate::cli;
// contains the rough ingredients to final
// output for a number, organized together
// to allow for easy generalization of output manipulation

View file

@ -1,5 +1,8 @@
//! handles creating printed output for numeric substitutions
use std::env;
use std::vec::Vec;
use super::format_field::{FieldType, FormatField};
use super::formatter::{Base, FormatPrimitive, Formatter, InPrefix};
use super::formatters::cninetyninehexfloatf::CninetyNineHexFloatf;
@ -7,9 +10,8 @@ use super::formatters::decf::Decf;
use super::formatters::floatf::Floatf;
use super::formatters::intf::Intf;
use super::formatters::scif::Scif;
use cli;
use std::env;
use std::vec::Vec;
use crate::cli;
pub fn warn_expected_numeric(pf_arg: &str) {
// important: keep println here not print

View file

@ -3,11 +3,6 @@
//! it is created by Sub's implementation of the Tokenizer trait
//! Subs which have numeric field chars make use of the num_format
//! submodule
use super::num_format::format_field::{FieldType, FormatField};
use super::num_format::num_format;
use super::token;
use super::unescaped_text::UnescapedText;
use cli;
use itertools::{put_back_n, PutBackN};
use std::iter::Peekable;
use std::process::exit;
@ -15,6 +10,12 @@ use std::slice::Iter;
use std::str::Chars;
// use std::collections::HashSet;
use super::num_format::format_field::{FieldType, FormatField};
use super::num_format::num_format;
use super::token;
use super::unescaped_text::UnescapedText;
use crate::cli;
fn err_conv(sofar: &str) {
cli::err_msg(&format!("%{}: invalid conversion specification", sofar));
exit(cli::EXIT_ERR);

View file

@ -3,8 +3,6 @@
//! and escaped character literals (of allowed escapes),
//! into an unescaped text byte array
use super::token;
use cli;
use itertools::PutBackN;
use std::char::from_u32;
use std::iter::Peekable;
@ -12,6 +10,10 @@ use std::process::exit;
use std::slice::Iter;
use std::str::Chars;
use super::token;
use crate::cli;
pub struct UnescapedText(Vec<u8>);
impl UnescapedText {
fn new() -> UnescapedText {

View file

@ -17,7 +17,7 @@ path = "src/stat.rs"
[dependencies]
getopts = "0.2.18"
time = "0.1.40"
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries"] }
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["entries", "libc"] }
uucore_procs = { version="0.0.3", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
[[bin]]

View file

@ -6,16 +6,15 @@
// that was distributed with this source code.
//
pub use super::uucore::libc;
extern crate time;
use self::time::Timespec;
pub use libc::{
use std::time::UNIX_EPOCH;
pub use uucore::libc::{
c_int, mode_t, strerror, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFREG,
S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR,
S_IXGRP, S_IXOTH, S_IXUSR,
};
use std::time::UNIX_EPOCH;
pub trait BirthTime {
fn pretty_birth(&self) -> String;
@ -153,7 +152,7 @@ use std::path::Path;
target_os = "android",
target_os = "freebsd"
))]
use libc::statfs as Sstatfs;
use uucore::libc::statfs as Sstatfs;
#[cfg(any(
target_os = "openbsd",
target_os = "netbsd",
@ -161,7 +160,7 @@ use libc::statfs as Sstatfs;
target_os = "bitrig",
target_os = "dragonfly"
))]
use libc::statvfs as Sstatfs;
use uucore::libc::statvfs as Sstatfs;
#[cfg(any(
target_os = "linux",
@ -169,7 +168,7 @@ use libc::statvfs as Sstatfs;
target_os = "android",
target_os = "freebsd"
))]
use libc::statfs as statfs_fn;
use uucore::libc::statfs as statfs_fn;
#[cfg(any(
target_os = "openbsd",
target_os = "netbsd",
@ -177,7 +176,7 @@ use libc::statfs as statfs_fn;
target_os = "bitrig",
target_os = "dragonfly"
))]
use libc::statvfs as statfs_fn;
use uucore::libc::statvfs as statfs_fn;
pub trait FsMeta {
fn fs_type(&self) -> i64;

View file

@ -10,7 +10,7 @@ use getopts::Options;
#[macro_use]
mod fsext;
pub use fsext::*;
pub use crate::fsext::*;
#[macro_use]
extern crate uucore;

View file

@ -15,14 +15,14 @@ extern crate getopts;
#[macro_use]
extern crate uucore;
mod expand;
use bit_set::BitSet;
use fnv::FnvHashMap;
use getopts::Options;
use std::io::{stdin, stdout, BufRead, BufWriter, Write};
use expand::ExpandSet;
mod expand;
use crate::expand::ExpandSet;
static NAME: &str = "tr";
static VERSION: &str = env!("CARGO_PKG_VERSION");

View file

@ -19,7 +19,7 @@ getopts = "0.2.18"
time = "0.1.40"
chrono = "0.4"
clap = "2.32"
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["utmpx"] }
uucore = { version="0.0.3", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary", features=["libc", "utmpx"] }
uucore_procs = { version="0.0.3", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
[[bin]]

View file

@ -28,11 +28,11 @@ in the run queue over the last 1, 5 and 15 minutes.";
static OPT_SINCE: &str = "SINCE";
#[cfg(unix)]
use libc::getloadavg;
use uucore::libc::getloadavg;
#[cfg(windows)]
extern "C" {
fn GetTickCount() -> libc::uint32_t;
fn GetTickCount() -> uucore::libc::uint32_t;
}
fn get_usage() -> String {
@ -78,7 +78,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
#[cfg(unix)]
fn print_loadavg() {
use libc::c_double;
use uucore::libc::c_double;
let mut avg: [c_double; 3] = [0.0; 3];
let loads: i32 = unsafe { getloadavg(avg.as_mut_ptr(), 3) };