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 11 pull requests #56155

Merged
merged 35 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bc18857
Return &T / &mut T in ManuallyDrop Deref(Mut) impl
petertodd Oct 29, 2018
b937be8
Clarifying documentation for collections::hash_map::Entry::or_insert
meltinglava Nov 8, 2018
8b750a7
The example values are now easyer to differenciate
meltinglava Nov 13, 2018
a9a48ed
Fix VecDeque pretty-printer
tromey Nov 14, 2018
052bdff
lint based on closure pipe span
csmoe Nov 15, 2018
dbd9abd
update closure arg suggesstion ui test
csmoe Nov 15, 2018
7cb068e
add ui test
lcnr Nov 16, 2018
80c2101
change expected error message
lcnr Nov 16, 2018
218e35e
eat CloseDelim
lcnr Nov 16, 2018
675319e
lint if a private item has doctests
GuillaumeGomez Oct 25, 2018
4c4aff9
remove license
lcnr Nov 16, 2018
646d68f
add a note to the error message
lcnr Nov 16, 2018
fe23ffb
improve error when self is used as not the first argument
lcnr Nov 16, 2018
2be930b
fix tidy (remove whitespace)
lcnr Nov 16, 2018
5bfdcc1
remove stray file with UI testing output
lcnr Nov 17, 2018
d93e5b0
reserve whitespaces between prefix and pipe
csmoe Nov 17, 2018
7c9bcc5
Update any.rs documentation using keyword dyn
0xrgb Nov 19, 2018
a44e446
Add `override_export_symbols` option to Rust target specification
Nov 19, 2018
b8da719
Fix error message for `-C panic=xxx`.
ehuss Nov 19, 2018
88d6094
improve error note
lcnr Nov 20, 2018
8a0909d
Remove incorrect doc comment
bjorn3 Nov 20, 2018
9ce7b11
Remove incorrect doc comment in rustc_mir::monomorphize::item
bjorn3 Nov 20, 2018
9e2e575
Add x86_64-fortanix-unknown-sgx target to the compiler
Nov 19, 2018
e538a4a
core/benches/num: Add `from_str/from_str_radix()` benchmarks
Turbo87 Nov 13, 2018
9aedfd5
Rollup merge of #55367 - GuillaumeGomez:private-item-doc-test-lint, r…
GuillaumeGomez Nov 22, 2018
1c57f0a
Rollup merge of #55485 - petertodd:2018-10-manuallydrop-deref, r=TimNN
GuillaumeGomez Nov 22, 2018
89e0fce
Rollup merge of #55784 - meltinglava:master, r=KodrAus
GuillaumeGomez Nov 22, 2018
fa3941c
Rollup merge of #55961 - tromey:Bug-55944-vecdeque, r=nikomatsakis
GuillaumeGomez Nov 22, 2018
636f0a9
Rollup merge of #55980 - csmoe:issue-55891, r=estebank
GuillaumeGomez Nov 22, 2018
75d226e
Rollup merge of #56002 - Axary:master, r=estebank
GuillaumeGomez Nov 22, 2018
1646fc9
Rollup merge of #56063 - 0xrgb:patch-1, r=joshtriplett
GuillaumeGomez Nov 22, 2018
b473157
Rollup merge of #56067 - jethrogb:jb/sgx-target-spec, r=alexcrichton
GuillaumeGomez Nov 22, 2018
1bc9708
Rollup merge of #56078 - ehuss:fix-panic-opt-msg, r=alexcrichton
GuillaumeGomez Nov 22, 2018
6afecfd
Rollup merge of #56106 - bjorn3:patch-1, r=alexcrichton
GuillaumeGomez Nov 22, 2018
61d7b3e
Rollup merge of #56126 - Turbo87:bench-parse, r=alexcrichton
GuillaumeGomez Nov 22, 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
14 changes: 11 additions & 3 deletions src/etc/gdb_rust_pretty_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,23 @@ def display_hint():
def to_string(self):
(tail, head, data_ptr, cap) = \
rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val)
if head >= tail:
size = head - tail
else:
size = cap + head - tail
return (self.__val.type.get_unqualified_type_name() +
("(len: %i, cap: %i)" % (head - tail, cap)))
("(len: %i, cap: %i)" % (size, cap)))

