Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests (first batch) #56818

Merged
merged 31 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
86822eb
Unconditionally emit the target-cpu LLVM attribute.
michaelwoerister Dec 7, 2018
0bb075f
rustdoc: Fix local reexports of proc macros
ollie27 Dec 8, 2018
85b50d0
Add missing, non-panicking `maybe_new_parser_from_file` variant
Xanewok Dec 9, 2018
771e8b8
[self-profiler] Add column for percent of total time
wesleywiser Dec 11, 2018
799cadb
Remove unnecessary feature gates from const fns
oli-obk Dec 11, 2018
1346619
Remove some dead code from `sgx`
oli-obk Dec 11, 2018
5457b19
Properly stage new feature gates
oli-obk Dec 11, 2018
510a9ff
Fix irrefutable matches on integer ranges
varkor Dec 10, 2018
2403146
Remove unneeded extra chars to reduce search-index size
GuillaumeGomez Dec 11, 2018
0f68749
Use a `newtype_index!` within `Symbol`.
nnethercote Dec 10, 2018
cd7e891
specialize: remove Boxes used by Children::insert
ljedrz Dec 12, 2018
8b67eb8
Increase required version for crates.io `libc` to get fix from PR rus…
pnkfelix Dec 6, 2018
78f20de
x86: Add the `adx` target feature to whitelist
alexcrichton Dec 12, 2018
4007adf
Disable btree pretty-printers on older gdbs
tromey Dec 12, 2018
987bf2e
Split on words instead
GuillaumeGomez Dec 11, 2018
5087aef
rustc: Add an unstable `simd_select_bitmask` intrinsic
alexcrichton Dec 13, 2018
6057147
Update panic message to be clearer about env-vars
kinnison Dec 12, 2018
4f0f110
Rollup merge of #56609 - michaelwoerister:unconditional-target-cpu-at…
kennytm Dec 14, 2018
795f18e
Rollup merge of #56637 - ollie27:rustdoc_proc_macro_local_reexport, r…
kennytm Dec 14, 2018
35fe8c9
Rollup merge of #56658 - Xanewok:non-panicking-file-parser, r=petroch…
kennytm Dec 14, 2018
53a2de2
Rollup merge of #56695 - varkor:let-exhaustive-range, r=estebank
kennytm Dec 14, 2018
dadf7fc
Rollup merge of #56699 - nnethercote:SymbolIndex, r=oli-obk
kennytm Dec 14, 2018
3e17988
Rollup merge of #56702 - wesleywiser:calc_total_time_stats, r=michael…
kennytm Dec 14, 2018
27c3631
Rollup merge of #56708 - oli-obk:stability_internal_const_fn, r=alexc…
kennytm Dec 14, 2018
facad1d
Rollup merge of #56709 - GuillaumeGomez:reduce-search-index, r=QuietM…
kennytm Dec 14, 2018
7ec1faa
Rollup merge of #56744 - ljedrz:unbox_the_children, r=matthewjasper
kennytm Dec 14, 2018
123b72a
Rollup merge of #56748 - kinnison:kinnison/fix-56734, r=dtolnay
kennytm Dec 14, 2018
adb674c
Rollup merge of #56749 - alexcrichton:adx, r=gnzlbg
kennytm Dec 14, 2018
4a0ee22
Rollup merge of #56756 - tromey:Bug-56730-btree-pretty-printer, r=ale…
kennytm Dec 14, 2018
3397b79
Rollup merge of #56789 - alexcrichton:simd_select_bitmask, r=rkruppe
kennytm Dec 14, 2018
e065de2
Rollup merge of #56562 - pnkfelix:issue-55465-update-libc-version, r=…
kennytm Dec 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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