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 #84718

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3090b01
Use flex more consistently.
Apr 22, 2021
5bd3187
Point out that behavior might be switched on 2015 and 2018 editions t…
est31 Apr 26, 2021
12642d9
Add a paragraph with possible alternatives on older editions
est31 Apr 27, 2021
aeb67ad
Drop branching blocks with same span as expanded macro
richkadel Apr 26, 2021
2c4fc3e
More improvements to macro coverage
richkadel Apr 26, 2021
bbf6bce
spanview debug output caused ICE when a function had no body
richkadel Apr 25, 2021
fd85fd3
addressed review feedback
richkadel Apr 28, 2021
31ae3b2
Add HAS_RE_LATE_BOUND if there are bound vars
jackh726 Apr 28, 2021
5f82e22
Don't rebind in transitive_bounds_that_define_assoc_type
jackh726 Apr 28, 2021
3e016a7
Minor grammar tweaks for readability
Ben-Lichtman Apr 29, 2021
8c04695
Remove unnecessary CSS rules for search results
GuillaumeGomez Apr 29, 2021
a20831e
Remove unneeded bottom margin on search results
GuillaumeGomez Apr 29, 2021
a352336
Ignore doctests in bootstrap
est31 Apr 29, 2021
da6261e
make feature recommendations optional
lcnr Apr 29, 2021
20b569f
Drop alias `reduce` for `fold` - we have a `reduce` function
joshtriplett Apr 29, 2021
16ff6c8
Fix labels for regression issue template
camelid Apr 29, 2021
2fb2f0b
Add std::os::unix::fs::chroot to change the root directory of the cur…
joshtriplett Apr 29, 2021
6d18bcf
Rollup merge of #84451 - torhovland:flex, r=jsha
jackh726 Apr 29, 2021
49effb0
Rollup merge of #84582 - richkadel:issue-84561, r=tmandry
jackh726 Apr 29, 2021
f82e345
Rollup merge of #84590 - est31:array_into_iter, r=nikomatsakis
jackh726 Apr 29, 2021
b88ea41
Rollup merge of #84682 - jackh726:transitive_bounds_rebind, r=nikomat…
jackh726 Apr 29, 2021
9274e3c
Rollup merge of #84683 - Ben-Lichtman:grammar, r=jonas-schievink
jackh726 Apr 29, 2021
dbaefd3
Rollup merge of #84688 - GuillaumeGomez:remove-unnecessary-css-for-se…
jackh726 Apr 29, 2021
d2c6ba2
Rollup merge of #84690 - GuillaumeGomez:unneeded-bottom-margin-search…
jackh726 Apr 29, 2021
6f279a3
Rollup merge of #84705 - lcnr:const_generics-rec, r=joshtriplett
jackh726 Apr 29, 2021
39f0fdc
Rollup merge of #84706 - joshtriplett:reduce-aliases, r=m-ou-se
jackh726 Apr 29, 2021
7702e48
Rollup merge of #84713 - camelid:fix-regression-issue-template, r=Mar…
jackh726 Apr 29, 2021
ac134c3
Rollup merge of #84716 - joshtriplett:chroot, r=dtolnay
jackh726 Apr 29, 2021
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/regression.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Regression
about: Report something that unexpectedly changed between Rust versions.
labels: C-bug regression-untriaged
labels: C-bug, regression-untriaged
---
<!--
Thank you for filing a regression report! 🐛 A regression is something that changed between versions of Rust but was not supposed to.
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
Some(assoc_name),
));
for (super_predicate, _) in super_predicates.predicates {
let bound_predicate = super_predicate.kind();
let subst_predicate = super_predicate
.subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder()));
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() {
stack.push(binder.value);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ impl FlagComputation {
{
let mut computation = FlagComputation::new();

if !value.bound_vars().is_empty() {
computation.flags = computation.flags | TypeFlags::HAS_RE_LATE_BOUND;
}

f(&mut computation, value.skip_binder());

self.add_flags(computation.flags);
Expand Down
209 changes: 176 additions & 33 deletions compiler/rustc_mir/src/transform/coverage/spans.rs

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions compiler/rustc_mir/src/transform/coverage/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//! This crate hosts a selection of "unit tests" for components of the `InstrumentCoverage` MIR
//! pass.
//!
//! ```shell
//! ./x.py test --keep-stage 1 compiler/rustc_mir --test-args '--show-output coverage'
//! ```
//!
//! The tests construct a few "mock" objects, as needed, to support the `InstrumentCoverage`
//! functions and algorithms. Mocked objects include instances of `mir::Body`; including
//! `Terminator`s of various `kind`s, and `Span` objects. Some functions used by or used on
Expand Down Expand Up @@ -679,10 +683,15 @@ fn test_make_bcb_counters() {
let mut basic_coverage_blocks = graph::CoverageGraph::from_mir(&mir_body);
let mut coverage_spans = Vec::new();
for (bcb, data) in basic_coverage_blocks.iter_enumerated() {
if let Some(span) =
if let Some((span, expn_span)) =
spans::filtered_terminator_span(data.terminator(&mir_body), body_span)
{
coverage_spans.push(spans::CoverageSpan::for_terminator(span, bcb, data.last_bb()));
coverage_spans.push(spans::CoverageSpan::for_terminator(
span,
expn_span,
bcb,
data.last_bb(),
));
}
}
let mut coverage_counters = counters::CoverageCounters::new(0);
Expand Down
19 changes: 10 additions & 9 deletions compiler/rustc_mir/src/util/spanview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ where
W: Write,
{
let def_id = body.source.def_id();
let body_span = hir_body(tcx, def_id).value.span;
let hir_body = hir_body(tcx, def_id);
if hir_body.is_none() {
return Ok(());
}
let body_span = hir_body.unwrap().value.span;
let mut span_viewables = Vec::new();
for (bb, data) in body.basic_blocks().iter_enumerated() {
match spanview {
Expand Down Expand Up @@ -664,19 +668,16 @@ fn fn_span<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Span {
let hir_id =
tcx.hir().local_def_id_to_hir_id(def_id.as_local().expect("expected DefId is local"));
let fn_decl_span = tcx.hir().span(hir_id);
let body_span = hir_body(tcx, def_id).value.span;
if fn_decl_span.ctxt() == body_span.ctxt() {
fn_decl_span.to(body_span)
if let Some(body_span) = hir_body(tcx, def_id).map(|hir_body| hir_body.value.span) {
if fn_decl_span.ctxt() == body_span.ctxt() { fn_decl_span.to(body_span) } else { body_span }
} else {
// This probably occurs for functions defined via macros
body_span
fn_decl_span
}
}

fn hir_body<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx rustc_hir::Body<'tcx> {
fn hir_body<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<&'tcx rustc_hir::Body<'tcx>> {
let hir_node = tcx.hir().get_if_local(def_id).expect("expected DefId is local");
let fn_body_id = hir::map::associated_body(hir_node).expect("HIR node is a function with body");
tcx.hir().body(fn_body_id)
hir::map::associated_body(hir_node).map(|fn_body_id| tcx.hir().body(fn_body_id))
}

fn escape_html(s: &str) -> String {
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ impl<'a> Resolver<'a> {
name
));
}
err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions");

if self.session.is_nightly_build() {
err.help(
"use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \
to allow generic const expressions"
);
}

err
}
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
),
)
} else {
tcx.sess
.struct_span_err(
hir_ty.span,
&format!(
"{} is forbidden as the type of a const generic parameter",
unsupported_type
),
)
.note("the only supported types are integers, `bool` and `char`")
.help("more complex types are supported with `#![feature(const_generics)]`")
.emit()
let mut err = tcx.sess.struct_span_err(
hir_ty.span,
&format!(
"{} is forbidden as the type of a const generic parameter",
unsupported_type
),
);
err.note("the only supported types are integers, `bool` and `char`");
if tcx.sess.is_nightly_build() {
err.help(
"more complex types are supported with `#![feature(const_generics)]`",
);
}
err.emit()
}
};

Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<K, V> LeafNode<K, V> {

/// The underlying representation of internal nodes. As with `LeafNode`s, these should be hidden
/// behind `BoxedNode`s to prevent dropping uninitialized keys and values. Any pointer to an
/// `InternalNode` can be directly casted to a pointer to the underlying `LeafNode` portion of the
/// `InternalNode` can be directly cast to a pointer to the underlying `LeafNode` portion of the
/// node, allowing code to act on leaf and internal nodes generically without having to even check
/// which of the two a pointer is pointing at. This property is enabled by the use of `repr(C)`.
#[repr(C)]
Expand Down Expand Up @@ -408,7 +408,7 @@ impl<K, V> NodeRef<marker::Dying, K, V, marker::LeafOrInternal> {
}

impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
/// Temporarily takes out another, mutable reference to the same node. Beware, as
/// Temporarily takes out another mutable reference to the same node. Beware, as
/// this method is very dangerous, doubly so since it may not immediately appear
/// dangerous.
///
Expand Down Expand Up @@ -759,15 +759,15 @@ impl<BorrowType, K, V, NodeType, HandleType> PartialEq
impl<BorrowType, K, V, NodeType, HandleType>
Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
{
/// Temporarily takes out another, immutable handle on the same location.
/// Temporarily takes out another immutable handle on the same location.
pub fn reborrow(&self) -> Handle<NodeRef<marker::Immut<'_>, K, V, NodeType>, HandleType> {
// We can't use Handle::new_kv or Handle::new_edge because we don't know our type
Handle { node: self.node.reborrow(), idx: self.idx, _marker: PhantomData }
}
}

impl<'a, K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, HandleType> {
/// Temporarily takes out another, mutable handle on the same location. Beware, as
/// Temporarily takes out another mutable handle on the same location. Beware, as
/// this method is very dangerous, doubly so since it may not immediately appear
/// dangerous.
///
Expand Down
1 change: 0 additions & 1 deletion library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,6 @@ pub trait Iterator {
/// ```
///
/// [`reduce()`]: Iterator::reduce
#[doc(alias = "reduce")]
#[doc(alias = "inject")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
49 changes: 47 additions & 2 deletions library/std/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,10 @@ mod prim_pointer {}
/// # Editions
///
/// Prior to Rust 1.53, arrays did not implement `IntoIterator` by value, so the method call
/// `array.into_iter()` auto-referenced into a slice iterator. That behavior is preserved in the
/// 2015 and 2018 editions of Rust for compatability, ignoring `IntoIterator` by value.
/// `array.into_iter()` auto-referenced into a slice iterator. Right now, the old behavior
/// is preserved in the 2015 and 2018 editions of Rust for compatibility, ignoring
/// `IntoIterator` by value. In the future, the behavior on the 2015 and 2018 edition
/// might be made consistent to the behavior of later editions.
///
#[cfg_attr(bootstrap, doc = "```rust,edition2018,ignore")]
#[cfg_attr(not(bootstrap), doc = "```rust,edition2018")]
Expand Down Expand Up @@ -601,6 +603,49 @@ mod prim_pointer {}
/// }
/// ```
///
/// Future language versions might start treating the `array.into_iter()`
/// syntax on editions 2015 and 2018 the same as on edition 2021. So code using
/// those older editions should still be written with this change in mind, to
/// prevent breakage in the future. The safest way to accomplish this is to
/// avoid the `into_iter` syntax on those editions. If an edition update is not
/// viable/desired, there are multiple alternatives:
/// * use `iter`, equivalent to the old behavior, creating references
/// * use [`array::IntoIter`], equivalent to the post-2021 behavior (Rust 1.51+)
/// * replace `for ... in array.into_iter() {` with `for ... in array {`,
/// equivalent to the post-2021 behavior (Rust 1.53+)
///
#[cfg_attr(bootstrap, doc = "```rust,edition2018,ignore")]
#[cfg_attr(not(bootstrap), doc = "```rust,edition2018")]
/// use std::array::IntoIter;
///
/// let array: [i32; 3] = [0; 3];
///
/// // This iterates by reference:
/// for item in array.iter() {
/// let x: &i32 = item;
/// println!("{}", x);
/// }
///
/// // This iterates by value:
/// for item in IntoIter::new(array) {
/// let x: i32 = item;
/// println!("{}", x);
/// }
///
/// // This iterates by value:
/// for item in array {
/// let x: i32 = item;
/// println!("{}", x);
/// }
///
/// // IntoIter can also start a chain.
/// // This iterates by value:
/// for item in IntoIter::new(array).enumerate() {
/// let (i, x): (usize, i32) = item;
/// println!("array[{}] = {}", i, x);
/// }
/// ```
///
/// [slice]: prim@slice
/// [`Debug`]: fmt::Debug
/// [`Hash`]: hash::Hash
Expand Down
24 changes: 24 additions & 0 deletions library/std/src/sys/unix/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,3 +884,27 @@ impl DirBuilderExt for fs::DirBuilder {
self
}
}

/// Change the root directory of the current process to the specified path.
///
/// This typically requires privileges, such as root or a specific capability.
///
/// This does not change the current working directory; you should call
/// [`std::env::set_current_dir`] afterwards.
///
/// # Examples
///
/// ```no_run
/// use std::os::unix::fs;
///
/// fn main() -> std::io::Result<()> {
/// fs::chroot("/sandbox")?;
/// std::env::set_current_dir("/")?;
/// // continue working in sandbox
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_chroot", issue = "84715")]
pub fn chroot<P: AsRef<Path>>(dir: P) -> io::Result<()> {
sys::fs::chroot(dir.as_ref())
}
6 changes: 6 additions & 0 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,3 +1328,9 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
})?;
Ok(bytes_copied as u64)
}

