diff --git a/src/doc/book b/src/doc/book index 30cd9dfe71c44..4e7c00bece154 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 30cd9dfe71c446de63826bb4472627af45acc9db +Subproject commit 4e7c00bece1544d409312ec93467beb62b5bd0cb diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 5555a97f04ad7..616962ad0dd80 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 5555a97f04ad7974ac6fb8fb47c267c4274adf4a +Subproject commit 616962ad0dd80f34d8b802da038d0aed9dd691bb diff --git a/src/doc/reference b/src/doc/reference index 5d40ba5c2515c..04d5d5d7ba624 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 5d40ba5c2515caffa7790cda621239dc21ef5a72 +Subproject commit 04d5d5d7ba624b6f5016298451f3a63d557f3260 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 7aa82129aa23e..6f94ccb48da6f 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 7aa82129aa23e7e181efbeb8da03a2a897ef6afc +Subproject commit 6f94ccb48da6fa4ed0031290f21411cf789f7d5e diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md index a941bc9348f2c..c4c985dd134ba 100644 --- a/src/doc/unstable-book/src/library-features/asm.md +++ b/src/doc/unstable-book/src/library-features/asm.md @@ -474,7 +474,7 @@ Here is the list of currently supported register classes: | AArch64 | `reg` | `x[0-28]`, `x30` | `r` | | AArch64 | `vreg` | `v[0-31]` | `w` | | AArch64 | `vreg_low16` | `v[0-15]` | `x` | -| ARM | `reg` | `r[0-r10]`, `r12`, `r14` | `r` | +| ARM | `reg` | `r[0-5]` `r7`\*, `r[8-10]`, `r11`\*, `r12`, `r14` | `r` | | ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` | | ARM (ARM) | `reg_thumb` | `r[0-r10]`, `r12`, `r14` | `l` | | ARM | `sreg` | `s[0-31]` | `t` | @@ -497,6 +497,8 @@ Here is the list of currently supported register classes: > Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register. > > Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported. +> +> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform. Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc). @@ -591,7 +593,9 @@ Some registers cannot be used for input or output operands: | Architecture | Unsupported register | Reason | | ------------ | -------------------- | ------ | | All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. | -| All | `bp` (x86), `r11` (ARM), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. | +| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. | +| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. | +| ARM | `r6` | `r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. | | x86 | `k0` | This is a constant zero register which can't be modified. | | x86 | `ip` | This is the program counter, not a real register. | | x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). | diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 350249f5db519..34cacebe79636 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -488,7 +488,7 @@ struct MergeIter> { } impl BTreeMap { - /// Makes a new empty BTreeMap with a reasonable choice for B. + /// Makes a new empty BTreeMap. /// /// Does not allocate anything on its own. /// diff --git a/src/liballoc/collections/vec_deque/tests.rs b/src/liballoc/collections/vec_deque/tests.rs index fc2ec7908e823..960af4bfda053 100644 --- a/src/liballoc/collections/vec_deque/tests.rs +++ b/src/liballoc/collections/vec_deque/tests.rs @@ -1,7 +1,5 @@ use super::*; -use test; - #[bench] #[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks fn bench_push_back_100(b: &mut test::Bencher) { diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index fc8a992e1701b..1265d0e56b576 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -62,7 +62,7 @@ use core::array::LengthAtMost32; use core::cmp::{self, Ordering}; use core::fmt; -use core::hash::{self, Hash}; +use core::hash::{Hash, Hasher}; use core::intrinsics::{arith_offset, assume}; use core::iter::{FromIterator, FusedIterator, TrustedLen}; use core::marker::PhantomData; @@ -1943,7 +1943,7 @@ impl Clone for Vec { #[stable(feature = "rust1", since = "1.0.0")] impl Hash for Vec { #[inline] - fn hash(&self, state: &mut H) { + fn hash(&self, state: &mut H) { Hash::hash(&**self, state) } } diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs index e98d709539d79..99fbb1ee3ea83 100644 --- a/src/librustc_ast/ast.rs +++ b/src/librustc_ast/ast.rs @@ -335,6 +335,8 @@ pub enum GenericParamKind { }, Const { ty: P, + /// Span of the `const` keyword. + kw_span: Span, }, } diff --git a/src/librustc_ast/mut_visit.rs b/src/librustc_ast/mut_visit.rs index 2ffef9d48c181..54f81ef106fe1 100644 --- a/src/librustc_ast/mut_visit.rs +++ b/src/librustc_ast/mut_visit.rs @@ -762,7 +762,7 @@ pub fn noop_flat_map_generic_param( GenericParamKind::Type { default } => { visit_opt(default, |default| vis.visit_ty(default)); } - GenericParamKind::Const { ty } => { + GenericParamKind::Const { ty, kw_span: _ } => { vis.visit_ty(ty); } } diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index b7894eb145b0a..d2c4478ccfeb6 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -1001,6 +1001,7 @@ impl<'hir> LoweringContext<'_, 'hir> { asm::InlineAsmReg::parse( sess.asm_arch?, |feature| sess.target_features.contains(&Symbol::intern(feature)), + &sess.target.target, s, ) .map_err(|e| { diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 39b14ac458832..897250a24fba0 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -2230,7 +2230,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { (hir::ParamName::Plain(param.ident), kind) } - GenericParamKind::Const { ref ty } => { + GenericParamKind::Const { ref ty, kw_span: _ } => { let ty = self .with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| { this.lower_ty(&ty, ImplTraitContext::disallowed()) diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs index 8eb125e444053..975881d9a0ac0 100644 --- a/src/librustc_ast_passes/ast_validation.rs +++ b/src/librustc_ast_passes/ast_validation.rs @@ -1135,9 +1135,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> { generics.params.iter().map(|param| { let ident = Some(param.ident.to_string()); let (kind, ident) = match ¶m.kind { - GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, ident), - GenericParamKind::Type { .. } => (ParamKindOrd::Type, ident), - GenericParamKind::Const { ref ty } => { + GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident), + GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident), + GenericParamKind::Const { ref ty, kw_span: _ } => { let ty = pprust::ty_to_string(ty); (ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty))) } diff --git a/src/librustc_ast_pretty/pprust.rs b/src/librustc_ast_pretty/pprust.rs index b1abc08aa67b0..ecbb3af5fb906 100644 --- a/src/librustc_ast_pretty/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -2578,7 +2578,7 @@ impl<'a> State<'a> { s.print_type(default) } } - ast::GenericParamKind::Const { ref ty } => { + ast::GenericParamKind::Const { ref ty, kw_span: _ } => { s.word_space("const"); s.print_ident(param.ident); s.s.space(); diff --git a/src/librustc_ast_pretty/pprust/tests.rs b/src/librustc_ast_pretty/pprust/tests.rs index f51439f89ffbe..f92e40ed6ffab 100644 --- a/src/librustc_ast_pretty/pprust/tests.rs +++ b/src/librustc_ast_pretty/pprust/tests.rs @@ -2,7 +2,6 @@ use super::*; use rustc_ast::ast; use rustc_ast::with_default_globals; -use rustc_span; use rustc_span::source_map::respan; use rustc_span::symbol::Ident; diff --git a/src/librustc_builtin_macros/deriving/mod.rs b/src/librustc_builtin_macros/deriving/mod.rs index 9660cade38241..dc21be3b296aa 100644 --- a/src/librustc_builtin_macros/deriving/mod.rs +++ b/src/librustc_builtin_macros/deriving/mod.rs @@ -123,7 +123,7 @@ fn inject_impl_of_structural_trait( *default = None; ast::GenericArg::Type(cx.ty_ident(span, param.ident)) } - ast::GenericParamKind::Const { ty: _ } => { + ast::GenericParamKind::Const { ty: _, kw_span: _ } => { ast::GenericArg::Const(cx.const_ident(span, param.ident)) } }) diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 67a2251e8593e..80278bb9f53d8 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -156,6 +156,10 @@ const ARM_WHITELIST: &[(&str, Option)] = &[ ("vfp2", Some(sym::arm_target_feature)), ("vfp3", Some(sym::arm_target_feature)), ("vfp4", Some(sym::arm_target_feature)), + // This is needed for inline assembly, but shouldn't be stabilized as-is + // since it should be enabled per-function using #[instruction_set], not + // #[target_feature]. + ("thumb-mode", Some(sym::arm_target_feature)), ]; const AARCH64_WHITELIST: &[(&str, Option)] = &[ diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index 39afb3d82ff5a..53d831749ceb7 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -358,7 +358,6 @@ cfg_if! { use parking_lot::Mutex as InnerLock; use parking_lot::RwLock as InnerRwLock; - use std; use std::thread; pub use rayon::{join, scope}; diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs index 7d1cb7738c35e..f3dfec7ca7215 100644 --- a/src/librustc_hir/hir.rs +++ b/src/librustc_hir/hir.rs @@ -1511,13 +1511,7 @@ pub fn is_range_literal(sm: &SourceMap, expr: &Expr<'_>) -> bool { // Check whether a span corresponding to a range expression is a // range literal, rather than an explicit struct or `new()` call. fn is_lit(sm: &SourceMap, span: &Span) -> bool { - let end_point = sm.end_point(*span); - - if let Ok(end_string) = sm.span_to_snippet(end_point) { - !(end_string.ends_with('}') || end_string.ends_with(')')) - } else { - false - } + sm.span_to_snippet(*span).map(|range_src| range_src.contains("..")).unwrap_or(false) }; match expr.kind { diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index ada48bc147e47..d25f8bd1b8c58 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -293,11 +293,9 @@ fn main() { } } - // LLVM requires symbols from this library, but apparently they're not printed - // during llvm-config? + // Libstdc++ depends on pthread which Rust doesn't link on MinGW + // since nothing else requires it. if target.contains("windows-gnu") { - println!("cargo:rustc-link-lib=static-nobundle=gcc_s"); println!("cargo:rustc-link-lib=static-nobundle=pthread"); - println!("cargo:rustc-link-lib=dylib=uuid"); } } diff --git a/src/librustc_parse/parser/generics.rs b/src/librustc_parse/parser/generics.rs index 04b64d93c70dd..47794746126da 100644 --- a/src/librustc_parse/parser/generics.rs +++ b/src/librustc_parse/parser/generics.rs @@ -47,21 +47,21 @@ impl<'a> Parser<'a> { } fn parse_const_param(&mut self, preceding_attrs: Vec) -> PResult<'a, GenericParam> { - let lo = self.token.span; + let const_span = self.token.span; self.expect_keyword(kw::Const)?; let ident = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty()?; - self.sess.gated_spans.gate(sym::const_generics, lo.to(self.prev_token.span)); + self.sess.gated_spans.gate(sym::const_generics, const_span.to(self.prev_token.span)); Ok(GenericParam { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs.into(), bounds: Vec::new(), - kind: GenericParamKind::Const { ty }, + kind: GenericParamKind::Const { ty, kw_span: const_span }, is_placeholder: false, }) } diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index afe96ca700781..2854683b61bab 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -643,18 +643,18 @@ impl<'a> Resolver<'a> { let not_local_module = crate_name.name != kw::Crate; let mut worklist = vec![(start_module, Vec::::new(), true, not_local_module)]; + let mut worklist_via_import = vec![]; - while let Some((in_module, path_segments, accessible, in_module_is_extern)) = worklist.pop() + while let Some((in_module, path_segments, accessible, in_module_is_extern)) = + match worklist.pop() { + None => worklist_via_import.pop(), + Some(x) => Some(x), + } { // We have to visit module children in deterministic order to avoid // instabilities in reported imports (#43552). in_module.for_each_child(self, |this, ident, ns, name_binding| { - // avoid imports entirely - if name_binding.is_import() && !name_binding.is_extern_crate() { - return; - } - - // avoid non-importable candidates as well + // avoid non-importable candidates if !name_binding.is_importable() { return; } @@ -667,6 +667,17 @@ impl<'a> Resolver<'a> { return; } + let via_import = name_binding.is_import() && !name_binding.is_extern_crate(); + + // There is an assumption elsewhere that paths of variants are in the enum's + // declaration and not imported. With this assumption, the variant component is + // chopped and the rest of the path is assumed to be the enum's own path. For + // errors where a variant is used as the type instead of the enum, this causes + // funny looking invalid suggestions, i.e `foo` instead of `foo::MyEnum`. + if via_import && name_binding.is_possibly_imported_variant() { + return; + } + // collect results based on the filter function // avoid suggesting anything from the same module in which we are resolving if ident.name == lookup_ident.name @@ -724,7 +735,8 @@ impl<'a> Resolver<'a> { let is_extern = in_module_is_extern || name_binding.is_extern_crate(); // add the module to the lookup if seen_modules.insert(module.def_id().unwrap()) { - worklist.push((module, path_segments, child_accessible, is_extern)); + if via_import { &mut worklist_via_import } else { &mut worklist } + .push((module, path_segments, child_accessible, is_extern)); } } } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 6f769c3c59cae..b8fb813ea155f 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -536,8 +536,8 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { for param in &generics.params { match param.kind { - GenericParamKind::Lifetime { .. } => self.visit_generic_param(param), - GenericParamKind::Type { ref default, .. } => { + GenericParamKind::Lifetime => self.visit_generic_param(param), + GenericParamKind::Type { ref default } => { for bound in ¶m.bounds { self.visit_param_bound(bound); } @@ -551,7 +551,7 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { // Allow all following defaults to refer to this type parameter. default_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name)); } - GenericParamKind::Const { ref ty } => { + GenericParamKind::Const { ref ty, kw_span: _ } => { for bound in ¶m.bounds { self.visit_param_bound(bound); } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ce068b8ac69a4..9ddcf9e1de7d1 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -703,6 +703,13 @@ impl<'a> NameBinding<'a> { } } + fn is_possibly_imported_variant(&self) -> bool { + match self.kind { + NameBindingKind::Import { binding, .. } => binding.is_possibly_imported_variant(), + _ => self.is_variant(), + } + } + // We sometimes need to treat variants as `pub` for backwards compatibility. fn pseudo_vis(&self) -> ty::Visibility { if self.is_variant() && self.res().def_id().is_local() { diff --git a/src/librustc_target/asm/arm.rs b/src/librustc_target/asm/arm.rs index 1798b2a094975..85a136b94aa79 100644 --- a/src/librustc_target/asm/arm.rs +++ b/src/librustc_target/asm/arm.rs @@ -1,4 +1,5 @@ use super::{InlineAsmArch, InlineAsmType}; +use crate::spec::Target; use rustc_macros::HashStable_Generic; use std::fmt; @@ -58,6 +59,37 @@ impl ArmInlineAsmRegClass { } } +// This uses the same logic as useR7AsFramePointer in LLVM +fn frame_pointer_is_r7(mut has_feature: impl FnMut(&str) -> bool, target: &Target) -> bool { + target.options.is_like_osx || (!target.options.is_like_windows && has_feature("thumb-mode")) +} + +fn frame_pointer_r11( + _arch: InlineAsmArch, + has_feature: impl FnMut(&str) -> bool, + target: &Target, + _allocating: bool, +) -> Result<(), &'static str> { + if !frame_pointer_is_r7(has_feature, target) { + Err("the frame pointer (r11) cannot be used as an operand for inline asm") + } else { + Ok(()) + } +} + +fn frame_pointer_r7( + _arch: InlineAsmArch, + has_feature: impl FnMut(&str) -> bool, + target: &Target, + _allocating: bool, +) -> Result<(), &'static str> { + if frame_pointer_is_r7(has_feature, target) { + Err("the frame pointer (r7) cannot be used as an operand for inline asm") + } else { + Ok(()) + } +} + def_regs! { Arm ArmInlineAsmReg ArmInlineAsmRegClass { r0: reg, reg_thumb = ["r0", "a1"], @@ -66,11 +98,11 @@ def_regs! { r3: reg, reg_thumb = ["r3", "a4"], r4: reg, reg_thumb = ["r4", "v1"], r5: reg, reg_thumb = ["r5", "v2"], - r6: reg, reg_thumb = ["r6", "v3"], - r7: reg, reg_thumb = ["r7", "v4"], + r7: reg, reg_thumb = ["r7", "v4"] % frame_pointer_r7, r8: reg = ["r8", "v5"], r9: reg = ["r9", "v6", "rfp"], r10: reg = ["r10", "sl"], + r11: reg = ["r11", "fp"] % frame_pointer_r11, r12: reg = ["r12", "ip"], r14: reg = ["r14", "lr"], s0: sreg, sreg_low16 = ["s0"], @@ -153,8 +185,8 @@ def_regs! { q13: qreg = ["q13"], q14: qreg = ["q14"], q15: qreg = ["q15"], - #error = ["r11", "fp"] => - "the frame pointer cannot be used as an operand for inline asm", + #error = ["r6", "v3"] => + "r6 is used internally by LLVM and cannot be used as an operand for inline asm", #error = ["r13", "sp"] => "the stack pointer cannot be used as an operand for inline asm", #error = ["r15", "pc"] => diff --git a/src/librustc_target/asm/mod.rs b/src/librustc_target/asm/mod.rs index 834d7c6d381a3..ccec17817d37d 100644 --- a/src/librustc_target/asm/mod.rs +++ b/src/librustc_target/asm/mod.rs @@ -1,4 +1,5 @@ use crate::abi::Size; +use crate::spec::Target; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_macros::HashStable_Generic; use rustc_span::Symbol; @@ -83,12 +84,13 @@ macro_rules! def_regs { pub fn parse( _arch: super::InlineAsmArch, mut _has_feature: impl FnMut(&str) -> bool, + _target: &crate::spec::Target, name: &str, ) -> Result { match name { $( $($alias)|* | $reg_name => { - $($filter(_arch, &mut _has_feature, false)?;)? + $($filter(_arch, &mut _has_feature, _target, false)?;)? Ok(Self::$reg) } )* @@ -103,6 +105,7 @@ macro_rules! def_regs { pub(super) fn fill_reg_map( _arch: super::InlineAsmArch, mut _has_feature: impl FnMut(&str) -> bool, + _target: &crate::spec::Target, _map: &mut rustc_data_structures::fx::FxHashMap< super::InlineAsmRegClass, rustc_data_structures::fx::FxHashSet, @@ -111,7 +114,7 @@ macro_rules! def_regs { #[allow(unused_imports)] use super::{InlineAsmReg, InlineAsmRegClass}; $( - if $($filter(_arch, &mut _has_feature, true).is_ok() &&)? true { + if $($filter(_arch, &mut _has_feature, _target, true).is_ok() &&)? true { if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) { set.insert(InlineAsmReg::$arch($arch_reg::$reg)); } @@ -234,6 +237,7 @@ impl InlineAsmReg { pub fn parse( arch: InlineAsmArch, has_feature: impl FnMut(&str) -> bool, + target: &Target, name: Symbol, ) -> Result { // FIXME: use direct symbol comparison for register names @@ -241,20 +245,22 @@ impl InlineAsmReg { let name = name.as_str(); Ok(match arch { InlineAsmArch::X86 | InlineAsmArch::X86_64 => { - Self::X86(X86InlineAsmReg::parse(arch, has_feature, &name)?) + Self::X86(X86InlineAsmReg::parse(arch, has_feature, target, &name)?) + } + InlineAsmArch::Arm => { + Self::Arm(ArmInlineAsmReg::parse(arch, has_feature, target, &name)?) } - InlineAsmArch::Arm => Self::Arm(ArmInlineAsmReg::parse(arch, has_feature, &name)?), InlineAsmArch::AArch64 => { - Self::AArch64(AArch64InlineAsmReg::parse(arch, has_feature, &name)?) + Self::AArch64(AArch64InlineAsmReg::parse(arch, has_feature, target, &name)?) } InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => { - Self::RiscV(RiscVInlineAsmReg::parse(arch, has_feature, &name)?) + Self::RiscV(RiscVInlineAsmReg::parse(arch, has_feature, target, &name)?) } InlineAsmArch::Nvptx64 => { - Self::Nvptx(NvptxInlineAsmReg::parse(arch, has_feature, &name)?) + Self::Nvptx(NvptxInlineAsmReg::parse(arch, has_feature, target, &name)?) } InlineAsmArch::Hexagon => { - Self::Hexagon(HexagonInlineAsmReg::parse(arch, has_feature, &name)?) + Self::Hexagon(HexagonInlineAsmReg::parse(arch, has_feature, target, &name)?) } }) } @@ -536,36 +542,37 @@ impl fmt::Display for InlineAsmType { pub fn allocatable_registers( arch: InlineAsmArch, has_feature: impl FnMut(&str) -> bool, + target: &crate::spec::Target, ) -> FxHashMap> { match arch { InlineAsmArch::X86 | InlineAsmArch::X86_64 => { let mut map = x86::regclass_map(); - x86::fill_reg_map(arch, has_feature, &mut map); + x86::fill_reg_map(arch, has_feature, target, &mut map); map } InlineAsmArch::Arm => { let mut map = arm::regclass_map(); - arm::fill_reg_map(arch, has_feature, &mut map); + arm::fill_reg_map(arch, has_feature, target, &mut map); map } InlineAsmArch::AArch64 => { let mut map = aarch64::regclass_map(); - aarch64::fill_reg_map(arch, has_feature, &mut map); + aarch64::fill_reg_map(arch, has_feature, target, &mut map); map } InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => { let mut map = riscv::regclass_map(); - riscv::fill_reg_map(arch, has_feature, &mut map); + riscv::fill_reg_map(arch, has_feature, target, &mut map); map } InlineAsmArch::Nvptx64 => { let mut map = nvptx::regclass_map(); - nvptx::fill_reg_map(arch, has_feature, &mut map); + nvptx::fill_reg_map(arch, has_feature, target, &mut map); map } InlineAsmArch::Hexagon => { let mut map = hexagon::regclass_map(); - hexagon::fill_reg_map(arch, has_feature, &mut map); + hexagon::fill_reg_map(arch, has_feature, target, &mut map); map } } diff --git a/src/librustc_target/asm/riscv.rs b/src/librustc_target/asm/riscv.rs index 3ff542247ff02..ced7483b00571 100644 --- a/src/librustc_target/asm/riscv.rs +++ b/src/librustc_target/asm/riscv.rs @@ -1,4 +1,5 @@ use super::{InlineAsmArch, InlineAsmType}; +use crate::spec::Target; use rustc_macros::HashStable_Generic; use std::fmt; @@ -50,6 +51,7 @@ impl RiscVInlineAsmRegClass { fn not_e( _arch: InlineAsmArch, mut has_feature: impl FnMut(&str) -> bool, + _target: &Target, _allocating: bool, ) -> Result<(), &'static str> { if has_feature("e") { diff --git a/src/librustc_target/asm/x86.rs b/src/librustc_target/asm/x86.rs index ed51b526414d1..0f62c19e1a3cd 100644 --- a/src/librustc_target/asm/x86.rs +++ b/src/librustc_target/asm/x86.rs @@ -1,4 +1,5 @@ use super::{InlineAsmArch, InlineAsmType}; +use crate::spec::Target; use rustc_macros::HashStable_Generic; use std::fmt; @@ -131,6 +132,7 @@ impl X86InlineAsmRegClass { fn x86_64_only( arch: InlineAsmArch, _has_feature: impl FnMut(&str) -> bool, + _target: &Target, _allocating: bool, ) -> Result<(), &'static str> { match arch { @@ -143,6 +145,7 @@ fn x86_64_only( fn high_byte( arch: InlineAsmArch, _has_feature: impl FnMut(&str) -> bool, + _target: &Target, allocating: bool, ) -> Result<(), &'static str> { match arch { diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index a4996d9eee810..c966d8d34e999 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -913,10 +913,28 @@ mod match_keyword {} // /// Organize code into [modules]. /// -/// The documentation for this keyword is [not yet complete]. Pull requests welcome! +/// Use `mod` to create new [modules] to encapsulate code, including other +/// modules: /// +/// ``` +/// mod foo { +/// mod bar { +/// type MyType = (u8, u8); +/// fn baz() {} +/// } +/// } +/// ``` +/// +/// Like [`struct`]s and [`enum`]s, a module and its content are private by +/// default, unaccessible to code outside of the module. +/// +/// To learn more about allowing access, see the documentation for the [`pub`] +/// keyword. +/// +/// [`enum`]: keyword.enum.html +/// [`pub`]: keyword.pub.html +/// [`struct`]: keyword.struct.html /// [modules]: ../reference/items/modules.html -/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 mod mod_keyword {} #[doc(keyword = "move")] diff --git a/src/libstd/os/illumos/fs.rs b/src/libstd/os/illumos/fs.rs index 2abbf1fa9fa16..b668aa2595d67 100644 --- a/src/libstd/os/illumos/fs.rs +++ b/src/libstd/os/illumos/fs.rs @@ -1,7 +1,5 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - use crate::fs::Metadata; use crate::sys_common::AsInner; diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index cd24605ec7ab7..ada8eaa1c9745 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -2,9 +2,6 @@ //! Unix-specific networking functionality -#[cfg(unix)] -use libc; - // FIXME(#43348): Make libc adapt #[doc(cfg(...))] so we don't need these fake definitions here? #[cfg(not(unix))] #[allow(non_camel_case_types)] diff --git a/src/libstd/sys/vxworks/args.rs b/src/libstd/sys/vxworks/args.rs index efd615f404db6..adff6c489bbc9 100644 --- a/src/libstd/sys/vxworks/args.rs +++ b/src/libstd/sys/vxworks/args.rs @@ -56,7 +56,6 @@ mod imp { use crate::ffi::{CStr, OsString}; use crate::marker::PhantomData; use crate::ptr; - use libc; use crate::sys_common::mutex::Mutex; diff --git a/src/libstd/sys/vxworks/ext/fs.rs b/src/libstd/sys/vxworks/ext/fs.rs index 9864a855df738..7cc64658ee1a9 100644 --- a/src/libstd/sys/vxworks/ext/fs.rs +++ b/src/libstd/sys/vxworks/ext/fs.rs @@ -6,7 +6,6 @@ use crate::path::Path; use crate::sys; use crate::sys::platform::fs::MetadataExt as UnixMetadataExt; use crate::sys_common::{AsInner, AsInnerMut, FromInner}; -use libc; /// Unix-specific extensions to [`File`]. /// diff --git a/src/libstd/sys/vxworks/rand.rs b/src/libstd/sys/vxworks/rand.rs index 87ebd2c9593fc..3a1ff5fd3b9c6 100644 --- a/src/libstd/sys/vxworks/rand.rs +++ b/src/libstd/sys/vxworks/rand.rs @@ -13,7 +13,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { mod imp { use crate::io; use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; - use libc; pub fn fill_bytes(v: &mut [u8]) { static RNG_INIT: AtomicBool = AtomicBool::new(false); diff --git a/src/libstd/sys/vxworks/rwlock.rs b/src/libstd/sys/vxworks/rwlock.rs index fd2e1a6e7bcfb..c90304c2b4a6a 100644 --- a/src/libstd/sys/vxworks/rwlock.rs +++ b/src/libstd/sys/vxworks/rwlock.rs @@ -1,6 +1,5 @@ use crate::cell::UnsafeCell; use crate::sync::atomic::{AtomicUsize, Ordering}; -use libc; pub struct RWLock { inner: UnsafeCell, diff --git a/src/libstd/sys/vxworks/time.rs b/src/libstd/sys/vxworks/time.rs index 8ebbf89213f32..8365c9ee9c995 100644 --- a/src/libstd/sys/vxworks/time.rs +++ b/src/libstd/sys/vxworks/time.rs @@ -1,7 +1,6 @@ use crate::cmp::Ordering; use crate::time::Duration; use ::core::hash::{Hash, Hasher}; -use libc; pub use self::inner::{Instant, SystemTime, UNIX_EPOCH}; use crate::convert::TryInto; @@ -104,7 +103,6 @@ mod inner { use crate::fmt; use crate::sys::cvt; use crate::time::Duration; - use libc; use super::Timespec; diff --git a/src/libstd/sys/wasi/alloc.rs b/src/libstd/sys/wasi/alloc.rs index bc61416278401..57187851a14e3 100644 --- a/src/libstd/sys/wasi/alloc.rs +++ b/src/libstd/sys/wasi/alloc.rs @@ -1,7 +1,6 @@ use crate::alloc::{GlobalAlloc, Layout, System}; use crate::ptr; use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN}; -use libc; #[stable(feature = "alloc_system_type", since = "1.28.0")] unsafe impl GlobalAlloc for System { diff --git a/src/test/ui/glob-resolve1.rs b/src/test/ui/glob-resolve1.rs index 63c435cc20641..32660fdb41876 100644 --- a/src/test/ui/glob-resolve1.rs +++ b/src/test/ui/glob-resolve1.rs @@ -29,3 +29,7 @@ fn main() { foo::(); //~ ERROR: cannot find type `C` in this scope foo::(); //~ ERROR: cannot find type `D` in this scope } + +mod other { + pub fn import() {} +} diff --git a/src/test/ui/glob-resolve1.stderr b/src/test/ui/glob-resolve1.stderr index 995da6cc1f975..3c818f3ae48ea 100644 --- a/src/test/ui/glob-resolve1.stderr +++ b/src/test/ui/glob-resolve1.stderr @@ -42,6 +42,11 @@ error[E0425]: cannot find function `import` in this scope | LL | import(); | ^^^^^^ not found in this scope + | +help: consider importing this function + | +LL | use other::import; + | error[E0412]: cannot find type `A` in this scope --> $DIR/glob-resolve1.rs:28:11 diff --git a/src/test/ui/impl-trait/issue-69840.rs b/src/test/ui/impl-trait/issue-69840.rs new file mode 100644 index 0000000000000..b270f88b6886e --- /dev/null +++ b/src/test/ui/impl-trait/issue-69840.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(impl_trait_in_bindings)] +#![allow(incomplete_features)] + +struct A<'a>(&'a ()); + +trait Trait {} + +impl Trait for () {} + +pub fn foo<'a>() { + let _x: impl Trait> = (); +} + +fn main() {} diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index c80055f00d7d9..ee730910ee441 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -16,7 +16,7 @@ help: consider importing one of these items instead | LL | use m2::S; | -LL | use namespace_mix::xm2::S; +LL | use xm2::S; | error[E0423]: expected value, found type alias `xm1::S` @@ -39,7 +39,7 @@ help: consider importing one of these items instead | LL | use m2::S; | -LL | use namespace_mix::xm2::S; +LL | use xm2::S; | error[E0423]: expected value, found struct variant `m7::V` @@ -61,7 +61,7 @@ help: consider importing one of these items instead | LL | use m8::V; | -LL | use namespace_mix::xm8::V; +LL | use xm8::V; | error[E0423]: expected value, found struct variant `xm7::V` @@ -83,7 +83,7 @@ help: consider importing one of these items instead | LL | use m8::V; | -LL | use namespace_mix::xm8::V; +LL | use xm8::V; | error[E0277]: the trait bound `c::Item: Impossible` is not satisfied diff --git a/src/test/ui/never_type/issue-51506.rs b/src/test/ui/never_type/issue-51506.rs new file mode 100644 index 0000000000000..d0fe6a0f59a87 --- /dev/null +++ b/src/test/ui/never_type/issue-51506.rs @@ -0,0 +1,41 @@ +#![feature(never_type, specialization)] +#![allow(incomplete_features)] + +use std::iter::{self, Empty}; + +trait Trait { + type Out: Iterator; + + fn f(&self) -> Option; +} + +impl Trait for T { + default type Out = !; //~ ERROR: `!` is not an iterator + + default fn f(&self) -> Option { + None + } +} + +struct X; + +impl Trait for X { + type Out = Empty; + + fn f(&self) -> Option { + Some(iter::empty()) + } +} + +fn f(a: T) { + if let Some(iter) = a.f() { + println!("Some"); + for x in iter { + println!("x = {}", x); + } + } +} + +pub fn main() { + f(10); +} diff --git a/src/test/ui/never_type/issue-51506.stderr b/src/test/ui/never_type/issue-51506.stderr new file mode 100644 index 0000000000000..73865a9b5a02c --- /dev/null +++ b/src/test/ui/never_type/issue-51506.stderr @@ -0,0 +1,14 @@ +error[E0277]: `!` is not an iterator + --> $DIR/issue-51506.rs:13:5 + | +LL | type Out: Iterator; + | ------------------------------- required by `Trait::Out` +... +LL | default type Out = !; + | ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `!` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.rs b/src/test/ui/range/issue-73553-misinterp-range-literal.rs new file mode 100644 index 0000000000000..e65dba0a03821 --- /dev/null +++ b/src/test/ui/range/issue-73553-misinterp-range-literal.rs @@ -0,0 +1,16 @@ +type Range = std::ops::Range; + +fn demo(r: &Range) { + println!("{:?}", r); +} + +fn tell(x: usize) -> usize { + x +} + +fn main() { + demo(tell(1)..tell(10)); + //~^ ERROR mismatched types + demo(1..10); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.stderr b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr new file mode 100644 index 0000000000000..5167b87fd27b8 --- /dev/null +++ b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/issue-73553-misinterp-range-literal.rs:12:10 + | +LL | demo(tell(1)..tell(10)); + | ^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::Range` + | help: consider borrowing here: `&(tell(1)..tell(10))` + | + = note: expected reference `&std::ops::Range` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/issue-73553-misinterp-range-literal.rs:14:10 + | +LL | demo(1..10); + | ^^^^^ + | | + | expected reference, found struct `std::ops::Range` + | help: consider borrowing here: `&(1..10)` + | + = note: expected reference `&std::ops::Range` + found struct `std::ops::Range<{integer}>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr index f9263d2af5026..d4fd7cb1257e0 100644 --- a/src/test/ui/resolve/issue-21221-2.stderr +++ b/src/test/ui/resolve/issue-21221-2.stderr @@ -4,7 +4,9 @@ error[E0405]: cannot find trait `T` in this scope LL | impl T for Foo { } | ^ not found in this scope | -help: consider importing this trait +help: consider importing one of these items + | +LL | use baz::T; | LL | use foo::bar::T; | diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index d9b1b9c59558a..16baa6c9b6233 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -132,7 +132,7 @@ LL | let _: E = m::n::Z; | ^ help: consider importing this enum | -LL | use m::n::Z; +LL | use m::Z; | error[E0423]: expected value, found enum `m::n::Z` @@ -165,7 +165,7 @@ LL | let _: E = m::n::Z::Fn; | ^ help: consider importing this enum | -LL | use m::n::Z; +LL | use m::Z; | error[E0412]: cannot find type `Z` in this scope @@ -183,7 +183,7 @@ LL | let _: E = m::n::Z::Struct; | ^ help: consider importing this enum | -LL | use m::n::Z; +LL | use m::Z; | error[E0423]: expected value, found struct variant `m::n::Z::Struct` @@ -212,7 +212,7 @@ LL | let _: E = m::n::Z::Unit {}; | ^ help: consider importing this enum | -LL | use m::n::Z; +LL | use m::Z; | error[E0603]: enum `Z` is private diff --git a/src/test/ui/specialization/issue-44861.rs b/src/test/ui/specialization/issue-44861.rs new file mode 100644 index 0000000000000..c37a6273de366 --- /dev/null +++ b/src/test/ui/specialization/issue-44861.rs @@ -0,0 +1,40 @@ +#![crate_type = "lib"] +#![feature(specialization)] +#![feature(unsize, coerce_unsized)] +#![allow(incomplete_features)] + +use std::ops::CoerceUnsized; + +pub struct SmartassPtr(A::Data); + +pub trait Smartass { + type Data; + type Data2: CoerceUnsized<*const [u8]>; +} + +pub trait MaybeObjectSafe {} + +impl MaybeObjectSafe for () {} + +impl Smartass for T { + type Data = ::Data2; + default type Data2 = (); + //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied +} + +impl Smartass for () { + type Data2 = *const [u8; 1]; +} + +impl Smartass for dyn MaybeObjectSafe { + type Data = *const [u8]; + type Data2 = *const [u8; 0]; +} + +impl CoerceUnsized> for SmartassPtr + where ::Data: std::ops::CoerceUnsized<::Data> +{} + +pub fn conv(s: SmartassPtr<()>) -> SmartassPtr { + s +} diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr new file mode 100644 index 0000000000000..b41b17e76a6ab --- /dev/null +++ b/src/test/ui/specialization/issue-44861.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied + --> $DIR/issue-44861.rs:21:5 + | +LL | type Data2: CoerceUnsized<*const [u8]>; + | --------------------------------------- required by `Smartass::Data2` +... +LL | default type Data2 = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/specialization/issue-59435.rs b/src/test/ui/specialization/issue-59435.rs new file mode 100644 index 0000000000000..47323d3096f3d --- /dev/null +++ b/src/test/ui/specialization/issue-59435.rs @@ -0,0 +1,17 @@ +#![feature(specialization)] +#![allow(incomplete_features)] + +struct MyStruct {} + +trait MyTrait { + type MyType: Default; +} + +impl MyTrait for i32 { + default type MyType = MyStruct; + //~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied +} + +fn main() { + let _x: ::MyType = ::MyType::default(); +} diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr new file mode 100644 index 0000000000000..fd512a539a3ee --- /dev/null +++ b/src/test/ui/specialization/issue-59435.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied + --> $DIR/issue-59435.rs:11:5 + | +LL | type MyType: Default; + | --------------------- required by `MyTrait::MyType` +... +LL | default type MyType = MyStruct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.rs b/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.rs new file mode 100644 index 0000000000000..0cf77da559470 --- /dev/null +++ b/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.rs @@ -0,0 +1,58 @@ +// check-pass +// +// rust-lang/rust#73592: borrow_mut through Deref should work. +// +// Before #72280, when we see something like `&mut *rcvr.method()`, we +// incorrectly requires `rcvr` to be type-checked as a mut place. While this +// requirement is usually correct for smart pointers, it is overly restrictive +// for types like `Mutex` or `RefCell` which can produce a guard that +// implements `DerefMut` from `&self`. +// +// Making it more confusing, because we use Deref as the fallback when DerefMut +// is implemented, we won't see an issue when the smart pointer does not +// implement `DerefMut`. It only causes an issue when `rcvr` is obtained via a +// type that implements both `Deref` or `DerefMut`. +// +// This bug is only discovered in #73592 after it is already fixed as a side-effect +// of a refactoring made in #72280. + +#![warn(unused_mut)] + +use std::pin::Pin; +use std::cell::RefCell; + +struct S(RefCell<()>); + +fn test_pin(s: Pin<&S>) { + // This works before #72280. + let _ = &mut *s.0.borrow_mut(); +} + +fn test_pin_mut(s: Pin<&mut S>) { + // This should compile but didn't before #72280. + let _ = &mut *s.0.borrow_mut(); +} + +fn test_vec(s: &Vec>) { + // This should compile but didn't before #72280. + let _ = &mut *s[0].borrow_mut(); +} + +fn test_mut_pin(mut s: Pin<&S>) { + //~^ WARN variable does not need to be mutable + let _ = &mut *s.0.borrow_mut(); +} + +fn test_mut_pin_mut(mut s: Pin<&mut S>) { + //~^ WARN variable does not need to be mutable + let _ = &mut *s.0.borrow_mut(); +} + +fn main() { + let mut s = S(RefCell::new(())); + test_pin(Pin::new(&s)); + test_pin_mut(Pin::new(&mut s)); + test_mut_pin(Pin::new(&s)); + test_mut_pin_mut(Pin::new(&mut s)); + test_vec(&vec![s.0]); +} diff --git a/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.stderr b/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.stderr new file mode 100644 index 0000000000000..51303adc9e533 --- /dev/null +++ b/src/test/ui/typeck/issue-73592-borrow_mut-through-deref.stderr @@ -0,0 +1,24 @@ +warning: variable does not need to be mutable + --> $DIR/issue-73592-borrow_mut-through-deref.rs:41:17 + | +LL | fn test_mut_pin(mut s: Pin<&S>) { + | ----^ + | | + | help: remove this `mut` + | +note: the lint level is defined here + --> $DIR/issue-73592-borrow_mut-through-deref.rs:19:9 + | +LL | #![warn(unused_mut)] + | ^^^^^^^^^^ + +warning: variable does not need to be mutable + --> $DIR/issue-73592-borrow_mut-through-deref.rs:46:21 + | +LL | fn test_mut_pin_mut(mut s: Pin<&mut S>) { + | ----^ + | | + | help: remove this `mut` + +warning: 2 warnings emitted + diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 39baa6b8540df..9eb43eb2df43f 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -7,7 +7,6 @@ #![deny(warnings)] use serde::Serialize; -use toml; use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs index e60e2a81e070b..e19a79dd8dad1 100755 --- a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs @@ -476,7 +476,7 @@ pub fn eq_generic_param(l: &GenericParam, r: &GenericParam) -> bool { && match (&l.kind, &r.kind) { (Lifetime, Lifetime) => true, (Type { default: l }, Type { default: r }) => both(l, r, |l, r| eq_ty(l, r)), - (Const { ty: l }, Const { ty: r }) => eq_ty(l, r), + (Const { ty: l, kw_span: _ }, Const { ty: r, kw_span: _ }) => eq_ty(l, r), _ => false, } && over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r)) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 52d0cbd4bfd7a..6ac7c3b9b474a 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -4,7 +4,6 @@ use crate::errors::{Error, ErrorKind}; use crate::runtest::ProcRes; use serde::Deserialize; -use serde_json; use std::path::{Path, PathBuf}; use std::str::FromStr; diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index c00b0f02c3a90..134ac66b7d15b 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -9,8 +9,6 @@ extern crate test; use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, Pretty, TestPaths}; use crate::util::logv; -use env_logger; -use getopts; use getopts::Options; use log::*; use std::env; diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index da1d3db49d70e..30a922057eb20 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -25,7 +25,6 @@ mod imp { #[cfg(unix)] mod imp { - use libc; use std::io; use std::io::prelude::*; use std::mem; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 95ea4fb078955..dd0c68ecd4965 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -13,7 +13,6 @@ use crate::header::TestProps; use crate::json; use crate::util::get_pointer_width; use crate::util::{logv, PathBufExt}; -use diff; use regex::{Captures, Regex}; use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};