Skip to content

Commit 1897657

Browse files
committed
Auto merge of rust-lang#56818 - kennytm:rollup-2, r=kennytm
Rollup of 14 pull requests (first batch) Successful merges: - rust-lang#56562 (Update libc version required by rustc) - rust-lang#56609 (Unconditionally emit the target-cpu LLVM attribute.) - rust-lang#56637 (rustdoc: Fix local reexports of proc macros) - rust-lang#56658 (Add non-panicking `maybe_new_parser_from_file` variant) - rust-lang#56695 (Fix irrefutable matches on integer ranges) - rust-lang#56699 (Use a `newtype_index!` within `Symbol`.) - rust-lang#56702 ([self-profiler] Add column for percent of total time) - rust-lang#56708 (Remove some unnecessary feature gates) - rust-lang#56709 (Remove unneeded extra chars to reduce search-index size) - rust-lang#56744 (specialize: remove Boxes used by Children::insert) - rust-lang#56748 (Update panic message to be clearer about env-vars) - rust-lang#56749 (x86: Add the `adx` target feature to whitelist) - rust-lang#56756 (Disable btree pretty-printers on older gdbs) - rust-lang#56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic) r? @ghost
2 parents 7d03617 + e065de2 commit 1897657

38 files changed

+335
-100
lines changed

Diff for: src/etc/gdb_rust_pretty_printing.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# except according to those terms.
1010

1111
import gdb
12+
import re
1213
import sys
1314
import debugger_pretty_printers_common as rustpp
1415

@@ -20,6 +21,16 @@
2021

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

24+
# The btree pretty-printers fail in a confusing way unless
25+
# https://sourceware.org/bugzilla/show_bug.cgi?id=21763 is fixed.
26+
# This fix went in 8.1, so check for that.
27+
# See https://github.com/rust-lang/rust/issues/56730
28+
gdb_81 = False
29+
_match = re.match('([0-9]+)\\.([0-9]+)', gdb.VERSION)
30+
if _match:
31+
if int(_match.group(1)) > 8 or (int(_match.group(1)) == 8 and int(_match.group(2)) >= 1):
32+
gdb_81 = True
33+
2334
#===============================================================================
2435
# GDB Pretty Printing Module for Rust
2536
#===============================================================================
@@ -110,10 +121,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
110121
if type_kind == rustpp.TYPE_KIND_STD_VECDEQUE:
111122
return RustStdVecDequePrinter(val)
112123

113-
if type_kind == rustpp.TYPE_KIND_STD_BTREESET:
124+
if type_kind == rustpp.TYPE_KIND_STD_BTREESET and gdb_81:
114125
return RustStdBTreeSetPrinter(val)
115126

116-
if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP:
127+
if type_kind == rustpp.TYPE_KIND_STD_BTREEMAP and gdb_81:
117128
return RustStdBTreeMapPrinter(val)
118129

119130
if type_kind == rustpp.TYPE_KIND_STD_STRING:

Diff for: src/librustc/traits/specialize/specialization_graph.rs

+33-8
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ impl<'a, 'gcx, 'tcx> Children {
132132
simplified_self,
133133
);
134134

