From 321d90e1d659c502ad633575866e6d972cf0cc5e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 29 Feb 2020 04:34:50 +0900 Subject: [PATCH 01/12] Remove the `no_debug` feature --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 4 ---- src/librustc_codegen_llvm/debuginfo/mod.rs | 9 +-------- src/librustc_feature/active.rs | 3 --- src/librustc_feature/builtin_attrs.rs | 10 ---------- src/librustc_feature/removed.rs | 2 ++ src/librustc_typeck/collect.rs | 2 -- src/test/ui/lint/suggestions.rs | 4 ---- 7 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 3916653eb1d76..b6c2b141bd9bf 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -2269,10 +2269,6 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global let tcx = cx.tcx; let attrs = tcx.codegen_fn_attrs(def_id); - if attrs.flags.contains(CodegenFnAttrFlags::NO_DEBUG) { - return; - } - let no_mangle = attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE); // We may want to remove the namespace scope if we're in an extern block (see // https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952). diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 6515d5e3bec7f..a68441f14cb9d 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -12,7 +12,6 @@ use crate::llvm; use crate::llvm::debuginfo::{ DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DISPFlags, DIScope, DIType, DIVariable, }; -use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc::ty::subst::{GenericArgKind, SubstsRef}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; @@ -22,7 +21,7 @@ use crate::common::CodegenCx; use crate::value::Value; use rustc::mir; use rustc::session::config::{self, DebugInfo}; -use rustc::ty::{self, Instance, InstanceDef, ParamEnv, Ty}; +use rustc::ty::{self, Instance, ParamEnv, Ty}; use rustc_codegen_ssa::debuginfo::type_names; use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -241,12 +240,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { return None; } - if let InstanceDef::Item(def_id) = instance.def { - if self.tcx().codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NO_DEBUG) { - return None; - } - } - let span = mir.span; // This can be the case for functions inlined from another crate diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index 0082f4f1a6e89..c5bffd4a41384 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -289,9 +289,6 @@ declare_features! ( /// Permits specifying whether a function should permit unwinding or abort on unwind. (active, unwind_attributes, "1.4.0", Some(58760), None), - /// Allows `#[no_debug]`. - (active, no_debug, "1.5.0", Some(29721), None), - /// Allows attributes on expressions and non-item statements. (active, stmt_expr_attributes, "1.6.0", Some(15701), None), diff --git a/src/librustc_feature/builtin_attrs.rs b/src/librustc_feature/builtin_attrs.rs index e2e061c185c03..735cd226b0625 100644 --- a/src/librustc_feature/builtin_attrs.rs +++ b/src/librustc_feature/builtin_attrs.rs @@ -503,16 +503,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ cfg_fn!(rustc_attrs), ), ), - ( - sym::no_debug, Whitelisted, template!(Word), - Gated( - Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721", None), - sym::no_debug, - "the `#[no_debug]` attribute was an experimental feature that has been \ - deprecated due to lack of demand", - cfg_fn!(no_debug) - ) - ), gated!( // Used in resolve: prelude_import, Whitelisted, template!(Word), diff --git a/src/librustc_feature/removed.rs b/src/librustc_feature/removed.rs index e6ea093fe89c7..4e348054fbd4b 100644 --- a/src/librustc_feature/removed.rs +++ b/src/librustc_feature/removed.rs @@ -111,6 +111,8 @@ declare_features! ( /// Allows overlapping impls of marker traits. (removed, overlapping_marker_traits, "1.42.0", Some(29864), None, Some("removed in favor of `#![feature(marker_trait_attr)]`")), + /// Allows `#[no_debug]`. + (removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")), // ------------------------------------------------------------------------- // feature-group-end: removed features // ------------------------------------------------------------------------- diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2dad3d1d6d708..87179e2b69d19 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2341,8 +2341,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE; } else if attr.check_name(sym::rustc_std_internal_symbol) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL; - } else if attr.check_name(sym::no_debug) { - codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_DEBUG; } else if attr.check_name(sym::used) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED; } else if attr.check_name(sym::thread_local) { diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index 29297d08dcac4..518b5f211e5da 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -1,7 +1,6 @@ // ignore-tidy-tab #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 -#![feature(no_debug)] #[no_mangle] const DISCOVERY: usize = 1; //~^ ERROR const items should never be `#[no_mangle]` @@ -39,9 +38,6 @@ struct Equinox { warp_factor: f32, } -#[no_debug] // should suggest removal of deprecated attribute -//~^ WARN deprecated -//~| HELP remove this attribute fn main() { while true { //~^ WARN denote infinite loops From 45a30cdf1d2109655ff02683b6a6e41255cbeebe Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 29 Feb 2020 04:58:09 +0900 Subject: [PATCH 02/12] Update tests --- src/test/debuginfo/no-debug-attribute.rs | 37 ------------------- .../feature-gates/feature-gate-no-debug-2.rs | 5 --- .../feature-gate-no-debug-2.stderr | 14 ------- .../ui/feature-gates/feature-gate-no-debug.rs | 4 -- .../feature-gate-no-debug.stderr | 12 ------ src/test/ui/lint/suggestions.stderr | 30 ++++++--------- 6 files changed, 11 insertions(+), 91 deletions(-) delete mode 100644 src/test/debuginfo/no-debug-attribute.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-no-debug-2.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-no-debug-2.stderr delete mode 100644 src/test/ui/feature-gates/feature-gate-no-debug.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-no-debug.stderr diff --git a/src/test/debuginfo/no-debug-attribute.rs b/src/test/debuginfo/no-debug-attribute.rs deleted file mode 100644 index db9ac4af629c9..0000000000000 --- a/src/test/debuginfo/no-debug-attribute.rs +++ /dev/null @@ -1,37 +0,0 @@ -// ignore-lldb - -// compile-flags:-g - -// gdb-command:run - -// gdb-command:info locals -// gdb-check:No locals. -// gdb-command:continue - -// gdb-command:info locals -// gdb-check:abc = 10 -// gdb-command:continue - -#![allow(unused_variables)] -#![feature(no_debug)] -#![feature(omit_gdb_pretty_printer_section)] -#![omit_gdb_pretty_printer_section] - -#[inline(never)] -fn id(x: T) -> T {x} - -fn function_with_debuginfo() { - let abc = 10_usize; - id(abc); // #break -} - -#[no_debug] -fn function_without_debuginfo() { - let abc = -57i32; - id(abc); // #break -} - -fn main() { - function_without_debuginfo(); - function_with_debuginfo(); -} diff --git a/src/test/ui/feature-gates/feature-gate-no-debug-2.rs b/src/test/ui/feature-gates/feature-gate-no-debug-2.rs deleted file mode 100644 index b399bd2cc0f8d..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-no-debug-2.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![deny(deprecated)] -#![feature(no_debug)] - -#[no_debug] //~ ERROR use of deprecated attribute `no_debug` -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-no-debug-2.stderr b/src/test/ui/feature-gates/feature-gate-no-debug-2.stderr deleted file mode 100644 index 9a6f898f2a5a8..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-no-debug-2.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/feature-gate-no-debug-2.rs:4:1 - | -LL | #[no_debug] - | ^^^^^^^^^^^ help: remove this attribute - | -note: the lint level is defined here - --> $DIR/feature-gate-no-debug-2.rs:1:9 - | -LL | #![deny(deprecated)] - | ^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/feature-gates/feature-gate-no-debug.rs b/src/test/ui/feature-gates/feature-gate-no-debug.rs deleted file mode 100644 index a472c4c7663f5..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-no-debug.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![allow(deprecated)] - -#[no_debug] //~ ERROR the `#[no_debug]` attribute was -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-no-debug.stderr b/src/test/ui/feature-gates/feature-gate-no-debug.stderr deleted file mode 100644 index e146d643bcbe3..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-no-debug.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand - --> $DIR/feature-gate-no-debug.rs:3:1 - | -LL | #[no_debug] - | ^^^^^^^^^^^ - | - = note: see issue #29721 for more information - = help: add `#![feature(no_debug)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 4e218ed0f1a92..0ef5d72609ae2 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,5 +1,5 @@ warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:46:5 + --> $DIR/suggestions.rs:42:5 | LL | while true { | ^^^^^^^^^^ help: use `loop` @@ -7,7 +7,7 @@ LL | while true { = note: `#[warn(while_true)]` on by default warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:49:31 + --> $DIR/suggestions.rs:45:31 | LL | let mut registry_no = (format!("NX-{}", 74205)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses @@ -18,16 +18,8 @@ note: the lint level is defined here LL | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^^^^ -warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:42:1 - | -LL | #[no_debug] // should suggest removal of deprecated attribute - | ^^^^^^^^^^^ help: remove this attribute - | - = note: `#[warn(deprecated)]` on by default - warning: variable does not need to be mutable - --> $DIR/suggestions.rs:49:13 + --> $DIR/suggestions.rs:45:13 | LL | let mut registry_no = (format!("NX-{}", 74205)); | ----^^^^^^^^^^^ @@ -41,7 +33,7 @@ LL | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issu | ^^^^^^^^^^ warning: variable does not need to be mutable - --> $DIR/suggestions.rs:55:13 + --> $DIR/suggestions.rs:51:13 | LL | let mut | _____________^ @@ -53,7 +45,7 @@ LL | || b = 1; | help: remove this `mut` error: const items should never be `#[no_mangle]` - --> $DIR/suggestions.rs:6:14 + --> $DIR/suggestions.rs:5:14 | LL | #[no_mangle] const DISCOVERY: usize = 1; | -----^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +55,7 @@ LL | #[no_mangle] const DISCOVERY: usize = 1; = note: `#[deny(no_mangle_const_items)]` on by default warning: functions generic over types or consts must be mangled - --> $DIR/suggestions.rs:12:1 + --> $DIR/suggestions.rs:11:1 | LL | #[no_mangle] | ------------ help: remove this attribute @@ -74,7 +66,7 @@ LL | pub fn defiant(_t: T) {} = note: `#[warn(no_mangle_generic_items)]` on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:61:23 + --> $DIR/suggestions.rs:57:23 | LL | Equinox { warp_factor: warp_factor } => {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use shorthand field pattern: `warp_factor` @@ -82,7 +74,7 @@ LL | Equinox { warp_factor: warp_factor } => {} = note: `#[warn(non_shorthand_field_patterns)]` on by default error: const items should never be `#[no_mangle]` - --> $DIR/suggestions.rs:22:18 + --> $DIR/suggestions.rs:21:18 | LL | #[no_mangle] pub const DAUNTLESS: bool = true; | ---------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +82,7 @@ LL | #[no_mangle] pub const DAUNTLESS: bool = true; | help: try a static value: `pub static` warning: functions generic over types or consts must be mangled - --> $DIR/suggestions.rs:25:18 + --> $DIR/suggestions.rs:24:18 | LL | #[no_mangle] pub fn val_jean() {} | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,7 +90,7 @@ LL | #[no_mangle] pub fn val_jean() {} | help: remove this attribute error: const items should never be `#[no_mangle]` - --> $DIR/suggestions.rs:30:18 + --> $DIR/suggestions.rs:29:18 | LL | #[no_mangle] pub(crate) const VETAR: bool = true; | ----------------^^^^^^^^^^^^^^^^^^^^ @@ -106,7 +98,7 @@ LL | #[no_mangle] pub(crate) const VETAR: bool = true; | help: try a static value: `pub static` warning: functions generic over types or consts must be mangled - --> $DIR/suggestions.rs:33:18 + --> $DIR/suggestions.rs:32:18 | LL | #[no_mangle] pub(crate) fn crossfield() {} | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From cc9aad452a315d953cebb57547a988aff6aeb563 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 4 Mar 2020 03:58:52 +0100 Subject: [PATCH 03/12] resolve, inconsistent binding mode: tweak wording. --- src/librustc_resolve/diagnostics.rs | 3 +- src/test/ui/mismatched_types/E0409.stderr | 2 +- src/test/ui/or-patterns/inconsistent-modes.rs | 16 ++--- .../ui/or-patterns/inconsistent-modes.stderr | 24 +++---- .../resolve-inconsistent-binding-mode.rs | 33 +++++----- .../resolve-inconsistent-binding-mode.stderr | 62 +++++++++---------- .../ui/resolve/resolve-inconsistent-names.rs | 2 +- .../resolve/resolve-inconsistent-names.stderr | 2 +- .../issue-44912-or.rs | 2 +- .../issue-44912-or.stderr | 2 +- 10 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 18192a18cef36..f8695061266a9 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -249,8 +249,7 @@ impl<'a> Resolver<'a> { self.session, span, E0409, - "variable `{}` is bound in inconsistent \ - ways within the same match arm", + "variable `{}` is bound inconsistently across alternatives separated by `|`", variable_name ); err.span_label(span, "bound in different ways"); diff --git a/src/test/ui/mismatched_types/E0409.stderr b/src/test/ui/mismatched_types/E0409.stderr index f5c8b02ae2722..ef03b67b1b0b1 100644 --- a/src/test/ui/mismatched_types/E0409.stderr +++ b/src/test/ui/mismatched_types/E0409.stderr @@ -1,4 +1,4 @@ -error[E0409]: variable `y` is bound in inconsistent ways within the same match arm +error[E0409]: variable `y` is bound inconsistently across alternatives separated by `|` --> $DIR/E0409.rs:5:23 | LL | (0, ref y) | (y, 0) => {} diff --git a/src/test/ui/or-patterns/inconsistent-modes.rs b/src/test/ui/or-patterns/inconsistent-modes.rs index 28b5f0c02fef4..fd5cb01ab42c5 100644 --- a/src/test/ui/or-patterns/inconsistent-modes.rs +++ b/src/test/ui/or-patterns/inconsistent-modes.rs @@ -5,22 +5,22 @@ fn main() { // One level: let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0); - //~^ ERROR variable `a` is bound in inconsistent ways + //~^ ERROR variable `a` is bound inconsistently let Ok(ref mut a) | Err(a): Result = Ok(0); - //~^ ERROR variable `a` is bound in inconsistent ways + //~^ ERROR variable `a` is bound inconsistently let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0); - //~^ ERROR variable `a` is bound in inconsistent ways + //~^ ERROR variable `a` is bound inconsistently //~| ERROR mismatched types let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0)); - //~^ ERROR variable `a` is bound in inconsistent ways - //~| ERROR variable `b` is bound in inconsistent ways + //~^ ERROR variable `a` is bound inconsistently + //~| ERROR variable `b` is bound inconsistently //~| ERROR mismatched types // Two levels: let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0); - //~^ ERROR variable `a` is bound in inconsistent ways + //~^ ERROR variable `a` is bound inconsistently // Three levels: - let Ok([ Ok((Ok(ref a) | Err(a),)) | Err(a) ]) | Err(a) = Err(&1); - //~^ ERROR variable `a` is bound in inconsistent ways + let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1); + //~^ ERROR variable `a` is bound inconsistently } diff --git a/src/test/ui/or-patterns/inconsistent-modes.stderr b/src/test/ui/or-patterns/inconsistent-modes.stderr index 8c01e00bae353..c5dcef36e0580 100644 --- a/src/test/ui/or-patterns/inconsistent-modes.stderr +++ b/src/test/ui/or-patterns/inconsistent-modes.stderr @@ -1,4 +1,4 @@ -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:7:25 | LL | let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0); @@ -6,7 +6,7 @@ LL | let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0); | | | first binding -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:9:29 | LL | let Ok(ref mut a) | Err(a): Result = Ok(0); @@ -14,25 +14,25 @@ LL | let Ok(ref mut a) | Err(a): Result = Ok(0); | | | first binding -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:11:33 | LL | let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0); | - first binding ^ bound in different ways -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:14:39 | LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0)); | - first binding ^ bound in different ways -error[E0409]: variable `b` is bound in inconsistent ways within the same match arm +error[E0409]: variable `b` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:14:46 | LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0)); | - first binding ^ bound in different ways -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` --> $DIR/inconsistent-modes.rs:20:38 | LL | let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0); @@ -40,13 +40,13 @@ LL | let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0); | | | first binding -error[E0409]: variable `a` is bound in inconsistent ways within the same match arm - --> $DIR/inconsistent-modes.rs:24:34 +error[E0409]: variable `a` is bound inconsistently across alternatives separated by `|` + --> $DIR/inconsistent-modes.rs:24:33 | -LL | let Ok([ Ok((Ok(ref a) | Err(a),)) | Err(a) ]) | Err(a) = Err(&1); - | - ^ bound in different ways - | | - | first binding +LL | let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1); + | - ^ bound in different ways + | | + | first binding error[E0308]: mismatched types --> $DIR/inconsistent-modes.rs:11:25 diff --git a/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs b/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs index e9c4e47f88775..43e9378b7d0ec 100644 --- a/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs +++ b/src/test/ui/resolve/resolve-inconsistent-binding-mode.rs @@ -1,39 +1,40 @@ enum Opts { - A(isize), B(isize), C(isize) + A(isize), + B(isize), + C(isize), } fn matcher1(x: Opts) { match x { - Opts::A(ref i) | Opts::B(i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - Opts::C(_) => {} + Opts::A(ref i) | Opts::B(i) => {} + //~^ ERROR variable `i` is bound inconsistently + //~^^ ERROR mismatched types + Opts::C(_) => {} } } fn matcher2(x: Opts) { match x { - Opts::A(ref i) | Opts::B(i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - Opts::C(_) => {} + Opts::A(ref i) | Opts::B(i) => {} + //~^ ERROR variable `i` is bound inconsistently + //~^^ ERROR mismatched types + Opts::C(_) => {} } } fn matcher4(x: Opts) { match x { - Opts::A(ref mut i) | Opts::B(ref i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - Opts::C(_) => {} + Opts::A(ref mut i) | Opts::B(ref i) => {} + //~^ ERROR variable `i` is bound inconsistently + //~^^ ERROR mismatched types + Opts::C(_) => {} } } - fn matcher5(x: Opts) { match x { - Opts::A(ref i) | Opts::B(ref i) => {} - Opts::C(_) => {} + Opts::A(ref i) | Opts::B(ref i) => {} + Opts::C(_) => {} } } diff --git a/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr index 749ed131b204e..c14dfa3601a8c 100644 --- a/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr +++ b/src/test/ui/resolve/resolve-inconsistent-binding-mode.stderr @@ -1,58 +1,58 @@ -error[E0409]: variable `i` is bound in inconsistent ways within the same match arm - --> $DIR/resolve-inconsistent-binding-mode.rs:7:32 +error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|` + --> $DIR/resolve-inconsistent-binding-mode.rs:9:34 | -LL | Opts::A(ref i) | Opts::B(i) => {} - | - ^ bound in different ways - | | - | first binding +LL | Opts::A(ref i) | Opts::B(i) => {} + | - ^ bound in different ways + | | + | first binding -error[E0409]: variable `i` is bound in inconsistent ways within the same match arm - --> $DIR/resolve-inconsistent-binding-mode.rs:16:32 +error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|` + --> $DIR/resolve-inconsistent-binding-mode.rs:18:34 | -LL | Opts::A(ref i) | Opts::B(i) => {} - | - ^ bound in different ways - | | - | first binding +LL | Opts::A(ref i) | Opts::B(i) => {} + | - ^ bound in different ways + | | + | first binding -error[E0409]: variable `i` is bound in inconsistent ways within the same match arm - --> $DIR/resolve-inconsistent-binding-mode.rs:25:40 +error[E0409]: variable `i` is bound inconsistently across alternatives separated by `|` + --> $DIR/resolve-inconsistent-binding-mode.rs:27:42 | -LL | Opts::A(ref mut i) | Opts::B(ref i) => {} - | - first binding ^ bound in different ways +LL | Opts::A(ref mut i) | Opts::B(ref i) => {} + | - first binding ^ bound in different ways error[E0308]: mismatched types - --> $DIR/resolve-inconsistent-binding-mode.rs:7:32 + --> $DIR/resolve-inconsistent-binding-mode.rs:9:34 | LL | match x { | - this expression has type `Opts` -LL | Opts::A(ref i) | Opts::B(i) => {} - | ----- ^ expected `&isize`, found `isize` - | | - | first introduced with type `&isize` here +LL | Opts::A(ref i) | Opts::B(i) => {} + | ----- ^ expected `&isize`, found `isize` + | | + | first introduced with type `&isize` here | = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/resolve-inconsistent-binding-mode.rs:16:32 + --> $DIR/resolve-inconsistent-binding-mode.rs:18:34 | LL | match x { | - this expression has type `Opts` -LL | Opts::A(ref i) | Opts::B(i) => {} - | ----- ^ expected `&isize`, found `isize` - | | - | first introduced with type `&isize` here +LL | Opts::A(ref i) | Opts::B(i) => {} + | ----- ^ expected `&isize`, found `isize` + | | + | first introduced with type `&isize` here | = note: in the same arm, a binding must have the same type in all alternatives error[E0308]: mismatched types - --> $DIR/resolve-inconsistent-binding-mode.rs:25:36 + --> $DIR/resolve-inconsistent-binding-mode.rs:27:38 | LL | match x { | - this expression has type `Opts` -LL | Opts::A(ref mut i) | Opts::B(ref i) => {} - | --------- ^^^^^ types differ in mutability - | | - | first introduced with type `&mut isize` here +LL | Opts::A(ref mut i) | Opts::B(ref i) => {} + | --------- ^^^^^ types differ in mutability + | | + | first introduced with type `&mut isize` here | = note: expected type `&mut isize` found type `&isize` diff --git a/src/test/ui/resolve/resolve-inconsistent-names.rs b/src/test/ui/resolve/resolve-inconsistent-names.rs index 2fb803c4b2ad4..b9202f556d12b 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.rs +++ b/src/test/ui/resolve/resolve-inconsistent-names.rs @@ -19,7 +19,7 @@ fn main() { (A, B) | (ref B, c) | (c, A) => () //~^ ERROR variable `A` is not bound in all patterns //~| ERROR variable `B` is not bound in all patterns - //~| ERROR variable `B` is bound in inconsistent ways + //~| ERROR variable `B` is bound inconsistently //~| ERROR mismatched types //~| ERROR variable `c` is not bound in all patterns //~| HELP consider making the path in the pattern qualified: `?::A` diff --git a/src/test/ui/resolve/resolve-inconsistent-names.stderr b/src/test/ui/resolve/resolve-inconsistent-names.stderr index 1d3079c90baf6..70e9c2e5bf598 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.stderr +++ b/src/test/ui/resolve/resolve-inconsistent-names.stderr @@ -47,7 +47,7 @@ LL | (A, B) | (ref B, c) | (c, A) => () | | variable not in all patterns | pattern doesn't bind `c` -error[E0409]: variable `B` is bound in inconsistent ways within the same match arm +error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|` --> $DIR/resolve-inconsistent-names.rs:19:23 | LL | (A, B) | (ref B, c) | (c, A) => () diff --git a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs index aa013d4bf3528..b4a0d8145c1d6 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.rs @@ -4,7 +4,7 @@ pub fn main() { let x = &Some((3, 3)); let _: &i32 = match x { Some((x, 3)) | &Some((ref x, 5)) => x, - //~^ ERROR is bound in inconsistent ways + //~^ ERROR is bound inconsistently _ => &5i32, }; } diff --git a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr index ff8dce32b2ab3..e1e1bf7f6d971 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr @@ -1,4 +1,4 @@ -error[E0409]: variable `x` is bound in inconsistent ways within the same match arm +error[E0409]: variable `x` is bound inconsistently across alternatives separated by `|` --> $DIR/issue-44912-or.rs:6:35 | LL | Some((x, 3)) | &Some((ref x, 5)) => x, From 81f435dd37c5ec828b621d37ec15bf41a33ff89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 3 Mar 2020 15:07:33 -0800 Subject: [PATCH 04/12] On mismatched delimiters, only point at empty blocks that are in the same line --- src/librustc_parse/lexer/tokentrees.rs | 7 ++++++- .../parser/mismatched-delim-brace-empty-block.stderr | 10 ++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/librustc_parse/lexer/tokentrees.rs b/src/librustc_parse/lexer/tokentrees.rs index 6c0acd0302fb1..b65b894172844 100644 --- a/src/librustc_parse/lexer/tokentrees.rs +++ b/src/librustc_parse/lexer/tokentrees.rs @@ -40,6 +40,7 @@ struct TokenTreesReader<'a> { /// Used only for error recovery when arriving to EOF with mismatched braces. matching_delim_spans: Vec<(token::DelimToken, Span, Span)>, last_unclosed_found_span: Option, + /// Collect empty block spans that might have been auto-inserted by editors. last_delim_empty_block_spans: FxHashMap, } @@ -138,7 +139,11 @@ impl<'a> TokenTreesReader<'a> { if tts.is_empty() { let empty_block_span = open_brace_span.to(close_brace_span); - self.last_delim_empty_block_spans.insert(delim, empty_block_span); + if !sm.is_multiline(empty_block_span) { + // Only track if the block is in the form of `{}`, otherwise it is + // likely that it was written on purpose. + self.last_delim_empty_block_spans.insert(delim, empty_block_span); + } } if self.open_braces.is_empty() { diff --git a/src/test/ui/parser/mismatched-delim-brace-empty-block.stderr b/src/test/ui/parser/mismatched-delim-brace-empty-block.stderr index 311f1768d829c..f1be5dc5ba7fa 100644 --- a/src/test/ui/parser/mismatched-delim-brace-empty-block.stderr +++ b/src/test/ui/parser/mismatched-delim-brace-empty-block.stderr @@ -1,14 +1,8 @@ error: unexpected closing delimiter: `}` --> $DIR/mismatched-delim-brace-empty-block.rs:5:1 | -LL | fn main() { - | ___________- -LL | | -LL | | } - | |_- this block is empty, you might have not meant to close it -LL | let _ = (); -LL | } - | ^ unexpected closing delimiter +LL | } + | ^ unexpected closing delimiter error: aborting due to previous error From 2770f300b12268925922152de1e53a2b9e2557a5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 5 Mar 2020 23:38:48 +0100 Subject: [PATCH 05/12] reduce test size for Miri --- src/liballoc/tests/slice.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 3d6b4bff5e060..8e49e6d8ebad9 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -1733,9 +1733,9 @@ fn panic_safe() { let moduli = &[5, 20, 50]; #[cfg(miri)] - let lens = 1..13; + let lens = 1..10; #[cfg(miri)] - let moduli = &[10]; + let moduli = &[5]; for len in lens { for &modulus in moduli { From 136ad015b6862274bf8c161dc5d2955409ed1465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 12:13:55 +0100 Subject: [PATCH 06/12] fix various typos --- config.toml.example | 2 +- src/bootstrap/compile.rs | 2 +- src/bootstrap/flags.rs | 2 +- src/ci/azure-pipelines/try.yml | 2 +- src/doc/rustdoc/src/unstable-features.md | 2 +- .../src/language-features/marker-trait-attr.md | 2 +- src/liballoc/collections/btree/node.rs | 2 +- src/liballoc/collections/linked_list.rs | 6 +++--- src/liballoc/collections/vec_deque.rs | 2 +- src/liballoc/vec.rs | 2 +- src/libcore/fmt/mod.rs | 2 +- src/libcore/mem/manually_drop.rs | 2 +- src/libcore/mem/mod.rs | 2 +- src/libcore/pin.rs | 4 ++-- src/libcore/ptr/const_ptr.rs | 8 ++++---- src/libcore/ptr/mod.rs | 2 +- src/libcore/ptr/mut_ptr.rs | 10 +++++----- src/libcore/tests/num/dec2flt/mod.rs | 2 +- src/libfmt_macros/lib.rs | 2 +- src/libproc_macro/bridge/client.rs | 4 ++-- src/librustc/hir/map/mod.rs | 2 +- src/librustc/mir/interpret/allocation.rs | 2 +- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/print/mod.rs | 2 +- src/librustc/ty/print/pretty.rs | 6 +++--- src/librustc/ty/query/on_disk_cache.rs | 2 +- src/librustc/ty/query/plumbing.rs | 2 +- src/librustc/ty/relate.rs | 2 +- src/librustc_ast/ast.rs | 4 ++-- src/librustc_ast_lowering/lib.rs | 2 +- src/librustc_builtin_macros/format.rs | 2 +- src/librustc_codegen_llvm/back/lto.rs | 4 ++-- src/librustc_codegen_llvm/back/profiling.rs | 4 ++-- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- src/librustc_codegen_ssa/back/write.rs | 2 +- src/librustc_codegen_ssa/traits/mod.rs | 2 +- src/librustc_codegen_utils/symbol_names.rs | 2 +- src/librustc_data_structures/graph/vec_graph/tests.rs | 2 +- src/librustc_data_structures/sharded.rs | 4 ++-- src/librustc_error_codes/error_codes/E0326.md | 2 +- src/librustc_error_codes/error_codes/E0591.md | 2 +- src/librustc_expand/mbe/macro_rules.rs | 2 +- src/librustc_expand/proc_macro.rs | 2 +- src/librustc_feature/active.rs | 2 +- src/librustc_feature/builtin_attrs.rs | 2 +- src/librustc_infer/infer/error_reporting/mod.rs | 2 +- .../infer/error_reporting/need_type_info.rs | 2 +- src/librustc_infer/infer/mod.rs | 4 ++-- src/librustc_infer/infer/opaque_types/mod.rs | 2 +- src/librustc_infer/infer/resolve.rs | 2 +- src/librustc_infer/traits/auto_trait.rs | 4 ++-- src/librustc_infer/traits/coherence.rs | 2 +- src/librustc_infer/traits/error_reporting/mod.rs | 2 +- src/librustc_infer/traits/object_safety.rs | 2 +- src/librustc_lexer/src/unescape.rs | 4 ++-- src/librustc_macros/src/query.rs | 4 ++-- src/librustc_metadata/locator.rs | 2 +- src/librustc_metadata/rmeta/mod.rs | 2 +- .../borrow_check/diagnostics/conflict_errors.rs | 2 +- .../borrow_check/diagnostics/mutability_errors.rs | 2 +- src/librustc_mir/borrow_check/invalidation.rs | 2 +- src/librustc_mir/borrow_check/member_constraints.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 2 +- src/librustc_mir/borrow_check/type_check/mod.rs | 2 +- src/librustc_mir/const_eval/eval_queries.rs | 4 ++-- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/interpret/machine.rs | 2 +- src/librustc_mir/interpret/operand.rs | 2 +- src/librustc_mir/interpret/snapshot.rs | 2 +- src/librustc_mir/transform/add_retag.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_mir/util/pretty.rs | 2 +- src/librustc_mir_build/hair/pattern/_match.rs | 2 +- src/librustc_parse/config.rs | 2 +- src/librustc_parse/parser/attr.rs | 2 +- src/librustc_parse/parser/diagnostics.rs | 2 +- src/librustc_parse/parser/expr.rs | 2 +- src/librustc_passes/region.rs | 2 +- src/librustc_passes/stability.rs | 2 +- src/librustc_resolve/diagnostics.rs | 2 +- src/librustc_resolve/imports.rs | 2 +- src/librustc_resolve/late.rs | 2 +- src/librustc_resolve/late/lifetimes.rs | 2 +- src/librustc_target/abi/call/mod.rs | 6 +++--- src/librustc_target/abi/mod.rs | 2 +- src/librustc_target/spec/i686_unknown_uefi.rs | 4 ++-- src/librustc_target/spec/nvptx64_nvidia_cuda.rs | 4 ++-- src/librustc_typeck/astconv.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/mod.rs | 8 ++++---- src/librustc_typeck/check/pat.rs | 4 ++-- src/librustc_typeck/coherence/orphan.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustdoc/clean/auto_trait.rs | 2 +- src/librustdoc/html/highlight.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/libstd/net/ip.rs | 2 +- src/libstd/os/linux/fs.rs | 2 +- src/libstd/sync/mpsc/spsc_queue.rs | 2 +- src/libstd/sys/sgx/abi/usercalls/alloc.rs | 2 +- src/libstd/sys/unix/mod.rs | 2 +- src/libstd/sys/vxworks/mod.rs | 2 +- src/libtest/cli.rs | 2 +- src/libtest/options.rs | 2 +- src/libtest/test_result.rs | 2 +- src/test/incremental/cyclic-trait-hierarchy.rs | 2 +- .../thinlto/cgu_invalidated_when_import_added.rs | 2 +- .../thinlto/cgu_invalidated_when_import_removed.rs | 2 +- src/test/ui/consts/const-int-arithmetic-overflow.rs | 2 +- src/test/ui/definition-reachable/nested-fn.rs | 2 +- .../impl-trait/must_outlive_least_region_or_bound.rs | 2 +- src/test/ui/mir/mir_assign_eval_order.rs | 2 +- src/test/ui/nll/issue-54556-used-vs-unused-tails.rs | 2 +- src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs | 2 +- src/test/ui/type-alias-impl-trait/issue-65918.rs | 2 +- .../type-alias-impl-trait/issue-67844-nested-opaque.rs | 2 +- .../issue-52082-type-param-shadows-existing-type.rs | 2 +- src/test/ui/wf/wf-array-elem-sized.rs | 2 +- src/tools/compiletest/src/errors.rs | 2 +- src/tools/compiletest/src/runtest.rs | 2 +- src/tools/tidy/src/pal.rs | 2 +- 122 files changed, 153 insertions(+), 153 deletions(-) diff --git a/config.toml.example b/config.toml.example index 9b7327ea69e0b..ce21b63467f53 100644 --- a/config.toml.example +++ b/config.toml.example @@ -315,7 +315,7 @@ # `0` - no debug info # `1` - line tables only # `2` - full debug info with variable and type information -# Can be overriden for specific subsets of Rust code (rustc, std or tools). +# Can be overridden for specific subsets of Rust code (rustc, std or tools). # Debuginfo for tests run with compiletest is not controlled by this option # and needs to be enabled separately with `debuginfo-level-tests`. #debuginfo-level = if debug { 2 } else { 0 } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7dded96e18efd..65a00db33949e 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -141,7 +141,7 @@ fn copy_third_party_objects( copy_and_stamp(&srcdir, "crt1.o"); } - // Copies libunwind.a compiled to be linked wit x86_64-fortanix-unknown-sgx. + // Copies libunwind.a compiled to be linked with x86_64-fortanix-unknown-sgx. // // This target needs to be linked to Fortanix's port of llvm's libunwind. // libunwind requires support for rwlock and printing to stderr, diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 516be6a30c235..0b2ab6bbbc021 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -33,7 +33,7 @@ pub struct Flags { pub rustc_error_format: Option, pub dry_run: bool, - // This overrides the deny-warnings configuation option, + // This overrides the deny-warnings configuration option, // which passes -Dwarnings to the compiler invocations. // // true => deny, false => warn diff --git a/src/ci/azure-pipelines/try.yml b/src/ci/azure-pipelines/try.yml index f8ddf0eb46cfd..a29d6f9ae1ec6 100644 --- a/src/ci/azure-pipelines/try.yml +++ b/src/ci/azure-pipelines/try.yml @@ -20,7 +20,7 @@ jobs: # The macOS and Windows builds here are currently disabled due to them not being # overly necessary on `try` builds. We also don't actually have anything that -# consumes the artifacts currently. Perhaps one day we can reenable, but for now +# consumes the artifacts currently. Perhaps one day we can re-enable, but for now # it helps free up capacity on Azure. # - job: macOS # timeoutInMinutes: 600 diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index a48526d39fd0a..22d2e297da3a2 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -453,7 +453,7 @@ override `ignore`. ### `--runtool`, `--runtool-arg`: program to run tests with; args to pass to it -Using thses options looks like this: +Using these options looks like this: ```bash $ rustdoc src/lib.rs -Z unstable-options --runtool runner --runtool-arg --do-thing --runtool-arg --do-other-thing diff --git a/src/doc/unstable-book/src/language-features/marker-trait-attr.md b/src/doc/unstable-book/src/language-features/marker-trait-attr.md index dedc7d3015d4d..be350cd616964 100644 --- a/src/doc/unstable-book/src/language-features/marker-trait-attr.md +++ b/src/doc/unstable-book/src/language-features/marker-trait-attr.md @@ -21,7 +21,7 @@ when they'd need to do the same thing for every type anyway). impl CheapToClone for T {} -// These could potentally overlap with the blanket implementation above, +// These could potentially overlap with the blanket implementation above, // so are only allowed because CheapToClone is a marker trait. impl CheapToClone for (T, U) {} impl CheapToClone for std::ops::Range {} diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 362755f8b7f63..edeb87a908d7c 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -306,7 +306,7 @@ impl Root { /// `NodeRef` could be pointing to either type of node. /// Note that in case of a leaf node, this might still be the shared root! /// Only turn this into a `LeafNode` reference if you know it is not the shared root! -/// Shared references must be dereferencable *for the entire size of their pointee*, +/// Shared references must be dereferenceable *for the entire size of their pointee*, /// so '&LeafNode` or `&InternalNode` pointing to the shared root is undefined behavior. /// Turning this into a `NodeHeader` reference is always safe. pub struct NodeRef { diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index a9b4e3e4706b8..e10d0db9d9a5b 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -841,10 +841,10 @@ impl LinkedList { /// d.push_front(2); /// d.push_front(3); /// - /// let mut splitted = d.split_off(2); + /// let mut split = d.split_off(2); /// - /// assert_eq!(splitted.pop_front(), Some(1)); - /// assert_eq!(splitted.pop_front(), None); + /// assert_eq!(split.pop_front(), Some(1)); + /// assert_eq!(split.pop_front(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn split_off(&mut self, at: usize) -> LinkedList { diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 85d1d98b8a9c2..9d56f17700a85 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2132,7 +2132,7 @@ impl VecDeque { // Safety: the following two methods require that the rotation amount // be less than half the length of the deque. // - // `wrap_copy` requres that `min(x, cap() - x) + copy_len <= cap()`, + // `wrap_copy` requires that `min(x, cap() - x) + copy_len <= cap()`, // but than `min` is never more than half the capacity, regardless of x, // so it's sound to call here because we're calling with something // less than half the length, which is never above half the capacity. diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 3fd7be06fd4fc..05f3dd28e98ca 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2894,7 +2894,7 @@ where /// The filter test predicate. pred: F, /// A flag that indicates a panic has occurred in the filter test prodicate. - /// This is used as a hint in the drop implmentation to prevent consumption + /// This is used as a hint in the drop implementation to prevent consumption /// of the remainder of the `DrainFilter`. Any unprocessed items will be /// backshifted in the `vec`, but no further items will be dropped or /// tested by the filter predicate. diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 993b1073493e9..b13e9bcc6b44e 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -255,7 +255,7 @@ pub struct ArgumentV1<'a> { formatter: fn(&Opaque, &mut Formatter<'_>) -> Result, } -// This gurantees a single stable value for the function pointer associated with +// This guarantees a single stable value for the function pointer associated with // indices/counts in the formatting infrastructure. // // Note that a function defined as such would not be correct as functions are diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs index 4c3b81ea5eca5..9e5c2b10d0d9e 100644 --- a/src/libcore/mem/manually_drop.rs +++ b/src/libcore/mem/manually_drop.rs @@ -93,7 +93,7 @@ impl ManuallyDrop { /// Instead of using [`ManuallyDrop::drop`] to manually drop the value, /// you can use this method to take the value and use it however desired. /// - /// Whenever possible, it is preferrable to use [`into_inner`][`ManuallyDrop::into_inner`] + /// Whenever possible, it is preferable to use [`into_inner`][`ManuallyDrop::into_inner`] /// instead, which prevents duplicating the content of the `ManuallyDrop`. /// /// # Safety diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 1120d6d4bc50e..90144d11dc9d1 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -91,7 +91,7 @@ pub use crate::intrinsics::transmute; /// Using `ManuallyDrop` here has two advantages: /// /// * We do not "touch" `v` after disassembling it. For some types, operations -/// such as passing ownership (to a funcion like `mem::forget`) requires them to actually +/// such as passing ownership (to a function like `mem::forget`) requires them to actually /// be fully owned right now; that is a promise we do not want to make here as we are /// in the process of transferring ownership to the new `String` we are building. /// * In case of an unexpected panic, `ManuallyDrop` is not dropped, but if the panic diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 676d2c784acee..774ecd997c201 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -312,7 +312,7 @@ //! //! ## Examples //! -//! For a type like [`Vec`], both possibilites (structural pinning or not) make sense. +//! For a type like [`Vec`], both possibilities (structural pinning or not) make sense. //! A [`Vec`] with structural pinning could have `get_pin`/`get_pin_mut` methods to get //! pinned references to elements. However, it could *not* allow calling //! [`pop`][Vec::pop] on a pinned [`Vec`] because that would move the (structurally pinned) @@ -539,7 +539,7 @@ impl Pin

{ /// ``` /// A value, once pinned, must remain pinned forever (unless its type implements `Unpin`). /// - /// Similarily, calling `Pin::new_unchecked` on an `Rc` is unsafe because there could be + /// Similarly, calling `Pin::new_unchecked` on an `Rc` is unsafe because there could be /// aliases to the same data that are not subject to the pinning restrictions: /// ``` /// use std::rc::Rc; diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs index fc3c02e1f066d..a540016854df3 100644 --- a/src/libcore/ptr/const_ptr.rs +++ b/src/libcore/ptr/const_ptr.rs @@ -53,7 +53,7 @@ impl *const T { /// all of the following is true: /// - it is properly aligned /// - it must point to an initialized instance of T; in particular, the pointer must be - /// "dereferencable" in the sense defined [here]. + /// "dereferenceable" in the sense defined [here]. /// /// This applies even if the result of this method is unused! /// (The part about being initialized is not yet fully decided, but until @@ -183,7 +183,7 @@ impl *const T { /// within the same allocated object: [`offset`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_offset` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`offset`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. @@ -480,7 +480,7 @@ impl *const T { /// within the same allocated object: [`add`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_add` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`add`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. @@ -535,7 +535,7 @@ impl *const T { /// within the same allocated object: [`sub`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_sub` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`sub`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index fcfa98d850721..72c46f58fcc7b 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -19,7 +19,7 @@ //! * All pointers (except for the null pointer) are valid for all operations of //! [size zero][zst]. //! * For a pointer to be valid, it is necessary, but not always sufficient, that the pointer -//! be *dereferencable*: the memory range of the given size starting at the pointer must all be +//! be *dereferenceable*: the memory range of the given size starting at the pointer must all be //! within the bounds of a single allocated object. Note that in Rust, //! every (stack-allocated) variable is considered a separate allocated object. //! * All accesses performed by functions in this module are *non-atomic* in the sense diff --git a/src/libcore/ptr/mut_ptr.rs b/src/libcore/ptr/mut_ptr.rs index 4bc0a3e9faa60..01d830ca18602 100644 --- a/src/libcore/ptr/mut_ptr.rs +++ b/src/libcore/ptr/mut_ptr.rs @@ -49,7 +49,7 @@ impl *mut T { /// memory. /// /// When calling this method, you have to ensure that if the pointer is - /// non-NULL, then it is properly aligned, dereferencable (for the whole + /// non-NULL, then it is properly aligned, dereferenceable (for the whole /// size of `T`) and points to an initialized instance of `T`. This applies /// even if the result of this method is unused! /// (The part about being initialized is not yet fully decided, but until @@ -176,7 +176,7 @@ impl *mut T { /// within the same allocated object: [`offset`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_offset` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`offset`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. @@ -224,7 +224,7 @@ impl *mut T { /// all of the following is true: /// - it is properly aligned /// - it must point to an initialized instance of T; in particular, the pointer must be - /// "dereferencable" in the sense defined [here]. + /// "dereferenceable" in the sense defined [here]. /// /// This applies even if the result of this method is unused! /// (The part about being initialized is not yet fully decided, but until @@ -526,7 +526,7 @@ impl *mut T { /// within the same allocated object: [`add`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_add` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`add`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. @@ -581,7 +581,7 @@ impl *mut T { /// within the same allocated object: [`sub`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_sub` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`sub`] can be optimized - /// better and is thus preferrable in performance-sensitive code. + /// better and is thus preferable in performance-sensitive code. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there. diff --git a/src/libcore/tests/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index a1fa5556ae5db..509097fdb5485 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -44,7 +44,7 @@ fn ordinary() { #[test] fn special_code_paths() { test_literal!(36893488147419103229.0); // 2^65 - 3, triggers half-to-even with even significand - test_literal!(101e-33); // Triggers the tricky underflow case in AlgorithmM (for f32) + test_literal!(101e-33); // Triggers the tricky underflow case in algorithm (for f32) test_literal!(1e23); // Triggers AlgorithmR test_literal!(2075e23); // Triggers another path through AlgorithmR test_literal!(8713e-23); // ... and yet another. diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 9ca7eee999fe0..e138503b508d5 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -176,7 +176,7 @@ pub struct Parser<'a> { skips: Vec, /// Span of the last opening brace seen, used for error reporting last_opening_brace: Option, - /// Wether the source string is comes from `println!` as opposed to `format!` or `print!` + /// Whether the source string is comes from `println!` as opposed to `format!` or `print!` append_newline: bool, } diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index dd948025c91ca..088db92253acf 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -15,7 +15,7 @@ macro_rules! define_handles { } impl HandleCounters { - // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of + // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of // a wrapper `fn` pointer, once `const fn` can reference `static`s. extern "C" fn get() -> &'static Self { static COUNTERS: HandleCounters = HandleCounters { @@ -334,7 +334,7 @@ impl Bridge<'_> { #[repr(C)] #[derive(Copy, Clone)] pub struct Client { - // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of + // FIXME(eddyb) use a reference to the `static COUNTERS`, instead of // a wrapper `fn` pointer, once `const fn` can reference `static`s. pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters, pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer, diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index bd26e02efb749..0f129904b4324 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -653,7 +653,7 @@ impl<'hir> Map<'hir> { } } - /// Wether `hir_id` corresponds to a `mod` or a crate. + /// Whether `hir_id` corresponds to a `mod` or a crate. pub fn is_hir_id_module(&self, hir_id: HirId) -> bool { match self.lookup(hir_id) { Some(Entry { node: Node::Item(Item { kind: ItemKind::Mod(_), .. }), .. }) diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index c8d35db0adeb2..546ba586d30f9 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -610,7 +610,7 @@ impl Allocation { // a naive undef mask copying algorithm would repeatedly have to read the undef mask from // the source and write it to the destination. Even if we optimized the memory accesses, // we'd be doing all of this `repeat` times. - // Therefor we precompute a compressed version of the undef mask of the source value and + // Therefore we precompute a compressed version of the undef mask of the source value and // then write it back `repeat` times without computing any more information from the source. // A precomputed cache for ranges of defined/undefined bits diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 7a5a417919d50..e257b48f11156 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2579,7 +2579,7 @@ where if let Some(kind) = pointee.safe { attrs.pointee_align = Some(pointee.align); - // `Box` (`UniqueBorrowed`) are not necessarily dereferencable + // `Box` (`UniqueBorrowed`) are not necessarily dereferenceable // for the entire duration of the function as they can be deallocated // any time. Set their valid size to 0. attrs.pointee_size = match kind { diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index 3ade9661917a2..8d784833bd310 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -97,7 +97,7 @@ pub trait Printer<'tcx>: Sized { args: &[GenericArg<'tcx>], ) -> Result; - // Defaults (should not be overriden): + // Defaults (should not be overridden): fn default_print_def_path( self, diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 4829955cb70c4..05dcc9e85ac52 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -221,7 +221,7 @@ pub trait PrettyPrinter<'tcx>: /// This is typically the case for all non-`'_` regions. fn region_should_not_be_omitted(&self, region: ty::Region<'_>) -> bool; - // Defaults (should not be overriden): + // Defaults (should not be overridden): /// If possible, this returns a global path resolving to `def_id` that is visible /// from at least one local module, and returns `true`. If the crate defining `def_id` is @@ -236,7 +236,7 @@ pub trait PrettyPrinter<'tcx>: /// post-process it into the valid and visible version that /// accounts for re-exports. /// - /// This method should only be callled by itself or + /// This method should only be called by itself or /// `try_print_visible_def_path`. /// /// `callers` is a chain of visible_parent's leading to `def_id`, @@ -685,7 +685,7 @@ pub trait PrettyPrinter<'tcx>: if self.tcx().sess.verbose() { p!(write("{:?}", sz)); } else if let ty::ConstKind::Unevaluated(..) = sz.val { - // do not try to evalute unevaluated constants. If we are const evaluating an + // do not try to evaluate unevaluated constants. If we are const evaluating an // array length anon const, rustc will (with debug assertions) print the // constant's path. Which will end up here again. p!(write("_")); diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 5e36e4df698ed..9c1db7c5f2b70 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -425,7 +425,7 @@ impl<'sess> OnDiskCache<'sess> { //- DECODING ------------------------------------------------------------------- -/// A decoder that can read fro the incr. comp. cache. It is similar to the one +/// A decoder that can read from the incr. comp. cache. It is similar to the one /// we use for crate metadata decoding in that it can rebase spans and eventually /// will also handle things that contain `Ty` instances. struct CacheDecoder<'a, 'tcx> { diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index a61256b9fcbbc..c94909549df22 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -1053,7 +1053,7 @@ macro_rules! define_queries_inner { impl TyCtxt<$tcx> { /// Returns a transparent wrapper for `TyCtxt`, which ensures queries - /// are executed instead of just returing their results. + /// are executed instead of just returning their results. #[inline(always)] pub fn ensure(self) -> TyCtxtEnsure<$tcx> { TyCtxtEnsure { diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 3b9df72266f09..8da82a80dd337 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -72,7 +72,7 @@ pub trait TypeRelation<'tcx>: Sized { b: &T, ) -> RelateResult<'tcx, T>; - // Overrideable relations. You shouldn't typically call these + // Overridable relations. You shouldn't typically call these // directly, instead call `relate()`, which in turn calls // these. This is both more uniform but also allows us to add // additional hooks for other types in the future if needed diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs index 7cc045ef34461..88a96dc6c6966 100644 --- a/src/librustc_ast/ast.rs +++ b/src/librustc_ast/ast.rs @@ -1078,7 +1078,7 @@ impl Expr { // If binary operator is `Add` and both `lhs` and `rhs` are trait bounds, // then type of result is trait object. - // Othewise we don't assume the result type. + // Otherwise we don't assume the result type. ExprKind::Binary(binop, lhs, rhs) if binop.node == BinOpKind::Add => { if let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) { TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None) @@ -2089,7 +2089,7 @@ impl Async { if let Async::Yes { .. } = self { true } else { false } } - /// In ths case this is an `async` return, the `NodeId` for the generated `impl Trait` item. + /// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item. pub fn opt_return_id(self) -> Option { match self { Async::Yes { return_impl_trait_id, .. } => Some(return_impl_trait_id), diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index df71b05ac2c98..dd9526ccee41a 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -1096,7 +1096,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { match arg { ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)), ast::GenericArg::Type(ty) => { - // We parse const arguments as path types as we cannot distiguish them durring + // We parse const arguments as path types as we cannot distinguish them during // parsing. We try to resolve that ambiguity by attempting resolution in both the // type and value namespaces. If we resolved the path in the value namespace, we // transform it into a generic const argument. diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index d6b8b8cafb79c..1baec5eafe687 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -904,7 +904,7 @@ pub fn expand_preparsed_format_args( }; /// Finds the indices of all characters that have been processed and differ between the actual - /// written code (code snippet) and the `InternedString` that get's processed in the `Parser` + /// written code (code snippet) and the `InternedString` that gets processed in the `Parser` /// in order to properly synthethise the intra-string `Span`s for error diagnostics. fn find_skips(snippet: &str, is_raw: bool) -> Vec { let mut eat_ws = false; diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index a39c25f6693c1..310cae978bf5e 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -504,7 +504,7 @@ fn thin_lto( // // This strategy means we can always save the computed imports as // canon: when we reuse the post-ThinLTO version, condition (3.) - // ensures that the curent import set is the same as the previous + // ensures that the current import set is the same as the previous // one. (And of course, when we don't reuse the post-ThinLTO // version, the current import set *is* the correct one, since we // are doing the ThinLTO in this current compilation cycle.) @@ -538,7 +538,7 @@ fn thin_lto( })); } - // Save the curent ThinLTO import information for the next compilation + // Save the current ThinLTO import information for the next compilation // session, overwriting the previous serialized imports (if any). if let Some(path) = import_map_path { if let Err(err) = curr_import_map.save_to_file(&path) { diff --git a/src/librustc_codegen_llvm/back/profiling.rs b/src/librustc_codegen_llvm/back/profiling.rs index d56ddac699b09..2741f7d848e79 100644 --- a/src/librustc_codegen_llvm/back/profiling.rs +++ b/src/librustc_codegen_llvm/back/profiling.rs @@ -9,8 +9,8 @@ fn llvm_args_to_string_id(profiler: &SelfProfiler, pass_name: &str, ir_name: &st let mut components = vec![StringComponent::Ref(pass_name)]; // handle that LazyCallGraph::SCC is a comma separated list within parentheses let parentheses: &[_] = &['(', ')']; - let trimed = ir_name.trim_matches(parentheses); - for part in trimed.split(", ") { + let trimmed = ir_name.trim_matches(parentheses); + for part in trimmed.split(", ") { let demangled_ir_name = rustc_demangle::demangle(part).to_string(); let ir_name = profiler.get_or_alloc_cached_string(demangled_ir_name); components.push(StringComponent::Value(SEPARATOR_BYTE)); diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 3916653eb1d76..cc9a51cf26bf4 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -637,7 +637,7 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp unsafe { // The choice of type here is pretty arbitrary - // anything reading the debuginfo for a recursive - // type is going to see *somthing* weird - the only + // type is going to see *something* weird - the only // question is what exactly it will see. let (size, align) = cx.size_and_align_of(t); llvm::LLVMRustDIBuilderCreateBasicType( diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index b313bf57d4a9a..3afa4758253d9 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -736,7 +736,7 @@ fn execute_work_item( } } -// Actual LTO type we end up chosing based on multiple factors. +// Actual LTO type we end up choosing based on multiple factors. enum ComputedLtoType { No, Thin, diff --git a/src/librustc_codegen_ssa/traits/mod.rs b/src/librustc_codegen_ssa/traits/mod.rs index b8afadaadef38..d03ff8d4d37d8 100644 --- a/src/librustc_codegen_ssa/traits/mod.rs +++ b/src/librustc_codegen_ssa/traits/mod.rs @@ -8,7 +8,7 @@ //! actual codegen, while the builder stores the information about the function during codegen and //! is used to produce the instructions of the backend IR. //! -//! Finaly, a third `Backend` structure has to implement methods related to how codegen information +//! Finally, a third `Backend` structure has to implement methods related to how codegen information //! is passed to the backend, especially for asynchronous compilation. //! //! The traits contain associated types that are backend-specific, such as the backend's value or diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 6713459f627ef..cfde09fad62cc 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -185,7 +185,7 @@ fn compute_symbol_name( // // * On the wasm32 targets there is a bug (or feature) in LLD [1] where the // same-named symbol when imported from different wasm modules will get - // hooked up incorectly. As a result foreign symbols, on the wasm target, + // hooked up incorrectly. As a result foreign symbols, on the wasm target, // with a wasm import module, get mangled. Additionally our codegen will // deduplicate symbols based purely on the symbol name, but for wasm this // isn't quite right because the same-named symbol on wasm can come from diff --git a/src/librustc_data_structures/graph/vec_graph/tests.rs b/src/librustc_data_structures/graph/vec_graph/tests.rs index 1db8bd4b102bf..c8f979267170f 100644 --- a/src/librustc_data_structures/graph/vec_graph/tests.rs +++ b/src/librustc_data_structures/graph/vec_graph/tests.rs @@ -23,7 +23,7 @@ fn num_nodes() { } #[test] -fn succesors() { +fn successors() { let graph = create_graph(); assert_eq!(graph.successors(0), &[1]); assert_eq!(graph.successors(1), &[2, 3]); diff --git a/src/librustc_data_structures/sharded.rs b/src/librustc_data_structures/sharded.rs index 15d1e2dd0b644..d08d46a7414d0 100644 --- a/src/librustc_data_structures/sharded.rs +++ b/src/librustc_data_structures/sharded.rs @@ -13,7 +13,7 @@ struct CacheAligned(T); #[cfg(parallel_compiler)] // 32 shards is sufficient to reduce contention on an 8-core Ryzen 7 1700, // but this should be tested on higher core count CPUs. How the `Sharded` type gets used -// may also affect the ideal nunber of shards. +// may also affect the ideal number of shards. const SHARD_BITS: usize = 5; #[cfg(not(parallel_compiler))] @@ -41,7 +41,7 @@ impl Sharded { let mut values: SmallVec<[_; SHARDS]> = (0..SHARDS).map(|_| CacheAligned(Lock::new(value()))).collect(); - // Create an unintialized array + // Create an uninitialized array let mut shards: mem::MaybeUninit<[CacheAligned>; SHARDS]> = mem::MaybeUninit::uninit(); diff --git a/src/librustc_error_codes/error_codes/E0326.md b/src/librustc_error_codes/error_codes/E0326.md index 3d357819c7f91..bc522e9cf4085 100644 --- a/src/librustc_error_codes/error_codes/E0326.md +++ b/src/librustc_error_codes/error_codes/E0326.md @@ -1,4 +1,4 @@ -An implementation of a trait doesn't match the type contraint. +An implementation of a trait doesn't match the type constraint. Erroneous code example: diff --git a/src/librustc_error_codes/error_codes/E0591.md b/src/librustc_error_codes/error_codes/E0591.md index 782d4cf29c32c..7f68815b1c21b 100644 --- a/src/librustc_error_codes/error_codes/E0591.md +++ b/src/librustc_error_codes/error_codes/E0591.md @@ -54,7 +54,7 @@ This pattern should be rewritten. There are a few possible ways to do this: - change the original fn declaration to match the expected signature, and do the cast in the fn body (the preferred option) -- cast the fn item fo a fn pointer before calling transmute, as shown here: +- cast the fn item of a fn pointer before calling transmute, as shown here: ``` # extern "C" fn foo(_: Box) {} diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs index b02c935039512..51b172a21148c 100644 --- a/src/librustc_expand/mbe/macro_rules.rs +++ b/src/librustc_expand/mbe/macro_rules.rs @@ -991,7 +991,7 @@ fn token_can_be_followed_by_any(tok: &mbe::TokenTree) -> bool { if let mbe::TokenTree::MetaVarDecl(_, _, frag_spec) = *tok { frag_can_be_followed_by_any(frag_spec.name) } else { - // (Non NT's can always be followed by anthing in matchers.) + // (Non NT's can always be followed by anything in matchers.) true } } diff --git a/src/librustc_expand/proc_macro.rs b/src/librustc_expand/proc_macro.rs index 84a546345bb28..5404ee192a61a 100644 --- a/src/librustc_expand/proc_macro.rs +++ b/src/librustc_expand/proc_macro.rs @@ -133,7 +133,7 @@ impl MultiItemModifier for ProcMacroDerive { }; let error_count_before = ecx.parse_sess.span_diagnostic.err_count(); - let msg = "proc-macro derive produced unparseable tokens"; + let msg = "proc-macro derive produced unparsable tokens"; let mut parser = rustc_parse::stream_to_parser(ecx.parse_sess, stream, Some("proc-macro derive")); diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index 6517a22701b0e..642a3bf8964e8 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -387,7 +387,7 @@ declare_features! ( /// Allows defining `trait X = A + B;` alias items. (active, trait_alias, "1.24.0", Some(41517), None), - /// Allows infering `'static` outlives requirements (RFC 2093). + /// Allows inferring `'static` outlives requirements (RFC 2093). (active, infer_static_outlives_requirements, "1.26.0", Some(54185), None), /// Allows accessing fields of unions inside `const` functions. diff --git a/src/librustc_feature/builtin_attrs.rs b/src/librustc_feature/builtin_attrs.rs index c140adf64d511..9810c0cfe6639 100644 --- a/src/librustc_feature/builtin_attrs.rs +++ b/src/librustc_feature/builtin_attrs.rs @@ -175,7 +175,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // Stable attributes: // ========================================================================== - // Condtional compilation: + // Conditional compilation: ungated!(cfg, Normal, template!(List: "predicate")), ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ...")), diff --git a/src/librustc_infer/infer/error_reporting/mod.rs b/src/librustc_infer/infer/error_reporting/mod.rs index bd133738db7ab..40b493de9f4d4 100644 --- a/src/librustc_infer/infer/error_reporting/mod.rs +++ b/src/librustc_infer/infer/error_reporting/mod.rs @@ -1819,7 +1819,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { "{} may not live long enough", labeled_user_string ); - // Explicitely use the name instead of `sub`'s `Display` impl. The `Display` impl + // Explicitly use the name instead of `sub`'s `Display` impl. The `Display` impl // for the bound is not suitable for suggestions when `-Zverbose` is set because it // uses `Debug` output, so we handle it specially here so that suggestions are // always correct. diff --git a/src/librustc_infer/infer/error_reporting/need_type_info.rs b/src/librustc_infer/infer/error_reporting/need_type_info.rs index a1e6a0a325ada..285f0c9cf51a9 100644 --- a/src/librustc_infer/infer/error_reporting/need_type_info.rs +++ b/src/librustc_infer/infer/error_reporting/need_type_info.rs @@ -391,7 +391,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.span_label(pattern.span, msg); } else if let Some(e) = local_visitor.found_method_call { if let ExprKind::MethodCall(segment, ..) = &e.kind { - // Suggest specifiying type params or point out the return type of the call: + // Suggest specifying type params or point out the return type of the call: // // error[E0282]: type annotations needed // --> $DIR/type-annotations-needed-expr.rs:2:39 diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs index 6adddf2500cdc..938a0e7ab39df 100644 --- a/src/librustc_infer/infer/mod.rs +++ b/src/librustc_infer/infer/mod.rs @@ -1667,14 +1667,14 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> { ty::IntVar(v) => { // If inlined_probe_value returns a value it's always a - // `ty::Int(_)` or `ty::UInt(_)`, which nevers matches a + // `ty::Int(_)` or `ty::UInt(_)`, which never matches a // `ty::Infer(_)`. self.infcx.inner.borrow_mut().int_unification_table.inlined_probe_value(v).is_some() } ty::FloatVar(v) => { // If inlined_probe_value returns a value it's always a - // `ty::Float(_)`, which nevers matches a `ty::Infer(_)`. + // `ty::Float(_)`, which never matches a `ty::Infer(_)`. // // Not `inlined_probe_value(v)` because this call site is colder. self.infcx.inner.borrow_mut().float_unification_table.probe_value(v).is_some() diff --git a/src/librustc_infer/infer/opaque_types/mod.rs b/src/librustc_infer/infer/opaque_types/mod.rs index 06d45690e4134..4d264008ee3ed 100644 --- a/src/librustc_infer/infer/opaque_types/mod.rs +++ b/src/librustc_infer/infer/opaque_types/mod.rs @@ -264,7 +264,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// ``` /// /// Here we would report a more complex "in constraint", like `'r - /// in ['a, 'b, 'static]` (where `'r` is some regon appearing in + /// in ['a, 'b, 'static]` (where `'r` is some region appearing in /// the hidden type). /// /// # Constrain regions, not the hidden concrete type diff --git a/src/librustc_infer/infer/resolve.rs b/src/librustc_infer/infer/resolve.rs index e2207d08ee61b..6bf123114dc38 100644 --- a/src/librustc_infer/infer/resolve.rs +++ b/src/librustc_infer/infer/resolve.rs @@ -169,7 +169,7 @@ where } // N.B. This type is not public because the protocol around checking the -// `err` field is not enforcable otherwise. +// `err` field is not enforceable otherwise. struct FullTypeResolver<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, err: Option>, diff --git a/src/librustc_infer/traits/auto_trait.rs b/src/librustc_infer/traits/auto_trait.rs index 3166fe0657697..39be8fc1c0fe6 100644 --- a/src/librustc_infer/traits/auto_trait.rs +++ b/src/librustc_infer/traits/auto_trait.rs @@ -455,7 +455,7 @@ impl AutoTraitFinder<'tcx> { // predicate has some other kind of region. An region // variable isn't something we can actually display to a user, // so we choose their new predicate (which doesn't have a region - // varaible). + // variable). // // In both cases, we want to remove the old predicate, // from `user_computed_preds`, and replace it with the new @@ -701,7 +701,7 @@ impl AutoTraitFinder<'tcx> { // some subobligations. We then process these subobligations // like any other generated sub-obligations. // - // 3. We receieve an 'ambiguous' result (Ok(None)) + // 3. We receive an 'ambiguous' result (Ok(None)) // If we were actually trying to compile a crate, // we would need to re-process this obligation later. // However, all we care about is finding out what bounds diff --git a/src/librustc_infer/traits/coherence.rs b/src/librustc_infer/traits/coherence.rs index 0dec5ae6da57a..15c5f4d402ac3 100644 --- a/src/librustc_infer/traits/coherence.rs +++ b/src/librustc_infer/traits/coherence.rs @@ -505,7 +505,7 @@ fn ty_is_non_local_constructor<'tcx>(ty: Ty<'tcx>, in_crate: InCrate) -> Option< // // We choose to treat all opaque types as non-local, even // those that appear within the same crate. This seems - // somewhat suprising at first, but makes sense when + // somewhat surprising at first, but makes sense when // you consider that opaque types are supposed to hide // the underlying type *within the same crate*. When an // opaque type is used from outside the module diff --git a/src/librustc_infer/traits/error_reporting/mod.rs b/src/librustc_infer/traits/error_reporting/mod.rs index 63c3f827c2ecb..10143ae015f2f 100644 --- a/src/librustc_infer/traits/error_reporting/mod.rs +++ b/src/librustc_infer/traits/error_reporting/mod.rs @@ -1142,7 +1142,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // we're only talking about builtin traits, which are known to be // inhabited. We used to check for `self.tcx.sess.has_errors()` to // avoid inundating the user with unnecessary errors, but we now - // check upstream for type errors and dont add the obligations to + // check upstream for type errors and don't add the obligations to // begin with in those cases. if self .tcx diff --git a/src/librustc_infer/traits/object_safety.rs b/src/librustc_infer/traits/object_safety.rs index f5bab7cfac976..6f20f5ac47e57 100644 --- a/src/librustc_infer/traits/object_safety.rs +++ b/src/librustc_infer/traits/object_safety.rs @@ -612,7 +612,7 @@ fn receiver_is_dispatchable<'tcx>( }; // the type `U` in the query - // use a bogus type parameter to mimick a forall(U) query using u32::MAX for now. + // use a bogus type parameter to mimic a forall(U) query using u32::MAX for now. // FIXME(mikeyhew) this is a total hack. Once object_safe_for_dispatch is stabilized, we can // replace this with `dyn Trait` let unsized_self_ty: Ty<'tcx> = diff --git a/src/librustc_lexer/src/unescape.rs b/src/librustc_lexer/src/unescape.rs index 4f5e03d008c99..c51bf735fa727 100644 --- a/src/librustc_lexer/src/unescape.rs +++ b/src/librustc_lexer/src/unescape.rs @@ -17,7 +17,7 @@ pub enum EscapeError { /// Escaped '\' character without continuation. LoneSlash, - /// Invalid escape characted (e.g. '\z'). + /// Invalid escape character (e.g. '\z'). InvalidEscape, /// Raw '\r' encountered. BareCarriageReturn, @@ -43,7 +43,7 @@ pub enum EscapeError { UnclosedUnicodeEscape, /// '\u{_12}' LeadingUnderscoreUnicodeEscape, - /// More than 6 charactes in '\u{..}', e.g. '\u{10FFFF_FF}' + /// More than 6 characters in '\u{..}', e.g. '\u{10FFFF_FF}' OverlongUnicodeEscape, /// Invalid in-bound unicode character code, e.g. '\u{DFFF}'. LoneSurrogateUnicodeEscape, diff --git a/src/librustc_macros/src/query.rs b/src/librustc_macros/src/query.rs index 6362f3c2c49f0..97b800decc59b 100644 --- a/src/librustc_macros/src/query.rs +++ b/src/librustc_macros/src/query.rs @@ -57,7 +57,7 @@ enum QueryModifier { /// Generate a dep node based on the dependencies of the query Anon, - /// Always evaluate the query, ignoring its depdendencies + /// Always evaluate the query, ignoring its dependencies EvalAlways, } @@ -228,7 +228,7 @@ struct QueryModifiers { /// Generate a dep node based on the dependencies of the query anon: bool, - // Always evaluate the query, ignoring its depdendencies + // Always evaluate the query, ignoring its dependencies eval_always: bool, } diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 2157b8ce15931..efa259d0c4e0d 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -711,7 +711,7 @@ impl<'a> CrateLocator<'a> { // See also #68149 which provides more detail on why emitting the // dependency on the rlib is a bad thing. // - // We currenty do not verify that these other sources are even in sync, + // We currently do not verify that these other sources are even in sync, // and this is arguably a bug (see #10786), but because reading metadata // is quite slow (especially from dylibs) we currently do not read it // from the other crate sources. diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index 9b05fd4734ca3..1553b6cf0affd 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -201,7 +201,7 @@ crate struct CrateRoot<'tcx> { per_def: LazyPerDefTables<'tcx>, - /// The DefIndex's of any proc macros delcared by this crate. + /// The DefIndex's of any proc macros declared by this crate. proc_macro_data: Option>, compiler_builtins: bool, diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index ca51d16f9f269..6ed4a1d491474 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -1231,7 +1231,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { GeneratorKind::Async(async_kind) => match async_kind { AsyncGeneratorKind::Block => "async block", AsyncGeneratorKind::Closure => "async closure", - _ => bug!("async block/closure expected, but async funtion found."), + _ => bug!("async block/closure expected, but async function found."), }, GeneratorKind::Gen => "generator", }, diff --git a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs index d91f6edc9800c..5c37faaa82a54 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs @@ -445,7 +445,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { err.buffer(&mut self.errors_buffer); } - /// Targetted error when encountering an `FnMut` closure where an `Fn` closure was expected. + /// Targeted error when encountering an `FnMut` closure where an `Fn` closure was expected. fn expected_fn_found_fn_mut_call(&self, err: &mut DiagnosticBuilder<'_>, sp: Span, act: &str) { err.span_label(sp, format!("cannot {}", act)); diff --git a/src/librustc_mir/borrow_check/invalidation.rs b/src/librustc_mir/borrow_check/invalidation.rs index 0bead27050ce6..d33639aa9d9a0 100644 --- a/src/librustc_mir/borrow_check/invalidation.rs +++ b/src/librustc_mir/borrow_check/invalidation.rs @@ -63,7 +63,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> { self.mutate_place(location, lhs, Shallow(None), JustWrite); } StatementKind::FakeRead(_, _) => { - // Only relavent for initialized/liveness/safety checks. + // Only relevant for initialized/liveness/safety checks. } StatementKind::SetDiscriminant { ref place, variant_index: _ } => { self.mutate_place(location, place, Shallow(None), JustWrite); diff --git a/src/librustc_mir/borrow_check/member_constraints.rs b/src/librustc_mir/borrow_check/member_constraints.rs index aeb29d2e11eb0..4323e2db84476 100644 --- a/src/librustc_mir/borrow_check/member_constraints.rs +++ b/src/librustc_mir/borrow_check/member_constraints.rs @@ -125,7 +125,7 @@ where // wind up mapped to the same key `S`, we would append the // linked list for `Ra` onto the end of the linked list for // `Rb` (or vice versa) -- this basically just requires - // rewriting the final link from one list to point at the othe + // rewriting the final link from one list to point at the other // other (see `append_list`). let MemberConstraintSet { first_constraints, mut constraints, choice_regions } = self; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 28974dcd08bf6..f93f2acfa8a6c 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -452,7 +452,7 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> { /// for the activation of the borrow. reservation_warnings: FxHashMap, Span, Location, BorrowKind, BorrowData<'tcx>)>, - /// This field keeps track of move errors that are to be reported for given move indicies. + /// This field keeps track of move errors that are to be reported for given move indices. /// /// There are situations where many errors can be reported for a single move out (see #53807) /// and we want only the best of those errors. diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index 652de6c7b6fdf..ace92949814a7 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -579,7 +579,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { | ConstraintCategory::UseAsConst | ConstraintCategory::UseAsStatic = constraint.category { - // "Returning" from a promoted is an assigment to a + // "Returning" from a promoted is an assignment to a // temporary from the user's point of view. constraint.category = ConstraintCategory::Boring; } diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index 1bf748e66e2a0..7a8e61db6d019 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -226,7 +226,7 @@ pub fn const_eval_validated_provider<'tcx>( match tcx.const_eval_validated(key) { // try again with reveal all as requested Err(ErrorHandled::TooGeneric) => {} - // dedupliate calls + // deduplicate calls other => return other, } } @@ -267,7 +267,7 @@ pub fn const_eval_raw_provider<'tcx>( match tcx.const_eval_raw(key) { // try again with reveal all as requested Err(ErrorHandled::TooGeneric) => {} - // dedupliate calls + // deduplicate calls other => return other, } } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 7a3f09ac80b3d..e683422e611a8 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -670,7 +670,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ); if cur_unwinding { // Follow the unwind edge. - let unwind = next_block.expect("Encounted StackPopCleanup::None when unwinding!"); + let unwind = next_block.expect("Encountered StackPopCleanup::None when unwinding!"); self.unwind_to_block(unwind); } else { // Follow the normal return edge. diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 69c9664b35156..6615cc608fb54 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -227,7 +227,7 @@ pub trait Machine<'mir, 'tcx>: Sized { /// it contains (in relocations) tagged. The way we construct allocations is /// to always first construct it without extra and then add the extra. /// This keeps uniform code paths for handling both allocations created by CTFE - /// for statics, and allocations ceated by Miri during evaluation. + /// for statics, and allocations created by Miri during evaluation. /// /// `kind` is the kind of the allocation being tagged; it can be `None` when /// it's a static and `STATIC_KIND` is `None`. diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 44b46d65bf1c7..22b1a7b7137d9 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -678,7 +678,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // Then computing the absolute variant idx should not overflow any more. let variant_index = variants_start .checked_add(variant_index_relative) - .expect("oveflow computing absolute variant idx"); + .expect("overflow computing absolute variant idx"); let variants_len = rval .layout .ty diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 2353b74016c2b..ee45179fd8b31 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -292,7 +292,7 @@ where let all_bytes = 0..self.len(); // This 'inspect' is okay since following access respects undef and relocations. This does - // influence interpreter exeuction, but only to detect the error of cycles in evalution + // influence interpreter exeuction, but only to detect the error of cycles in evaluation // dependencies. let bytes = self.inspect_with_undef_and_ptr_outside_interpreter(all_bytes); diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index a5b467c1e101f..67444a267828c 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -20,7 +20,7 @@ fn is_stable(place: PlaceRef<'_, '_>) -> bool { // Which place this evaluates to can change with any memory write, // so cannot assume this to be stable. ProjectionElem::Deref => false, - // Array indices are intersting, but MIR building generates a *fresh* + // Array indices are interesting, but MIR building generates a *fresh* // temporary for every array access, so the index cannot be changed as // a side-effect. ProjectionElem::Index { .. } | diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index c196e748df381..0560f77f5c99f 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -664,7 +664,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { return; } - // FIXME> figure out what tho do when try_read_immediate fails + // FIXME> figure out what to do when try_read_immediate fails let imm = self.use_ecx(|this| this.ecx.try_read_immediate(value)); if let Some(Ok(imm)) = imm { diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index f7239ae55faa2..07b0765488d34 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -731,7 +731,7 @@ where self.elaborator.patch().new_block(base_block) } - /// Ceates a pair of drop-loops of `place`, which drops its contents, even + /// Creates a pair of drop-loops of `place`, which drops its contents, even /// in the case of 1 panic. If `ptr_based`, creates a pointer loop, /// otherwise create an index loop. fn drop_loop_pair( diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6fd8f06fe8f25..65cc6a900341e 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -490,7 +490,7 @@ fn write_scope_tree( } let children = match scope_tree.get(&parent) { - Some(childs) => childs, + Some(children) => children, None => return Ok(()), }; diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 5b054c0452243..066fd8281cc7c 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -837,7 +837,7 @@ impl<'tcx> Constructor<'tcx> { // eliminate it straight away. remaining_ranges = vec![]; } else { - // Otherwise explicitely compute the remaining ranges. + // Otherwise explicitly compute the remaining ranges. remaining_ranges = other_range.subtract_from(remaining_ranges); } diff --git a/src/librustc_parse/config.rs b/src/librustc_parse/config.rs index 17b9e78e5df46..f42091e7c296a 100644 --- a/src/librustc_parse/config.rs +++ b/src/librustc_parse/config.rs @@ -257,7 +257,7 @@ impl<'a> StripUnconfigured<'a> { /// Parse and expand all `cfg_attr` attributes into a list of attributes /// that are within each `cfg_attr` that has a true configuration predicate. /// - /// Gives compiler warnigns if any `cfg_attr` does not contain any + /// Gives compiler warnings if any `cfg_attr` does not contain any /// attributes and is in the original source code. Gives compiler errors if /// the syntax of any `cfg_attr` is incorrect. pub fn process_cfg_attrs(&mut self, node: &mut T) { diff --git a/src/librustc_parse/parser/attr.rs b/src/librustc_parse/parser/attr.rs index 2dccb04f6cce1..bdd78e671a8b3 100644 --- a/src/librustc_parse/parser/attr.rs +++ b/src/librustc_parse/parser/attr.rs @@ -138,7 +138,7 @@ impl<'a> Parser<'a> { if let Some(prev_attr_sp) = prev_attr_sp { diagnostic - .span_label(attr_sp, "not permitted following an outer attibute") + .span_label(attr_sp, "not permitted following an outer attribute") .span_label(prev_attr_sp, prev_attr_note); } diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index 8b43b424f5502..6587e763d50c5 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -895,7 +895,7 @@ impl<'a> Parser<'a> { let msg = format!("expected `;`, found `{}`", super::token_descr(&self.token)); let appl = Applicability::MachineApplicable; if self.token.span == DUMMY_SP || self.prev_token.span == DUMMY_SP { - // Likely inside a macro, can't provide meaninful suggestions. + // Likely inside a macro, can't provide meaningful suggestions. return self.expect(&token::Semi).map(drop); } else if !sm.is_multiline(self.prev_token.span.until(self.token.span)) { // The current token is in the same line as the prior token, not recoverable. diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 18ddd23588e48..e9ee797b90f1b 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1373,7 +1373,7 @@ impl<'a> Parser<'a> { )) } - /// Parses an optional `move` prefix to a closure lke construct. + /// Parses an optional `move` prefix to a closure-like construct. fn parse_capture_clause(&mut self) -> CaptureBy { if self.eat_keyword(kw::Move) { CaptureBy::Value } else { CaptureBy::Ref } } diff --git a/src/librustc_passes/region.rs b/src/librustc_passes/region.rs index e636144794ab6..282bd20a9bed9 100644 --- a/src/librustc_passes/region.rs +++ b/src/librustc_passes/region.rs @@ -285,7 +285,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h // Ordinarily, we can rely on the visit order of HIR intravisit // to correspond to the actual execution order of statements. - // However, there's a weird corner case with compund assignment + // However, there's a weird corner case with compound assignment // operators (e.g. `a += b`). The evaluation order depends on whether // or not the operator is overloaded (e.g. whether or not a trait // like AddAssign is implemented). diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index f075385ae18b9..7ea9ab5335db3 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -655,7 +655,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) { } // FIXME(#44232): the `used_features` table no longer exists, so we - // don't lint about unused features. We should reenable this one day! + // don't lint about unused features. We should re-enable this one day! } fn unnecessary_stable_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol, since: Symbol) { diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 18192a18cef36..ab5816cb7759b 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -1090,7 +1090,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { } // Sort extern crate names in reverse order to get - // 1) some consistent ordering for emitted dignostics, and + // 1) some consistent ordering for emitted diagnostics, and // 2) `std` suggestions before `core` suggestions. let mut extern_crate_names = self.r.extern_prelude.iter().map(|(ident, _)| ident.name).collect::>(); diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index 3b018005a88d2..5d4df992b949a 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -1075,7 +1075,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { // single import (see test `issue-55884-2.rs`). In theory single imports should // always block globs, even if they are not yet resolved, so that this kind of // self-inconsistent resolution never happens. - // Reenable the assert when the issue is fixed. + // Re-enable the assert when the issue is fixed. // assert!(result[ns].get().is_err()); } } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index a3554ea2ee0a3..ee67cecde9ad6 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -553,7 +553,7 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { let prev = replace(&mut self.diagnostic_metadata.currently_processing_generics, true); match arg { GenericArg::Type(ref ty) => { - // We parse const arguments as path types as we cannot distiguish them during + // We parse const arguments as path types as we cannot distinguish them during // parsing. We try to resolve that ambiguity by attempting resolution the type // namespace first, and if that fails we try again in the value namespace. If // resolution in the value namespace succeeds, we have an generic const argument on diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index 193b6d75935b2..bd46e8e08699a 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -540,7 +540,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { LifetimeName::Implicit => { // For types like `dyn Foo`, we should // generate a special form of elided. - span_bug!(ty.span, "object-lifetime-default expected, not implict",); + span_bug!(ty.span, "object-lifetime-default expected, not implicit",); } LifetimeName::ImplicitObjectLifetimeDefault => { // If the user does not write *anything*, we diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index 8c7108229bd80..77e7ff1e2a738 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -365,11 +365,11 @@ impl<'a, Ty> TyLayout<'a, Ty> { // // NB: for all tagged `enum`s (which include all non-C-like // `enum`s with defined FFI representation), this will - // match the homogenous computation on the equivalent + // match the homogeneous computation on the equivalent // `struct { tag; union { variant1; ... } }` and/or // `union { struct { tag; variant1; } ... }` // (the offsets of variant fields should be identical - // between the two for either to be a homogenous aggregate). + // between the two for either to be a homogeneous aggregate). let variant_start = total; for variant_idx in variants.indices() { let (variant_result, variant_total) = @@ -542,7 +542,7 @@ pub struct FnAbi<'a, Ty> { /// The count of non-variadic arguments. /// /// Should only be different from args.len() when c_variadic is true. - /// This can be used to know wether an argument is variadic or not. + /// This can be used to know whether an argument is variadic or not. pub fixed_count: usize, pub conv: Conv, diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index ffef38cedfc17..e9bb94ca49050 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -401,7 +401,7 @@ impl Align { } } -/// A pair of aligments, ABI-mandated and preferred. +/// A pair of alignments, ABI-mandated and preferred. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] #[derive(HashStable_Generic)] pub struct AbiAndPrefAlign { diff --git a/src/librustc_target/spec/i686_unknown_uefi.rs b/src/librustc_target/spec/i686_unknown_uefi.rs index 345590a00be8b..e299f92fdeb63 100644 --- a/src/librustc_target/spec/i686_unknown_uefi.rs +++ b/src/librustc_target/spec/i686_unknown_uefi.rs @@ -29,7 +29,7 @@ pub fn target() -> TargetResult { base.abi_return_struct_as_int = true; // Use -GNU here, because of the reason below: - // Backgound and Problem: + // Background and Problem: // If we use i686-unknown-windows, the LLVM IA32 MSVC generates compiler intrinsic // _alldiv, _aulldiv, _allrem, _aullrem, _allmul, which will cause undefined symbol. // A real issue is __aulldiv() is referred by __udivdi3() - udivmod_inner!(), from @@ -64,7 +64,7 @@ pub fn target() -> TargetResult { // i386/umoddi3.S // Possible solution: // 1. Eliminate Intrinsics generation. - // 1.1 Choose differnt target to bypass isTargetKnownWindowsMSVC(). + // 1.1 Choose different target to bypass isTargetKnownWindowsMSVC(). // 1.2 Remove the "Setup Windows compiler runtime calls" in LLVM // 2. Implement Intrinsics. // We evaluated all options. diff --git a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs index f070a3e5da443..e0a402533e777 100644 --- a/src/librustc_target/spec/nvptx64_nvidia_cuda.rs +++ b/src/librustc_target/spec/nvptx64_nvidia_cuda.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { // The linker can be installed from `crates.io`. linker: Some("rust-ptx-linker".to_string()), - // With `ptx-linker` approach, it can be later overriden via link flags. + // With `ptx-linker` approach, it can be later overridden via link flags. cpu: "sm_30".to_string(), // FIXME: create tests for the atomics. @@ -43,7 +43,7 @@ pub fn target() -> TargetResult { // Let the `ptx-linker` to handle LLVM lowering into MC / assembly. obj_is_bitcode: true, - // Convinient and predicable naming scheme. + // Convenient and predicable naming scheme. dll_prefix: "".to_string(), dll_suffix: ".ptx".to_string(), exe_suffix: ".ptx".to_string(), diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 199b476cb9a3e..c3cf0cdc61da6 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -661,7 +661,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { /// Given the type/lifetime/const arguments provided to some path (along with /// an implicit `Self`, if this is a trait reference), returns the complete /// set of substitutions. This may involve applying defaulted type parameters. - /// Also returns back constriants on associated types. + /// Also returns back constraints on associated types. /// /// Example: /// @@ -2924,7 +2924,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let tcx = self.tcx(); - // We proactively collect all the infered type params to emit a single error per fn def. + // We proactively collect all the inferred type params to emit a single error per fn def. let mut visitor = PlaceholderHirTyCollector::default(); for ty in decl.inputs { visitor.visit_ty(ty); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 40cafb626d7c2..b271bc95d9453 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1040,7 +1040,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { return r; } - debug!("pick: actual search failed, assemble diagnotics"); + debug!("pick: actual search failed, assemble diagnostics"); let static_candidates = mem::take(&mut self.static_candidates); let private_candidate = self.private_candidate.take(); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d8b23998e727f..1ec97a48001b8 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -457,7 +457,7 @@ pub enum Diverges { /// where all arms diverge), we may be /// able to provide a more informative /// message to the user. - /// If this is `None`, a default messsage + /// If this is `None`, a default message /// will be generated, which is suitable /// for most cases. custom_note: Option<&'static str>, @@ -896,7 +896,7 @@ where ty::Opaque(def_id, substs) => { debug!("fixup_opaque_types: found type {:?}", ty); // Here, we replace any inference variables that occur within - // the substs of an opaque type. By definition, any type occuring + // the substs of an opaque type. By definition, any type occurring // in the substs has a corresponding generic parameter, which is what // we replace it with. // This replacement is only run on the function signature, so any @@ -1937,7 +1937,7 @@ fn check_specialization_validity<'tcx>( } }); - // If `opt_result` is `None`, we have only encoutered `default impl`s that don't contain the + // If `opt_result` is `None`, we have only encountered `default impl`s that don't contain the // item. This is allowed, the item isn't actually getting specialized here. let result = opt_result.unwrap_or(Ok(())); @@ -3452,7 +3452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // } // ``` // - // In the above snippet, the inference varaible created by + // In the above snippet, the inference variable created by // instantiating `Option` will be completely unconstrained. // We treat this as a non-defining use by making the inference // variable fall back to the opaque type itself. diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index b7aac707a9838..32f04f03a1d28 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -98,7 +98,7 @@ const INITIAL_BM: BindingMode = BindingMode::BindByValue(hir::Mutability::Not); enum AdjustMode { /// Peel off all immediate reference types. Peel, - /// Reset binding mode to the inital mode. + /// Reset binding mode to the initial mode. Reset, /// Pass on the input binding mode and expected type. Pass, @@ -841,7 +841,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern // with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`. let missing_parenthesis = match (&expected.kind, fields, had_err) { - // #67037: only do this if we could sucessfully type-check the expected type against + // #67037: only do this if we could successfully type-check the expected type against // the tuple struct pattern. Otherwise the substs could get out of range on e.g., // `let P() = U;` where `P != U` with `struct P(T);`. (ty::Adt(_, substs), [field], false) => { diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index a8e5a0ddf2686..0a57449357324 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -174,7 +174,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { // impl !Send for (A, B) { } // ``` // - // This final impl is legal according to the orpan + // This final impl is legal according to the orphan // rules, but it invalidates the reasoning from // `two_foos` above. debug!( diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 26462e61e5d57..fc1ef4f756c09 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1395,7 +1395,7 @@ fn are_suggestable_generic_args(generic_args: &[hir::GenericArg<'_>]) -> bool { .any(is_suggestable_infer_ty) } -/// Whether `ty` is a type with `_` placeholders that can be infered. Used in diagnostics only to +/// Whether `ty` is a type with `_` placeholders that can be inferred. Used in diagnostics only to /// use inference to provide suggestions for the appropriate type if possible. fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool { use hir::TyKind::*; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 289923b45e648..407b50382fa37 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -493,7 +493,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // Writing a projection trait bound of the form // ::Name : ?Sized // is illegal, because ?Sized bounds can only - // be written in the (here, nonexistant) definition + // be written in the (here, nonexistent) definition // of the type. // Therefore, we make sure that we never add a ?Sized // bound for projections diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 0b4bb304fe9e0..02f1947c99e5f 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -135,7 +135,7 @@ trait Writer { fn string(&mut self, text: T, klass: Class) -> io::Result<()>; } -// Implement `Writer` for anthing that can be written to, this just implements +// Implement `Writer` for anything that can be written to, this just implements // the default rustdoc behaviour. impl Writer for U { fn string(&mut self, text: T, klass: Class) -> io::Result<()> { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 07fe439ace226..c64c476970862 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3601,7 +3601,7 @@ fn render_impl( use_absolute: Option, is_on_foreign_type: bool, show_default_items: bool, - // This argument is used to reference same type with different pathes to avoid duplication + // This argument is used to reference same type with different paths to avoid duplication // in documentation pages for trait with automatic implementations like "Send" and "Sync". aliases: &[String], ) { diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 200b00b119595..edc28033c9b83 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -651,7 +651,7 @@ impl Ipv4Addr { /// Returns [`true`] if this address is reserved by IANA for future use. [IETF RFC 1112] /// defines the block of reserved addresses as `240.0.0.0/4`. This range normally includes the - /// broadcast address `255.255.255.255`, but this implementation explicitely excludes it, since + /// broadcast address `255.255.255.255`, but this implementation explicitly excludes it, since /// it is obviously not reserved for future use. /// /// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112 diff --git a/src/libstd/os/linux/fs.rs b/src/libstd/os/linux/fs.rs index dd71201b50b91..d22b44a066662 100644 --- a/src/libstd/os/linux/fs.rs +++ b/src/libstd/os/linux/fs.rs @@ -34,7 +34,7 @@ pub trait MetadataExt { /// } /// ``` #[stable(feature = "metadata_ext", since = "1.1.0")] - #[rustc_deprecated(since = "1.8.0", reason = "other methods of this trait are now prefered")] + #[rustc_deprecated(since = "1.8.0", reason = "other methods of this trait are now preferred")] #[allow(deprecated)] fn as_raw_stat(&self) -> &raw::stat; diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index c51aa7619db77..0274268f69f25 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -40,7 +40,7 @@ struct Consumer { tail: UnsafeCell<*mut Node>, // where to pop from tail_prev: AtomicPtr>, // where to pop from cache_bound: usize, // maximum cache size - cached_nodes: AtomicUsize, // number of nodes marked as cachable + cached_nodes: AtomicUsize, // number of nodes marked as cacheable addition: Addition, } diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index b54c115a2b6b6..76a9b427b39c6 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -151,7 +151,7 @@ unsafe impl UserSafe for [T] { /// It is also possible to obtain a mutable reference `&mut UserRef`. Unlike /// regular mutable references, these are not exclusive. Userspace may always /// write to the backing memory at any time, so it can't be assumed that there -/// the pointed-to memory is uniquely borrowed. The two different refence types +/// the pointed-to memory is uniquely borrowed. The two different reference types /// are used solely to indicate intent: a mutable reference is for writing to /// user memory, an immutable reference for reading from user memory. #[unstable(feature = "sgx_platform", issue = "56975")] diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 06876cb06149e..fbcb006ecdf11 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -156,7 +156,7 @@ where // On Unix-like platforms, libc::abort will unregister signal handlers // including the SIGABRT handler, preventing the abort from being blocked, and -// fclose streams, with the side effect of flushing them so libc bufferred +// fclose streams, with the side effect of flushing them so libc buffered // output will be printed. Additionally the shell will generally print a more // understandable error message like "Abort trap" rather than "Illegal // instruction" that intrinsics::abort would cause, as intrinsics::abort is diff --git a/src/libstd/sys/vxworks/mod.rs b/src/libstd/sys/vxworks/mod.rs index 12bbfa1d4e1a6..e23191c94311f 100644 --- a/src/libstd/sys/vxworks/mod.rs +++ b/src/libstd/sys/vxworks/mod.rs @@ -103,7 +103,7 @@ where // On Unix-like platforms, libc::abort will unregister signal handlers // including the SIGABRT handler, preventing the abort from being blocked, and -// fclose streams, with the side effect of flushing them so libc bufferred +// fclose streams, with the side effect of flushing them so libc buffered // output will be printed. Additionally the shell will generally print a more // understandable error message like "Abort trap" rather than "Illegal // instruction" that intrinsics::abort would cause, as intrinsics::abort is diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs index a800bd17c503b..5317063b80d11 100644 --- a/src/libtest/cli.rs +++ b/src/libtest/cli.rs @@ -283,7 +283,7 @@ fn is_nightly() -> bool { bootstrap || !disable_unstable_features } -// Gets the CLI options assotiated with `report-time` feature. +// Gets the CLI options associated with `report-time` feature. fn get_time_options( matches: &getopts::Matches, allow_unstable: bool, diff --git a/src/libtest/options.rs b/src/libtest/options.rs index 7db164c269a5e..8e7bd8de92499 100644 --- a/src/libtest/options.rs +++ b/src/libtest/options.rs @@ -41,7 +41,7 @@ pub enum OutputFormat { Json, } -/// Whether ignored test should be runned or not +/// Whether ignored test should be run or not #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum RunIgnored { Yes, diff --git a/src/libtest/test_result.rs b/src/libtest/test_result.rs index 5c975c6272b97..465f3f8f99427 100644 --- a/src/libtest/test_result.rs +++ b/src/libtest/test_result.rs @@ -27,7 +27,7 @@ pub enum TestResult { unsafe impl Send for TestResult {} /// Creates a `TestResult` depending on the raw result of test execution -/// and assotiated data. +/// and associated data. pub fn calc_result<'a>( desc: &TestDesc, task_result: Result<(), &'a (dyn Any + 'static + Send)>, diff --git a/src/test/incremental/cyclic-trait-hierarchy.rs b/src/test/incremental/cyclic-trait-hierarchy.rs index 27287d06d54b1..03bb5eea765cc 100644 --- a/src/test/incremental/cyclic-trait-hierarchy.rs +++ b/src/test/incremental/cyclic-trait-hierarchy.rs @@ -1,4 +1,4 @@ -// Adapated from rust-lang/rust#58813 +// Adapted from rust-lang/rust#58813 // revisions: rpass1 cfail2 diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs b/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs index 42168dd273eff..9c17c8745f8ca 100644 --- a/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs +++ b/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs @@ -4,7 +4,7 @@ // rust-lang/rust#59535: // -// This is analgous to cgu_invalidated_when_import_removed.rs, but it covers +// This is analogous to cgu_invalidated_when_import_removed.rs, but it covers // the other direction: // // We start with a call-graph like `[A] -> [B -> D] [C]` (where the letters are diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs b/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs index 19ce7b3e148f7..1214e37f982ed 100644 --- a/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs +++ b/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs @@ -41,7 +41,7 @@ mod foo { // In cfail2, ThinLTO decides that foo() does not get inlined into main, and // instead bar() gets inlined into foo(). But faulty logic in our incr. // ThinLTO implementation thought that `main()` is unchanged and thus reused - // the object file still containing a call to the now non-existant bar(). + // the object file still containing a call to the now non-existent bar(). pub fn foo(){ bar() } diff --git a/src/test/ui/consts/const-int-arithmetic-overflow.rs b/src/test/ui/consts/const-int-arithmetic-overflow.rs index 75dac812f1e3a..99bbeaafda5c4 100644 --- a/src/test/ui/consts/const-int-arithmetic-overflow.rs +++ b/src/test/ui/consts/const-int-arithmetic-overflow.rs @@ -8,7 +8,7 @@ const fn add(x: i8, y: i8) -> i8 { x+y } const fn sub(x: i8, y: i8) -> i8 { x-y } const fn mul(x: i8, y: i8) -> i8 { x*y } -// div and rem are always checked, so we cannot test their result in case of oveflow. +// div and rem are always checked, so we cannot test their result in case of overflow. const fn neg(x: i8) -> i8 { -x } fn main() { diff --git a/src/test/ui/definition-reachable/nested-fn.rs b/src/test/ui/definition-reachable/nested-fn.rs index b596ba8936a43..b665b049f32f9 100644 --- a/src/test/ui/definition-reachable/nested-fn.rs +++ b/src/test/ui/definition-reachable/nested-fn.rs @@ -1,4 +1,4 @@ -// Check that functions visible to macros through paths with >2 segements are +// Check that functions visible to macros through paths with >2 segments are // considered reachable // aux-build:field-method-macro.rs diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index 1c3b5ac76138f..00f3490991b52 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -12,7 +12,7 @@ impl<'a> LifetimeTrait<'a> for &'a i32 {} fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~^ ERROR cannot infer an appropriate lifetime -// Tests that a closure type contianing 'b cannot be returned from a type where +// Tests that a closure type containing 'b cannot be returned from a type where // only 'a was expected. fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { //~^ ERROR lifetime mismatch diff --git a/src/test/ui/mir/mir_assign_eval_order.rs b/src/test/ui/mir/mir_assign_eval_order.rs index 1594421b0b13b..799bf7f3a12a8 100644 --- a/src/test/ui/mir/mir_assign_eval_order.rs +++ b/src/test/ui/mir/mir_assign_eval_order.rs @@ -12,7 +12,7 @@ fn evaluate_reborrow_before_assign() { let y = &mut &2; let z = &3; // There's an implicit reborrow of `x` on the right-hand side of the - // assignement. Note that writing an explicit reborrow would not show this + // assignment. Note that writing an explicit reborrow would not show this // bug, as now there would be two reborrows on the right-hand side and at // least one of them would happen before the left-hand side is evaluated. *{ x = z; &mut *y } = x; diff --git a/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs b/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs index 0d96767a05d03..a111acca66fef 100644 --- a/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs +++ b/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs @@ -1,4 +1,4 @@ -// Ths test case is exploring the space of how blocs with tail +// This test case is exploring the space of how blocks with tail // expressions and statements can be composed, trying to keep each // case on one line so that we can compare them via a vertical scan // with the human eye. diff --git a/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs b/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs index 61d5d51cfd248..d0984bbe65fd5 100644 --- a/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs +++ b/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs @@ -1,6 +1,6 @@ // Regression test for sanitizer function instrumentation passes not // being run when compiling with new LLVM pass manager and ThinLTO. -// Note: The issue occured only on non-zero opt-level. +// Note: The issue occurred only on non-zero opt-level. // // min-llvm-version 9.0 // needs-sanitizer-support diff --git a/src/test/ui/type-alias-impl-trait/issue-65918.rs b/src/test/ui/type-alias-impl-trait/issue-65918.rs index 4ba778d53ac08..af6d501092017 100644 --- a/src/test/ui/type-alias-impl-trait/issue-65918.rs +++ b/src/test/ui/type-alias-impl-trait/issue-65918.rs @@ -6,7 +6,7 @@ use std::marker::PhantomData; -/* copied Index and TryFrom for convinience (and simplicity) */ +/* copied Index and TryFrom for convenience (and simplicity) */ trait MyIndex { type O; fn my_index(self) -> Self::O; diff --git a/src/test/ui/type-alias-impl-trait/issue-67844-nested-opaque.rs b/src/test/ui/type-alias-impl-trait/issue-67844-nested-opaque.rs index 2f844b4a05f5f..7da0b049264c2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-67844-nested-opaque.rs +++ b/src/test/ui/type-alias-impl-trait/issue-67844-nested-opaque.rs @@ -1,6 +1,6 @@ // check-pass // Regression test for issue #67844 -// Ensures that we properly handle nested TAIT occurences +// Ensures that we properly handle nested TAIT occurrences // with generic parameters #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/typeck/issue-52082-type-param-shadows-existing-type.rs b/src/test/ui/typeck/issue-52082-type-param-shadows-existing-type.rs index c57e8149574c9..7bf151514c3dd 100644 --- a/src/test/ui/typeck/issue-52082-type-param-shadows-existing-type.rs +++ b/src/test/ui/typeck/issue-52082-type-param-shadows-existing-type.rs @@ -1,4 +1,4 @@ -// Fix issue 52082: Confusing error if accidentially defining a type paramter with the same name as +// Fix issue 52082: Confusing error if accidentally defining a type parameter with the same name as // an existing type // // To this end, make sure that when trying to retrieve a field of a (reference to) type parameter, diff --git a/src/test/ui/wf/wf-array-elem-sized.rs b/src/test/ui/wf/wf-array-elem-sized.rs index 41c2d3c43e975..34bf22034265c 100644 --- a/src/test/ui/wf/wf-array-elem-sized.rs +++ b/src/test/ui/wf/wf-array-elem-sized.rs @@ -1,4 +1,4 @@ -// Check that array elemen types must be Sized. Issue #25692. +// Check that array element types must be Sized. Issue #25692. #![allow(dead_code)] diff --git a/src/tools/compiletest/src/errors.rs b/src/tools/compiletest/src/errors.rs index c3d699b3e2307..8f685fb8559f5 100644 --- a/src/tools/compiletest/src/errors.rs +++ b/src/tools/compiletest/src/errors.rs @@ -125,7 +125,7 @@ fn parse_expected( let captures = RE.captures(line)?; match (cfg, captures.name("cfgs")) { - // Only error messages that contain our `cfg` betweeen the square brackets apply to us. + // Only error messages that contain our `cfg` between the square brackets apply to us. (Some(cfg), Some(filter)) if !filter.as_str().split(',').any(|s| s == cfg) => return None, (Some(_), Some(_)) => {} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ac808b1f14e13..424bac88c8531 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1487,7 +1487,7 @@ impl<'test> TestCx<'test> { // can turn it back on if needed. if !self.is_rustdoc() // Note that we use the local pass mode here as we don't want - // to set unused to allow if we've overriden the pass mode + // to set unused to allow if we've overridden the pass mode // via command line flags. && local_pm != Some(PassMode::Run) { diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index f11394bd95f1f..349829d872507 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -41,7 +41,7 @@ const EXCEPTION_PATHS: &[&str] = &[ "src/libpanic_unwind", "src/libunwind", // black_box implementation is LLVM-version specific and it uses - // target_os to tell targets with different LLVM-versions appart + // target_os to tell targets with different LLVM-versions apart // (e.g. `wasm32-unknown-emscripten` vs `wasm32-unknown-unknown`): "src/libcore/hint.rs", "src/libstd/sys/", // Platform-specific code for std lives here. From 18080e60728401c9bd4d102bbb33a0d6d53740f6 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 7 Mar 2020 03:32:01 +0900 Subject: [PATCH 07/12] Remove `NO_DEBUG` const --- src/librustc/middle/codegen_fn_attrs.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/librustc/middle/codegen_fn_attrs.rs b/src/librustc/middle/codegen_fn_attrs.rs index 82adcfddc289e..61b25cc486446 100644 --- a/src/librustc/middle/codegen_fn_attrs.rs +++ b/src/librustc/middle/codegen_fn_attrs.rs @@ -58,9 +58,6 @@ bitflags! { /// "weird symbol" for the standard library in that it has slightly /// different linkage, visibility, and reachability rules. const RUSTC_STD_INTERNAL_SYMBOL = 1 << 6; - /// `#[no_debug]`: an indicator that no debugging information should be - /// generated for this function by LLVM. - const NO_DEBUG = 1 << 7; /// `#[thread_local]`: indicates a static is actually a thread local /// piece of memory const THREAD_LOCAL = 1 << 8; From 4c2b0f1631f40f7dce7292b3b3b4e2a752b82f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 16:02:32 +0100 Subject: [PATCH 08/12] bless tests --- src/libcore/tests/num/dec2flt/mod.rs | 2 +- src/librustc_expand/proc_macro.rs | 2 +- src/test/ui/explain.stdout | 2 +- src/test/ui/parser/attr-stmt-expr-attr-bad.stderr | 10 +++++----- src/test/ui/parser/inner-attr-after-doc-comment.stderr | 2 +- src/test/ui/parser/inner-attr.stderr | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcore/tests/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index 509097fdb5485..a1fa5556ae5db 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -44,7 +44,7 @@ fn ordinary() { #[test] fn special_code_paths() { test_literal!(36893488147419103229.0); // 2^65 - 3, triggers half-to-even with even significand - test_literal!(101e-33); // Triggers the tricky underflow case in algorithm (for f32) + test_literal!(101e-33); // Triggers the tricky underflow case in AlgorithmM (for f32) test_literal!(1e23); // Triggers AlgorithmR test_literal!(2075e23); // Triggers another path through AlgorithmR test_literal!(8713e-23); // ... and yet another. diff --git a/src/librustc_expand/proc_macro.rs b/src/librustc_expand/proc_macro.rs index 5404ee192a61a..84a546345bb28 100644 --- a/src/librustc_expand/proc_macro.rs +++ b/src/librustc_expand/proc_macro.rs @@ -133,7 +133,7 @@ impl MultiItemModifier for ProcMacroDerive { }; let error_count_before = ecx.parse_sess.span_diagnostic.err_count(); - let msg = "proc-macro derive produced unparsable tokens"; + let msg = "proc-macro derive produced unparseable tokens"; let mut parser = rustc_parse::stream_to_parser(ecx.parse_sess, stream, Some("proc-macro derive")); diff --git a/src/test/ui/explain.stdout b/src/test/ui/explain.stdout index 9ea56271f593f..c50c46ee56416 100644 --- a/src/test/ui/explain.stdout +++ b/src/test/ui/explain.stdout @@ -46,7 +46,7 @@ This pattern should be rewritten. There are a few possible ways to do this: - change the original fn declaration to match the expected signature, and do the cast in the fn body (the preferred option) -- cast the fn item fo a fn pointer before calling transmute, as shown here: +- cast the fn item of a fn pointer before calling transmute, as shown here: ``` let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_)); diff --git a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr index b03db85422d0c..6159acd5080f5 100644 --- a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -292,7 +292,7 @@ error: an inner attribute is not permitted following an outer attribute --> $DIR/attr-stmt-expr-attr-bad.rs:80:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } - | ------- ^^^^^^^^ not permitted following an outer attibute + | ------- ^^^^^^^^ not permitted following an outer attribute | | | previous outer attribute | @@ -302,7 +302,7 @@ error: an inner attribute is not permitted following an outer attribute --> $DIR/attr-stmt-expr-attr-bad.rs:82:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } - | ------- ^^^^^^^^ not permitted following an outer attibute + | ------- ^^^^^^^^ not permitted following an outer attribute | | | previous outer attribute | @@ -312,7 +312,7 @@ error: an inner attribute is not permitted following an outer attribute --> $DIR/attr-stmt-expr-attr-bad.rs:84:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); } - | ------- ^^^^^^^^ not permitted following an outer attibute + | ------- ^^^^^^^^ not permitted following an outer attribute | | | previous outer attribute | @@ -322,7 +322,7 @@ error: an inner attribute is not permitted following an outer attribute --> $DIR/attr-stmt-expr-attr-bad.rs:86:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; } - | ------- ^^^^^^^^ not permitted following an outer attibute + | ------- ^^^^^^^^ not permitted following an outer attribute | | | previous outer attribute | @@ -332,7 +332,7 @@ error: an inner attribute is not permitted following an outer attribute --> $DIR/attr-stmt-expr-attr-bad.rs:88:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; } - | ------- ^^^^^^^^ not permitted following an outer attibute + | ------- ^^^^^^^^ not permitted following an outer attribute | | | previous outer attribute | diff --git a/src/test/ui/parser/inner-attr-after-doc-comment.stderr b/src/test/ui/parser/inner-attr-after-doc-comment.stderr index b012abc25e7f3..c1e9e7a427f89 100644 --- a/src/test/ui/parser/inner-attr-after-doc-comment.stderr +++ b/src/test/ui/parser/inner-attr-after-doc-comment.stderr @@ -7,7 +7,7 @@ LL | | */ | |___- previous doc comment LL | LL | #![recursion_limit="100"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attibute + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. diff --git a/src/test/ui/parser/inner-attr.stderr b/src/test/ui/parser/inner-attr.stderr index 070d9f47d96f9..e1bf2cca1c963 100644 --- a/src/test/ui/parser/inner-attr.stderr +++ b/src/test/ui/parser/inner-attr.stderr @@ -5,7 +5,7 @@ LL | #[feature(lang_items)] | ---------------------- previous outer attribute LL | LL | #![recursion_limit="100"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attibute + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. From 0ed6e795fb3e8e70765576b929e3eb030c4f10d3 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 6 Mar 2020 18:22:17 -0300 Subject: [PATCH 09/12] mir::Local is Copy we can pass it by value in these cases --- src/librustc/mir/visit.rs | 10 +++++----- src/librustc_codegen_ssa/mir/analyze.rs | 2 +- .../transform/check_consts/validation.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 409c981801b34..2aca6f684f4fe 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -888,7 +888,7 @@ macro_rules! visit_place_fns { () => ( fn visit_projection( &mut self, - local: &Local, + local: Local, projection: &[PlaceElem<'tcx>], context: PlaceContext, location: Location, @@ -898,7 +898,7 @@ macro_rules! visit_place_fns { fn visit_projection_elem( &mut self, - local: &Local, + local: Local, proj_base: &[PlaceElem<'tcx>], elem: &PlaceElem<'tcx>, context: PlaceContext, @@ -925,7 +925,7 @@ macro_rules! visit_place_fns { self.visit_place_base(&place.local, context, location); - self.visit_projection(&place.local, + self.visit_projection(place.local, &place.projection, context, location); @@ -933,7 +933,7 @@ macro_rules! visit_place_fns { fn super_projection( &mut self, - local: &Local, + local: Local, projection: &[PlaceElem<'tcx>], context: PlaceContext, location: Location, @@ -947,7 +947,7 @@ macro_rules! visit_place_fns { fn super_projection_elem( &mut self, - _local: &Local, + _local: Local, _proj_base: &[PlaceElem<'tcx>], elem: &PlaceElem<'tcx>, _context: PlaceContext, diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index 7bf222f4701b7..b8a7d7df487b3 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -203,7 +203,7 @@ impl> LocalAnalyzer<'mir, 'a, 'tcx, Bx> { } self.visit_place_base(&place_ref.local, context, location); - self.visit_projection(&place_ref.local, place_ref.projection, context, location); + self.visit_projection(place_ref.local, place_ref.projection, context, location); } } } diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 1553f826c7e4b..133772407c5dd 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -276,7 +276,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { } }; self.visit_place_base(&place.local, ctx, location); - self.visit_projection(&place.local, reborrowed_proj, ctx, location); + self.visit_projection(place.local, reborrowed_proj, ctx, location); return; } } @@ -289,7 +289,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf), }; self.visit_place_base(&place.local, ctx, location); - self.visit_projection(&place.local, reborrowed_proj, ctx, location); + self.visit_projection(place.local, reborrowed_proj, ctx, location); return; } } @@ -408,7 +408,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { } fn visit_projection_elem( &mut self, - place_local: &Local, + place_local: Local, proj_base: &[PlaceElem<'tcx>], elem: &PlaceElem<'tcx>, context: PlaceContext, @@ -428,11 +428,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { match elem { ProjectionElem::Deref => { - let base_ty = Place::ty_from(*place_local, proj_base, *self.body, self.tcx).ty; + let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty; if let ty::RawPtr(_) = base_ty.kind { if proj_base.is_empty() { if let (local, []) = (place_local, proj_base) { - let decl = &self.body.local_decls[*local]; + let decl = &self.body.local_decls[local]; if let LocalInfo::StaticRef { def_id, .. } = decl.local_info { let span = decl.source_info.span; self.check_static(def_id, span); @@ -452,7 +452,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { | ProjectionElem::Subslice { .. } | ProjectionElem::Field(..) | ProjectionElem::Index(_) => { - let base_ty = Place::ty_from(*place_local, proj_base, *self.body, self.tcx).ty; + let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty; match base_ty.ty_adt_def() { Some(def) if def.is_union() => { self.check_op(ops::UnionAccess); From 545ef9d83ab383bdc99376a2fe4164e46f4a3f6e Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Sat, 7 Mar 2020 02:40:54 +0100 Subject: [PATCH 10/12] Add `Layout::dangling()` to return a well-aligned `NonNull` --- src/libcore/alloc.rs | 12 ++++++++++++ src/libcore/tests/alloc.rs | 3 +++ src/libcore/tests/lib.rs | 1 + 3 files changed, 16 insertions(+) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index f3a2b73f2b8de..4f401c75104de 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -140,6 +140,18 @@ impl Layout { unsafe { Layout::from_size_align_unchecked(size, align) } } + /// Creates a `NonNull` that is dangling, but well-aligned for this Layout. + /// + /// Note that the pointer value may potentially represent a valid pointer to + /// a `T`, which means this must not be used as a "not yet initialized" + /// sentinel value. Types that lazily allocate must track initialization by + /// some other means. + #[unstable(feature = "alloc_layout_extra", issue = "55724")] + pub const fn dangling(&self) -> NonNull { + // align is non-zero and a power of two + unsafe { NonNull::new_unchecked(self.align() as *mut u8) } + } + /// Creates a layout describing the record that can hold a value /// of the same layout as `self`, but that also is aligned to /// alignment `align` (measured in bytes). diff --git a/src/libcore/tests/alloc.rs b/src/libcore/tests/alloc.rs index 63537ba23d84d..c8592e40a69a0 100644 --- a/src/libcore/tests/alloc.rs +++ b/src/libcore/tests/alloc.rs @@ -1,10 +1,13 @@ use core::alloc::Layout; +use core::ptr::NonNull; #[test] fn const_unchecked_layout() { const SIZE: usize = 0x2000; const ALIGN: usize = 0x1000; const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) }; + const DANGLING: NonNull = LAYOUT.dangling(); assert_eq!(LAYOUT.size(), SIZE); assert_eq!(LAYOUT.align(), ALIGN); + assert_eq!(Some(DANGLING), NonNull::new(ALIGN as *mut u8)); } diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 991458db5b72b..71a061af28920 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -1,3 +1,4 @@ +#![feature(alloc_layout_extra)] #![feature(bool_to_option)] #![feature(bound_cloned)] #![feature(box_syntax)] From 09d3ba13afb8fdf449928b160431787e2d259db1 Mon Sep 17 00:00:00 2001 From: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com> Date: Sat, 7 Mar 2020 02:45:55 +0100 Subject: [PATCH 11/12] Update alloc.rs --- src/libcore/alloc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 4f401c75104de..0a7a8ab266aee 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -142,8 +142,8 @@ impl Layout { /// Creates a `NonNull` that is dangling, but well-aligned for this Layout. /// - /// Note that the pointer value may potentially represent a valid pointer to - /// a `T`, which means this must not be used as a "not yet initialized" + /// Note that the pointer value may potentially represent a valid pointer, + /// which means this must not be used as a "not yet initialized" /// sentinel value. Types that lazily allocate must track initialization by /// some other means. #[unstable(feature = "alloc_layout_extra", issue = "55724")] From dffd18fafc5ffe41b958bf9cacc0c3a6ef257348 Mon Sep 17 00:00:00 2001 From: Jonathan Giddy Date: Sat, 7 Mar 2020 08:21:27 +0000 Subject: [PATCH 12/12] Correct version that relaxed orphan rules --- src/libcore/convert/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index 959fd63df51c2..47ab8715cfa14 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -229,7 +229,7 @@ pub trait AsMut { /// /// # Implementing [`Into`] for conversions to external types in old versions of Rust /// -/// Prior to Rust 1.40, if the destination type was not part of the current crate +/// Prior to Rust 1.41, if the destination type was not part of the current crate /// then you couldn't implement [`From`] directly. /// For example, take this code: ///