Auto merge of #67721 - JohnTitor:rollup-o8zm4r9, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #64273 (Stabilize attribute macros on inline modules)
 - #67287 (typeck: note other end-point when checking range pats)
 - #67564 (docs: Iterator adapters have unspecified results after a panic)
 - #67622 (Some keyword documentation.)
 - #67657 (Clean up const-hack PRs now that const if / match exist.)
 - #67677 (resolve: Minor cleanup of duplicate macro reexports)
 - #67687 (Do not ICE on lifetime error involving closures)
 - #67698 (Move reachable_set and diagnostic_items to librustc_passes.)
 - #67701 (tidy: Enforce formatting rather than just check it if `--bless` is specified)
 - #67715 (Typo fix)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-12-30 05:12:48 +00:00
commit d297b19663
40 changed files with 340 additions and 269 deletions

View File

@ -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());
}
}

View File

@ -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

View File

@ -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)]

View File

@ -121,7 +121,7 @@ impl<T: ?Sized> ManuallyDrop<T> {
/// 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<T>`.
///
/// [`ManuallyDrop::into_inner`]: #method.into_inner

View File

@ -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,
}
}
}

View File

@ -288,10 +288,7 @@ pub fn wrapping_offset(self, count: isize) -> *const T
T: Sized,
{
let pointee_size = mem::size_of::<T>();
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)
}

View File

@ -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;

View File

@ -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<Symbol, Symbol>,
pub unstable: FxHashSet<Symbol>,
}
impl LibFeatures {
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
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;

View File

@ -510,7 +510,7 @@
}
Other {
query reachable_set(_: CrateNum) -> ReachableSet {
query reachable_set(_: CrateNum) -> Lrc<HirIdSet> {
desc { "reachability" }
}

View File

@ -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);

View File

@ -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;

View File

@ -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)
}

View File

@ -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);

View File

@ -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()
})
),
);

View File

@ -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<Symbol> {
}
/// Traverse and collect the diagnostic items in the current
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
// Initialize the collector.
let mut collector = DiagnosticItemCollector::new(tcx);
@ -104,7 +105,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
}
/// Traverse and collect all the diagnostic items in all crates.
pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
// Initialize the collector.
let mut collector = FxHashMap::default();
@ -117,3 +118,14 @@ pub fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
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)
};
}

View File

@ -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);
}

View File

@ -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<Symbol, Symbol>,
pub unstable: FxHashSet<Symbol>,
}
impl LibFeatures {
fn new() -> LibFeatures {
fn new_lib_features() -> LibFeatures {
LibFeatures { stable: Default::default(), unstable: Default::default() }
}
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
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 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<Symbol>, 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))
};
}

View File

@ -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<HirIdSet>);
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet {
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
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<'_>) {

View File

@ -528,33 +528,9 @@ 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);
}
}
}
} else {
resolution.binding = Some(binding);
}

View File

@ -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<Span>,
) -> Option<Ty<'tcx>> {
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));

View File

@ -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")]

View File

@ -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(..)

View File

@ -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

View File

@ -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}`

View File

@ -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}`

View File

@ -6,6 +6,7 @@ fn main() {
//~^ ERROR `..X` range patterns are not supported
//~| ERROR mismatched types
//~| ERROR mismatched types
//~| ERROR mismatched types
_ => {},
}
}

View File

@ -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`.

View File

@ -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() {}

View File

@ -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`.

View File

@ -0,0 +1,3 @@
fn main() {
[0].iter().flat_map(|a| [0].iter().map(|_| &a)); //~ ERROR `a` does not live long enough
}

View File

@ -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 <https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references>
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View File

@ -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

View File

@ -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`

View File

@ -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

View File

@ -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() {}

View File

@ -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

View File

@ -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;
}

View File

@ -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`.

View File

@ -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

View File

@ -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,8 +16,14 @@ 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
error: key-value macro attributes are not supported
--> $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]
| ^^^^^^^^^^^^^
@ -25,21 +31,6 @@ 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
|
LL | #[empty_attr = "y"]
| ^^^^^^^^^^^^^^^^^^^
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`.