Skip to content

Commit

Permalink
Auto merge of #56818 - kennytm:rollup-2, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests (first batch)

Successful merges:

 - #56562 (Update libc version required by rustc)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56637 (rustdoc: Fix local reexports of proc macros)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56709 (Remove unneeded extra chars to reduce search-index size)
 - #56744 (specialize: remove Boxes used by Children::insert)
 - #56748 (Update panic message to be clearer about env-vars)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)

r? @ghost
  • Loading branch information
bors committed Dec 14, 2018
2 parents 7d03617 + e065de2 commit 1897657
Show file tree
Hide file tree
Showing 38 changed files with 335 additions and 100 deletions.
15 changes: 13 additions & 2 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# except according to those terms.

import gdb
import re
import sys
import debugger_pretty_printers_common as rustpp

Expand All @@ -20,6 +21,16 @@

rust_enabled = 'set language rust' in gdb.execute('complete set language ru', to_string = True)

# The btree pretty-printers fail in a confusing way unless
# https://sourceware.org/bugzilla/show_bug.cgi?id=21763 is fixed.
# This fix went in 8.1, so check for that.
# See https://github.com/rust-lang/rust/issues/56730
gdb_81 = False
_match = re.match('([0-9]+)\\.([0-9]+)', gdb.VERSION)
if _match:
if int(_match.group(1)) > 8 or (int(_match.group(1)) == 8 and int(_match.group(2)) >= 1):
gdb_81 = True

#===============================================================================
# GDB Pretty Printing Module for Rust
#===============================================================================
Expand Down Expand Up @@ -110,10 +121,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
if type_kind == rustpp.TYPE_KIND_STD_VECDEQUE:
return RustStdVecDequePrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
if type_kind == rustpp.TYPE_KIND_STD_BTREESET and gdb_81:
return RustStdBTreeSetPrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP and gdb_81:
return RustStdBTreeMapPrinter(val)

if type_kind == rustpp.TYPE_KIND_STD_STRING:
Expand Down
41 changes: 33 additions & 8 deletions src/librustc/traits/specialize/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ impl<'a, 'gcx, 'tcx> Children {
simplified_self,
);

for possible_sibling in match simplified_self {
Some(sty) => self.filtered(sty),
None => self.iter(),
} {
let possible_siblings = match simplified_self {
Some(sty) => PotentialSiblings::Filtered(self.filtered(sty)),
None => PotentialSiblings::Unfiltered(self.iter()),
};

for possible_sibling in possible_siblings {
debug!(
"insert: impl_def_id={:?}, simplified_self={:?}, possible_sibling={:?}",
impl_def_id,
Expand Down Expand Up @@ -222,14 +224,37 @@ impl<'a, 'gcx, 'tcx> Children {
Ok(Inserted::BecameNewSibling(last_lint))
}

fn iter(&mut self) -> Box<dyn Iterator<Item = DefId> + '_> {
fn iter(&mut self) -> impl Iterator<Item = DefId> + '_ {
let nonblanket = self.nonblanket_impls.iter_mut().flat_map(|(_, v)| v.iter());
Box::new(self.blanket_impls.iter().chain(nonblanket).cloned())
self.blanket_impls.iter().chain(nonblanket).cloned()
}

fn filtered(&mut self, sty: SimplifiedType) -> Box<dyn Iterator<Item = DefId> + '_> {
fn filtered(&mut self, sty: SimplifiedType) -> impl Iterator<Item = DefId> + '_ {
let nonblanket = self.nonblanket_impls.entry(sty).or_default().iter();
Box::new(self.blanket_impls.iter().chain(nonblanket).cloned())
self.blanket_impls.iter().chain(nonblanket).cloned()
}
}

// A custom iterator used by Children::insert
enum PotentialSiblings<I, J>
where I: Iterator<Item = DefId>,
J: Iterator<Item = DefId>
{
Unfiltered(I),
Filtered(J)
}