pub fn chroot(dir: &Path) -> io::Result<()> {
let dir = cstr(dir)?;
cvt(unsafe { libc::chroot(dir.as_ptr()) })?;
Ok(())
}
30 changes: 8 additions & 22 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
}
h1.fqn {
display: flex;
width: 100%;
border-bottom: 1px dashed;
margin-top: 0;

/* workaround to keep flex from breaking below 700 px width due to the float: right on the nav
above the h1 */
padding-left: 1px;
}
h1.fqn > .in-band > a:hover {
text-decoration: underline;
Expand Down Expand Up @@ -385,17 +388,9 @@ nav.sub {
position: relative;
}

#results {
position: absolute;
right: 0;
left: 0;
overflow: auto;
}

#results > table {
width: 100%;
table-layout: fixed;
margin-bottom: 40px;
}

.content pre.line-numbers {
Expand Down Expand Up @@ -453,20 +448,14 @@ nav.sub {
}

.content .out-of-band {
float: right;
flex-grow: 0;
text-align: right;
font-size: 23px;
margin: 0px;
padding: 0px;
padding: 0 0 0 12px;
font-weight: normal;
}

h1.fqn > .out-of-band {
float: unset;
flex: 1;
text-align: right;
margin-left: 8px;
}

h3.impl > .out-of-band {
font-size: 21px;
}
Expand All @@ -486,6 +475,7 @@ h4 > code, h3 > code, .invisible > code {
}

.content .in-band {
flex-grow: 1;
margin: 0px;
padding: 0px;
}
Expand Down Expand Up @@ -1484,10 +1474,6 @@ h4 > .notable-traits {
display: none !important;
}

h1.fqn {
overflow: initial;
}

.theme-picker {
left: 10px;
top: 54px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
1| |#![allow(unused_assignments, unused_variables, dead_code)]
2| |
3| 1|fn main() {
4| | // Initialize test constants in a way that cannot be determined at compile time, to ensure
5| | // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
6| | // dependent conditions.
4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
6| 1| // dependent conditions.
7| 1| let is_true = std::env::args().len() == 1;
8| 1|
9| 1| let mut countdown = 0;
Expand Down
Loading