Auto merge of #91350 - matthiaskrgr:rollup-nleabdj, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #91049 (Add a caveat to std::os::windows::fs::symlink_file)
 - #91281 (Add demonstration test for #91161)
 - #91327 (Delete an unreachable codepath from format_args implementation)
 - #91336 (Remove unused root_parent.)
 - #91349 (Accumulate all values of `-C remark` option)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-11-29 10:34:52 +00:00
commit 8b954910c5
9 changed files with 77 additions and 36 deletions

View file

@ -88,8 +88,8 @@ struct Context<'a, 'b> {
/// * Implicit argument resolution: `"{1:.0$} {2:.foo$} {1:.3$} {4:.0$}"`
/// * Name resolution: `"{1:.0$} {2:.5$} {1:.3$} {4:.0$}"`
/// * `count_positions` (in JSON): `{0: 0, 5: 1, 3: 2}`
/// * `count_args`: `vec![Exact(0), Exact(5), Exact(3)]`
count_args: Vec<Position>,
/// * `count_args`: `vec![0, 5, 3]`
count_args: Vec<usize>,
/// Relative slot numbers for count arguments.
count_positions: FxHashMap<usize, usize>,
/// Number of count slots assigned.
@ -513,7 +513,7 @@ impl<'a, 'b> Context<'a, 'b> {
if let Entry::Vacant(e) = self.count_positions.entry(arg) {
let i = self.count_positions_count;
e.insert(i);
self.count_args.push(Exact(arg));
self.count_args.push(arg);
self.count_positions_count += 1;
}
}
@ -774,11 +774,7 @@ impl<'a, 'b> Context<'a, 'b> {
// (the span is otherwise unavailable in MIR)
heads.push(self.ecx.expr_addr_of(e.span.with_ctxt(self.macsp.ctxt()), e));
}
for pos in self.count_args {
let index = match pos {
Exact(i) => i,
_ => panic!("should never happen"),
};
for index in self.count_args {
let span = spans_pos[index];
args.push(Context::format_arg(self.ecx, self.macsp, span, &Count, index));
}

View file

@ -7,13 +7,12 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
use crate::ty::TyCtxt;
use rustc_hir as hir;
use rustc_hir::Node;
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir as hir;
use rustc_hir::Node;
use rustc_macros::HashStable;
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
use rustc_span::{Span, DUMMY_SP};
use std::fmt;
@ -210,11 +209,6 @@ pub struct ScopeTree {
/// If not empty, this body is the root of this region hierarchy.
pub root_body: Option<hir::HirId>,
/// The parent of the root body owner, if the latter is an
/// an associated const or method, as impls/traits can also
/// have lifetime parameters free in this body.
pub root_parent: Option<hir::HirId>,
/// Maps from a scope ID to the enclosing scope id;
/// this is usually corresponding to the lexical nesting, though
/// in the case of closures the parent scope is the innermost
@ -445,7 +439,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let ScopeTree {
root_body,
root_parent,
ref body_expr_count,
ref parent_map,
ref var_map,
@ -455,8 +448,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
} = *self;
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
root_body.hash_stable(hcx, hasher);
root_parent.hash_stable(hcx, hasher);
root_body.hash_stable(hcx, hasher)
});
body_expr_count.hash_stable(hcx, hasher);

View file

@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{Arm, Block, Expr, Local, Node, Pat, PatKind, Stmt};
use rustc_hir::{Arm, Block, Expr, Local, Pat, PatKind, Stmt};
use rustc_index::vec::Idx;
use rustc_middle::middle::region::*;
use rustc_middle::ty::query::Providers;
@ -837,19 +837,7 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
let body = tcx.hir().body(body_id);
visitor.scope_tree.root_body = Some(body.value.hir_id);
// If the item is an associated const or a method,
// record its impl/trait parent, as it can also have
// lifetime parameters free in this body.
match tcx.hir().get(id) {
Node::ImplItem(_) | Node::TraitItem(_) => {
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));
}
_ => {}
}
visitor.visit_body(body);
visitor.scope_tree
} else {
ScopeTree::default()

View file

@ -833,6 +833,13 @@ impl Passes {
Passes::All => false,
}
}
pub fn extend(&mut self, passes: impl IntoIterator<Item = String>) {
match *self {
Passes::Some(ref mut v) => v.extend(passes),
Passes::All => {}
}
}
}
pub const fn default_lib_output() -> CrateType {

View file

@ -567,7 +567,7 @@ mod parse {
v => {
let mut passes = vec![];
if parse_list(&mut passes, v) {
*slot = Passes::Some(passes);
slot.extend(passes);
true
} else {
false

View file

@ -543,6 +543,16 @@ impl FileTypeExt for fs::FileType {
/// Ok(())
/// }
/// ```
///
/// # Limitations
///
/// Windows treats symlink creation as a [privileged action][symlink-security],
/// therefore this function is likely to fail unless the user makes changes to
/// their system to permit symlink creation. Users can try enabling Developer
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
/// the process as an administrator.
///
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
#[stable(feature = "symlink", since = "1.1.0")]
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), false)
@ -572,6 +582,16 @@ pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io:
/// Ok(())
/// }
/// ```
///
/// # Limitations
///
/// Windows treats symlink creation as a [privileged action][symlink-security],
/// therefore this function is likely to fail unless the user makes changes to
/// their system to permit symlink creation. Users can try enabling Developer
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
/// the process as an administrator.
///
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
#[stable(feature = "symlink", since = "1.1.0")]
pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), true)

View file

@ -1,10 +1,19 @@
// build-pass
// ignore-pass
// no-system-llvm
// revisions: all inline
// revisions: all inline merge1 merge2
// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2
//
// Check that remarks can be enabled individually or with "all":
//
// [all] compile-flags: -Cremark=all
// [inline] compile-flags: -Cremark=inline
//
// Check that values of -Cremark flag are accumulated:
//
// [merge1] compile-flags: -Cremark=all -Cremark=giraffe
// [merge2] compile-flags: -Cremark=inline -Cremark=giraffe
//
// error-pattern: inline: f not inlined into g
// dont-check-compiler-stderr

View file

@ -30,3 +30,15 @@ pub enum VariantNonExhaustive {
pub enum NonExhaustiveSingleVariant {
A(bool),
}
#[repr(u8)]
pub enum FieldLessWithNonExhaustiveVariant {
A,
B,
#[non_exhaustive]
C,
}
impl Default for FieldLessWithNonExhaustiveVariant {
fn default() -> Self { Self::A }
}

View file

@ -0,0 +1,17 @@
// aux-build:enums.rs
// run-pass
extern crate enums;
use enums::FieldLessWithNonExhaustiveVariant;
fn main() {
let e = FieldLessWithNonExhaustiveVariant::default();
// FIXME: https://github.com/rust-lang/rust/issues/91161
// This `as` cast *should* be an error, since it would fail
// if the non-exhaustive variant got fields. But today it
// doesn't. The fix for that will update this test to
// show an error (and not be run-pass any more).
let d = e as u8;
assert_eq!(d, 0);
}