diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index 70e125d688787..62a55c0e49ed0 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -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, + /// * `count_args`: `vec![0, 5, 3]` + count_args: Vec, /// Relative slot numbers for count arguments. count_positions: FxHashMap, /// 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)); } diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index 605e0bc2e63ef..39ca41c92ff75 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -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, - /// 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, - /// 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> 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> 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); diff --git a/compiler/rustc_passes/src/region.rs b/compiler/rustc_passes/src/region.rs index 6a8feb041da19..ae423070392e1 100644 --- a/compiler/rustc_passes/src/region.rs +++ b/compiler/rustc_passes/src/region.rs @@ -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() diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ab3c122053c5e..16b68d95858b8 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -833,6 +833,13 @@ impl Passes { Passes::All => false, } } + + pub fn extend(&mut self, passes: impl IntoIterator) { + match *self { + Passes::Some(ref mut v) => v.extend(passes), + Passes::All => {} + } + } } pub const fn default_lib_output() -> CrateType { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 4165e750df50f..779f29e3dfedf 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -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 diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs index be35ab0ca1e66..31d1e3c1e42ee 100644 --- a/library/std/src/os/windows/fs.rs +++ b/library/std/src/os/windows/fs.rs @@ -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, Q: AsRef>(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, Q: AsRef>(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, Q: AsRef>(original: P, link: Q) -> io::Result<()> { sys::fs::symlink_inner(original.as_ref(), link.as_ref(), true) diff --git a/src/test/ui/optimization-remark.rs b/src/test/ui/optimization-remark.rs index 7aedb09928b64..36549cbc554bf 100644 --- a/src/test/ui/optimization-remark.rs +++ b/src/test/ui/optimization-remark.rs @@ -1,10 +1,19 @@ // build-pass // ignore-pass // no-system-llvm -// revisions: all inline -// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 +// 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 diff --git a/src/test/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs b/src/test/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs index 0098f087d10f8..cb2b585ab96a8 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs @@ -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 } +} diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs new file mode 100644 index 0000000000000..d9657bac77685 --- /dev/null +++ b/src/test/ui/rfc-2008-non-exhaustive/enum-as-cast.rs @@ -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); +}