Auto merge of #64883 - Centril:rollup-uehjt63, r=Centril
Rollup of 10 pull requests Successful merges: - #64131 (data_structures: Add deterministic FxHashMap and FxHashSet wrappers) - #64387 (Fix redundant semicolon lint interaction with proc macro attributes) - #64678 (added more context for duplicate lang item errors (fixes #60561)) - #64763 (Add E0734 and its long explanation) - #64793 (Fix format macro expansions spans to be macro-generated) - #64837 (Improve wording in documentation of MaybeUninit) - #64852 (Print ParamTy span when accessing a field (#52082)) - #64875 (Upgrade async/await to "used" keywords.) - #64876 (Fix typo in intrinsics op safety) - #64880 (Slice docs: fix typo) Failed merges: r? @ghost
This commit is contained in:
commit
b61e694339
54 changed files with 620 additions and 163 deletions
|
@ -5,12 +5,12 @@ use crate::mem::ManuallyDrop;
|
||||||
///
|
///
|
||||||
/// # Initialization invariant
|
/// # Initialization invariant
|
||||||
///
|
///
|
||||||
/// The compiler, in general, assumes that variables are properly initialized
|
/// The compiler, in general, assumes that a variable is properly initialized
|
||||||
/// at their respective type. For example, a variable of reference type must
|
/// according to the requirements of the variable's type. For example, a variable of
|
||||||
/// be aligned and non-NULL. This is an invariant that must *always* be upheld,
|
/// reference type must be aligned and non-NULL. This is an invariant that must
|
||||||
/// even in unsafe code. As a consequence, zero-initializing a variable of reference
|
/// *always* be upheld, even in unsafe code. As a consequence, zero-initializing a
|
||||||
/// type causes instantaneous [undefined behavior][ub], no matter whether that reference
|
/// variable of reference type causes instantaneous [undefined behavior][ub],
|
||||||
/// ever gets used to access memory:
|
/// no matter whether that reference ever gets used to access memory:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #![allow(invalid_value)]
|
/// # #![allow(invalid_value)]
|
||||||
|
|
|
@ -2217,6 +2217,23 @@ Examples of erroneous code:
|
||||||
static X: u32 = 42;
|
static X: u32 = 42;
|
||||||
```
|
```
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
|
E0734: r##"
|
||||||
|
A stability attribute has been used outside of the standard library.
|
||||||
|
|
||||||
|
Erroneous code examples:
|
||||||
|
|
||||||
|
```compile_fail,E0734
|
||||||
|
#[rustc_deprecated(since = "b", reason = "text")] // invalid
|
||||||
|
#[stable(feature = "a", since = "b")] // invalid
|
||||||
|
#[unstable(feature = "b", issue = "0")] // invalid
|
||||||
|
fn foo(){}
|
||||||
|
```
|
||||||
|
|
||||||
|
These attributes are meant to only be used by the standard library and are
|
||||||
|
rejected in your own crates.
|
||||||
|
"##,
|
||||||
|
|
||||||
;
|
;
|
||||||
// E0006, // merged with E0005
|
// E0006, // merged with E0005
|
||||||
// E0101, // replaced with E0282
|
// E0101, // replaced with E0282
|
||||||
|
|
|
@ -126,10 +126,17 @@ pub struct ExternCrate {
|
||||||
/// used to select the extern with the shortest path
|
/// used to select the extern with the shortest path
|
||||||
pub path_len: usize,
|
pub path_len: usize,
|
||||||
|
|
||||||
|
/// Crate that depends on this crate
|
||||||
|
pub dependency_of: CrateNum,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExternCrate {
|
||||||
/// If true, then this crate is the crate named by the extern
|
/// If true, then this crate is the crate named by the extern
|
||||||
/// crate referenced above. If false, then this crate is a dep
|
/// crate referenced above. If false, then this crate is a dep
|
||||||
/// of the crate.
|
/// of the crate.
|
||||||
pub direct: bool,
|
pub fn is_direct(&self) -> bool {
|
||||||
|
self.dependency_of == LOCAL_CRATE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, HashStable)]
|
#[derive(Copy, Clone, Debug, HashStable)]
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::hir::def_id::DefId;
|
||||||
use crate::hir::check_attr::Target;
|
use crate::hir::check_attr::Target;
|
||||||
use crate::ty::{self, TyCtxt};
|
use crate::ty::{self, TyCtxt};
|
||||||
use crate::middle::weak_lang_items;
|
use crate::middle::weak_lang_items;
|
||||||
|
use crate::middle::cstore::ExternCrate;
|
||||||
use crate::util::nodemap::FxHashMap;
|
use crate::util::nodemap::FxHashMap;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
@ -182,16 +183,39 @@ impl LanguageItemCollector<'tcx> {
|
||||||
E0152,
|
E0152,
|
||||||
"duplicate lang item found: `{}`.",
|
"duplicate lang item found: `{}`.",
|
||||||
name),
|
name),
|
||||||
None => self.tcx.sess.struct_err(&format!(
|
None => {
|
||||||
"duplicate lang item in crate `{}`: `{}`.",
|
match self.tcx.extern_crate(item_def_id) {
|
||||||
self.tcx.crate_name(item_def_id.krate),
|
Some(ExternCrate {dependency_of, ..}) => {
|
||||||
name)),
|
self.tcx.sess.struct_err(&format!(
|
||||||
|
"duplicate lang item in crate `{}` (which `{}` depends on): `{}`.",
|
||||||
|
self.tcx.crate_name(item_def_id.krate),
|
||||||
|
self.tcx.crate_name(*dependency_of),
|
||||||
|
name))
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
self.tcx.sess.struct_err(&format!(
|
||||||
|
"duplicate lang item in crate `{}`: `{}`.",
|
||||||
|
self.tcx.crate_name(item_def_id.krate),
|
||||||
|
name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
|
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
|
||||||
span_note!(&mut err, span, "first defined here.");
|
span_note!(&mut err, span, "first defined here.");
|
||||||
} else {
|
} else {
|
||||||
err.note(&format!("first defined in crate `{}`.",
|
match self.tcx.extern_crate(original_def_id) {
|
||||||
|
Some(ExternCrate {dependency_of, ..}) => {
|
||||||
|
err.note(&format!(
|
||||||
|
"first defined in crate `{}` (which `{}` depends on).",
|
||||||
|
self.tcx.crate_name(original_def_id.krate),
|
||||||
|
self.tcx.crate_name(*dependency_of)));
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
err.note(&format!("first defined in crate `{}`.",
|
||||||
self.tcx.crate_name(original_def_id.krate)));
|
self.tcx.crate_name(original_def_id.krate)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
||||||
let name = attr.name_or_empty();
|
let name = attr.name_or_empty();
|
||||||
if [sym::unstable, sym::stable, sym::rustc_deprecated].contains(&name) {
|
if [sym::unstable, sym::stable, sym::rustc_deprecated].contains(&name) {
|
||||||
attr::mark_used(attr);
|
attr::mark_used(attr);
|
||||||
self.tcx.sess.span_err(attr.span, "stability attributes may not be used \
|
struct_span_err!(
|
||||||
outside of the standard library");
|
self.tcx.sess,
|
||||||
|
attr.span,
|
||||||
|
E0734,
|
||||||
|
"stability attributes may not be used outside of the standard library",
|
||||||
|
).emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
match self.tcx().extern_crate(def_id) {
|
match self.tcx().extern_crate(def_id) {
|
||||||
Some(&ExternCrate {
|
Some(&ExternCrate {
|
||||||
src: ExternCrateSource::Extern(def_id),
|
src: ExternCrateSource::Extern(def_id),
|
||||||
direct: true,
|
dependency_of: LOCAL_CRATE,
|
||||||
span,
|
span,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
|
|
|
@ -73,6 +73,7 @@ pub mod box_region;
|
||||||
pub mod const_cstr;
|
pub mod const_cstr;
|
||||||
pub mod flock;
|
pub mod flock;
|
||||||
pub mod fx;
|
pub mod fx;
|
||||||
|
pub mod stable_map;
|
||||||
pub mod graph;
|
pub mod graph;
|
||||||
pub mod indexed_vec;
|
pub mod indexed_vec;
|
||||||
pub mod jobserver;
|
pub mod jobserver;
|
||||||
|
@ -84,6 +85,7 @@ pub mod small_c_str;
|
||||||
pub mod snapshot_map;
|
pub mod snapshot_map;
|
||||||
pub use ena::snapshot_vec;
|
pub use ena::snapshot_vec;
|
||||||
pub mod sorted_map;
|
pub mod sorted_map;
|
||||||
|
pub mod stable_set;
|
||||||
#[macro_use] pub mod stable_hasher;
|
#[macro_use] pub mod stable_hasher;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
pub mod sharded;
|
pub mod sharded;
|
||||||
|
|
99
src/librustc_data_structures/stable_map.rs
Normal file
99
src/librustc_data_structures/stable_map.rs
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
pub use rustc_hash::FxHashMap;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
use std::collections::hash_map::Entry;
|
||||||
|
use std::fmt;
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
/// A deterministic wrapper around FxHashMap that does not provide iteration support.
|
||||||
|
///
|
||||||
|
/// It supports insert, remove, get and get_mut functions from FxHashMap.
|
||||||
|
/// It also allows to convert hashmap to a sorted vector with the method `into_sorted_vector()`.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct StableMap<K, V> {
|
||||||
|
base: FxHashMap<K, V>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<K, V> Default for StableMap<K, V>
|
||||||
|
where
|
||||||
|
K: Eq + Hash,
|
||||||
|
{
|
||||||
|
fn default() -> StableMap<K, V> {
|
||||||
|
StableMap::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<K, V> fmt::Debug for StableMap<K, V>
|
||||||
|
where
|
||||||
|
K: Eq + Hash + fmt::Debug,
|
||||||
|
V: fmt::Debug,
|
||||||
|
{
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{:?}", self.base)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<K, V> PartialEq for StableMap<K, V>
|
||||||
|
where
|
||||||
|
K: Eq + Hash,
|
||||||
|
V: PartialEq,
|
||||||
|
{
|
||||||
|
fn eq(&self, other: &StableMap<K, V>) -> bool {
|
||||||
|
self.base == other.base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<K, V> Eq for StableMap<K, V>
|
||||||
|
where
|
||||||
|
K: Eq + Hash,
|
||||||
|
V: Eq,
|
||||||
|
{}
|
||||||
|
|
||||||
|
impl<K, V> StableMap<K, V>
|
||||||
|
where
|
||||||
|
K: Eq + Hash,
|
||||||
|
{
|
||||||
|
pub fn new() -> StableMap<K, V> {
|
||||||
|
StableMap { base: FxHashMap::default() }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_sorted_vector(self) -> Vec<(K, V)>
|
||||||
|
where
|
||||||
|
K: Ord + Copy,
|
||||||
|
{
|
||||||
|
let mut vector = self.base.into_iter().collect::<Vec<_>>();
|
||||||
|
vector.sort_unstable_by_key(|pair| pair.0);
|
||||||
|
vector
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn entry(&mut self, k: K) -> Entry<'_, K, V> {
|
||||||
|
self.base.entry(k)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
|
||||||
|
where
|
||||||
|
K: Borrow<Q>,
|
||||||
|
Q: Hash + Eq,
|
||||||
|
{
|
||||||
|
self.base.get(k)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
|
||||||
|
where
|
||||||
|
K: Borrow<Q>,
|
||||||
|
Q: Hash + Eq,
|
||||||
|
{
|
||||||
|
self.base.get_mut(k)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
|
||||||
|
self.base.insert(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
|
||||||
|
where
|
||||||
|
K: Borrow<Q>,
|
||||||
|
Q: Hash + Eq,
|
||||||
|
{
|
||||||
|
self.base.remove(k)
|
||||||
|
}
|
||||||
|
}
|
77
src/librustc_data_structures/stable_set.rs
Normal file
77
src/librustc_data_structures/stable_set.rs
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
pub use rustc_hash::FxHashSet;
|
||||||
|
use std::borrow::Borrow;
|
||||||
|
use std::fmt;
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
/// A deterministic wrapper around FxHashSet that does not provide iteration support.
|
||||||
|
///
|
||||||
|
/// It supports insert, remove, get functions from FxHashSet.
|
||||||
|
/// It also allows to convert hashset to a sorted vector with the method `into_sorted_vector()`.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct StableSet<T> {
|
||||||
|
base: FxHashSet<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Default for StableSet<T>
|
||||||
|
where
|
||||||
|
T: Eq + Hash,
|
||||||
|
{
|
||||||
|
fn default() -> StableSet<T> {
|
||||||
|
StableSet::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> fmt::Debug for StableSet<T>
|
||||||
|
where
|
||||||
|
T: Eq + Hash + fmt::Debug,
|
||||||
|
{
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{:?}", self.base)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> PartialEq<StableSet<T>> for StableSet<T>
|
||||||
|
where
|
||||||
|
T: Eq + Hash,
|
||||||
|
{
|
||||||
|
fn eq(&self, other: &StableSet<T>) -> bool {
|
||||||
|
self.base == other.base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Eq for StableSet<T> where T: Eq + Hash {}
|
||||||
|
|
||||||
|
impl<T: Hash + Eq> StableSet<T> {
|
||||||
|
pub fn new() -> StableSet<T> {
|
||||||
|
StableSet { base: FxHashSet::default() }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn into_sorted_vector(self) -> Vec<T>
|
||||||
|
where
|
||||||
|
T: Ord,
|
||||||
|
{
|
||||||
|
let mut vector = self.base.into_iter().collect::<Vec<_>>();
|
||||||
|
vector.sort_unstable();
|
||||||
|
vector
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
|
||||||
|
where
|
||||||
|
T: Borrow<Q>,
|
||||||
|
Q: Hash + Eq,
|
||||||
|
{
|
||||||
|
self.base.get(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert(&mut self, value: T) -> bool {
|
||||||
|
self.base.insert(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||||
|
where
|
||||||
|
T: Borrow<Q>,
|
||||||
|
Q: Hash + Eq,
|
||||||
|
{
|
||||||
|
self.base.remove(value)
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ use rustc::middle::cstore::{ExternCrate, ExternCrateSource};
|
||||||
use rustc::util::common::record_time;
|
use rustc::util::common::record_time;
|
||||||
use rustc::util::nodemap::FxHashSet;
|
use rustc::util::nodemap::FxHashSet;
|
||||||
use rustc::hir::map::Definitions;
|
use rustc::hir::map::Definitions;
|
||||||
|
use rustc::hir::def_id::LOCAL_CRATE;
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -430,7 +431,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
mut extern_crate: ExternCrate,
|
mut extern_crate: ExternCrate,
|
||||||
visited: &mut FxHashSet<(CrateNum, bool)>)
|
visited: &mut FxHashSet<(CrateNum, bool)>)
|
||||||
{
|
{
|
||||||
if !visited.insert((cnum, extern_crate.direct)) { return }
|
if !visited.insert((cnum, extern_crate.is_direct())) { return }
|
||||||
|
|
||||||
let cmeta = self.cstore.get_crate_data(cnum);
|
let cmeta = self.cstore.get_crate_data(cnum);
|
||||||
let mut old_extern_crate = cmeta.extern_crate.borrow_mut();
|
let mut old_extern_crate = cmeta.extern_crate.borrow_mut();
|
||||||
|
@ -441,14 +442,14 @@ impl<'a> CrateLoader<'a> {
|
||||||
// - shorter paths to longer (tuple.2).
|
// - shorter paths to longer (tuple.2).
|
||||||
let new_rank = (
|
let new_rank = (
|
||||||
true,
|
true,
|
||||||
extern_crate.direct,
|
extern_crate.is_direct(),
|
||||||
cmp::Reverse(extern_crate.path_len),
|
cmp::Reverse(extern_crate.path_len),
|
||||||
);
|
);
|
||||||
let old_rank = match *old_extern_crate {
|
let old_rank = match *old_extern_crate {
|
||||||
None => (false, false, cmp::Reverse(usize::max_value())),
|
None => (false, false, cmp::Reverse(usize::max_value())),
|
||||||
Some(ref c) => (
|
Some(ref c) => (
|
||||||
true,
|
true,
|
||||||
c.direct,
|
c.is_direct(),
|
||||||
cmp::Reverse(c.path_len),
|
cmp::Reverse(c.path_len),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
@ -460,7 +461,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
drop(old_extern_crate);
|
drop(old_extern_crate);
|
||||||
|
|
||||||
// Propagate the extern crate info to dependencies.
|
// Propagate the extern crate info to dependencies.
|
||||||
extern_crate.direct = false;
|
extern_crate.dependency_of = cnum;
|
||||||
for &dep_cnum in cmeta.dependencies.borrow().iter() {
|
for &dep_cnum in cmeta.dependencies.borrow().iter() {
|
||||||
self.update_extern_crate(dep_cnum, extern_crate, visited);
|
self.update_extern_crate(dep_cnum, extern_crate, visited);
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1031,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
src: ExternCrateSource::Extern(def_id),
|
src: ExternCrateSource::Extern(def_id),
|
||||||
span: item.span,
|
span: item.span,
|
||||||
path_len,
|
path_len,
|
||||||
direct: true,
|
dependency_of: LOCAL_CRATE,
|
||||||
},
|
},
|
||||||
&mut FxHashSet::default(),
|
&mut FxHashSet::default(),
|
||||||
);
|
);
|
||||||
|
@ -1057,7 +1058,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
span,
|
span,
|
||||||
// to have the least priority in `update_extern_crate`
|
// to have the least priority in `update_extern_crate`
|
||||||
path_len: usize::max_value(),
|
path_len: usize::max_value(),
|
||||||
direct: true,
|
dependency_of: LOCAL_CRATE,
|
||||||
},
|
},
|
||||||
&mut FxHashSet::default(),
|
&mut FxHashSet::default(),
|
||||||
);
|
);
|
||||||
|
@ -1081,7 +1082,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
span,
|
span,
|
||||||
// to have the least priority in `update_extern_crate`
|
// to have the least priority in `update_extern_crate`
|
||||||
path_len: usize::max_value(),
|
path_len: usize::max_value(),
|
||||||
direct: true,
|
dependency_of: LOCAL_CRATE,
|
||||||
},
|
},
|
||||||
&mut FxHashSet::default(),
|
&mut FxHashSet::default(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -233,7 +233,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
|
|
||||||
missing_extern_crate_item => {
|
missing_extern_crate_item => {
|
||||||
let r = match *cdata.extern_crate.borrow() {
|
let r = match *cdata.extern_crate.borrow() {
|
||||||
Some(extern_crate) if !extern_crate.direct => true,
|
Some(extern_crate) if !extern_crate.is_direct() => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
r
|
r
|
||||||
|
|
|
@ -1394,30 +1394,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
|
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
|
||||||
self.ban_take_value_of_method(expr, expr_t, field);
|
self.ban_take_value_of_method(expr, expr_t, field);
|
||||||
} else if !expr_t.is_primitive_ty() {
|
} else if !expr_t.is_primitive_ty() {
|
||||||
let mut err = self.no_such_field_err(field.span, field, expr_t);
|
self.ban_nonexisting_field(field, base, expr, expr_t);
|
||||||
|
|
||||||
match expr_t.kind {
|
|
||||||
ty::Adt(def, _) if !def.is_enum() => {
|
|
||||||
self.suggest_fields_on_recordish(&mut err, def, field);
|
|
||||||
}
|
|
||||||
ty::Array(_, len) => {
|
|
||||||
self.maybe_suggest_array_indexing(&mut err, expr, base, field, len);
|
|
||||||
}
|
|
||||||
ty::RawPtr(..) => {
|
|
||||||
self.suggest_first_deref_field(&mut err, expr, base, field);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if field.name == kw::Await {
|
|
||||||
// We know by construction that `<expr>.await` is either on Rust 2015
|
|
||||||
// or results in `ExprKind::Await`. Suggest switching the edition to 2018.
|
|
||||||
err.note("to `.await` a `Future`, switch to Rust 2018");
|
|
||||||
err.help("set `edition = \"2018\"` in `Cargo.toml`");
|
|
||||||
err.note("for more on editions, read https://doc.rust-lang.org/edition-guide");
|
|
||||||
}
|
|
||||||
|
|
||||||
err.emit();
|
|
||||||
} else {
|
} else {
|
||||||
type_error_struct!(
|
type_error_struct!(
|
||||||
self.tcx().sess,
|
self.tcx().sess,
|
||||||
|
@ -1433,6 +1410,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.tcx().types.err
|
self.tcx().types.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ban_nonexisting_field(
|
||||||
|
&self,
|
||||||
|
field: ast::Ident,
|
||||||
|
base: &'tcx hir::Expr,
|
||||||
|
expr: &'tcx hir::Expr,
|
||||||
|
expr_t: Ty<'tcx>,
|
||||||
|
) {
|
||||||
|
let mut err = self.no_such_field_err(field.span, field, expr_t);
|
||||||
|
|
||||||
|
match expr_t.peel_refs().kind {
|
||||||
|
ty::Array(_, len) => {
|
||||||
|
self.maybe_suggest_array_indexing(&mut err, expr, base, field, len);
|
||||||
|
}
|
||||||
|
ty::RawPtr(..) => {
|
||||||
|
self.suggest_first_deref_field(&mut err, expr, base, field);
|
||||||
|
}
|
||||||
|
ty::Adt(def, _) if !def.is_enum() => {
|
||||||
|
self.suggest_fields_on_recordish(&mut err, def, field);
|
||||||
|
}
|
||||||
|
ty::Param(param_ty) => {
|
||||||
|
self.point_at_param_definition(&mut err, param_ty);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if field.name == kw::Await {
|
||||||
|
// We know by construction that `<expr>.await` is either on Rust 2015
|
||||||
|
// or results in `ExprKind::Await`. Suggest switching the edition to 2018.
|
||||||
|
err.note("to `.await` a `Future`, switch to Rust 2018");
|
||||||
|
err.help("set `edition = \"2018\"` in `Cargo.toml`");
|
||||||
|
err.note("for more on editions, read https://doc.rust-lang.org/edition-guide");
|
||||||
|
}
|
||||||
|
|
||||||
|
err.emit();
|
||||||
|
}
|
||||||
|
|
||||||
fn ban_private_field_access(
|
fn ban_private_field_access(
|
||||||
&self,
|
&self,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
|
@ -1495,6 +1508,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn point_at_param_definition(&self, err: &mut DiagnosticBuilder<'_>, param: ty::ParamTy) {
|
||||||
|
let generics = self.tcx.generics_of(self.body_id.owner_def_id());
|
||||||
|
let generic_param = generics.type_param(¶m, self.tcx);
|
||||||
|
if let ty::GenericParamDefKind::Type{synthetic: Some(..), ..} = generic_param.kind {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let param_def_id = generic_param.def_id;
|
||||||
|
let param_hir_id = match self.tcx.hir().as_local_hir_id(param_def_id) {
|
||||||
|
Some(x) => x,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
let param_span = self.tcx.hir().span(param_hir_id);
|
||||||
|
let param_name = self.tcx.hir().ty_param_name(param_hir_id);
|
||||||
|
|
||||||
|
err.span_label(param_span, &format!("type parameter '{}' declared here", param_name));
|
||||||
|
}
|
||||||
|
|
||||||
fn suggest_fields_on_recordish(
|
fn suggest_fields_on_recordish(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
|
|
|
@ -63,7 +63,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the given intrinsic is unsafe to call or not.
|
/// Returns `true` if the given intrinsic is unsafe to call or not.
|
||||||
pub fn intrisic_operation_unsafety(intrinsic: &str) -> hir::Unsafety {
|
pub fn intrinsic_operation_unsafety(intrinsic: &str) -> hir::Unsafety {
|
||||||
match intrinsic {
|
match intrinsic {
|
||||||
"size_of" | "min_align_of" | "needs_drop" |
|
"size_of" | "min_align_of" | "needs_drop" |
|
||||||
"add_with_overflow" | "sub_with_overflow" | "mul_with_overflow" |
|
"add_with_overflow" | "sub_with_overflow" | "mul_with_overflow" |
|
||||||
|
@ -130,7 +130,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
||||||
} else if &name[..] == "abort" || &name[..] == "unreachable" {
|
} else if &name[..] == "abort" || &name[..] == "unreachable" {
|
||||||
(0, Vec::new(), tcx.types.never, hir::Unsafety::Unsafe)
|
(0, Vec::new(), tcx.types.never, hir::Unsafety::Unsafe)
|
||||||
} else {
|
} else {
|
||||||
let unsafety = intrisic_operation_unsafety(&name[..]);
|
let unsafety = intrinsic_operation_unsafety(&name[..]);
|
||||||
let (n_tps, inputs, output) = match &name[..] {
|
let (n_tps, inputs, output) = match &name[..] {
|
||||||
"breakpoint" => (0, Vec::new(), tcx.mk_unit()),
|
"breakpoint" => (0, Vec::new(), tcx.mk_unit()),
|
||||||
"size_of" |
|
"size_of" |
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
use crate::astconv::{AstConv, Bounds, SizedByDefault};
|
use crate::astconv::{AstConv, Bounds, SizedByDefault};
|
||||||
use crate::constrained_generic_params as cgp;
|
use crate::constrained_generic_params as cgp;
|
||||||
use crate::check::intrinsic::intrisic_operation_unsafety;
|
use crate::check::intrinsic::intrinsic_operation_unsafety;
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
use crate::middle::resolve_lifetime as rl;
|
use crate::middle::resolve_lifetime as rl;
|
||||||
use crate::middle::weak_lang_items;
|
use crate::middle::weak_lang_items;
|
||||||
|
@ -2366,7 +2366,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||||
abi: abi::Abi,
|
abi: abi::Abi,
|
||||||
) -> ty::PolyFnSig<'tcx> {
|
) -> ty::PolyFnSig<'tcx> {
|
||||||
let unsafety = if abi == abi::Abi::RustIntrinsic {
|
let unsafety = if abi == abi::Abi::RustIntrinsic {
|
||||||
intrisic_operation_unsafety(&*tcx.item_name(def_id).as_str())
|
intrinsic_operation_unsafety(&*tcx.item_name(def_id).as_str())
|
||||||
} else {
|
} else {
|
||||||
hir::Unsafety::Unsafe
|
hir::Unsafety::Unsafe
|
||||||
};
|
};
|
||||||
|
|
|
@ -567,7 +567,7 @@ mod prim_array { }
|
||||||
#[doc(alias = "]")]
|
#[doc(alias = "]")]
|
||||||
#[doc(alias = "[]")]
|
#[doc(alias = "[]")]
|
||||||
/// A dynamically-sized view into a contiguous sequence, `[T]`. Contiguous here
|
/// A dynamically-sized view into a contiguous sequence, `[T]`. Contiguous here
|
||||||
/// means that elements are layed out so that every element is the same
|
/// means that elements are laid out so that every element is the same
|
||||||
/// distance from its neighbors.
|
/// distance from its neighbors.
|
||||||
///
|
///
|
||||||
/// *[See also the `std::slice` module](slice/index.html).*
|
/// *[See also the `std::slice` module](slice/index.html).*
|
||||||
|
|
|
@ -1657,9 +1657,18 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::StmtKind::Semi(ref expr) => {
|
ast::StmtKind::Semi(ref expr) => {
|
||||||
self.space_if_not_bol();
|
match expr.kind {
|
||||||
self.print_expr_outer_attr_style(expr, false);
|
// Filter out empty `Tup` exprs created for the `redundant_semicolon`
|
||||||
self.s.word(";");
|
// lint, as they shouldn't be visible and interact poorly
|
||||||
|
// with proc macros.
|
||||||
|
ast::ExprKind::Tup(ref exprs) if exprs.is_empty()
|
||||||
|
&& expr.attrs.is_empty() => (),
|
||||||
|
_ => {
|
||||||
|
self.space_if_not_bol();
|
||||||
|
self.print_expr_outer_attr_style(expr, false);
|
||||||
|
self.s.word(";");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast::StmtKind::Mac(ref mac) => {
|
ast::StmtKind::Mac(ref mac) => {
|
||||||
let (ref mac, style, ref attrs) = **mac;
|
let (ref mac, style, ref attrs) = **mac;
|
||||||
|
|
|
@ -695,7 +695,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
// Now create a vector containing all the arguments
|
// Now create a vector containing all the arguments
|
||||||
let args = locals.into_iter().chain(counts.into_iter());
|
let args = locals.into_iter().chain(counts.into_iter());
|
||||||
|
|
||||||
let args_array = self.ecx.expr_vec(self.fmtsp, args.collect());
|
let args_array = self.ecx.expr_vec(self.macsp, args.collect());
|
||||||
|
|
||||||
// Constructs an AST equivalent to:
|
// Constructs an AST equivalent to:
|
||||||
//
|
//
|
||||||
|
@ -724,12 +724,12 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
//
|
//
|
||||||
// But the nested match expression is proved to perform not as well
|
// But the nested match expression is proved to perform not as well
|
||||||
// as series of let's; the first approach does.
|
// as series of let's; the first approach does.
|
||||||
let pat = self.ecx.pat_tuple(self.fmtsp, pats);
|
let pat = self.ecx.pat_tuple(self.macsp, pats);
|
||||||
let arm = self.ecx.arm(self.fmtsp, pat, args_array);
|
let arm = self.ecx.arm(self.macsp, pat, args_array);
|
||||||
let head = self.ecx.expr(self.fmtsp, ast::ExprKind::Tup(heads));
|
let head = self.ecx.expr(self.macsp, ast::ExprKind::Tup(heads));
|
||||||
let result = self.ecx.expr_match(self.fmtsp, head, vec![arm]);
|
let result = self.ecx.expr_match(self.macsp, head, vec![arm]);
|
||||||
|
|
||||||
let args_slice = self.ecx.expr_addr_of(self.fmtsp, result);
|
let args_slice = self.ecx.expr_addr_of(self.macsp, result);
|
||||||
|
|
||||||
// Now create the fmt::Arguments struct with all our locals we created.
|
// Now create the fmt::Arguments struct with all our locals we created.
|
||||||
let (fn_name, fn_args) = if self.all_pieces_simple {
|
let (fn_name, fn_args) = if self.all_pieces_simple {
|
||||||
|
|
|
@ -83,11 +83,11 @@ symbols! {
|
||||||
Yield: "yield",
|
Yield: "yield",
|
||||||
|
|
||||||
// Edition-specific keywords that are used in stable Rust.
|
// Edition-specific keywords that are used in stable Rust.
|
||||||
|
Async: "async", // >= 2018 Edition only
|
||||||
|
Await: "await", // >= 2018 Edition only
|
||||||
Dyn: "dyn", // >= 2018 Edition only
|
Dyn: "dyn", // >= 2018 Edition only
|
||||||
|
|
||||||
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
|
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
|
||||||
Async: "async", // >= 2018 Edition only
|
|
||||||
Await: "await", // >= 2018 Edition only
|
|
||||||
Try: "try", // >= 2018 Edition only
|
Try: "try", // >= 2018 Edition only
|
||||||
|
|
||||||
// Special lifetime names
|
// Special lifetime names
|
||||||
|
@ -1088,11 +1088,11 @@ pub mod sym {
|
||||||
|
|
||||||
impl Symbol {
|
impl Symbol {
|
||||||
fn is_used_keyword_2018(self) -> bool {
|
fn is_used_keyword_2018(self) -> bool {
|
||||||
self == kw::Dyn
|
self >= kw::Async && self <= kw::Dyn
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_unused_keyword_2018(self) -> bool {
|
fn is_unused_keyword_2018(self) -> bool {
|
||||||
self >= kw::Async && self <= kw::Try
|
self == kw::Try
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used for sanity checking rustdoc keyword sections.
|
/// Used for sanity checking rustdoc keyword sections.
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
mod outer_mod {
|
mod outer_mod {
|
||||||
pub mod await { //~ ERROR expected identifier, found reserved keyword `await`
|
pub mod await { //~ ERROR expected identifier, found keyword `await`
|
||||||
pub struct await; //~ ERROR expected identifier, found reserved keyword `await`
|
pub struct await; //~ ERROR expected identifier, found keyword `await`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use self::outer_mod::await::await; //~ ERROR expected identifier, found reserved keyword `await`
|
use self::outer_mod::await::await; //~ ERROR expected identifier, found keyword `await`
|
||||||
//~^ ERROR expected identifier, found reserved keyword `await`
|
//~^ ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
struct Foo { await: () }
|
struct Foo { await: () }
|
||||||
//~^ ERROR expected identifier, found reserved keyword `await`
|
//~^ ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
impl Foo { fn await() {} }
|
impl Foo { fn await() {} }
|
||||||
//~^ ERROR expected identifier, found reserved keyword `await`
|
//~^ ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
macro_rules! await {
|
macro_rules! await {
|
||||||
//~^ ERROR expected identifier, found reserved keyword `await`
|
//~^ ERROR expected identifier, found keyword `await`
|
||||||
() => {}
|
() => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:6:13
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:6:13
|
||||||
|
|
|
|
||||||
LL | pub mod await {
|
LL | pub mod await {
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | pub mod r#await {
|
LL | pub mod r#await {
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:7:20
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:7:20
|
||||||
|
|
|
|
||||||
LL | pub struct await;
|
LL | pub struct await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | pub struct r#await;
|
LL | pub struct r#await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:22
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:22
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::await;
|
LL | use self::outer_mod::await::await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::r#await::await;
|
LL | use self::outer_mod::r#await::await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:29
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:10:29
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::await;
|
LL | use self::outer_mod::await::await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::r#await;
|
LL | use self::outer_mod::await::r#await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:13:14
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:13:14
|
||||||
|
|
|
|
||||||
LL | struct Foo { await: () }
|
LL | struct Foo { await: () }
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | struct Foo { r#await: () }
|
LL | struct Foo { r#await: () }
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:16:15
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:16:15
|
||||||
|
|
|
|
||||||
LL | impl Foo { fn await() {} }
|
LL | impl Foo { fn await() {} }
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | impl Foo { fn r#await() {} }
|
LL | impl Foo { fn r#await() {} }
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error-in-non-macro-position.rs:19:14
|
--> $DIR/2018-edition-error-in-non-macro-position.rs:19:14
|
||||||
|
|
|
|
||||||
LL | macro_rules! await {
|
LL | macro_rules! await {
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | macro_rules! r#await {
|
LL | macro_rules! r#await {
|
||||||
|
|
|
@ -7,9 +7,9 @@ mod outer_mod {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use self::outer_mod::await::await; //~ ERROR expected identifier
|
use self::outer_mod::await::await; //~ ERROR expected identifier
|
||||||
//~^ ERROR expected identifier, found reserved keyword `await`
|
//~^ ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
macro_rules! await { () => {}; } //~ ERROR expected identifier, found reserved keyword `await`
|
macro_rules! await { () => {}; } //~ ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
await!(); //~ ERROR expected expression, found `)`
|
await!(); //~ ERROR expected expression, found `)`
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error.rs:5:13
|
--> $DIR/2018-edition-error.rs:5:13
|
||||||
|
|
|
|
||||||
LL | pub mod await {
|
LL | pub mod await {
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | pub mod r#await {
|
LL | pub mod r#await {
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error.rs:6:20
|
--> $DIR/2018-edition-error.rs:6:20
|
||||||
|
|
|
|
||||||
LL | pub struct await;
|
LL | pub struct await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | pub struct r#await;
|
LL | pub struct r#await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error.rs:9:22
|
--> $DIR/2018-edition-error.rs:9:22
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::await;
|
LL | use self::outer_mod::await::await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::r#await::await;
|
LL | use self::outer_mod::r#await::await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error.rs:9:29
|
--> $DIR/2018-edition-error.rs:9:29
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::await;
|
LL | use self::outer_mod::await::await;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | use self::outer_mod::await::r#await;
|
LL | use self::outer_mod::await::r#await;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/2018-edition-error.rs:12:14
|
--> $DIR/2018-edition-error.rs:12:14
|
||||||
|
|
|
|
||||||
LL | macro_rules! await { () => {}; }
|
LL | macro_rules! await { () => {}; }
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | macro_rules! r#await { () => {}; }
|
LL | macro_rules! r#await { () => {}; }
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
// compile-flags: --crate-type lib
|
// compile-flags: --crate-type lib
|
||||||
|
|
||||||
pub const async fn x() {}
|
pub const async fn x() {}
|
||||||
//~^ ERROR expected identifier, found reserved keyword `async`
|
//~^ ERROR expected identifier, found keyword `async`
|
||||||
//~^^ expected `:`, found keyword `fn`
|
//~^^ expected `:`, found keyword `fn`
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/no-const-async.rs:5:11
|
--> $DIR/no-const-async.rs:5:11
|
||||||
|
|
|
|
||||||
LL | pub const async fn x() {}
|
LL | pub const async fn x() {}
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | pub const r#async fn x() {}
|
LL | pub const r#async fn x() {}
|
||||||
|
|
|
@ -2,7 +2,7 @@ error[E0609]: no field `c` on type `&Foo`
|
||||||
--> $DIR/issue-30580.rs:12:11
|
--> $DIR/issue-30580.rs:12:11
|
||||||
|
|
|
|
||||||
LL | b.c;
|
LL | b.c;
|
||||||
| ^
|
| ^ help: a field with a similar name exists: `a`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | | loop {}
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
|
|
||||||
= note: first defined in crate `std`.
|
= note: first defined in crate `std` (which `duplicate_entry_error` depends on).
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern crate edition_kw_macro_2018;
|
extern crate edition_kw_macro_2018;
|
||||||
|
|
||||||
mod one_async {
|
mod one_async {
|
||||||
produces_async! {} //~ ERROR expected identifier, found reserved keyword
|
produces_async! {} //~ ERROR expected identifier, found keyword
|
||||||
}
|
}
|
||||||
mod two_async {
|
mod two_async {
|
||||||
produces_async_raw! {} // OK
|
produces_async_raw! {} // OK
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2015-2018-expansion.rs:8:5
|
--> $DIR/edition-keywords-2015-2018-expansion.rs:8:5
|
||||||
|
|
|
|
||||||
LL | produces_async! {}
|
LL | produces_async! {}
|
||||||
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
| ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
|
||||||
|
|
|
|
||||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern crate edition_kw_macro_2015;
|
extern crate edition_kw_macro_2015;
|
||||||
|
|
||||||
pub fn check_async() {
|
pub fn check_async() {
|
||||||
let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async`
|
let mut async = 1; //~ ERROR expected identifier, found keyword `async`
|
||||||
let mut r#async = 1; // OK
|
let mut r#async = 1; // OK
|
||||||
|
|
||||||
r#async = consumes_async!(async); // OK
|
r#async = consumes_async!(async); // OK
|
||||||
|
@ -15,6 +15,6 @@ pub fn check_async() {
|
||||||
|
|
||||||
if passes_ident!(async) == 1 {}
|
if passes_ident!(async) == 1 {}
|
||||||
if passes_ident!(r#async) == 1 {} // OK
|
if passes_ident!(r#async) == 1 {} // OK
|
||||||
module::async(); //~ ERROR expected identifier, found reserved keyword `async`
|
module::async(); //~ ERROR expected identifier, found keyword `async`
|
||||||
module::r#async(); // OK
|
module::r#async(); // OK
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:8:13
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:8:13
|
||||||
|
|
|
|
||||||
LL | let mut async = 1;
|
LL | let mut async = 1;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | let mut r#async = 1;
|
LL | let mut r#async = 1;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2015-parsing.rs:18:13
|
--> $DIR/edition-keywords-2018-2015-parsing.rs:18:13
|
||||||
|
|
|
|
||||||
LL | module::async();
|
LL | module::async();
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | module::r#async();
|
LL | module::r#async();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern crate edition_kw_macro_2018;
|
extern crate edition_kw_macro_2018;
|
||||||
|
|
||||||
mod one_async {
|
mod one_async {
|
||||||
produces_async! {} //~ ERROR expected identifier, found reserved keyword `async`
|
produces_async! {} //~ ERROR expected identifier, found keyword `async`
|
||||||
}
|
}
|
||||||
mod two_async {
|
mod two_async {
|
||||||
produces_async_raw! {} // OK
|
produces_async_raw! {} // OK
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-expansion.rs:8:5
|
--> $DIR/edition-keywords-2018-2018-expansion.rs:8:5
|
||||||
|
|
|
|
||||||
LL | produces_async! {}
|
LL | produces_async! {}
|
||||||
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
| ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
|
||||||
|
|
|
|
||||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern crate edition_kw_macro_2018;
|
extern crate edition_kw_macro_2018;
|
||||||
|
|
||||||
pub fn check_async() {
|
pub fn check_async() {
|
||||||
let mut async = 1; //~ ERROR expected identifier, found reserved keyword `async`
|
let mut async = 1; //~ ERROR expected identifier, found keyword `async`
|
||||||
let mut r#async = 1; // OK
|
let mut r#async = 1; // OK
|
||||||
|
|
||||||
r#async = consumes_async!(async); // OK
|
r#async = consumes_async!(async); // OK
|
||||||
|
@ -15,6 +15,6 @@ pub fn check_async() {
|
||||||
|
|
||||||
if passes_ident!(async) == 1 {}
|
if passes_ident!(async) == 1 {}
|
||||||
if passes_ident!(r#async) == 1 {} // OK
|
if passes_ident!(r#async) == 1 {} // OK
|
||||||
module::async(); //~ ERROR expected identifier, found reserved keyword `async`
|
module::async(); //~ ERROR expected identifier, found keyword `async`
|
||||||
module::r#async(); // OK
|
module::r#async(); // OK
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:8:13
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:8:13
|
||||||
|
|
|
|
||||||
LL | let mut async = 1;
|
LL | let mut async = 1;
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | let mut r#async = 1;
|
LL | let mut r#async = 1;
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `async`
|
error: expected identifier, found keyword `async`
|
||||||
--> $DIR/edition-keywords-2018-2018-parsing.rs:18:13
|
--> $DIR/edition-keywords-2018-2018-parsing.rs:18:13
|
||||||
|
|
|
|
||||||
LL | module::async();
|
LL | module::async();
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | module::r#async();
|
LL | module::r#async();
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0152]: duplicate lang item found: `arc`.
|
||||||
LL | struct Foo;
|
LL | struct Foo;
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: first defined in crate `alloc`.
|
= note: first defined in crate `alloc` (which `std` depends on).
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #![rustc_deprecated()]
|
LL | #![rustc_deprecated()]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:10:1
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:10:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()]
|
LL | #[rustc_deprecated()]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:13:17
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:13:17
|
||||||
|
|
|
|
||||||
LL | mod inner { #![rustc_deprecated()] }
|
LL | mod inner { #![rustc_deprecated()] }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:5
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()] fn f() { }
|
LL | #[rustc_deprecated()] fn f() { }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:19:5
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:19:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()] struct S;
|
LL | #[rustc_deprecated()] struct S;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:22:5
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:22:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()] type T = S;
|
LL | #[rustc_deprecated()] type T = S;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:25:5
|
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:25:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()] impl S { }
|
LL | #[rustc_deprecated()] impl S { }
|
||||||
|
@ -42,3 +42,4 @@ LL | #[rustc_deprecated()] impl S { }
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #![stable()]
|
LL | #![stable()]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
||||||
|
|
|
|
||||||
LL | #[stable()]
|
LL | #[stable()]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:13:17
|
--> $DIR/issue-43106-gating-of-stable.rs:13:17
|
||||||
|
|
|
|
||||||
LL | mod inner { #![stable()] }
|
LL | mod inner { #![stable()] }
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:16:5
|
--> $DIR/issue-43106-gating-of-stable.rs:16:5
|
||||||
|
|
|
|
||||||
LL | #[stable()] fn f() { }
|
LL | #[stable()] fn f() { }
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:19:5
|
--> $DIR/issue-43106-gating-of-stable.rs:19:5
|
||||||
|
|
|
|
||||||
LL | #[stable()] struct S;
|
LL | #[stable()] struct S;
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:22:5
|
--> $DIR/issue-43106-gating-of-stable.rs:22:5
|
||||||
|
|
|
|
||||||
LL | #[stable()] type T = S;
|
LL | #[stable()] type T = S;
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:25:5
|
--> $DIR/issue-43106-gating-of-stable.rs:25:5
|
||||||
|
|
|
|
||||||
LL | #[stable()] impl S { }
|
LL | #[stable()] impl S { }
|
||||||
|
@ -42,3 +42,4 @@ LL | #[stable()] impl S { }
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #![unstable()]
|
LL | #![unstable()]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
||||||
|
|
|
|
||||||
LL | #[unstable()]
|
LL | #[unstable()]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:13:17
|
--> $DIR/issue-43106-gating-of-unstable.rs:13:17
|
||||||
|
|
|
|
||||||
LL | mod inner { #![unstable()] }
|
LL | mod inner { #![unstable()] }
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:16:5
|
--> $DIR/issue-43106-gating-of-unstable.rs:16:5
|
||||||
|
|
|
|
||||||
LL | #[unstable()] fn f() { }
|
LL | #[unstable()] fn f() { }
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:19:5
|
--> $DIR/issue-43106-gating-of-unstable.rs:19:5
|
||||||
|
|
|
|
||||||
LL | #[unstable()] struct S;
|
LL | #[unstable()] struct S;
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:22:5
|
--> $DIR/issue-43106-gating-of-unstable.rs:22:5
|
||||||
|
|
|
|
||||||
LL | #[unstable()] type T = S;
|
LL | #[unstable()] type T = S;
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:25:5
|
--> $DIR/issue-43106-gating-of-unstable.rs:25:5
|
||||||
|
|
|
|
||||||
LL | #[unstable()] impl S { }
|
LL | #[unstable()] impl S { }
|
||||||
|
@ -42,3 +42,4 @@ LL | #[unstable()] impl S { }
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/feature-gate-staged_api.rs:1:1
|
--> $DIR/feature-gate-staged_api.rs:1:1
|
||||||
|
|
|
|
||||||
LL | #![stable(feature = "a", since = "b")]
|
LL | #![stable(feature = "a", since = "b")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/feature-gate-staged_api.rs:8:1
|
--> $DIR/feature-gate-staged_api.rs:8:1
|
||||||
|
|
|
|
||||||
LL | #[stable(feature = "a", since = "b")]
|
LL | #[stable(feature = "a", since = "b")]
|
||||||
|
@ -12,3 +12,4 @@ LL | #[stable(feature = "a", since = "b")]
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -15,5 +15,5 @@ impl ::std::fmt::Write for Stream {
|
||||||
fn main() {
|
fn main() {
|
||||||
write(|| format_args!("{}", String::from("Hello world")));
|
write(|| format_args!("{}", String::from("Hello world")));
|
||||||
//~^ ERROR cannot return value referencing temporary value
|
//~^ ERROR cannot return value referencing temporary value
|
||||||
//~| ERROR cannot return value referencing temporary value
|
//~| ERROR cannot return reference to temporary value
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,11 @@ LL | write(|| format_args!("{}", String::from("Hello world")));
|
||||||
| | temporary value created here
|
| | temporary value created here
|
||||||
| returns a value referencing data owned by the current function
|
| returns a value referencing data owned by the current function
|
||||||
|
|
||||||
error[E0515]: cannot return value referencing temporary value
|
error[E0515]: cannot return reference to temporary value
|
||||||
--> $DIR/issue-27592.rs:16:14
|
--> $DIR/issue-27592.rs:16:14
|
||||||
|
|
|
|
||||||
LL | write(|| format_args!("{}", String::from("Hello world")));
|
LL | write(|| format_args!("{}", String::from("Hello world")));
|
||||||
| ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a reference to data owned by the current function
|
||||||
| | |
|
|
||||||
| | temporary value created here
|
|
||||||
| returns a value referencing data owned by the current function
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ error[E0609]: no field `trace` on type `&T`
|
||||||
LL | if $ctx.trace {
|
LL | if $ctx.trace {
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
...
|
...
|
||||||
|
LL | fn wrap<T>(context: &T) -> ()
|
||||||
|
| - type parameter 'T' declared here
|
||||||
|
LL | {
|
||||||
LL | log!(context, "entered wrapper");
|
LL | log!(context, "entered wrapper");
|
||||||
| --------------------------------- in this macro invocation
|
| --------------------------------- in this macro invocation
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
// force-host
|
||||||
|
// no-prefer-dynamic
|
||||||
|
#![crate_type="proc-macro"]
|
||||||
|
#![crate_name="redundant_semi_proc_macro"]
|
||||||
|
extern crate proc_macro;
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn should_preserve_spans(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
|
eprintln!("{:?}", item);
|
||||||
|
item
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
// aux-build:redundant-semi-proc-macro-def.rs
|
||||||
|
|
||||||
|
#![deny(redundant_semicolon)]
|
||||||
|
extern crate redundant_semi_proc_macro;
|
||||||
|
use redundant_semi_proc_macro::should_preserve_spans;
|
||||||
|
|
||||||
|
#[should_preserve_spans]
|
||||||
|
fn span_preservation() {
|
||||||
|
let tst = 123;; //~ ERROR unnecessary trailing semicolon
|
||||||
|
match tst {
|
||||||
|
// Redundant semicolons are parsed as empty tuple exprs
|
||||||
|
// for the lint, so ensure the lint doesn't affect
|
||||||
|
// empty tuple exprs explicitly in source.
|
||||||
|
123 => (),
|
||||||
|
_ => ()
|
||||||
|
};;; //~ ERROR unnecessary trailing semicolons
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,21 @@
|
||||||
|
TokenStream [Ident { ident: "fn", span: #0 bytes(197..199) }, Ident { ident: "span_preservation", span: #0 bytes(200..217) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: #0 bytes(217..219) }, Group { delimiter: Brace, stream: TokenStream [Ident { ident: "let", span: #0 bytes(227..230) }, Ident { ident: "tst", span: #0 bytes(231..234) }, Punct { ch: '=', spacing: Alone, span: #0 bytes(235..236) }, Literal { lit: Lit { kind: Integer, symbol: 123, suffix: None }, span: Span { lo: BytePos(237), hi: BytePos(240), ctxt: #0 } }, Punct { ch: ';', spacing: Joint, span: #0 bytes(240..241) }, Punct { ch: ';', spacing: Alone, span: #0 bytes(241..242) }, Ident { ident: "match", span: #0 bytes(288..293) }, Ident { ident: "tst", span: #0 bytes(294..297) }, Group { delimiter: Brace, stream: TokenStream [Literal { lit: Lit { kind: Integer, symbol: 123, suffix: None }, span: Span { lo: BytePos(482), hi: BytePos(485), ctxt: #0 } }, Punct { ch: '=', spacing: Joint, span: #0 bytes(486..488) }, Punct { ch: '>', spacing: Alone, span: #0 bytes(486..488) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: #0 bytes(489..491) }, Punct { ch: ',', spacing: Alone, span: #0 bytes(491..492) }, Ident { ident: "_", span: #0 bytes(501..502) }, Punct { ch: '=', spacing: Joint, span: #0 bytes(503..505) }, Punct { ch: '>', spacing: Alone, span: #0 bytes(503..505) }, Group { delimiter: Parenthesis, stream: TokenStream [], span: #0 bytes(506..508) }], span: #0 bytes(298..514) }, Punct { ch: ';', spacing: Joint, span: #0 bytes(514..515) }, Punct { ch: ';', spacing: Joint, span: #0 bytes(515..516) }, Punct { ch: ';', spacing: Alone, span: #0 bytes(516..517) }], span: #0 bytes(221..561) }]
|
||||||
|
error: unnecessary trailing semicolon
|
||||||
|
--> $DIR/redundant-semi-proc-macro.rs:9:19
|
||||||
|
|
|
||||||
|
LL | let tst = 123;;
|
||||||
|
| ^ help: remove this semicolon
|
||||||
|
|
|
||||||
|
note: lint level defined here
|
||||||
|
--> $DIR/redundant-semi-proc-macro.rs:3:9
|
||||||
|
|
|
||||||
|
LL | #![deny(redundant_semicolon)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: unnecessary trailing semicolons
|
||||||
|
--> $DIR/redundant-semi-proc-macro.rs:16:7
|
||||||
|
|
|
||||||
|
LL | };;;
|
||||||
|
| ^^ help: remove these semicolons
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | | loop {}
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
|
|
||||||
= note: first defined in crate `std`.
|
= note: first defined in crate `std` (which `panic_handler_std` depends on).
|
||||||
|
|
||||||
error: argument should be `&PanicInfo`
|
error: argument should be `&PanicInfo`
|
||||||
--> $DIR/panic-handler-std.rs:7:16
|
--> $DIR/panic-handler-std.rs:7:16
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub fn main() {
|
||||||
//~| ERROR `mut` must be attached to each individual binding
|
//~| ERROR `mut` must be attached to each individual binding
|
||||||
//~| ERROR expected identifier, found reserved keyword `yield`
|
//~| ERROR expected identifier, found reserved keyword `yield`
|
||||||
//~| ERROR expected identifier, found reserved keyword `become`
|
//~| ERROR expected identifier, found reserved keyword `become`
|
||||||
//~| ERROR expected identifier, found reserved keyword `await`
|
//~| ERROR expected identifier, found keyword `await`
|
||||||
|
|
||||||
struct W<T, U>(T, U);
|
struct W<T, U>(T, U);
|
||||||
struct B { f: Box<u8> }
|
struct B { f: Box<u8> }
|
||||||
|
|
|
@ -62,11 +62,11 @@ help: you can escape reserved keywords to use them as identifiers
|
||||||
LL | let mut mut yield(r#become, await) = r#yield(0, 0);
|
LL | let mut mut yield(r#become, await) = r#yield(0, 0);
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: expected identifier, found reserved keyword `await`
|
error: expected identifier, found keyword `await`
|
||||||
--> $DIR/mut-patterns.rs:26:31
|
--> $DIR/mut-patterns.rs:26:31
|
||||||
|
|
|
|
||||||
LL | let mut mut yield(become, await) = r#yield(0, 0);
|
LL | let mut mut yield(become, await) = r#yield(0, 0);
|
||||||
| ^^^^^ expected identifier, found reserved keyword
|
| ^^^^^ expected identifier, found keyword
|
||||||
help: you can escape reserved keywords to use them as identifiers
|
help: you can escape reserved keywords to use them as identifiers
|
||||||
|
|
|
|
||||||
LL | let mut mut yield(become, r#await) = r#yield(0, 0);
|
LL | let mut mut yield(become, r#await) = r#yield(0, 0);
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1
|
--> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1
|
||||||
|
|
|
|
||||||
LL | #[unstable()]
|
LL | #[unstable()]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1
|
--> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[stable()]
|
LL | #[stable()]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1
|
--> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()]
|
LL | #[rustc_deprecated()]
|
||||||
|
@ -18,3 +18,4 @@ LL | #[rustc_deprecated()]
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged.rs:1:1
|
--> $DIR/stability-attribute-non-staged.rs:1:1
|
||||||
|
|
|
|
||||||
LL | #[unstable()]
|
LL | #[unstable()]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged.rs:2:1
|
--> $DIR/stability-attribute-non-staged.rs:2:1
|
||||||
|
|
|
|
||||||
LL | #[stable()]
|
LL | #[stable()]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/stability-attribute-non-staged.rs:3:1
|
--> $DIR/stability-attribute-non-staged.rs:3:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_deprecated()]
|
LL | #[rustc_deprecated()]
|
||||||
|
@ -18,3 +18,4 @@ LL | #[rustc_deprecated()]
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0734`.
|
||||||
|
|
|
@ -2,7 +2,7 @@ error[E0609]: no field `d` on type `&A`
|
||||||
--> $DIR/struct-pat-derived-error.rs:8:31
|
--> $DIR/struct-pat-derived-error.rs:8:31
|
||||||
|
|
|
|
||||||
LL | let A { x, y } = self.d;
|
LL | let A { x, y } = self.d;
|
||||||
| ^
|
| ^ help: a field with a similar name exists: `b`
|
||||||
|
|
||||||
error[E0026]: struct `A` does not have fields named `x`, `y`
|
error[E0026]: struct `A` does not have fields named `x`, `y`
|
||||||
--> $DIR/struct-pat-derived-error.rs:8:17
|
--> $DIR/struct-pat-derived-error.rs:8:17
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
// Fix issue 52082: Confusing error if accidentially defining a type paramter with the same name as
|
||||||
|
// an existing type
|
||||||
|
//
|
||||||
|
// To this end, make sure that when trying to retrieve a field of a (reference to) type parameter,
|
||||||
|
// rustc points to the point where the parameter was defined.
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Point
|
||||||
|
{
|
||||||
|
x: i32,
|
||||||
|
y: i32
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Point
|
||||||
|
{
|
||||||
|
fn add(a: &Point, b: &Point) -> Point
|
||||||
|
{
|
||||||
|
Point {x: a.x + b.x, y: a.y + b.y}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Eq
|
||||||
|
{
|
||||||
|
fn equals_ref<T>(a: &T, b: &T) -> bool;
|
||||||
|
fn equals_val<T>(a: T, b: T) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for Point
|
||||||
|
{
|
||||||
|
fn equals_ref<Point>(a: &Point, b: &Point) -> bool
|
||||||
|
{
|
||||||
|
a.x == b.x && a.y == b.y //~ ERROR no field `x` on type `&Point` [E0609]
|
||||||
|
//~|ERROR no field `x` on type `&Point` [E0609]
|
||||||
|
//~|ERROR no field `y` on type `&Point` [E0609]
|
||||||
|
//~|ERROR no field `y` on type `&Point` [E0609]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn equals_val<Point>(a: Point, b: Point) -> bool
|
||||||
|
{
|
||||||
|
a.x == b.x && a.y == b.y //~ ERROR no field `x` on type `Point` [E0609]
|
||||||
|
//~|ERROR no field `x` on type `Point` [E0609]
|
||||||
|
//~|ERROR no field `y` on type `Point` [E0609]
|
||||||
|
//~|ERROR no field `y` on type `Point` [E0609]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main()
|
||||||
|
{
|
||||||
|
let p1 = Point {x: 0, y: 10};
|
||||||
|
let p2 = Point {x: 20, y: 42};
|
||||||
|
println!("{:?}", Point::add(&p1, &p2));
|
||||||
|
println!("p1: {:?}, p2: {:?}", p1, p2);
|
||||||
|
println!("&p1 == &p2: {:?}", Point::equals_ref(&p1, &p2));
|
||||||
|
println!("p1 == p2: {:?}", Point::equals_val(p1, p2));
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
error[E0609]: no field `x` on type `&Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:31:11
|
||||||
|
|
|
||||||
|
LL | fn equals_ref<Point>(a: &Point, b: &Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `x` on type `&Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:31:18
|
||||||
|
|
|
||||||
|
LL | fn equals_ref<Point>(a: &Point, b: &Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `y` on type `&Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:31:25
|
||||||
|
|
|
||||||
|
LL | fn equals_ref<Point>(a: &Point, b: &Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `y` on type `&Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:31:32
|
||||||
|
|
|
||||||
|
LL | fn equals_ref<Point>(a: &Point, b: &Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `x` on type `Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:39:11
|
||||||
|
|
|
||||||
|
LL | fn equals_val<Point>(a: Point, b: Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `x` on type `Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:39:18
|
||||||
|
|
|
||||||
|
LL | fn equals_val<Point>(a: Point, b: Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `y` on type `Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:39:25
|
||||||
|
|
|
||||||
|
LL | fn equals_val<Point>(a: Point, b: Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error[E0609]: no field `y` on type `Point`
|
||||||
|
--> $DIR/issue-52082-type-param-shadows-existing-type.rs:39:32
|
||||||
|
|
|
||||||
|
LL | fn equals_val<Point>(a: Point, b: Point) -> bool
|
||||||
|
| ----- type parameter 'Point' declared here
|
||||||
|
LL | {
|
||||||
|
LL | a.x == b.x && a.y == b.y
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0609`.
|
|
@ -384,7 +384,7 @@ fn map_lib_features(base_src_path: &Path,
|
||||||
let file = entry.path();
|
let file = entry.path();
|
||||||
let filename = file.file_name().unwrap().to_string_lossy();
|
let filename = file.file_name().unwrap().to_string_lossy();
|
||||||
if !filename.ends_with(".rs") || filename == "features.rs" ||
|
if !filename.ends_with(".rs") || filename == "features.rs" ||
|
||||||
filename == "diagnostic_list.rs" {
|
filename == "diagnostic_list.rs" || filename == "error_codes.rs" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue