Skip to content

Rollup of 10 pull requests #60090

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

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cc2689a
implement nth_back for Bytes
koalatux Apr 16, 2019
fae2a68
implement nth_back for Fuse
koalatux Apr 16, 2019
2605537
implement nth_back for Enumerate
koalatux Apr 16, 2019
ca19ffe
Update rustfmt to 1.2.1
topecongiro Apr 17, 2019
365a48a
whitelist rtm x86 cpu feature
mtak- Apr 17, 2019
007b40b
Point at try `?` on errors affecting the err match arm of the desugar…
estebank Apr 18, 2019
1e99b2e
Give custom error for E0277 on `?` error case
estebank Apr 18, 2019
379c541
Simplify the returning of a Result a bit
janhohenheim Apr 17, 2019
553ec5d
Update run-make PGO test to new commandline syntax.
michaelwoerister Apr 17, 2019
4269be3
Prefix PROFILER_SUPPORT and SANITIZER_SUPPORT test env vars with RUST…
michaelwoerister Apr 18, 2019
227be65
compiletest: Allow for tests requiring profiler-rt or sanitizer-rt su…
michaelwoerister Apr 18, 2019
e2acaee
Add codegen test that makes sure PGO instrumentation is emitted as ex…
michaelwoerister Apr 16, 2019
d98afc5
Fix small errors in docs for `rchunks_exact` and `rchunks_exact_mut`.
nathankleyn Apr 18, 2019
cc77087
Use new `needs-(profiler|sanitizer)-support` compiletest directive to…
michaelwoerister Apr 18, 2019
08efbac
Implement event filtering for self-profiler.
michaelwoerister Apr 12, 2019
ae1f2b5
Update miri
TimDiekmann Apr 18, 2019
b6f148c
hide `--explain` hint if error has no extended info
euclio Apr 17, 2019
a4a544e
Rollup merge of #59915 - michaelwoerister:sp-event-filters-1, r=wesle…
Centril Apr 18, 2019
28cf45f
Rollup merge of #60023 - koalatux:nth-back, r=scottmcm
Centril Apr 18, 2019
69093c1
Rollup merge of #60038 - michaelwoerister:pgo-updates-2, r=alexcrichton
Centril Apr 18, 2019
b13cf83
Rollup merge of #60041 - jnferner:patch-1, r=shepmaster
Centril Apr 18, 2019
72494e8
Rollup merge of #60046 - euclio:missing-error-code-descriptions, r=es…
Centril Apr 18, 2019
ebec567
Rollup merge of #60056 - topecongiro:rustfmt-1.2.1, r=alexcrichton
Centril Apr 18, 2019
7dc08c0
Rollup merge of #60060 - mtak-:rtm-x86-feature, r=petrochenkov
Centril Apr 18, 2019
c6732f0
Rollup merge of #60064 - estebank:issue-59980, r=varkor
Centril Apr 18, 2019
d482e1d
Rollup merge of #60080 - nathankleyn:fix-issue-60068, r=Centril
Centril Apr 18, 2019
8ddc493
Rollup merge of #60082 - TimDiekmann:master, r=RalfJung
Centril Apr 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 14 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "annotate-snippets"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "ansi_term"
version = "0.11.0"
Expand Down Expand Up @@ -2246,7 +2254,7 @@ dependencies = [
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustfmt-nightly 1.2.0",
"rustfmt-nightly 1.2.1",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3038,8 +3046,9 @@ dependencies = [

[[package]]
name = "rustfmt-nightly"
version = "1.2.0"
version = "1.2.1"
dependencies = [
"annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -3049,6 +3058,7 @@ dependencies = [
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -3061,7 +3071,7 @@ dependencies = [
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode_categories 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3987,6 +3997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
"checksum ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd4c682378117e4186a492b2252b9537990e1617f44aed9788b9a1149de45477"
"checksum annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8bcdcd5b291ce85a78f2b9d082a8de9676c12b1840d386d67bc5eea6f9d2b4e"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arc-swap 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1025aeae2b664ca0ea726a89d574fe8f4e77dd712d443236ad1de00379450cf6"
"checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392"
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,11 @@ impl Step for Compiletest {
builder.add_rust_test_threads(&mut cmd);

if builder.config.sanitizers {
cmd.env("SANITIZER_SUPPORT", "1");
cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
}

if builder.config.profiler {
cmd.env("PROFILER_SUPPORT", "1");
cmd.env("RUSTC_PROFILER_SUPPORT", "1");
}

cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
Expand Down
26 changes: 26 additions & 0 deletions src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,16 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
})
}

#[inline]
fn nth_back(&mut self, n: usize) -> Option<(usize, <I as Iterator>::Item)> {
self.iter.nth_back(n).map(|a| {
let len = self.iter.len();
// Can safely add, `ExactSizeIterator` promises that the number of
// elements fits into a `usize`.
(self.count + len, a)
})
}

#[inline]
fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, mut fold: Fold) -> R where
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
Expand Down Expand Up @@ -1789,6 +1799,17 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
}
}

#[inline]
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
if self.done {
None
} else {
let nth = self.iter.nth_back(n);
self.done = nth.is_none();
nth
}
}

#[inline]
default fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
Expand Down Expand Up @@ -1877,6 +1898,11 @@ impl<I> DoubleEndedIterator for Fuse<I>
self.iter.next_back()
}

#[inline]
fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
self.iter.nth_back(n)
}