135-
for possible_sibling in match simplified_self {
136-
Some(sty) => self.filtered(sty),
137-
None => self.iter(),
138-
} {
135+
let possible_siblings = match simplified_self {
136+
Some(sty) => PotentialSiblings::Filtered(self.filtered(sty)),
137+
None => PotentialSiblings::Unfiltered(self.iter()),
138+
};
139+
140+
for possible_sibling in possible_siblings {
139141
debug!(
140142
"insert: impl_def_id={:?}, simplified_self={:?}, possible_sibling={:?}",
141143
impl_def_id,
@@ -222,14 +224,37 @@ impl<'a, 'gcx, 'tcx> Children {
222224
Ok(Inserted::BecameNewSibling(last_lint))
223225
}
224226

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

230-
fn filtered(&mut self, sty: SimplifiedType) -> Box<dyn Iterator<Item = DefId> + '_> {
232+
fn filtered(&mut self, sty: SimplifiedType) -> impl Iterator<Item = DefId> + '_ {
231233
let nonblanket = self.nonblanket_impls.entry(sty).or_default().iter();
232-
Box::new(self.blanket_impls.iter().chain(nonblanket).cloned())
234+
self.blanket_impls.iter().chain(nonblanket).cloned()
235+
}
236+
}
237+
238+
// A custom iterator used by Children::insert
239+
enum PotentialSiblings<I, J>
240+
where I: Iterator<Item = DefId>,
241+
J: Iterator<Item = DefId>
242+
{
243+
Unfiltered(I),
244+
Filtered(J)
245+
}
246+
247+
impl<I, J> Iterator for PotentialSiblings<I, J>
248+
where I: Iterator<Item = DefId>,
249+
J: Iterator<Item = DefId>
250+
{
251+
type Item = DefId;
252+
253+
fn next(&mut self) -> Option<Self::Item> {
254+
match *self {
255+
PotentialSiblings::Unfiltered(ref mut iter) => iter.next(),
256+
PotentialSiblings::Filtered(ref mut iter) => iter.next()
257+
}
233258
}
234259
}
235260

Diff for: src/librustc/util/profiling.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ macro_rules! define_categories {
6262
}
6363