def children(self):
(tail, head, data_ptr, cap) = \
rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val)
gdb_ptr = data_ptr.get_wrapped_value()
for index in xrange(tail, head):
yield (str(index), (gdb_ptr + index).dereference())
if head >= tail:
size = head - tail
else:
size = cap + head - tail
for index in xrange(0, size):
yield (str(index), (gdb_ptr + ((tail + index) % cap)).dereference())


class RustStdBTreeSetPrinter(object):
Expand Down
22 changes: 11 additions & 11 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//!
//! // Logger function for any type that implements Debug.
//! fn log<T: Any + Debug>(value: &T) {
//! let value_any = value as &Any;
//! let value_any = value as &dyn Any;
//!
//! // try to convert our value to a String. If successful, we want to
//! // output the String's length as well as its value. If not, it's a
Expand Down Expand Up @@ -95,7 +95,7 @@ pub trait Any: 'static {
///
/// use std::any::{Any, TypeId};
///
/// fn is_string(s: &Any) -> bool {
/// fn is_string(s: &dyn Any) -> bool {
/// TypeId::of::<String>() == s.get_type_id()
/// }
///
Expand Down Expand Up @@ -151,7 +151,7 @@ impl dyn Any {
/// ```
/// use std::any::Any;
///
/// fn is_string(s: &Any) {
/// fn is_string(s: &dyn Any) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
Expand Down Expand Up @@ -185,7 +185,7 @@ impl dyn Any {
/// ```
/// use std::any::Any;
///
/// fn print_if_string(s: &Any) {
/// fn print_if_string(s: &dyn Any) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
Expand Down Expand Up @@ -218,7 +218,7 @@ impl dyn Any {
/// ```
/// use std::any::Any;
///
/// fn modify_if_u32(s: &mut Any) {
/// fn modify_if_u32(s: &mut dyn Any) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
Expand Down Expand Up @@ -256,7 +256,7 @@ impl dyn Any+Send {
/// ```
/// use std::any::Any;
///
/// fn is_string(s: &(Any + Send)) {
/// fn is_string(s: &(dyn Any + Send)) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
Expand All @@ -282,7 +282,7 @@ impl dyn Any+Send {
/// ```
/// use std::any::Any;
///
/// fn print_if_string(s: &(Any + Send)) {
/// fn print_if_string(s: &(dyn Any + Send)) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
Expand All @@ -308,7 +308,7 @@ impl dyn Any+Send {
/// ```
/// use std::any::Any;
///
/// fn modify_if_u32(s: &mut (Any + Send)) {
/// fn modify_if_u32(s: &mut (dyn Any + Send)) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
Expand Down Expand Up @@ -340,7 +340,7 @@ impl dyn Any+Send+Sync {
/// ```
/// use std::any::Any;
///
/// fn is_string(s: &(Any + Send + Sync)) {
/// fn is_string(s: &(dyn Any + Send + Sync)) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
Expand All @@ -366,7 +366,7 @@ impl dyn Any+Send+Sync {
/// ```
/// use std::any::Any;
///
/// fn print_if_string(s: &(Any + Send + Sync)) {
/// fn print_if_string(s: &(dyn Any + Send + Sync)) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
Expand All @@ -392,7 +392,7 @@ impl dyn Any+Send+Sync {
/// ```
/// use std::any::Any;
///
/// fn modify_if_u32(s: &mut (Any + Send + Sync)) {
/// fn modify_if_u32(s: &mut (dyn Any + Send + Sync)) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
Expand Down
105 changes: 105 additions & 0 deletions src/libcore/benches/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,108 @@

mod flt2dec;
mod dec2flt;

use test::Bencher;
use std::str::FromStr;

const ASCII_NUMBERS: [&str; 19] = [
"0",
"1",
"2",
"43",
"765",
"76567",
"987245987",
"-4aa32",
"1786235",
"8723095",
"f##5s",
"83638730",
"-2345",
"562aa43",
"-1",
"-0",
"abc",
"xyz",
"c0ffee",
];

macro_rules! from_str_bench {
($mac:ident, $t:ty) => (
#[bench]
fn $mac(b: &mut Bencher) {
b.iter(|| {
ASCII_NUMBERS
.iter()
.cycle()
.take(5_000)
.filter_map(|s| <($t)>::from_str(s).ok())
.max()
})
}
)
}

macro_rules! from_str_radix_bench {
($mac:ident, $t:ty, $radix:expr) => (
#[bench]
fn $mac(b: &mut Bencher) {
b.iter(|| {
ASCII_NUMBERS
.iter()
.cycle()
.take(5_000)
.filter_map(|s| <($t)>::from_str_radix(s, $radix).ok())
.max()
})
}
)
}

from_str_bench!(bench_u8_from_str, u8);
from_str_radix_bench!(bench_u8_from_str_radix_2, u8, 2);
from_str_radix_bench!(bench_u8_from_str_radix_10, u8, 10);
from_str_radix_bench!(bench_u8_from_str_radix_16, u8, 16);
from_str_radix_bench!(bench_u8_from_str_radix_36, u8, 36);

from_str_bench!(bench_u16_from_str, u16);
from_str_radix_bench!(bench_u16_from_str_radix_2, u16, 2);
from_str_radix_bench!(bench_u16_from_str_radix_10, u16, 10);
from_str_radix_bench!(bench_u16_from_str_radix_16, u16, 16);
from_str_radix_bench!(bench_u16_from_str_radix_36, u16, 36);

from_str_bench!(bench_u32_from_str, u32);
from_str_radix_bench!(bench_u32_from_str_radix_2, u32, 2);
from_str_radix_bench!(bench_u32_from_str_radix_10, u32, 10);
from_str_radix_bench!(bench_u32_from_str_radix_16, u32, 16);
from_str_radix_bench!(bench_u32_from_str_radix_36, u32, 36);

from_str_bench!(bench_u64_from_str, u64);
from_str_radix_bench!(bench_u64_from_str_radix_2, u64, 2);
from_str_radix_bench!(bench_u64_from_str_radix_10, u64, 10);
from_str_radix_bench!(bench_u64_from_str_radix_16, u64, 16);
from_str_radix_bench!(bench_u64_from_str_radix_36, u64, 36);

from_str_bench!(bench_i8_from_str, i8);
from_str_radix_bench!(bench_i8_from_str_radix_2, i8, 2);
from_str_radix_bench!(bench_i8_from_str_radix_10, i8, 10);
from_str_radix_bench!(bench_i8_from_str_radix_16, i8, 16);
from_str_radix_bench!(bench_i8_from_str_radix_36, i8, 36);

from_str_bench!(bench_i16_from_str, i16);
from_str_radix_bench!(bench_i16_from_str_radix_2, i16, 2);
from_str_radix_bench!(bench_i16_from_str_radix_10, i16, 10);
from_str_radix_bench!(bench_i16_from_str_radix_16, i16, 16);
from_str_radix_bench!(bench_i16_from_str_radix_36, i16, 36);

from_str_bench!(bench_i32_from_str, i32);
from_str_radix_bench!(bench_i32_from_str_radix_2, i32, 2);
from_str_radix_bench!(bench_i32_from_str_radix_10, i32, 10);
from_str_radix_bench!(bench_i32_from_str_radix_16, i32, 16);
from_str_radix_bench!(bench_i32_from_str_radix_36, i32, 36);

from_str_bench!(bench_i64_from_str, i64);
from_str_radix_bench!(bench_i64_from_str_radix_2, i64, 2);
from_str_radix_bench!(bench_i64_from_str_radix_10, i64, 10);
from_str_radix_bench!(bench_i64_from_str_radix_16, i64, 16);
from_str_radix_bench!(bench_i64_from_str_radix_36, i64, 36);
4 changes: 2 additions & 2 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,15 +1016,15 @@ impl<T: ?Sized> ManuallyDrop<T> {
impl<T: ?Sized> Deref for ManuallyDrop<T> {
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
fn deref(&self) -> &T {
&self.value
}
}

#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
fn deref_mut(&mut self) -> &mut T {
&mut self.value
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ declare_lint! {
"warn about missing code example in an item's documentation"
}

declare_lint! {
pub PRIVATE_DOC_TESTS,
Allow,
"warn about doc test in private item"
}

declare_lint! {
pub WHERE_CLAUSES_OBJECT_SAFETY,
Warn,
Expand Down Expand Up @@ -415,6 +421,7 @@ impl LintPass for HardwiredLints {
DUPLICATE_MACRO_EXPORTS,
INTRA_DOC_LINK_RESOLUTION_FAILURE,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
WHERE_CLAUSES_OBJECT_SAFETY,
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
MACRO_USE_EXTERN_CRATE,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ macro_rules! options {
pub const parse_opt_uint: Option<&'static str> =
Some("a number");
pub const parse_panic_strategy: Option<&'static str> =
Some("either `panic` or `abort`");
Some("either `unwind` or `abort`");
pub const parse_relro_level: Option<&'static str> =
Some("one of: `full`, `partial`, or `off`");
pub const parse_sanitizer: Option<&'static str> =
Expand Down
16 changes: 15 additions & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,13 +1092,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if let Some(found_span) = found_span {
err.span_label(found_span, format!("takes {}", found_str));

// move |_| { ... }
// ^^^^^^^^-- def_span
//
// move |_| { ... }
// ^^^^^-- prefix
let prefix_span = self.tcx.sess.source_map().span_until_non_whitespace(found_span);
// move |_| { ... }
// ^^^-- pipe_span
let pipe_span = if let Some(span) = found_span.trim_start(prefix_span) {
span
} else {
found_span
};

// Suggest to take and ignore the arguments with expected_args_length `_`s if
// found arguments is empty (assume the user just wants to ignore args in this case).
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
if found_args.is_empty() && is_closure {
let underscores = vec!["_"; expected_args.len()].join(", ");
err.span_suggestion_with_applicability(
found_span,
pipe_span,
&format!(
"consider changing the closure to take and ignore the expected argument{}",
if expected_args.len() < 2 {
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ impl<'a> Linker for WasmLd<'a> {
}

fn exported_symbols(tcx: TyCtxt, crate_type: CrateType) -> Vec<String> {
if let Some(ref exports) = tcx.sess.target.target.options.override_export_symbols {
return exports.clone()
}

let mut symbols = Vec::new();

let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
Expand Down
6 changes: 0 additions & 6 deletions src/librustc_codegen_ssa/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Walks the crate looking for items/impl-items/trait-items that have
//! either a `rustc_symbol_name` or `rustc_item_path` attribute and
//! generates an error giving, respectively, the symbol name or
//! item-path. This is used for unit testing the code that generates
//! paths etc in all kinds of annoying scenarios.

use base;
use rustc::hir;
use rustc::hir::def::Def;
Expand Down
6 changes: 0 additions & 6 deletions src/librustc_mir/monomorphize/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Walks the crate looking for items/impl-items/trait-items that have
//! either a `rustc_symbol_name` or `rustc_item_path` attribute and
//! generates an error giving, respectively, the symbol name or
//! item-path. This is used for unit testing the code that generates
//! paths etc in all kinds of annoying scenarios.

use monomorphize::Instance;
use rustc::hir;
use rustc::hir::def_id::DefId;
Expand Down
Loading