#[inline]
fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ impl<T> [T] {
}

/// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the
/// beginning of the slice.
/// end of the slice.
///
/// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the
/// slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved
Expand All @@ -849,7 +849,7 @@ impl<T> [T] {
///
/// See [`rchunks`] for a variant of this iterator that also returns the remainder as a smaller
/// chunk, and [`chunks_exact`] for the same iterator but starting at the beginning of the
/// slice of the slice.
/// slice.
///
/// # Panics
///
Expand Down Expand Up @@ -890,7 +890,7 @@ impl<T> [T] {
///
/// See [`rchunks_mut`] for a variant of this iterator that also returns the remainder as a
/// smaller chunk, and [`chunks_exact_mut`] for the same iterator but starting at the beginning
/// of the slice of the slice.
/// of the slice.
///
/// # Panics
///
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,11 @@ impl DoubleEndedIterator for Bytes<'_> {
self.0.next_back()
}

#[inline]
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
self.0.nth_back(n)
}

#[inline]
fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool
Expand Down
18 changes: 18 additions & 0 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,24 @@ fn test_iterator_enumerate_nth() {
assert_eq!(i, 3);
}

#[test]
fn test_iterator_enumerate_nth_back() {
let xs = [0, 1, 2, 3, 4, 5];
let mut it = xs.iter().enumerate();
while let Some((i, &x)) = it.nth_back(0) {
assert_eq!(i, x);
}

let mut it = xs.iter().enumerate();
while let Some((i, &x)) = it.nth_back(1) {
assert_eq!(i, x);
}

let (i, &x) = xs.iter().enumerate().nth_back(3).unwrap();
assert_eq!(i, x);
assert_eq!(i, 2);
}

#[test]
fn test_iterator_enumerate_count() {
let xs = [0, 1, 2, 3, 4, 5];
Expand Down
22 changes: 15 additions & 7 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4685,6 +4685,14 @@ impl<'a> LoweringContext<'a> {
Symbol::intern("try_trait")
].into()),
);
let try_span = self.sess.source_map().end_point(e.span);
let try_span = self.mark_span_with_reason(
CompilerDesugaringKind::QuestionMark,
try_span,
Some(vec![
Symbol::intern("try_trait")
].into()),
);

// `Try::into_result(<expr>)`
let discr = {
Expand Down Expand Up @@ -4729,14 +4737,14 @@ impl<'a> LoweringContext<'a> {
// return Try::from_error(From::from(err)),`
let err_arm = {
let err_ident = self.str_to_ident("err");
let (err_local, err_local_nid) = self.pat_ident(e.span, err_ident);
let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident);
let from_expr = {
let path = &["convert", "From", "from"];
let from = P(self.expr_std_path(
e.span, path, None, ThinVec::new()));
let err_expr = self.expr_ident(e.span, err_ident, err_local_nid);
try_span, path, None, ThinVec::new()));
let err_expr = self.expr_ident(try_span, err_ident, err_local_nid);

self.expr_call(e.span, from, hir_vec![err_expr])
self.expr_call(try_span, from, hir_vec![err_expr])
};
let from_err_expr =
self.wrap_in_try_constructor("from_error", from_expr, unstable_span);
Expand All @@ -4745,7 +4753,7 @@ impl<'a> LoweringContext<'a> {
let ret_expr = if let Some(catch_node) = catch_scope {
let target_id = Ok(self.lower_node_id(catch_node).hir_id);
P(self.expr(
e.span,
try_span,
hir::ExprKind::Break(
hir::Destination {
label: None,
Expand All @@ -4756,10 +4764,10 @@ impl<'a> LoweringContext<'a> {
thin_attrs,
))
} else {
P(self.expr(e.span, hir::ExprKind::Ret(Some(from_err_expr)), thin_attrs))
P(self.expr(try_span, hir::ExprKind::Ret(Some(from_err_expr)), thin_attrs))
};

let err_pat = self.pat_err(e.span, err_local);
let err_pat = self.pat_err(try_span, err_local);
self.arm(hir_vec![err_pat], ret_expr)
};

Expand Down
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"inject the given attribute in the crate"),
self_profile: bool = (false, parse_bool, [UNTRACKED],
"run the self profiler and output the raw event data"),
self_profile_events: Option<Vec<String>> = (None, parse_opt_comma_list, [UNTRACKED],
"specifies which kinds of events get recorded by the self profiler"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
"emits a section containing stack size metadata"),
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ fn build_session_(
) -> Session {
let self_profiler =
if sopts.debugging_opts.self_profile {
let profiler = SelfProfiler::new();
let profiler = SelfProfiler::new(&sopts.debugging_opts.self_profile_events);
match profiler {
Ok(profiler) => {
crate::ty::query::QueryName::register_with_profiler(&profiler);
Expand Down
12 changes: 12 additions & 0 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let OnUnimplementedNote { message, label, note }
= self.on_unimplemented_note(trait_ref, obligation);
let have_alt_message = message.is_some() || label.is_some();
let is_try = self.tcx.sess.source_map().span_to_snippet(span)
.map(|s| &s == "?")
.unwrap_or(false);
let is_from = format!("{}", trait_ref).starts_with("std::convert::From<");
let message = if is_try && is_from {
Some(format!(
"`?` couldn't convert the error to `{}`",
trait_ref.self_ty(),
))
} else {
message
};

let mut err = struct_span_err!(
self.tcx.sess,
Expand Down
Loading