Skip to content

Commit 3ca1b70

Browse files
authored
Rollup merge of rust-lang#58111 - Centril:libterm-2018, r=oli-obk
libterm => 2018 Transitions `libterm` to Rust 2018; cc rust-lang#58099 r? @oli-obk
2 parents 3dbb31e + 0ce5129 commit 3ca1b70

File tree

6 files changed

+42
-39
lines changed

6 files changed

+42
-39
lines changed

Diff for: src/libterm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "term"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "term"

Diff for: src/libterm/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@
3535
test(attr(deny(warnings))))]
3636
#![deny(missing_docs)]
3737

38+
#![deny(rust_2018_idioms)]
39+
3840
#![cfg_attr(windows, feature(libc))]
3941
// Handle rustfmt skips
4042
#![feature(custom_attribute)]
41-
#![feature(nll)]
4243
#![allow(unused_attributes)]
4344

4445
use std::io::prelude::*;
46+
use std::io::{self, Stdout, Stderr};
4547

4648
pub use terminfo::TerminfoTerminal;
4749
#[cfg(windows)]
4850
pub use win::WinConsole;
4951

50-
use std::io::{self, Stdout, Stderr};
51-
5252
pub mod terminfo;
5353

5454
#[cfg(windows)]

Diff for: src/libterm/terminfo/mod.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ use std::env;
55
use std::error;
66
use std::fmt;
77
use std::fs::File;
8-
use std::io::prelude::*;
9-
use std::io;
10-
use std::io::BufReader;
8+
use std::io::{self, prelude::*, BufReader};
119
use std::path::Path;
1210

13-
use Attr;
14-
use color;
15-
use Terminal;
16-
use self::searcher::get_dbpath_for_term;
17-
use self::parser::compiled::{parse, msys_terminfo};
18-
use self::parm::{expand, Variables, Param};
11+
use crate::Attr;
12+
use crate::color;
13+
use crate::Terminal;
1914

15+
use searcher::get_dbpath_for_term;
16+
use parser::compiled::{parse, msys_terminfo};
17+
use parm::{expand, Variables, Param};
2018

2119
/// A parsed terminfo database entry.
2220
#[derive(Debug)]
@@ -49,7 +47,7 @@ impl error::Error for Error {
4947
}
5048