impl<I, J> Iterator for PotentialSiblings<I, J>
where I: Iterator<Item = DefId>,
J: Iterator<Item = DefId>
{
type Item = DefId;

fn next(&mut self) -> Option<Self::Item> {
match *self {
PotentialSiblings::Unfiltered(ref mut iter) => iter.next(),
PotentialSiblings::Filtered(ref mut iter) => iter.next()
}
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/librustc/util/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ macro_rules! define_categories {
}

fn print(&self, lock: &mut StderrLock<'_>) {
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |")
writeln!(lock, "| Phase | Time (ms) \
| Time (%) | Queries | Hits (%)")
.unwrap();
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |")
writeln!(lock, "| ---------------- | -------------- \
| -------- | -------------- | --------")
.unwrap();

let total_time = ($(self.times.$name + )* 0) as f32;

$(
let (hits, total) = self.query_counts.$name;
let (hits, total) = if total > 0 {
Expand All @@ -78,11 +82,12 @@ macro_rules! define_categories {

writeln!(
lock,
"| {0: <16} | {1: <14} | {2: <14} | {3: <8} |",
"| {0: <16} | {1: <14} | {2: <8.2} | {3: <14} | {4: <8}",
stringify!($name),
self.times.$name / 1_000_000,
((self.times.$name as f32) / total_time) * 100.0,
total,
hits
hits,
).unwrap();
)*
}
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer;
use rustc::ty::{self, TyCtxt, PolyFnSig};
use rustc::ty::layout::HasTyCtxt;
use rustc::ty::query::Providers;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::spec::PanicStrategy;
Expand Down Expand Up @@ -130,8 +131,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
}

pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let cpu = llvm_util::target_cpu(cx.tcx.sess);
let target_cpu = CString::new(cpu).unwrap();
let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess));
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
Expand Down Expand Up @@ -231,11 +231,7 @@ pub fn from_fn_attrs(
// Always annotate functions with the target-cpu they are compiled for.
// Without this, ThinLTO won't inline Rust functions into Clang generated
// functions (because Clang annotates functions this way too).
// NOTE: For now we just apply this if -Zcross-lang-lto is specified, since
// it introduce a little overhead and isn't really necessary otherwise.
if cx.tcx.sess.opts.debugging_opts.cross_lang_lto.enabled() {
apply_target_cpu_attr(cx, llfn);
}
apply_target_cpu_attr(cx, llfn);

let features = llvm_target_features(cx.tcx.sess)
.map(|s| s.to_string())
Expand Down
21 changes: 21 additions & 0 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,27 @@ fn generic_simd_intrinsic(
);
let arg_tys = sig.inputs();

if name == "simd_select_bitmask" {
let in_ty = arg_tys[0];
let m_len = match in_ty.sty {
// Note that this `.unwrap()` crashes for isize/usize, that's sort
// of intentional as there's not currently a use case for that.
ty::Int(i) => i.bit_width().unwrap(),
ty::Uint(i) => i.bit_width().unwrap(),
_ => return_error!("`{}` is not an integral type", in_ty),
};
require_simd!(arg_tys[1], "argument");
let v_len = arg_tys[1].simd_size(tcx);
require!(m_len == v_len,
"mismatched lengths: mask length `{}` != other vector length `{}`",
m_len, v_len
);
let i1 = bx.type_i1();
let i1xn = bx.type_vector(i1, m_len as u64);
let m_i1s = bx.bitcast(args[0].immediate(), i1xn);
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
}

// every intrinsic takes a SIMD vector as its first argument
require_simd!(arg_tys[0], "input");
let in_ty = arg_tys[0];
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const AARCH64_WHITELIST: &[(&str, Option<&str>)] = &[
];

const X86_WHITELIST: &[(&str, Option<&str>)] = &[
("adx", Some("adx_target_feature")),
("aes", None),
("avx", None),
("avx2", None),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ num_cpus = "1.0"
rustc-demangle = "0.1.4"
memmap = "0.6"
log = "0.4.5"
libc = "0.2.43"
libc = "0.2.44"
jobserver = "0.1.11"

serialize = { path = "../libserialize" }
Expand Down
34 changes: 33 additions & 1 deletion src/librustc_mir/build/matches/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ use build::{BlockAnd, BlockAndExtension, Builder};
use build::matches::{Ascription, Binding, MatchPair, Candidate};
use hair::*;
use rustc::mir::*;
use rustc::ty;
use rustc::ty::layout::{Integer, IntegerExt, Size};
use syntax::attr::{SignedInt, UnsignedInt};
use rustc::hir::RangeEnd;

use std::mem;

Expand Down Expand Up @@ -62,6 +66,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
match_pair: MatchPair<'pat, 'tcx>,
candidate: &mut Candidate<'pat, 'tcx>)
-> Result<(), MatchPair<'pat, 'tcx>> {
let tcx = self.hir.tcx();
match *match_pair.pattern.kind {
PatternKind::AscribeUserType { ref subpattern, ref user_ty, user_ty_span } => {
candidate.ascriptions.push(Ascription {
Expand Down Expand Up @@ -104,7 +109,34 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
Err(match_pair)
}

PatternKind::Range { .. } => {
PatternKind::Range { lo, hi, ty, end } => {
let range = match ty.sty {
ty::Char => {
Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32)))
}
ty::Int(ity) => {
// FIXME(49937): refactor these bit manipulations into interpret.
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
let min = 1u128 << (size.bits() - 1);
let max = (1u128 << (size.bits() - 1)) - 1;
Some((min, max, size))
}
ty::Uint(uty) => {
// FIXME(49937): refactor these bit manipulations into interpret.
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
let max = !0u128 >> (128 - size.bits());
Some((0, max, size))
}
_ => None,
};
if let Some((min, max, sz)) = range {
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) {
// Irrefutable pattern match.
return Ok(());
}
}
}
Err(match_pair)
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)),
"simd_extract" => (2, vec![param(0), tcx.types.u32], param(1)),
"simd_cast" => (2, vec![param(0)], param(1)),
"simd_select" => (2, vec![param(0), param(1), param(1)], param(1)),
"simd_select" |
"simd_select_bitmask" => (2, vec![param(0), param(1), param(1)], param(1)),
"simd_reduce_all" | "simd_reduce_any" => (1, vec![param(0)], tcx.types.bool),
"simd_reduce_add_ordered" | "simd_reduce_mul_ordered"
=> (2, vec![param(0), param(1)], param(1)),
Expand Down
20 changes: 19 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ impl<'a> fmt::Display for MarkdownSummaryLine<'a> {
}

pub fn plain_summary_line(md: &str) -> String {
plain_summary_line_full(md, false)
}

pub fn plain_summary_line_full(md: &str, limit_length: bool) -> String {
struct ParserWrapper<'a> {
inner: Parser<'a>,
is_in: isize,
Expand Down Expand Up @@ -852,7 +856,21 @@ pub fn plain_summary_line(md: &str) -> String {
s.push_str(&t);
}
}
s
if limit_length && s.chars().count() > 60 {
let mut len = 0;
let mut ret = s.split_whitespace()
.take_while(|p| {
// + 1 for the added character after the word.
len += p.chars().count() + 1;
len < 60
})
.collect::<Vec<_>>()
.join(" ");
ret.push('…');
ret
} else {
s
}
}

pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
Expand Down
19 changes: 13 additions & 6 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
ty: item.type_(),
name: item.name.clone().unwrap(),
path: fqp[..fqp.len() - 1].join("::"),
desc: plain_summary_line(item.doc_value()),
desc: plain_summary_line_short(item.doc_value()),
parent: Some(did),
parent_idx: None,
search_type: get_index_search_type(&item),
Expand Down Expand Up @@ -736,7 +736,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
}

let crate_doc = krate.module.as_ref().map(|module| {
plain_summary_line(module.doc_value())
plain_summary_line_short(module.doc_value())
}).unwrap_or(String::new());

let mut crate_data = BTreeMap::new();
Expand Down Expand Up @@ -1481,7 +1481,7 @@ impl DocFolder for Cache {
ty: item.type_(),
name: s.to_string(),
path: path.join("::"),
desc: plain_summary_line(item.doc_value()),
desc: plain_summary_line_short(item.doc_value()),
parent,
parent_idx: None,
search_type: get_index_search_type(&item),
Expand Down Expand Up @@ -1512,7 +1512,8 @@ impl DocFolder for Cache {
clean::FunctionItem(..) | clean::ModuleItem(..) |
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
clean::ConstantItem(..) | clean::StaticItem(..) |
clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..)
clean::UnionItem(..) | clean::ForeignTypeItem |
clean::MacroItem(..) | clean::ProcMacroItem(..)
if !self.stripped_mod => {
// Re-exported items mean that the same id can show up twice
// in the rustdoc ast that we're looking at. We know,
Expand Down Expand Up @@ -1673,7 +1674,7 @@ impl<'a> Cache {
ty: item.type_(),
name: item_name.to_string(),
path: path.clone(),
desc: plain_summary_line(item.doc_value()),
desc: plain_summary_line_short(item.doc_value()),
parent: None,
parent_idx: None,
search_type: get_index_search_type(&item),
Expand Down Expand Up @@ -2388,7 +2389,13 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
#[inline]
fn plain_summary_line(s: Option<&str>) -> String {
let line = shorter(s).replace("\n", " ");
markdown::plain_summary_line(&line[..])
markdown::plain_summary_line_full(&line[..], false)
}

#[inline]
fn plain_summary_line_short(s: Option<&str>) -> String {
let line = shorter(s).replace("\n", " ");
markdown::plain_summary_line_full(&line[..], true)
}

fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
hir::ItemKind::Use(ref path, kind) => {
let is_glob = kind == hir::UseKind::Glob;

// Struct and variant constructors always show up alongside their definitions, we've
// already processed them so just discard these.
// Struct and variant constructors and proc macro stubs always show up alongside
// their definitions, we've already processed them so just discard these.
match path.def {
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) => return,
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) |
Def::Macro(_, MacroKind::ProcMacroStub) => return,
_ => {}
}

Expand Down
1 change: 0 additions & 1 deletion src/libstd/io/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const fn done<T>() -> *mut Arc<T> { 1_usize as *mut _ }
unsafe impl<T> Sync for Lazy<T> {}

impl<T> Lazy<T> {
#[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
pub const fn new() -> Lazy<T> {
Lazy {
lock: Mutex::new(),
Expand Down
1 change: 1 addition & 0 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
#![feature(libc)]
#![feature(link_args)]
#![feature(linkage)]
#![cfg_attr(not(stage0), feature(min_const_unsafe_fn))]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![feature(nll)]
Expand Down
Loading

0 comments on commit 1897657

Please sign in to comment.