commit
a5c2d0fffa
20 changed files with 50 additions and 73 deletions
|
@ -8,7 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::iter;
|
||||
use core::num::dec2flt::parse::{Decimal, parse_decimal};
|
||||
use core::num::dec2flt::parse::ParseResult::{Valid, Invalid};
|
||||
|
||||
|
@ -46,7 +45,7 @@ fn valid() {
|
|||
assert_eq!(parse_decimal("1.e300"), Valid(Decimal::new(b"1", b"", 300)));
|
||||
assert_eq!(parse_decimal(".1e300"), Valid(Decimal::new(b"", b"1", 300)));
|
||||
assert_eq!(parse_decimal("101e-33"), Valid(Decimal::new(b"101", b"", -33)));
|
||||
let zeros: String = iter::repeat('0').take(25).collect();
|
||||
let zeros = "0".repeat(25);
|
||||
let s = format!("1.5e{}", zeros);
|
||||
assert_eq!(parse_decimal(&s), Valid(Decimal::new(b"1", b"5", 0)));
|
||||
}
|
||||
|
|
|
@ -334,11 +334,8 @@ macro_rules! define_dep_nodes {
|
|||
pub fn extract_def_id(&self, tcx: TyCtxt) -> Option<DefId> {
|
||||
if self.kind.can_reconstruct_query_key() {
|
||||
let def_path_hash = DefPathHash(self.hash);
|
||||
if let Some(ref def_path_map) = tcx.def_path_hash_to_def_id.as_ref() {
|
||||
def_path_map.get(&def_path_hash).cloned()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
tcx.def_path_hash_to_def_id.as_ref()?
|
||||
.get(&def_path_hash).cloned()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -489,7 +489,12 @@ impl DepGraph {
|
|||
}
|
||||
|
||||
pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
|
||||
self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned())
|
||||
self.data
|
||||
.as_ref()?
|
||||
.dep_node_debug
|
||||
.borrow()
|
||||
.get(&dep_node)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn edge_deduplication_data(&self) -> (u64, u64) {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
|
|||
let actual_len = self.len();
|
||||
EnumerateAndAdjust {
|
||||
enumerate: self.enumerate(),
|
||||
gap_pos: if let Some(gap_pos) = gap_pos { gap_pos } else { expected_len },
|
||||
gap_pos: gap_pos.unwrap_or(expected_len),
|
||||
gap_len: expected_len - actual_len,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -805,7 +805,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
// Foo<_, Qux>
|
||||
// ^ elided type as this type argument was the same in both sides
|
||||
let type_arguments = sub1.types().zip(sub2.types());
|
||||
let regions_len = sub1.regions().collect::<Vec<_>>().len();
|
||||
let regions_len = sub1.regions().count();
|
||||
for (i, (ta1, ta2)) in type_arguments.take(len).enumerate() {
|
||||
let i = i + regions_len;
|
||||
if ta1 == ta2 {
|
||||
|
|
|
@ -17,7 +17,6 @@ use std::collections::HashMap;
|
|||
use std::ffi::CString;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, BuildHasher};
|
||||
use std::iter::repeat;
|
||||
use std::panic;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
@ -219,7 +218,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) {
|
|||
None => "".to_owned(),
|
||||
};
|
||||
println!("{}time: {}{}\t{}",
|
||||
repeat(" ").take(indentation).collect::<String>(),
|
||||
" ".repeat(indentation),
|
||||
duration_to_secs_str(dur),
|
||||
mem_string,
|
||||
what);
|
||||
|
|
|
@ -206,9 +206,8 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
})
|
||||
.collect();
|
||||
|
||||
if let Some(_) = *tcx.sess.entry_fn.borrow() {
|
||||
let symbol_name = "main".to_string();
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
|
||||
if tcx.sess.entry_fn.borrow().is_some() {
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new("main"));
|
||||
|
||||
symbols.push((exported_symbol, SymbolExportLevel::C));
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ use std::error::Error;
|
|||
use std::ffi::OsString;
|
||||
use std::fmt::{self, Display};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::iter::repeat;
|
||||
use std::mem;
|
||||
use std::panic;
|
||||
use std::path::{PathBuf, Path};
|
||||
|
@ -1227,7 +1226,7 @@ Available lint options:
|
|||
fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
|
||||
-> Vec<(&'static str, Vec<lint::LintId>)> {
|
||||
let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect();
|
||||
lints.sort_by_key(|ref l| l.0);
|
||||
lints.sort_by_key(|l| l.0);
|
||||
lints
|
||||
}
|
||||
|
||||
|
@ -1251,9 +1250,7 @@ Available lint options:
|
|||
.max()
|
||||
.unwrap_or(0);
|
||||
let padded = |x: &str| {
|
||||
let mut s = repeat(" ")
|
||||
.take(max_name_len - x.chars().count())
|
||||
.collect::<String>();
|
||||
let mut s = " ".repeat(max_name_len - x.chars().count());
|
||||
s.push_str(x);
|
||||
s
|
||||
};
|
||||
|
@ -1285,9 +1282,7 @@ Available lint options:
|
|||
.unwrap_or(0));
|
||||
|
||||
let padded = |x: &str| {
|
||||
let mut s = repeat(" ")
|
||||
.take(max_name_len - x.chars().count())
|
||||
.collect::<String>();
|
||||
let mut s = " ".repeat(max_name_len - x.chars().count());
|
||||
s.push_str(x);
|
||||
s
|
||||
};
|
||||
|
|
|
@ -208,7 +208,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
|
|||
for (ref cons, ref qm) in counts.iter() {
|
||||
data.push((cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone()));
|
||||
};
|
||||
data.sort_by_key(|&k| Reverse(k.3));
|
||||
data.sort_by_key(|k| Reverse(k.3));
|
||||
for (cons, count, dur_total, dur_self) in data {
|
||||
write!(count_file, "{}, {}, {}, {}\n",
|
||||
cons, count,
|
||||
|
|
|
@ -528,9 +528,7 @@ impl EmitterWriter {
|
|||
|
||||
// If there are no annotations or the only annotations on this line are
|
||||
// MultilineLine, then there's only code being shown, stop processing.
|
||||
if line.annotations.is_empty() || line.annotations.iter()
|
||||
.filter(|a| !a.is_line()).collect::<Vec<_>>().len() == 0
|
||||
{
|
||||
if line.annotations.iter().all(|a| a.is_line()) {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
|
@ -901,9 +899,7 @@ impl EmitterWriter {
|
|||
// | | length of label
|
||||
// | magic `3`
|
||||
// `max_line_num_len`
|
||||
let padding = (0..padding + label.len() + 5)
|
||||
.map(|_| " ")
|
||||
.collect::<String>();
|
||||
let padding = " ".repeat(padding + label.len() + 5);
|
||||
|
||||
/// Return whether `style`, or the override if present and the style is `NoStyle`.
|
||||
fn style_or_override(style: Style, override_style: Option<Style>) -> Style {
|
||||
|
|
|
@ -608,9 +608,8 @@ impl Handler {
|
|||
if can_show_explain && are_there_diagnostics {
|
||||
let mut error_codes =
|
||||
self.emitted_diagnostic_codes.borrow()
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter_map(|x| match x {
|
||||
.iter()
|
||||
.filter_map(|x| match *x {
|
||||
DiagnosticId::Error(ref s) => Some(s.clone()),
|
||||
_ => None,
|
||||
})
|
||||
|
|
|
@ -83,12 +83,10 @@ impl NonCamelCaseTypes {
|
|||
} else {
|
||||
c.to_lowercase().collect()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.concat()
|
||||
.collect::<String>()
|
||||
})
|
||||
.filter(|x| !x.is_empty())
|
||||
.collect::<Vec<_>>()
|
||||
.iter().fold((String::new(), None), |(acc, prev): (String, Option<&String>), next| {
|
||||
.fold((String::new(), None), |(acc, prev): (String, Option<String>), next| {
|
||||
// separate two components with an underscore if their boundary cannot
|
||||
// be distinguished using a uppercase/lowercase case distinction
|
||||
let join = if let Some(prev) = prev {
|
||||
|
@ -96,7 +94,7 @@ impl NonCamelCaseTypes {
|
|||
let f = next.chars().next().unwrap();
|
||||
!char_has_case(l) && !char_has_case(f)
|
||||
} else { false };
|
||||
(acc + if join { "_" } else { "" } + next, Some(next))
|
||||
(acc + if join { "_" } else { "" } + &next, Some(next))
|
||||
}).0
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ use arena::TypedArena;
|
|||
|
||||
use std::cmp::{self, Ordering};
|
||||
use std::fmt;
|
||||
use std::iter::{FromIterator, IntoIterator, repeat};
|
||||
use std::iter::{FromIterator, IntoIterator};
|
||||
|
||||
pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pattern<'tcx>)
|
||||
-> &'a Pattern<'tcx>
|
||||
|
@ -115,7 +115,7 @@ impl<'a, 'tcx> fmt::Debug for Matrix<'a, 'tcx> {
|
|||
}).collect();
|
||||
|
||||
let total_width = column_widths.iter().cloned().sum::<usize>() + column_count * 3 + 1;
|
||||
let br = repeat('+').take(total_width).collect::<String>();
|
||||
let br = "+".repeat(total_width);
|
||||
write!(f, "{}\n", br)?;
|
||||
for row in pretty_printed_matrix {
|
||||
write!(f, "+")?;
|
||||
|
|
|
@ -29,13 +29,13 @@ pub fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mon
|
|||
(mono_item, mono_item.symbol_name(tcx))
|
||||
}).collect();
|
||||
|
||||
(&mut symbols[..]).sort_by_key(|&sym| sym.1);
|
||||
symbols.sort_by_key(|sym| sym.1);
|
||||
|
||||
for pair in (&symbols[..]).windows(2) {
|
||||
for pair in symbols.windows(2) {
|
||||
let sym1 = &pair[0].1;
|
||||
let sym2 = &pair[1].1;
|
||||
|
||||
if *sym1 == *sym2 {
|
||||
if sym1 == sym2 {
|
||||
let mono_item1 = pair[0].0;
|
||||
let mono_item2 = pair[1].0;
|
||||
|
||||
|
@ -51,9 +51,7 @@ pub fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mon
|
|||
span2
|
||||
})
|
||||
}
|
||||
(Some(span), None) |
|
||||
(None, Some(span)) => Some(span),
|
||||
_ => None
|
||||
(span1, span2) => span1.or(span2),
|
||||
};
|
||||
|
||||
let error_message = format!("symbol `{}` is already defined", sym1);
|
||||
|
|
|
@ -269,7 +269,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
|||
err
|
||||
}
|
||||
ResolutionError::VariableNotBoundInPattern(binding_error) => {
|
||||
let target_sp = binding_error.target.iter().map(|x| *x).collect::<Vec<_>>();
|
||||
let target_sp = binding_error.target.iter().cloned().collect::<Vec<_>>();
|
||||
let msp = MultiSpan::from_spans(target_sp.clone());
|
||||
let msg = format!("variable `{}` is not bound in all patterns", binding_error.name);
|
||||
let mut err = resolver.session.struct_span_err_with_code(
|
||||
|
@ -280,7 +280,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
|
|||
for sp in target_sp {
|
||||
err.span_label(sp, format!("pattern doesn't bind `{}`", binding_error.name));
|
||||
}
|
||||
let origin_sp = binding_error.origin.iter().map(|x| *x).collect::<Vec<_>>();
|
||||
let origin_sp = binding_error.origin.iter().cloned();
|
||||
for sp in origin_sp {
|
||||
err.span_label(sp, "variable not in all patterns");
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
//! them in the future to instead emit any format desired.
|
||||
|
||||
use std::fmt;
|
||||
use std::iter::repeat;
|
||||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
@ -235,10 +234,9 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
|||
|
||||
if !f.alternate() {
|
||||
clause.push_str("</span>");
|
||||
let padding = repeat(" ").take(indent + 4).collect::<String>();
|
||||
let padding = " ".repeat(indent + 4);
|
||||
clause = clause.replace("<br>", &format!("<br>{}", padding));
|
||||
clause.insert_str(0, &repeat(" ").take(indent.saturating_sub(1))
|
||||
.collect::<String>());
|
||||
clause.insert_str(0, &" ".repeat(indent.saturating_sub(1)));
|
||||
if !end_newline {
|
||||
clause.insert_str(0, "<br>");
|
||||
}
|
||||
|
@ -409,13 +407,13 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
|||
let loc = CURRENT_LOCATION_KEY.with(|l| l.borrow().clone());
|
||||
let (fqp, shortty, mut url) = match cache.paths.get(&did) {
|
||||
Some(&(ref fqp, shortty)) => {
|
||||
(fqp, shortty, repeat("../").take(loc.len()).collect())
|
||||
(fqp, shortty, "../".repeat(loc.len()))
|
||||
}
|
||||
None => {
|
||||
let &(ref fqp, shortty) = cache.external_paths.get(&did)?;
|
||||
(fqp, shortty, match cache.extern_locations[&did.krate] {
|
||||
(.., render::Remote(ref s)) => s.to_string(),
|
||||
(.., render::Local) => repeat("../").take(loc.len()).collect(),
|
||||
(.., render::Local) => "../".repeat(loc.len()),
|
||||
(.., render::Unknown) => return None,
|
||||
})
|
||||
}
|
||||
|
@ -481,7 +479,7 @@ fn primitive_link(f: &mut fmt::Formatter,
|
|||
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
|
||||
let len = if len == 0 {0} else {len - 1};
|
||||
write!(f, "<a class=\"primitive\" href=\"{}primitive.{}.html\">",
|
||||
repeat("../").take(len).collect::<String>(),
|
||||
"../".repeat(len),
|
||||
prim.to_url_str())?;
|
||||
needs_termination = true;
|
||||
}
|
||||
|
@ -492,7 +490,7 @@ fn primitive_link(f: &mut fmt::Formatter,
|
|||
}
|
||||
(ref cname, _, render::Local) => {
|
||||
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
|
||||
Some((cname, repeat("../").take(len).collect::<String>()))
|
||||
Some((cname, "../".repeat(len)))
|
||||
}
|
||||
(.., render::Unknown) => None,
|
||||
};
|
||||
|
@ -907,15 +905,15 @@ impl<'a> fmt::Display for Method<'a> {
|
|||
format!("{}", decl.output)
|
||||
};
|
||||
|
||||
let pad = repeat(" ").take(name_len).collect::<String>();
|
||||
let pad = " ".repeat(name_len);
|
||||
let plain = format!("{pad}({args}){arrow}",
|
||||
pad = pad,
|
||||
args = args_plain,
|
||||
arrow = arrow_plain);
|
||||
|
||||
let output = if plain.len() > 80 {
|
||||
let full_pad = format!("<br>{}", repeat(" ").take(indent + 4).collect::<String>());
|
||||
let close_pad = format!("<br>{}", repeat(" ").take(indent).collect::<String>());
|
||||
let full_pad = format!("<br>{}", " ".repeat(indent + 4));
|
||||
let close_pad = format!("<br>{}", " ".repeat(indent));
|
||||
format!("({args}{close}){arrow}",
|
||||
args = args.replace("<br>", &full_pad),
|
||||
close = close_pad,
|
||||
|
|
|
@ -46,7 +46,6 @@ use std::ffi::OsStr;
|
|||
use std::fs::{self, File, OpenOptions};
|
||||
use std::io::prelude::*;
|
||||
use std::io::{self, BufWriter, BufReader};
|
||||
use std::iter::repeat;
|
||||
use std::mem;
|
||||
use std::path::{PathBuf, Path, Component};
|
||||
use std::str;
|
||||
|
@ -1712,7 +1711,7 @@ impl Context {
|
|||
/// String representation of how to get back to the root path of the 'doc/'
|
||||
/// folder in terms of a relative URL.
|
||||
fn root_path(&self) -> String {
|
||||
repeat("../").take(self.current.len()).collect::<String>()
|
||||
"../".repeat(self.current.len())
|
||||
}
|
||||
|
||||
/// Recurse in the directory structure and change the "root path" to make
|
||||
|
@ -2113,8 +2112,7 @@ impl<'a> fmt::Display for Item<'a> {
|
|||
let amt = if self.item.is_mod() { cur.len() - 1 } else { cur.len() };
|
||||
for (i, component) in cur.iter().enumerate().take(amt) {
|
||||
write!(fmt, "<a href='{}index.html'>{}</a>::<wbr>",
|
||||
repeat("../").take(cur.len() - i - 1)
|
||||
.collect::<String>(),
|
||||
"../".repeat(cur.len() - i - 1),
|
||||
component)?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
extern crate rand;
|
||||
|
||||
use std::env::*;
|
||||
use std::iter::repeat;
|
||||
use std::ffi::{OsString, OsStr};
|
||||
|
||||
use rand::Rng;
|
||||
|
@ -72,7 +71,7 @@ fn test_var_big() {
|
|||
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||
fn test_env_set_get_huge() {
|
||||
let n = make_rand_name();
|
||||
let s = repeat("x").take(10000).collect::<String>();
|
||||
let s = "x".repeat(10000);
|
||||
set_var(&n, &s);
|
||||
eq(var_os(&n), Some(&s));
|
||||
remove_var(&n);
|
||||
|
|
|
@ -32,7 +32,7 @@ use tokenstream::{self, TokenStream, TokenTree};
|
|||
|
||||
use std::ascii;
|
||||
use std::io::{self, Write, Read};
|
||||
use std::iter::{self, Peekable};
|
||||
use std::iter::Peekable;
|
||||
use std::vec;
|
||||
|
||||
pub enum AnnNode<'a> {
|
||||
|
@ -235,11 +235,11 @@ pub fn token_to_string(tok: &Token) -> String {
|
|||
token::Integer(c) => c.to_string(),
|
||||
token::Str_(s) => format!("\"{}\"", s),
|
||||
token::StrRaw(s, n) => format!("r{delim}\"{string}\"{delim}",
|
||||
delim=repeat("#", n as usize),
|
||||
delim="#".repeat(n as usize),
|
||||
string=s),
|
||||
token::ByteStr(v) => format!("b\"{}\"", v),
|
||||
token::ByteStrRaw(s, n) => format!("br{delim}\"{string}\"{delim}",
|
||||
delim=repeat("#", n as usize),
|
||||
delim="#".repeat(n as usize),
|
||||
string=s),
|
||||
};
|
||||
|
||||
|
@ -661,7 +661,7 @@ pub trait PrintState<'a> {
|
|||
}
|
||||
ast::StrStyle::Raw(n) => {
|
||||
(format!("r{delim}\"{string}\"{delim}",
|
||||
delim=repeat("#", n as usize),
|
||||
delim="#".repeat(n as usize),
|
||||
string=st))
|
||||
}
|
||||
};
|
||||
|
@ -3180,8 +3180,6 @@ impl<'a> State<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn repeat(s: &str, n: usize) -> String { iter::repeat(s).take(n).collect() }
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -64,7 +64,6 @@ use std::fmt;
|
|||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::io;
|
||||
use std::iter::repeat;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Termination;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
@ -143,7 +142,7 @@ impl TestDesc {
|
|||
fn padded_name(&self, column_count: usize, align: NamePadding) -> String {
|
||||
let mut name = String::from(self.name.as_slice());
|
||||
let fill = column_count.saturating_sub(name.len());
|
||||
let pad = repeat(" ").take(fill).collect::<String>();
|
||||
let pad = " ".repeat(fill);
|
||||
match align {
|
||||
PadNone => name,
|
||||
PadOnRight => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue