diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index f2a7d1d00cf..b5c8de057d0 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -736,7 +736,7 @@ fn run(self, builder: &Builder<'_>) { if builder.config.channel == "dev" || builder.config.channel == "nightly" { builder.info("fmt check"); - crate::format::format(&builder.build, true); + crate::format::format(&builder.build, !builder.config.cmd.bless()); } } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 80294de714d..0d5af3986fb 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -216,6 +216,11 @@ //! Common iterator adapters include [`map`], [`take`], and [`filter`]. //! For more, see their documentation. //! +//! If an iterator adapter panics, the iterator will be in an unspecified (but +//! memory safe) state. This state is also not guaranteed to stay the same +//! across versions of Rust, so you should avoid relying on the exact values +//! returned by an iterator which panicked. +//! //! [`map`]: trait.Iterator.html#method.map //! [`take`]: trait.Iterator.html#method.take //! [`filter`]: trait.Iterator.html#method.filter diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 7d11dd2800f..590f4e46c1d 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -71,6 +71,8 @@ #![feature(cfg_target_has_atomic)] #![feature(concat_idents)] #![feature(const_fn)] +#![feature(const_if_match)] +#![feature(const_panic)] #![feature(const_fn_union)] #![feature(const_generics)] #![feature(const_ptr_offset_from)] diff --git a/src/libcore/mem/manually_drop.rs b/src/libcore/mem/manually_drop.rs index af4635f89f6..36064488eb2 100644 --- a/src/libcore/mem/manually_drop.rs +++ b/src/libcore/mem/manually_drop.rs @@ -121,7 +121,7 @@ impl ManuallyDrop { /// This function runs the destructor of the contained value and thus the wrapped value /// now represents uninitialized data. It is up to the user of this method to ensure the /// uninitialized data is not actually used. - /// In particular, this function can only be called called at most once + /// In particular, this function can only be called at most once /// for a given instance of `ManuallyDrop`. /// /// [`ManuallyDrop::into_inner`]: #method.into_inner diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 8a32479b2ff..14540394cab 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1416,18 +1416,14 @@ pub const fn wrapping_shr(self, rhs: u32) -> Self { ```"), #[stable(feature = "no_panic_abs", since = "1.13.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] + #[allow_internal_unstable(const_if_match)] #[inline] pub const fn wrapping_abs(self) -> Self { - // sign is -1 (all ones) for negative numbers, 0 otherwise. - let sign = self >> ($BITS - 1); - // For positive self, sign == 0 so the expression is simply - // (self ^ 0).wrapping_sub(0) == self == abs(self). - // - // For negative self, self ^ sign == self ^ all_ones. - // But all_ones ^ self == all_ones - self == -1 - self. - // So for negative numbers, (self ^ sign).wrapping_sub(sign) is - // (-1 - self).wrapping_sub(-1) == -self == abs(self). - (self ^ sign).wrapping_sub(sign) + if self.is_negative() { + self.wrapping_neg() + } else { + self + } } } @@ -1713,8 +1709,13 @@ pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { #[inline] #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] + #[allow_internal_unstable(const_if_match)] pub const fn overflowing_neg(self) -> (Self, bool) { - ((!self).wrapping_add(1), self == Self::min_value()) + if self == Self::min_value() { + (Self::min_value(), true) + } else { + (-self, false) + } } } @@ -2041,7 +2042,11 @@ pub const fn abs(self) -> Self { #[rustc_const_unstable(feature = "const_int_sign", issue = "53718")] #[inline] pub const fn signum(self) -> Self { - (self > 0) as Self - (self < 0) as Self + match self { + n if n > 0 => 1, + 0 => 0, + _ => -1, + } } } diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs index e5297a0c1e0..fc3c02e1f06 100644 --- a/src/libcore/ptr/const_ptr.rs +++ b/src/libcore/ptr/const_ptr.rs @@ -288,10 +288,7 @@ pub fn wrapping_offset(self, count: isize) -> *const T T: Sized, { let pointee_size = mem::size_of::(); - let ok = 0 < pointee_size && pointee_size <= isize::max_value() as usize; - // assert that the pointee size is valid in a const eval compatible way - // FIXME: do this with a real assert at some point - [()][(!ok) as usize]; + assert!(0 < pointee_size && pointee_size <= isize::max_value() as usize); intrinsics::ptr_offset_from(self, origin) } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 55713aedbcb..76588dfa5e2 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -95,24 +95,7 @@ pub mod ich; pub mod infer; pub mod lint; - -pub mod middle { - pub mod cstore; - pub mod dependency_format; - pub mod diagnostic_items; - pub mod exported_symbols; - pub mod free_region; - pub mod lang_items; - pub mod lib_features; - pub mod privacy; - pub mod reachable; - pub mod recursion_limit; - pub mod region; - pub mod resolve_lifetime; - pub mod stability; - pub mod weak_lang_items; -} - +pub mod middle; pub mod mir; pub use rustc_session as session; pub mod traits; diff --git a/src/librustc/middle/mod.rs b/src/librustc/middle/mod.rs new file mode 100644 index 00000000000..030bcf3bf42 --- /dev/null +++ b/src/librustc/middle/mod.rs @@ -0,0 +1,35 @@ +pub mod cstore; +pub mod dependency_format; +pub mod exported_symbols; +pub mod free_region; +pub mod lang_items; +pub mod lib_features { + use rustc_data_structures::fx::{FxHashMap, FxHashSet}; + use syntax::symbol::Symbol; + + #[derive(HashStable)] + pub struct LibFeatures { + // A map from feature to stabilisation version. + pub stable: FxHashMap, + pub unstable: FxHashSet, + } + + impl LibFeatures { + pub fn to_vec(&self) -> Vec<(Symbol, Option)> { + let mut all_features: Vec<_> = self + .stable + .iter() + .map(|(f, s)| (*f, Some(*s))) + .chain(self.unstable.iter().map(|f| (*f, None))) + .collect(); + all_features.sort_unstable_by_key(|f| f.0.as_str()); + all_features + } + } +} +pub mod privacy; +pub mod recursion_limit; +pub mod region; +pub mod resolve_lifetime; +pub mod stability; +pub mod weak_lang_items; diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 24841a1ccf4..9b7ae099335 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -510,7 +510,7 @@ } Other { - query reachable_set(_: CrateNum) -> ReachableSet { + query reachable_set(_: CrateNum) -> Lrc { desc { "reachability" } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 95860397036..b84b0e4f45d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2751,22 +2751,10 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { assert_eq!(id, LOCAL_CRATE); tcx.crate_name }; - providers.get_lib_features = |tcx, id| { - assert_eq!(id, LOCAL_CRATE); - tcx.arena.alloc(middle::lib_features::collect(tcx)) - }; providers.get_lang_items = |tcx, id| { assert_eq!(id, LOCAL_CRATE); tcx.arena.alloc(middle::lang_items::collect(tcx)) }; - providers.diagnostic_items = |tcx, id| { - assert_eq!(id, LOCAL_CRATE); - middle::diagnostic_items::collect(tcx) - }; - providers.all_diagnostic_items = |tcx, id| { - assert_eq!(id, LOCAL_CRATE); - middle::diagnostic_items::collect_all(tcx) - }; providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id); providers.maybe_unused_extern_crates = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 8be0536a18e..f523cee49ec 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -10,7 +10,6 @@ use crate::middle::lang_items::{LangItem, LanguageItems}; use crate::middle::lib_features::LibFeatures; use crate::middle::privacy::AccessLevels; -use crate::middle::reachable::ReachableSet; use crate::middle::region; use crate::middle::resolve_lifetime::{ObjectLifetimeDefault, Region, ResolveLifetimes}; use crate::middle::stability::{self, DeprecationEntry}; @@ -37,7 +36,7 @@ use crate::ty::util::NeedsDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; use crate::util::common::ErrorReported; -use crate::util::nodemap::{DefIdMap, DefIdSet}; +use crate::util::nodemap::{DefIdMap, DefIdSet, HirIdSet}; use rustc_data_structures::profiling::ProfileCategory::*; use rustc_data_structures::fingerprint::Fingerprint; diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 07ff5c362eb..5bdb310f9b5 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -65,7 +65,6 @@ fn reachable_non_generics_provider( let mut reachable_non_generics: DefIdMap<_> = tcx .reachable_set(LOCAL_CRATE) - .0 .iter() .filter_map(|&hir_id| { // We want to ignore some FFI functions that are not exposed from @@ -313,7 +312,7 @@ fn upstream_monomorphizations_for_provider( fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> bool { if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) { - !tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id) + !tcx.reachable_set(LOCAL_CRATE).contains(&hir_id) } else { bug!("is_unreachable_local_definition called with non-local DefId: {:?}", def_id) } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 9d0ec585c20..b4522f4c665 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -10,7 +10,7 @@ use rustc::hir::lowering::lower_crate; use rustc::lint; use rustc::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn}; -use rustc::middle::{self, reachable, resolve_lifetime, stability}; +use rustc::middle::{self, resolve_lifetime, stability}; use rustc::session::config::{self, CrateType, Input, OutputFilenames, OutputType}; use rustc::session::config::{PpMode, PpSourceMode}; use rustc::session::search_paths::PathKind; @@ -678,14 +678,12 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) { plugin::build::provide(providers); hir::provide(providers); mir::provide(providers); - reachable::provide(providers); resolve_lifetime::provide(providers); rustc_privacy::provide(providers); typeck::provide(providers); ty::provide(providers); traits::provide(providers); stability::provide(providers); - reachable::provide(providers); rustc_passes::provide(providers); rustc_traits::provide(providers); middle::region::provide(providers); diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 79221329ead..af6fcb6922a 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -882,9 +882,27 @@ fn report_local_value_does_not_live_long_enough( err.span_label( drop_span, format!( - "...but `{}` will be dropped here, when the function `{}` returns", + "...but `{}` will be dropped here, when the {} returns", name, - self.infcx.tcx.hir().name(fn_hir_id), + self.infcx + .tcx + .hir() + .opt_name(fn_hir_id) + .map(|name| format!("function `{}`", name)) + .unwrap_or_else(|| { + match &self + .infcx + .tcx + .typeck_tables_of(self.mir_def_id) + .node_type(fn_hir_id) + .kind + { + ty::Closure(..) => "enclosing closure", + ty::Generator(..) => "enclosing generator", + kind => bug!("expected closure or generator, found {:?}", kind), + } + .to_string() + }) ), ); diff --git a/src/librustc/middle/diagnostic_items.rs b/src/librustc_passes/diagnostic_items.rs similarity index 85% rename from src/librustc/middle/diagnostic_items.rs rename to src/librustc_passes/diagnostic_items.rs index 32ef1338712..65138fad43b 100644 --- a/src/librustc/middle/diagnostic_items.rs +++ b/src/librustc_passes/diagnostic_items.rs @@ -9,12 +9,13 @@ //! //! * Compiler internal types like `Ty` and `TyCtxt` -use crate::hir::def_id::{DefId, LOCAL_CRATE}; -use crate::ty::TyCtxt; -use crate::util::nodemap::FxHashMap; +use rustc::hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::ty::query::Providers; +use rustc::ty::TyCtxt; +use rustc::util::nodemap::FxHashMap; -use crate::hir; -use crate::hir::itemlikevisit::ItemLikeVisitor; +use rustc::hir; +use rustc::hir::itemlikevisit::ItemLikeVisitor; use syntax::ast; use syntax::symbol::{sym, Symbol}; @@ -93,7 +94,7 @@ fn extract(attrs: &[ast::Attribute]) -> Option { } /// Traverse and collect the diagnostic items in the current -pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { +fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { // Initialize the collector. let mut collector = DiagnosticItemCollector::new(tcx); @@ -104,7 +105,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { } /// Traverse and collect all the diagnostic items in all crates. -pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { +fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { // Initialize the collector. let mut collector = FxHashMap::default(); @@ -117,3 +118,14 @@ pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap { tcx.arena.alloc(collector) } + +pub fn provide(providers: &mut Providers<'_>) { + providers.diagnostic_items = |tcx, id| { + assert_eq!(id, LOCAL_CRATE); + collect(tcx) + }; + providers.all_diagnostic_items = |tcx, id| { + assert_eq!(id, LOCAL_CRATE); + collect_all(tcx) + }; +} diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 5c2ccd28383..da781f2bae5 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -22,17 +22,23 @@ pub mod ast_validation; mod check_const; pub mod dead; +mod diagnostic_items; pub mod entry; pub mod hir_stats; mod intrinsicck; pub mod layout_test; +mod lib_features; mod liveness; pub mod loops; +mod reachable; pub fn provide(providers: &mut Providers<'_>) { check_const::provide(providers); + diagnostic_items::provide(providers); entry::provide(providers); + lib_features::provide(providers); loops::provide(providers); liveness::provide(providers); intrinsicck::provide(providers); + reachable::provide(providers); } diff --git a/src/librustc/middle/lib_features.rs b/src/librustc_passes/lib_features.rs similarity index 83% rename from src/librustc/middle/lib_features.rs rename to src/librustc_passes/lib_features.rs index b4ddb09861d..0b0183f3cce 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc_passes/lib_features.rs @@ -4,38 +4,19 @@ // and `#[unstable (..)]`), but are not declared in one single location // (unlike lang features), which means we need to collect them instead. -use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; -use crate::ty::TyCtxt; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_macros::HashStable; +use rustc::hir::def_id::LOCAL_CRATE; +use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::middle::lib_features::LibFeatures; +use rustc::ty::query::Providers; +use rustc::ty::TyCtxt; use syntax::ast::{Attribute, MetaItem, MetaItemKind}; use syntax::symbol::Symbol; use syntax_pos::{sym, Span}; use rustc_error_codes::*; -#[derive(HashStable)] -pub struct LibFeatures { - // A map from feature to stabilisation version. - pub stable: FxHashMap, - pub unstable: FxHashSet, -} - -impl LibFeatures { - fn new() -> LibFeatures { - LibFeatures { stable: Default::default(), unstable: Default::default() } - } - - pub fn to_vec(&self) -> Vec<(Symbol, Option)> { - let mut all_features: Vec<_> = self - .stable - .iter() - .map(|(f, s)| (*f, Some(*s))) - .chain(self.unstable.iter().map(|f| (*f, None))) - .collect(); - all_features.sort_unstable_by_key(|f| f.0.as_str()); - all_features - } +fn new_lib_features() -> LibFeatures { + LibFeatures { stable: Default::default(), unstable: Default::default() } } pub struct LibFeatureCollector<'tcx> { @@ -45,7 +26,7 @@ pub struct LibFeatureCollector<'tcx> { impl LibFeatureCollector<'tcx> { fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> { - LibFeatureCollector { tcx, lib_features: LibFeatures::new() } + LibFeatureCollector { tcx, lib_features: new_lib_features() } } fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option, Span)> { @@ -142,7 +123,7 @@ fn visit_attribute(&mut self, attr: &'tcx Attribute) { } } -pub fn collect(tcx: TyCtxt<'_>) -> LibFeatures { +fn collect(tcx: TyCtxt<'_>) -> LibFeatures { let mut collector = LibFeatureCollector::new(tcx); let krate = tcx.hir().krate(); for attr in krate.non_exported_macro_attrs { @@ -151,3 +132,10 @@ pub fn collect(tcx: TyCtxt<'_>) -> LibFeatures { intravisit::walk_crate(&mut collector, krate); collector.lib_features } + +pub fn provide(providers: &mut Providers<'_>) { + providers.get_lib_features = |tcx, id| { + assert_eq!(id, LOCAL_CRATE); + tcx.arena.alloc(collect(tcx)) + }; +} diff --git a/src/librustc/middle/reachable.rs b/src/librustc_passes/reachable.rs similarity index 95% rename from src/librustc/middle/reachable.rs rename to src/librustc_passes/reachable.rs index c6598f2d328..5241d9ea43f 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -5,23 +5,22 @@ // makes all other generics or inline functions that it references // reachable as well. -use crate::hir::def::{DefKind, Res}; -use crate::hir::def_id::{CrateNum, DefId}; -use crate::hir::Node; -use crate::hir::{CodegenFnAttrFlags, CodegenFnAttrs}; -use crate::middle::privacy; -use crate::session::config; -use crate::ty::query::Providers; -use crate::ty::{self, TyCtxt}; -use crate::util::nodemap::{FxHashSet, HirIdSet}; +use rustc::hir::def::{DefKind, Res}; +use rustc::hir::def_id::{CrateNum, DefId}; +use rustc::hir::Node; +use rustc::hir::{CodegenFnAttrFlags, CodegenFnAttrs}; +use rustc::middle::privacy; +use rustc::session::config; +use rustc::ty::query::Providers; +use rustc::ty::{self, TyCtxt}; +use rustc::util::nodemap::{FxHashSet, HirIdSet}; use rustc_data_structures::sync::Lrc; -use crate::hir; -use crate::hir::def_id::LOCAL_CRATE; -use crate::hir::intravisit; -use crate::hir::intravisit::{NestedVisitorMap, Visitor}; -use crate::hir::itemlikevisit::ItemLikeVisitor; -use rustc_macros::HashStable; +use rustc::hir; +use rustc::hir::def_id::LOCAL_CRATE; +use rustc::hir::intravisit; +use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; +use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc_target::spec::abi::Abi; // Returns true if the given item must be inlined because it may be @@ -378,12 +377,7 @@ fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) { } } -// We introduce a new-type here, so we can have a specialized HashStable -// implementation for it. -#[derive(Clone, HashStable)] -pub struct ReachableSet(pub Lrc); - -fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet { +fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc { debug_assert!(crate_num == LOCAL_CRATE); let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); @@ -429,7 +423,7 @@ fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet { debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols); // Return the set of reachable symbols. - ReachableSet(Lrc::new(reachable_context.reachable_symbols)) + Lrc::new(reachable_context.reachable_symbols) } pub fn provide(providers: &mut Providers<'_>) { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 800c40ffdb1..afbfb647b3c 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -528,31 +528,7 @@ impl<'a> Resolver<'a> { resolution.shadowed_glob = Some(glob_binding); } (false, false) => { - if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) = - (&old_binding.kind, &binding.kind) - { - this.session - .struct_span_err( - binding.span, - &format!( - "a macro named `{}` has already been exported", - key.ident - ), - ) - .span_label( - binding.span, - format!("`{}` already exported", key.ident), - ) - .span_note( - old_binding.span, - "previous macro export is now shadowed", - ) - .emit(); - - resolution.binding = Some(binding); - } else { - return Err(old_binding); - } + return Err(old_binding); } } } else { diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 156126a748a..2f53378303b 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -353,13 +353,13 @@ fn check_pat_lit( fn check_pat_range( &self, span: Span, - begin: &'tcx hir::Expr<'tcx>, - end: &'tcx hir::Expr<'tcx>, + lhs: &'tcx hir::Expr<'tcx>, + rhs: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, discrim_span: Option, ) -> Option> { - let lhs_ty = self.check_expr(begin); - let rhs_ty = self.check_expr(end); + let lhs_ty = self.check_expr(lhs); + let rhs_ty = self.check_expr(rhs); // Check that both end-points are of numeric or char type. let numeric_or_char = |ty: Ty<'_>| ty.is_numeric() || ty.is_char() || ty.references_error(); @@ -367,7 +367,7 @@ fn check_pat_range( let rhs_fail = !numeric_or_char(rhs_ty); if lhs_fail || rhs_fail { - self.emit_err_pat_range(span, begin.span, end.span, lhs_fail, rhs_fail, lhs_ty, rhs_ty); + self.emit_err_pat_range(span, lhs.span, rhs.span, lhs_fail, rhs_fail, lhs_ty, rhs_ty); return None; } @@ -376,11 +376,24 @@ fn check_pat_range( let common_type = self.resolve_vars_if_possible(&lhs_ty); // Subtyping doesn't matter here, as the value is some kind of scalar. - self.demand_eqtype_pat(span, expected, lhs_ty, discrim_span); - self.demand_eqtype_pat(span, expected, rhs_ty, discrim_span); + let demand_eqtype = |x_span, y_span, x_ty, y_ty| { + self.demand_eqtype_pat_diag(x_span, expected, x_ty, discrim_span).map(|mut err| { + self.endpoint_has_type(&mut err, y_span, y_ty); + err.emit(); + }); + }; + demand_eqtype(lhs.span, rhs.span, lhs_ty, rhs_ty); + demand_eqtype(rhs.span, lhs.span, rhs_ty, lhs_ty); + Some(common_type) } + fn endpoint_has_type(&self, err: &mut DiagnosticBuilder<'_>, span: Span, ty: Ty<'_>) { + if !ty.references_error() { + err.span_label(span, &format!("this is of type `{}`", ty)); + } + } + fn emit_err_pat_range( &self, span: Span, @@ -408,9 +421,7 @@ fn emit_err_pat_range( let msg = |ty| format!("this is of type `{}` but it should be `char` or numeric", ty); let mut one_side_err = |first_span, first_ty, second_span, second_ty: Ty<'_>| { err.span_label(first_span, &msg(first_ty)); - if !second_ty.references_error() { - err.span_label(second_span, &format!("this is of type `{}`", second_ty)); - } + self.endpoint_has_type(&mut err, second_span, second_ty); }; if lhs_fail && rhs_fail { err.span_label(begin_span, &msg(lhs_ty)); diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 7901c8197b5..5c7ee9bded9 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -1149,20 +1149,39 @@ mod where_keyword {} // /// Return a [`Future`] instead of blocking the current thread. /// -/// The documentation for this keyword is [not yet complete]. Pull requests welcome! +/// Use `async` in front of `fn`, `closure`, or a `block` to turn the marked code into a `Future`. +/// As such the code will not be run immediately, but will only be evaluated when the returned +/// future is `.await`ed. +/// +/// We have written an [async book] detailing async/await and trade-offs compared to using threads. +/// +/// ## Editions +/// +/// `async` is a keyword from the 2018 edition onwards. +/// +/// It is available for use in stable rust from version 1.39 onwards. /// /// [`Future`]: ./future/trait.Future.html -/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 +/// [async book]: https://rust-lang.github.io/async-book/ mod async_keyword {} #[doc(keyword = "await")] // /// Suspend execution until the result of a [`Future`] is ready. /// -/// The documentation for this keyword is [not yet complete]. Pull requests welcome! +/// `.await`ing a future will suspend the current function's execution until the `executor` +/// has run the future to completion. +/// +/// Read the [async book] for details on how async/await and executors work. +/// +/// ## Editions +/// +/// `await` is a keyword from the 2018 edition onwards. +/// +/// It is available for use in stable rust from version 1.39 onwards. /// /// [`Future`]: ./future/trait.Future.html -/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 +/// [async book]: https://rust-lang.github.io/async-book/ mod await_keyword {} #[doc(keyword = "dyn")] diff --git a/src/libsyntax_expand/expand.rs b/src/libsyntax_expand/expand.rs index 4df51ff41f3..089dd471f3b 100644 --- a/src/libsyntax_expand/expand.rs +++ b/src/libsyntax_expand/expand.rs @@ -717,13 +717,10 @@ fn expand_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtensionKind) -> AstF fn gate_proc_macro_attr_item(&self, span: Span, item: &Annotatable) { let kind = match item { - Annotatable::Item(item) => match &item.kind { - ItemKind::Mod(m) if m.inline => "modules", - _ => return, - }, - Annotatable::TraitItem(_) | Annotatable::ImplItem(_) | Annotatable::ForeignItem(_) => { - return; - } + Annotatable::Item(_) + | Annotatable::TraitItem(_) + | Annotatable::ImplItem(_) + | Annotatable::ForeignItem(_) => return, Annotatable::Stmt(_) => "statements", Annotatable::Expr(_) => "expressions", Annotatable::Arm(..) diff --git a/src/test/ui/error-codes/E0308-4.stderr b/src/test/ui/error-codes/E0308-4.stderr index 127fdaadbc5..46805d6e13b 100644 --- a/src/test/ui/error-codes/E0308-4.stderr +++ b/src/test/ui/error-codes/E0308-4.stderr @@ -1,10 +1,12 @@ error[E0308]: mismatched types - --> $DIR/E0308-4.rs:4:9 + --> $DIR/E0308-4.rs:4:15 | LL | match x { | - this match expression has type `u8` LL | 0u8..=3i8 => (), - | ^^^^^^^^^ expected `u8`, found `i8` + | --- ^^^ expected `u8`, found `i8` + | | + | this is of type `u8` error: aborting due to previous error diff --git a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision.stderr b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision.stderr index 2029cfaf75d..04538cd74b1 100644 --- a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision.stderr +++ b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision.stderr @@ -10,7 +10,7 @@ error[E0308]: mismatched types LL | match [5..4, 99..105, 43..44] { | ----------------------- this match expression has type `std::ops::Range<{integer}>` LL | [_, 99.., _] => {}, - | ^^^^ expected struct `std::ops::Range`, found integer + | ^^ expected struct `std::ops::Range`, found integer | = note: expected struct `std::ops::Range<{integer}>` found type `{integer}` diff --git a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision2.stderr b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision2.stderr index 6a88d05837a..c918d0a385c 100644 --- a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision2.stderr +++ b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision2.stderr @@ -16,7 +16,7 @@ error[E0308]: mismatched types LL | match [5..4, 99..105, 43..44] { | ----------------------- this match expression has type `std::ops::Range<{integer}>` LL | [_, 99..] => {}, - | ^^^^ expected struct `std::ops::Range`, found integer + | ^^ expected struct `std::ops::Range`, found integer | = note: expected struct `std::ops::Range<{integer}>` found type `{integer}` diff --git a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.rs b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.rs index 95e58b1d48c..1557f592b2a 100644 --- a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.rs +++ b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.rs @@ -6,6 +6,7 @@ fn main() { //~^ ERROR `..X` range patterns are not supported //~| ERROR mismatched types //~| ERROR mismatched types + //~| ERROR mismatched types _ => {}, } } diff --git a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.stderr b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.stderr index 5c49fbe4c5c..e6ee3817b35 100644 --- a/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.stderr +++ b/src/test/ui/exclusive-range/exclusive_range_pattern_syntax_collision3.stderr @@ -5,12 +5,12 @@ LL | [..9, 99..100, _] => {}, | ^^^ help: try using the minimum value for the type: `MIN..9` error[E0308]: mismatched types - --> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:10 + --> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:12 | LL | match [5..4, 99..105, 43..44] { | ----------------------- this match expression has type `std::ops::Range<{integer}>` LL | [..9, 99..100, _] => {}, - | ^^^ expected struct `std::ops::Range`, found integer + | ^ expected struct `std::ops::Range`, found integer | = note: expected struct `std::ops::Range<{integer}>` found type `{integer}` @@ -21,11 +21,26 @@ error[E0308]: mismatched types LL | match [5..4, 99..105, 43..44] { | ----------------------- this match expression has type `std::ops::Range<{integer}>` LL | [..9, 99..100, _] => {}, - | ^^^^^^^ expected struct `std::ops::Range`, found integer + | ^^ --- this is of type `{integer}` + | | + | expected struct `std::ops::Range`, found integer | = note: expected struct `std::ops::Range<{integer}>` found type `{integer}` -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/exclusive_range_pattern_syntax_collision3.rs:5:19 + | +LL | match [5..4, 99..105, 43..44] { + | ----------------------- this match expression has type `std::ops::Range<{integer}>` +LL | [..9, 99..100, _] => {}, + | -- ^^^ expected struct `std::ops::Range`, found integer + | | + | this is of type `{integer}` + | + = note: expected struct `std::ops::Range<{integer}>` + found type `{integer}` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-38715.rs b/src/test/ui/issues/issue-38715.rs index 7e9defab588..9a9a501cae1 100644 --- a/src/test/ui/issues/issue-38715.rs +++ b/src/test/ui/issues/issue-38715.rs @@ -2,6 +2,6 @@ macro_rules! foo { ($i:ident) => {} } #[macro_export] -macro_rules! foo { () => {} } //~ ERROR a macro named `foo` has already been exported +macro_rules! foo { () => {} } //~ ERROR the name `foo` is defined multiple times fn main() {} diff --git a/src/test/ui/issues/issue-38715.stderr b/src/test/ui/issues/issue-38715.stderr index d7c4f88ff50..c87d9f7360b 100644 --- a/src/test/ui/issues/issue-38715.stderr +++ b/src/test/ui/issues/issue-38715.stderr @@ -1,14 +1,14 @@ -error: a macro named `foo` has already been exported +error[E0428]: the name `foo` is defined multiple times --> $DIR/issue-38715.rs:5:1 | -LL | macro_rules! foo { () => {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` already exported - | -note: previous macro export is now shadowed - --> $DIR/issue-38715.rs:2:1 - | LL | macro_rules! foo { ($i:ident) => {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ---------------- previous definition of the macro `foo` here +... +LL | macro_rules! foo { () => {} } + | ^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the macro namespace of this module error: aborting due to previous error +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.rs b/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.rs new file mode 100644 index 00000000000..19d7f019047 --- /dev/null +++ b/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.rs @@ -0,0 +1,3 @@ +fn main() { + [0].iter().flat_map(|a| [0].iter().map(|_| &a)); //~ ERROR `a` does not live long enough +} diff --git a/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.stderr b/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.stderr new file mode 100644 index 00000000000..cb0b481e748 --- /dev/null +++ b/src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.stderr @@ -0,0 +1,15 @@ +error[E0597]: `a` does not live long enough + --> $DIR/unnamed-closure-doesnt-life-long-enough-issue-67634.rs:2:49 + | +LL | [0].iter().flat_map(|a| [0].iter().map(|_| &a)); + | - ^- ...but `a` will be dropped here, when the enclosing closure returns + | | | + | | `a` would have to be valid for `'_`... + | has type `&i32` + | + = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments + = note: to learn more, visit + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/match/match-range-fail.stderr b/src/test/ui/match/match-range-fail.stderr index adaaf29aae4..64105dc73d3 100644 --- a/src/test/ui/match/match-range-fail.stderr +++ b/src/test/ui/match/match-range-fail.stderr @@ -28,7 +28,9 @@ error[E0308]: mismatched types --> $DIR/match-range-fail.rs:18:9 | LL | 'c' ..= 100 => { } - | ^^^^^^^^^^^ expected integer, found `char` + | ^^^ --- this is of type `{integer}` + | | + | expected integer, found `char` error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/pat-tuple-5.stderr b/src/test/ui/parser/pat-tuple-5.stderr index 3579a2c4e09..5b0253cd273 100644 --- a/src/test/ui/parser/pat-tuple-5.stderr +++ b/src/test/ui/parser/pat-tuple-5.stderr @@ -19,7 +19,7 @@ error[E0308]: mismatched types LL | match (0, 1) { | ------ this match expression has type `({integer}, {integer})` LL | (PAT ..) => {} - | ^^^^^^ expected tuple, found `u8` + | ^^^ expected tuple, found `u8` | = note: expected tuple `({integer}, {integer})` found type `u8` diff --git a/src/test/ui/parser/recover-range-pats.stderr b/src/test/ui/parser/recover-range-pats.stderr index af03b577548..50a44192707 100644 --- a/src/test/ui/parser/recover-range-pats.stderr +++ b/src/test/ui/parser/recover-range-pats.stderr @@ -417,13 +417,17 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:21:12 | LL | if let .0..Y = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ - this is of type `u8` + | | + | expected integer, found floating-point number error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:23:12 + --> $DIR/recover-range-pats.rs:23:16 | LL | if let X.. .0 = 0 {} - | ^^^^^^ expected integer, found floating-point number + | - ^^ expected integer, found floating-point number + | | + | this is of type `u8` error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:32:12 @@ -445,13 +449,17 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:34:12 | LL | if let .0..=Y = 0 {} - | ^^^^^^ expected integer, found floating-point number + | ^^ - this is of type `u8` + | | + | expected integer, found floating-point number error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:36:12 + --> $DIR/recover-range-pats.rs:36:16 | LL | if let X..=.0 = 0 {} - | ^^^^^^ expected integer, found floating-point number + | - ^^ expected integer, found floating-point number + | | + | this is of type `u8` error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:45:12 @@ -473,13 +481,17 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:49:12 | LL | if let .0...Y = 0 {} - | ^^^^^^ expected integer, found floating-point number + | ^^ - this is of type `u8` + | | + | expected integer, found floating-point number error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:52:12 + --> $DIR/recover-range-pats.rs:52:17 | LL | if let X... .0 = 0 {} - | ^^^^^^^ expected integer, found floating-point number + | - ^^ expected integer, found floating-point number + | | + | this is of type `u8` error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:60:12 @@ -491,7 +503,7 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:62:12 | LL | if let .0.. = 0 {} - | ^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:70:12 @@ -503,7 +515,7 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:72:12 | LL | if let .0..= = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:82:12 @@ -515,7 +527,7 @@ error[E0308]: mismatched types --> $DIR/recover-range-pats.rs:85:12 | LL | if let .0... = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:94:14 @@ -524,10 +536,10 @@ LL | if let ..true = 0 {} | ^^^^ this is of type `bool` but it should be `char` or numeric error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:96:12 + --> $DIR/recover-range-pats.rs:96:15 | LL | if let .. .0 = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:104:15 @@ -536,10 +548,10 @@ LL | if let ..=true = 0 {} | ^^^^ this is of type `bool` but it should be `char` or numeric error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:106:12 + --> $DIR/recover-range-pats.rs:106:15 | LL | if let ..=.0 = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:116:15 @@ -548,10 +560,10 @@ LL | if let ...true = 0 {} | ^^^^ this is of type `bool` but it should be `char` or numeric error[E0308]: mismatched types - --> $DIR/recover-range-pats.rs:119:12 + --> $DIR/recover-range-pats.rs:119:15 | LL | if let ....3 = 0 {} - | ^^^^^ expected integer, found floating-point number + | ^^ expected integer, found floating-point number error: aborting due to 85 previous errors diff --git a/src/test/ui/proc-macro/attributes-on-modules-fail.rs b/src/test/ui/proc-macro/attributes-on-modules-fail.rs index c8bc0b34374..c506e903e7f 100644 --- a/src/test/ui/proc-macro/attributes-on-modules-fail.rs +++ b/src/test/ui/proc-macro/attributes-on-modules-fail.rs @@ -3,7 +3,7 @@ #[macro_use] extern crate test_macros; -#[identity_attr] //~ ERROR custom attributes cannot be applied to modules +#[identity_attr] mod m { pub struct X; @@ -19,11 +19,28 @@ mod n {} #[empty_attr] mod module; //~ ERROR non-inline modules in proc macro input are unstable -#[empty_attr] //~ ERROR custom attributes cannot be applied to modules +#[empty_attr] mod outer { mod inner; //~ ERROR non-inline modules in proc macro input are unstable mod inner_inline {} // OK } +#[derive(Empty)] +struct S { + field: [u8; { + #[path = "outer/inner.rs"] + mod inner; //~ ERROR non-inline modules in proc macro input are unstable + mod inner_inline {} // OK + 0 + }] +} + +#[identity_attr] +fn f() { + #[path = "outer/inner.rs"] + mod inner; //~ ERROR non-inline modules in proc macro input are unstable + mod inner_inline {} // OK +} + fn main() {} diff --git a/src/test/ui/proc-macro/attributes-on-modules-fail.stderr b/src/test/ui/proc-macro/attributes-on-modules-fail.stderr index 34a5a5aaa54..74b9932a916 100644 --- a/src/test/ui/proc-macro/attributes-on-modules-fail.stderr +++ b/src/test/ui/proc-macro/attributes-on-modules-fail.stderr @@ -1,12 +1,3 @@ -error[E0658]: custom attributes cannot be applied to modules - --> $DIR/attributes-on-modules-fail.rs:6:1 - | -LL | #[identity_attr] - | ^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/54727 - = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable - error: `derive` may only be applied to structs, enums and unions --> $DIR/attributes-on-modules-fail.rs:16:1 | @@ -31,11 +22,20 @@ LL | mod inner; = note: for more information, see https://github.com/rust-lang/rust/issues/54727 = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable -error[E0658]: custom attributes cannot be applied to modules - --> $DIR/attributes-on-modules-fail.rs:22:1 +error[E0658]: non-inline modules in proc macro input are unstable + --> $DIR/attributes-on-modules-fail.rs:33:9 | -LL | #[empty_attr] - | ^^^^^^^^^^^^^ +LL | mod inner; + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error[E0658]: non-inline modules in proc macro input are unstable + --> $DIR/attributes-on-modules-fail.rs:42:5 + | +LL | mod inner; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/54727 = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable diff --git a/src/test/ui/proc-macro/attributes-on-modules.rs b/src/test/ui/proc-macro/attributes-on-modules.rs index 12c3ac6d947..6c73b0bf19c 100644 --- a/src/test/ui/proc-macro/attributes-on-modules.rs +++ b/src/test/ui/proc-macro/attributes-on-modules.rs @@ -1,13 +1,19 @@ +// check-pass // aux-build:test-macros.rs #[macro_use] extern crate test_macros; -#[identity_attr] //~ ERROR custom attributes cannot be applied to modules +#[identity_attr] mod m { pub struct S; } +#[identity_attr] +fn f() { + mod m {} +} + fn main() { let s = m::S; } diff --git a/src/test/ui/proc-macro/attributes-on-modules.stderr b/src/test/ui/proc-macro/attributes-on-modules.stderr deleted file mode 100644 index df75f0bf4b1..00000000000 --- a/src/test/ui/proc-macro/attributes-on-modules.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: custom attributes cannot be applied to modules - --> $DIR/attributes-on-modules.rs:6:1 - | -LL | #[identity_attr] - | ^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/54727 - = help: add `#![feature(proc_macro_hygiene)]` 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/proc-macro/proc-macro-gates.rs b/src/test/ui/proc-macro/proc-macro-gates.rs index 591c1e039bd..5df6ac422ac 100644 --- a/src/test/ui/proc-macro/proc-macro-gates.rs +++ b/src/test/ui/proc-macro/proc-macro-gates.rs @@ -10,12 +10,8 @@ fn _test_inner() { #![empty_attr] //~ ERROR: non-builtin inner attributes are unstable } -#[empty_attr] //~ ERROR: custom attributes cannot be applied to modules -mod _test2 {} - mod _test2_inner { - #![empty_attr] //~ ERROR: custom attributes cannot be applied to modules - //~| ERROR: non-builtin inner attributes are unstable + #![empty_attr] //~ ERROR: non-builtin inner attributes are unstable } #[empty_attr = "y"] //~ ERROR: key-value macro attributes are not supported diff --git a/src/test/ui/proc-macro/proc-macro-gates.stderr b/src/test/ui/proc-macro/proc-macro-gates.stderr index e939434243b..fff96572e34 100644 --- a/src/test/ui/proc-macro/proc-macro-gates.stderr +++ b/src/test/ui/proc-macro/proc-macro-gates.stderr @@ -8,7 +8,7 @@ LL | #![empty_attr] = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable error[E0658]: non-builtin inner attributes are unstable - --> $DIR/proc-macro-gates.rs:17:5 + --> $DIR/proc-macro-gates.rs:14:5 | LL | #![empty_attr] | ^^^^^^^^^^^^^^ @@ -16,30 +16,21 @@ LL | #![empty_attr] = note: for more information, see https://github.com/rust-lang/rust/issues/54726 = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable -error[E0658]: custom attributes cannot be applied to modules - --> $DIR/proc-macro-gates.rs:13:1 - | -LL | #[empty_attr] - | ^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/54727 - = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable - -error[E0658]: custom attributes cannot be applied to modules - --> $DIR/proc-macro-gates.rs:17:5 - | -LL | #![empty_attr] - | ^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/54727 - = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable - error: key-value macro attributes are not supported - --> $DIR/proc-macro-gates.rs:21:1 + --> $DIR/proc-macro-gates.rs:17:1 | LL | #[empty_attr = "y"] | ^^^^^^^^^^^^^^^^^^^ +error[E0658]: custom attributes cannot be applied to statements + --> $DIR/proc-macro-gates.rs:26:5 + | +LL | #[empty_attr] + | ^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + error[E0658]: custom attributes cannot be applied to statements --> $DIR/proc-macro-gates.rs:30:5 | @@ -58,17 +49,8 @@ LL | #[empty_attr] = note: for more information, see https://github.com/rust-lang/rust/issues/54727 = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable -error[E0658]: custom attributes cannot be applied to statements - --> $DIR/proc-macro-gates.rs:38:5 - | -LL | #[empty_attr] - | ^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/54727 - = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable - error[E0658]: custom attributes cannot be applied to expressions - --> $DIR/proc-macro-gates.rs:42:14 + --> $DIR/proc-macro-gates.rs:38:14 | LL | let _x = #[identity_attr] 2; | ^^^^^^^^^^^^^^^^ @@ -77,7 +59,7 @@ LL | let _x = #[identity_attr] 2; = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: custom attributes cannot be applied to expressions - --> $DIR/proc-macro-gates.rs:45:15 + --> $DIR/proc-macro-gates.rs:41:15 | LL | let _x = [#[identity_attr] 2]; | ^^^^^^^^^^^^^^^^ @@ -86,7 +68,7 @@ LL | let _x = [#[identity_attr] 2]; = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: custom attributes cannot be applied to expressions - --> $DIR/proc-macro-gates.rs:48:14 + --> $DIR/proc-macro-gates.rs:44:14 | LL | let _x = #[identity_attr] println!(); | ^^^^^^^^^^^^^^^^ @@ -95,7 +77,7 @@ LL | let _x = #[identity_attr] println!(); = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: procedural macros cannot be expanded to patterns - --> $DIR/proc-macro-gates.rs:53:12 + --> $DIR/proc-macro-gates.rs:49:12 | LL | if let identity!(Some(_x)) = Some(3) {} | ^^^^^^^^^^^^^^^^^^^ @@ -104,7 +86,7 @@ LL | if let identity!(Some(_x)) = Some(3) {} = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: procedural macros cannot be expanded to statements - --> $DIR/proc-macro-gates.rs:56:5 + --> $DIR/proc-macro-gates.rs:52:5 | LL | empty!(struct S;); | ^^^^^^^^^^^^^^^^^^ @@ -113,7 +95,7 @@ LL | empty!(struct S;); = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: procedural macros cannot be expanded to statements - --> $DIR/proc-macro-gates.rs:57:5 + --> $DIR/proc-macro-gates.rs:53:5 | LL | empty!(let _x = 3;); | ^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +104,7 @@ LL | empty!(let _x = 3;); = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: procedural macros cannot be expanded to expressions - --> $DIR/proc-macro-gates.rs:59:14 + --> $DIR/proc-macro-gates.rs:55:14 | LL | let _x = identity!(3); | ^^^^^^^^^^^^ @@ -131,7 +113,7 @@ LL | let _x = identity!(3); = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable error[E0658]: procedural macros cannot be expanded to expressions - --> $DIR/proc-macro-gates.rs:60:15 + --> $DIR/proc-macro-gates.rs:56:15 | LL | let _x = [empty!(3)]; | ^^^^^^^^^ @@ -139,6 +121,6 @@ LL | let _x = [empty!(3)]; = note: for more information, see https://github.com/rust-lang/rust/issues/54727 = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable -error: aborting due to 16 previous errors +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0658`.