6464
fn print(&self, lock: &mut StderrLock<'_>) {
65-
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |")
65+
writeln!(lock, "| Phase | Time (ms) \
66+
| Time (%) | Queries | Hits (%)")
6667
.unwrap();
67-
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |")
68+
writeln!(lock, "| ---------------- | -------------- \
69+
| -------- | -------------- | --------")
6870
.unwrap();
6971

72+
let total_time = ($(self.times.$name + )* 0) as f32;
73+
7074
$(
7175
let (hits, total) = self.query_counts.$name;
7276
let (hits, total) = if total > 0 {
@@ -78,11 +82,12 @@ macro_rules! define_categories {
7882

7983
writeln!(
8084
lock,
81-
"| {0: <16} | {1: <14} | {2: <14} | {3: <8} |",
85+
"| {0: <16} | {1: <14} | {2: <8.2} | {3: <14} | {4: <8}",
8286
stringify!($name),
8387
self.times.$name / 1_000_000,
88+
((self.times.$name as f32) / total_time) * 100.0,
8489
total,
85-
hits
90+
hits,
8691
).unwrap();
8792
)*
8893
}

Diff for: src/librustc_codegen_llvm/attributes.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer;
1818
use rustc::ty::{self, TyCtxt, PolyFnSig};
1919
use rustc::ty::layout::HasTyCtxt;
2020
use rustc::ty::query::Providers;
21+
use rustc_data_structures::small_c_str::SmallCStr;
2122
use rustc_data_structures::sync::Lrc;
2223
use rustc_data_structures::fx::FxHashMap;
2324
use rustc_target::spec::PanicStrategy;
@@ -130,8 +131,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
130131
}
131132

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

240236
let features = llvm_target_features(cx.tcx.sess)
241237
.map(|s| s.to_string())

Diff for: src/librustc_codegen_llvm/intrinsic.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,27 @@ fn generic_simd_intrinsic(
11711171
);
11721172
let arg_tys = sig.inputs();
11731173

1174+
if name == "simd_select_bitmask" {
1175+
let in_ty = arg_tys[0];
1176+
let m_len = match in_ty.sty {
1177+
// Note that this `.unwrap()` crashes for isize/usize, that's sort
1178+
// of intentional as there's not currently a use case for that.
1179+
ty::Int(i) => i.bit_width().unwrap(),
1180+
ty::Uint(i) => i.bit_width().unwrap(),
1181+
_ => return_error!("`{}` is not an integral type", in_ty),
1182+
};
1183+
require_simd!(arg_tys[1], "argument");
1184+
let v_len = arg_tys[1].simd_size(tcx);
1185+
require!(m_len == v_len,
1186+
"mismatched lengths: mask length `{}` != other vector length `{}`",
1187+
m_len, v_len
1188+
);
1189+
let i1 = bx.type_i1();
1190+
let i1xn = bx.type_vector(i1, m_len as u64);
1191+
let m_i1s = bx.bitcast(args[0].immediate(), i1xn);
1192+
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
1193+
}
1194+
11741195
// every intrinsic takes a SIMD vector as its first argument
11751196
require_simd!(arg_tys[0], "input");
11761197
let in_ty = arg_tys[0];

Diff for: src/librustc_codegen_llvm/llvm_util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const AARCH64_WHITELIST: &[(&str, Option<&str>)] = &[
124124
];
125125

126126
const X86_WHITELIST: &[(&str, Option<&str>)] = &[
127+
("adx", Some("adx_target_feature")),
127128
("aes", None),
128129
("avx", None),
129130
("avx2", None),

Diff for: src/librustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ num_cpus = "1.0"
1616
rustc-demangle = "0.1.4"
1717
memmap = "0.6"
1818
log = "0.4.5"
19-
libc = "0.2.43"
19+
libc = "0.2.44"
2020
jobserver = "0.1.11"
2121

2222
serialize = { path = "../libserialize" }

Diff for: src/librustc_mir/build/matches/simplify.rs

+33-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ use build::{BlockAnd, BlockAndExtension, Builder};
2626
use build::matches::{Ascription, Binding, MatchPair, Candidate};
2727
use hair::*;
2828
use rustc::mir::*;
29+
use rustc::ty;
30+
use rustc::ty::layout::{Integer, IntegerExt, Size};
31+
use syntax::attr::{SignedInt, UnsignedInt};
32+
use rustc::hir::RangeEnd;
2933

3034
use std::mem;
3135

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

107-
PatternKind::Range { .. } => {
112+
PatternKind::Range { lo, hi, ty, end } => {
113+
let range = match ty.sty {
114+
ty::Char => {
115+
Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32)))
116+
}
117+
ty::Int(ity) => {
118+
// FIXME(49937): refactor these bit manipulations into interpret.
119+
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
120+
let min = 1u128 << (size.bits() - 1);
121+
let max = (1u128 << (size.bits() - 1)) - 1;
122+
Some((min, max, size))
123+
}
124+
ty::Uint(uty) => {
125+
// FIXME(49937): refactor these bit manipulations into interpret.
126+
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
127+
let max = !0u128 >> (128 - size.bits());
128+
Some((0, max, size))
129+
}
130+
_ => None,
131+
};
132+
if let Some((min, max, sz)) = range {
133+
if let (Some(lo), Some(hi)) = (lo.val.try_to_bits(sz), hi.val.try_to_bits(sz)) {
134+
if lo <= min && (hi > max || hi == max && end == RangeEnd::Included) {
135+
// Irrefutable pattern match.
136+
return Ok(());
137+
}
138+
}
139+
}
108140
Err(match_pair)
109141
}
110142

Diff for: src/librustc_typeck/check/intrinsic.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
435435
"simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)),
436436
"simd_extract" => (2, vec![param(0), tcx.types.u32], param(1)),
437437
"simd_cast" => (2, vec![param(0)], param(1)),
438-
"simd_select" => (2, vec![param(0), param(1), param(1)], param(1)),
438+
"simd_select" |
439+
"simd_select_bitmask" => (2, vec![param(0), param(1), param(1)], param(1)),
439440
"simd_reduce_all" | "simd_reduce_any" => (1, vec![param(0)], tcx.types.bool),
440441
"simd_reduce_add_ordered" | "simd_reduce_mul_ordered"
441442
=> (2, vec![param(0), param(1)], param(1)),

Diff for: src/librustdoc/html/markdown.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,10 @@ impl<'a> fmt::Display for MarkdownSummaryLine<'a> {
806806
}
807807

808808
pub fn plain_summary_line(md: &str) -> String {
809+
plain_summary_line_full(md, false)
810+
}
811+
812+
pub fn plain_summary_line_full(md: &str, limit_length: bool) -> String {
809813
struct ParserWrapper<'a> {
810814
inner: Parser<'a>,
811815
is_in: isize,
@@ -852,7 +856,21 @@ pub fn plain_summary_line(md: &str) -> String {
852856
s.push_str(&t);
853857
}
854858
}
855-
s
859+
if limit_length && s.chars().count() > 60 {
860+
let mut len = 0;
861+
let mut ret = s.split_whitespace()
862+
.take_while(|p| {
863+
// + 1 for the added character after the word.
864+
len += p.chars().count() + 1;
865+
len < 60
866+
})
867+
.collect::<Vec<_>>()
868+
.join(" ");
869+
ret.push('…');
870+
ret
871+
} else {
872+
s
873+
}
856874
}
857875

858876
pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {

Diff for: src/librustdoc/html/render.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
698698
ty: item.type_(),
699699
name: item.name.clone().unwrap(),
700700
path: fqp[..fqp.len() - 1].join("::"),
701-
desc: plain_summary_line(item.doc_value()),
701+
desc: plain_summary_line_short(item.doc_value()),
702702
parent: Some(did),
703703
parent_idx: None,
704704
search_type: get_index_search_type(&item),
@@ -736,7 +736,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
736736
}
737737

738738
let crate_doc = krate.module.as_ref().map(|module| {
739-
plain_summary_line(module.doc_value())
739+
plain_summary_line_short(module.doc_value())
740740
}).unwrap_or(String::new());
741741

742742
let mut crate_data = BTreeMap::new();
@@ -1481,7 +1481,7 @@ impl DocFolder for Cache {
14811481
ty: item.type_(),
14821482
name: s.to_string(),
14831483
path: path.join("::"),
1484-
desc: plain_summary_line(item.doc_value()),
1484+
desc: plain_summary_line_short(item.doc_value()),
14851485
parent,
14861486
parent_idx: None,
14871487
search_type: get_index_search_type(&item),
@@ -1512,7 +1512,8 @@ impl DocFolder for Cache {
15121512
clean::FunctionItem(..) | clean::ModuleItem(..) |
15131513
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
15141514
clean::ConstantItem(..) | clean::StaticItem(..) |
1515-
clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..)
1515+
clean::UnionItem(..) | clean::ForeignTypeItem |
1516+
clean::MacroItem(..) | clean::ProcMacroItem(..)
15161517
if !self.stripped_mod => {
15171518
// Re-exported items mean that the same id can show up twice
15181519
// in the rustdoc ast that we're looking at. We know,
@@ -1673,7 +1674,7 @@ impl<'a> Cache {
16731674
ty: item.type_(),
16741675
name: item_name.to_string(),
16751676
path: path.clone(),
1676-
desc: plain_summary_line(item.doc_value()),
1677+
desc: plain_summary_line_short(item.doc_value()),
16771678
parent: None,
16781679
parent_idx: None,
16791680
search_type: get_index_search_type(&item),
@@ -2388,7 +2389,13 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
23882389
#[inline]
23892390
fn plain_summary_line(s: Option<&str>) -> String {
23902391
let line = shorter(s).replace("\n", " ");
2391-
markdown::plain_summary_line(&line[..])
2392+
markdown::plain_summary_line_full(&line[..], false)
2393+
}
2394+
2395+
#[inline]
2396+
fn plain_summary_line_short(s: Option<&str>) -> String {
2397+
let line = shorter(s).replace("\n", " ");
2398+
markdown::plain_summary_line_full(&line[..], true)
23922399
}
23932400

23942401
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {

Diff for: src/librustdoc/visit_ast.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
424424
hir::ItemKind::Use(ref path, kind) => {
425425
let is_glob = kind == hir::UseKind::Glob;
426426

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

Diff for: src/libstd/io/lazy.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const fn done<T>() -> *mut Arc<T> { 1_usize as *mut _ }
2626
unsafe impl<T> Sync for Lazy<T> {}
2727

2828
impl<T> Lazy<T> {
29-
#[unstable(feature = "sys_internals", issue = "0")] // FIXME: min_const_fn
3029
pub const fn new() -> Lazy<T> {
3130
Lazy {
3231
lock: Mutex::new(),

Diff for: src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@
271271
#![feature(libc)]
272272
#![feature(link_args)]
273273
#![feature(linkage)]
274+
#![cfg_attr(not(stage0), feature(min_const_unsafe_fn))]
274275
#![feature(needs_panic_runtime)]
275276
#![feature(never_type)]
276277
#![feature(nll)]

0 commit comments

Comments
 (0)