5149
fn cause(&self) -> Option<&dyn error::Error> {
52-
use self::Error::*;
50+
use Error::*;
5351
match *self {
5452
IoError(ref e) => Some(e),
5553
_ => None,
@@ -58,8 +56,8 @@ impl error::Error for Error {
5856
}
5957

6058
impl fmt::Display for Error {
61-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
62-
use self::Error::*;
59+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60+
use Error::*;
6361
match *self {
6462
TermUnset => Ok(()),
6563
MalformedTerminfo(ref e) => e.fmt(f),

Diff for: src/libterm/terminfo/parm.rs

+18-14
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,27 @@ pub enum Param {
4040
/// Container for static and dynamic variable arrays
4141
pub struct Variables {
4242
/// Static variables A-Z
43-
sta: [Param; 26],
43+
sta_va: [Param; 26],
4444
/// Dynamic variables a-z
45-
dyn: [Param; 26],
45+
dyn_va: [Param; 26],
4646
}
4747

4848
impl Variables {
4949
/// Return a new zero-initialized Variables
5050
pub fn new() -> Variables {
5151
Variables {
52-
sta: [Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
53-
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
54-
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
55-
Number(0), Number(0), Number(0), Number(0), Number(0)],
56-
dyn: [Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
57-
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
58-
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
59-
Number(0), Number(0), Number(0), Number(0), Number(0)],
52+
sta_va: [
53+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
54+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
55+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
56+
Number(0), Number(0), Number(0), Number(0), Number(0)
57+
],
58+
dyn_va: [
59+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
60+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
61+
Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0),
62+
Number(0), Number(0), Number(0), Number(0), Number(0)
63+
],
6064
}
6165
}
6266
}
@@ -249,14 +253,14 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
249253
if cur >= 'A' && cur <= 'Z' {
250254
if let Some(arg) = stack.pop() {
251255
let idx = (cur as u8) - b'A';
252-
vars.sta[idx as usize] = arg;
256+
vars.sta_va[idx as usize] = arg;
253257
} else {
254258
return Err("stack is empty".to_string());
255259
}
256260
} else if cur >= 'a' && cur <= 'z' {
257261
if let Some(arg) = stack.pop() {
258262
let idx = (cur as u8) - b'a';
259-
vars.dyn[idx as usize] = arg;
263+
vars.dyn_va[idx as usize] = arg;
260264
} else {
261265
return Err("stack is empty".to_string());
262266
}
@@ -267,10 +271,10 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result<Vec<
267271
GetVar => {
268272
if cur >= 'A' && cur <= 'Z' {
269273
let idx = (cur as u8) - b'A';
270-
stack.push(vars.sta[idx as usize].clone());
274+
stack.push(vars.sta_va[idx as usize].clone());
271275
} else if cur >= 'a' && cur <= 'z' {
272276
let idx = (cur as u8) - b'a';
273-
stack.push(vars.dyn[idx as usize].clone());
277+
stack.push(vars.dyn_va[idx as usize].clone());
274278
} else {
275279
return Err("bad variable name in %g".to_string());
276280
}

Diff for: src/libterm/terminfo/parser/compiled.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
//! ncurses-compatible compiled terminfo format parsing (term(5))
44
55
use std::collections::HashMap;
6-
use std::io::prelude::*;
76
use std::io;
7+
use std::io::prelude::*;
88
use super::super::TermInfo;
99

1010
// These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable.
1111

1212
#[rustfmt_skip]
13-
pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin",
13+
pub static boolfnames: &[&str] = &["auto_left_margin", "auto_right_margin",
1414
"no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type",
1515
"hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above",
1616
"memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok",
@@ -23,13 +23,13 @@ pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_righ
2323
"return_does_clr_eol"];
2424

2525
#[rustfmt_skip]
26-
pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
26+
pub static boolnames: &[&str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
2727
"gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon",
2828
"nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy",
2929
"xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
3030

3131
#[rustfmt_skip]
32-
pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines",
32+
pub static numfnames: &[&str] = &[ "columns", "init_tabs", "lines",
3333
"lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal",
3434
"width_status_line", "num_labels", "label_height", "label_width", "max_attributes",
3535
"maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity",
@@ -40,13 +40,13 @@ pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines
4040
"new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"];
4141

4242
#[rustfmt_skip]
43-
pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb",
43+
pub static numnames: &[&str] = &[ "cols", "it", "lines", "lm", "xmc", "pb",
4444
"vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv",
4545
"spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs",
4646
"btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"];
4747

4848
#[rustfmt_skip]
49-
pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return",
49+
pub static stringfnames: &[&str] = &[ "back_tab", "bell", "carriage_return",
5050
"change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos",
5151
"column_address", "command_character", "cursor_address", "cursor_down", "cursor_home",
5252
"cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right",
@@ -120,7 +120,7 @@ pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carria
120120
"acs_plus", "memory_lock", "memory_unlock", "box_chars_1"];
121121

122122
#[rustfmt_skip]
123-
pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
123+
pub static stringnames: &[&str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
124124
"_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1",
125125
"ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc",
126126
"dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc",

Diff for: src/libterm/win.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ extern crate libc;
77
use std::io;
88
use std::io::prelude::*;
99

10-
use Attr;
11-
use color;
12-
use Terminal;
10+
use crate::Attr;
11+
use crate::color;
12+
use crate::Terminal;
1313

1414
/// A Terminal implementation which uses the Win32 Console API.
1515
pub struct WinConsole<T> {

0 commit comments

Comments
 (0)