Skip to content

Commit 8b95491

Browse files
committed
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
2 parents 44723c5 + e15e0ba commit 8b95491

File tree

9 files changed

+77
-36
lines changed

9 files changed

+77
-36
lines changed

compiler/rustc_builtin_macros/src/format.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ struct Context<'a, 'b> {
8888
/// * Implicit argument resolution: `"{1:.0$} {2:.foo$} {1:.3$} {4:.0$}"`
8989
/// * Name resolution: `"{1:.0$} {2:.5$} {1:.3$} {4:.0$}"`
9090
/// * `count_positions` (in JSON): `{0: 0, 5: 1, 3: 2}`
91-
/// * `count_args`: `vec![Exact(0), Exact(5), Exact(3)]`
92-
count_args: Vec<Position>,
91+
/// * `count_args`: `vec![0, 5, 3]`
92+
count_args: Vec<usize>,
9393
/// Relative slot numbers for count arguments.
9494
count_positions: FxHashMap<usize, usize>,
9595
/// Number of count slots assigned.
@@ -513,7 +513,7 @@ impl<'a, 'b> Context<'a, 'b> {
513513
if let Entry::Vacant(e) = self.count_positions.entry(arg) {
514514
let i = self.count_positions_count;
515515
e.insert(i);
516-
self.count_args.push(Exact(arg));
516+
self.count_args.push(arg);
517517
self.count_positions_count += 1;
518518
}
519519
}
@@ -774,11 +774,7 @@ impl<'a, 'b> Context<'a, 'b> {
774774
// (the span is otherwise unavailable in MIR)
775775
heads.push(self.ecx.expr_addr_of(e.span.with_ctxt(self.macsp.ctxt()), e));
776776
}
777-
for pos in self.count_args {
778-
let index = match pos {
779-
Exact(i) => i,
780-
_ => panic!("should never happen"),
781-
};
777+
for index in self.count_args {
782778
let span = spans_pos[index];
783779
args.push(Context::format_arg(self.ecx, self.macsp, span, &Count, index));
784780
}

compiler/rustc_middle/src/middle/region.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
88
99
use crate::ty::TyCtxt;
10-
use rustc_hir as hir;
11-
use rustc_hir::Node;
12-
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
13-
1410
use rustc_data_structures::fx::FxHashMap;
1511
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
12+
use rustc_hir as hir;
13+
use rustc_hir::Node;
1614
use rustc_macros::HashStable;
15+
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
1716
use rustc_span::{Span, DUMMY_SP};
1817

1918
use std::fmt;
@@ -210,11 +209,6 @@ pub struct ScopeTree {
210209
/// If not empty, this body is the root of this region hierarchy.
211210
pub root_body: Option<hir::HirId>,
212211

213-
/// The parent of the root body owner, if the latter is an
214-
/// an associated const or method, as impls/traits can also
215-
/// have lifetime parameters free in this body.
216-
pub root_parent: Option<hir::HirId>,
217-
218212
/// Maps from a scope ID to the enclosing scope id;
219213
/// this is usually corresponding to the lexical nesting, though
220214
/// in the case of closures the parent scope is the innermost
@@ -445,7 +439,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
445439
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
446440
let ScopeTree {
447441
root_body,
448-
root_parent,
449442
ref body_expr_count,
450443
ref parent_map,
451444
ref var_map,
@@ -455,8 +448,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
455448
} = *self;
456449

457450
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
458-
root_body.hash_stable(hcx, hasher);
459-
root_parent.hash_stable(hcx, hasher);
451+
root_body.hash_stable(hcx, hasher)
460452
});
461453

462454
body_expr_count.hash_stable(hcx, hasher);

compiler/rustc_passes/src/region.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
1111
use rustc_hir as hir;
1212
use rustc_hir::def_id::DefId;
1313
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
14-
use rustc_hir::{Arm, Block, Expr, Local, Node, Pat, PatKind, Stmt};
14+
use rustc_hir::{Arm, Block, Expr, Local, Pat, PatKind, Stmt};
1515
use rustc_index::vec::Idx;
1616
use rustc_middle::middle::region::*;
1717
use rustc_middle::ty::query::Providers;
@@ -837,19 +837,7 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
837837

838838
let body = tcx.hir().body(body_id);
839839
visitor.scope_tree.root_body = Some(body.value.hir_id);
840-
841-
// If the item is an associated const or a method,
842-
// record its impl/trait parent, as it can also have
843-
// lifetime parameters free in this body.
844-
match tcx.hir().get(id) {
845-
Node::ImplItem(_) | Node::TraitItem(_) => {
846-
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));
847-
}
848-
_ => {}
849-
}
850-
851840
visitor.visit_body(body);
852-
853841
visitor.scope_tree
854842
} else {
855843
ScopeTree::default()

compiler/rustc_session/src/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,13 @@ impl Passes {
833833
Passes::All => false,
834834
}
835835
}
836+
837+
pub fn extend(&mut self, passes: impl IntoIterator<Item = String>) {
838+
match *self {
839+
Passes::Some(ref mut v) => v.extend(passes),
840+
Passes::All => {}
841+
}
842+
}
836843
}
837844

838845
pub const fn default_lib_output() -> CrateType {

compiler/rustc_session/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ mod parse {
567567
v => {
568568
let mut passes = vec![];
569569
if parse_list(&mut passes, v) {
570-
*slot = Passes::Some(passes);
570+
slot.extend(passes);
571571
true
572572
} else {
573573
false

library/std/src/os/windows/fs.rs

+20
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,16 @@ impl FileTypeExt for fs::FileType {
543543
/// Ok(())
544544
/// }
545545
/// ```
546+
///
547+
/// # Limitations
548+
///
549+
/// Windows treats symlink creation as a [privileged action][symlink-security],
550+
/// therefore this function is likely to fail unless the user makes changes to
551+
/// their system to permit symlink creation. Users can try enabling Developer
552+
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
553+
/// the process as an administrator.
554+
///
555+
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
546556
#[stable(feature = "symlink", since = "1.1.0")]
547557
pub fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
548558
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:
572582
/// Ok(())
573583
/// }
574584
/// ```
585+
///
586+
/// # Limitations
587+
///
588+
/// Windows treats symlink creation as a [privileged action][symlink-security],
589+
/// therefore this function is likely to fail unless the user makes changes to
590+
/// their system to permit symlink creation. Users can try enabling Developer
591+
/// Mode, granting the `SeCreateSymbolicLinkPrivilege` privilege, or running
592+
/// the process as an administrator.
593+
///
594+
/// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
575595
#[stable(feature = "symlink", since = "1.1.0")]
576596
pub fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
577597
sys::fs::symlink_inner(original.as_ref(), link.as_ref(), true)

src/test/ui/optimization-remark.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
// build-pass
22
// ignore-pass
33
// no-system-llvm
4-
// revisions: all inline
5-
// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2
4+
// revisions: all inline merge1 merge2
5+
// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2
6+
//
7+
// Check that remarks can be enabled individually or with "all":
8+
//
69
// [all] compile-flags: -Cremark=all
710
// [inline] compile-flags: -Cremark=inline
11+
//
12+
// Check that values of -Cremark flag are accumulated:
13+
//
14+
// [merge1] compile-flags: -Cremark=all -Cremark=giraffe
15+
// [merge2] compile-flags: -Cremark=inline -Cremark=giraffe
16+
//
817
// error-pattern: inline: f not inlined into g
918
// dont-check-compiler-stderr
1019

src/test/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs

+12
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ pub enum VariantNonExhaustive {
3030
pub enum NonExhaustiveSingleVariant {
3131
A(bool),
3232
}
33+
34+
#[repr(u8)]
35+
pub enum FieldLessWithNonExhaustiveVariant {
36+
A,
37+
B,
38+
#[non_exhaustive]
39+
C,
40+
}
41+
42+
impl Default for FieldLessWithNonExhaustiveVariant {
43+
fn default() -> Self { Self::A }
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// aux-build:enums.rs
2+
// run-pass
3+
4+
extern crate enums;
5+
6+
use enums::FieldLessWithNonExhaustiveVariant;
7+
8+
fn main() {
9+
let e = FieldLessWithNonExhaustiveVariant::default();
10+
// FIXME: https://github.com/rust-lang/rust/issues/91161
11+
// This `as` cast *should* be an error, since it would fail
12+
// if the non-exhaustive variant got fields. But today it
13+
// doesn't. The fix for that will update this test to
14+
// show an error (and not be run-pass any more).
15+
let d = e as u8;
16+
assert_eq!(d, 0);
17+
}

0 commit comments

Comments
 (0)