mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Auto merge of #70383 - Centril:rollup-hmfft3y, r=Centril
Rollup of 7 pull requests Successful merges: - #70331 (Increase verbosity when using update syntax with private fields) - #70349 (move `hir_id_validation` to `rustc_passes` + simplify `hir::map` code) - #70361 (Update backtrace crate to 0.3.46) - #70364 (resolve: Remove `rustc_attrs` as a standalone feature gate) - #70369 (Fix smaller issues with invalid placeholder type errors) - #70373 (normalize some imports & prefer direct ones) - #70376 (Add test for #66312) Failed merges: r? @ghost
This commit is contained in:
commit
cdb50c6f25
@ -121,9 +121,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.45"
|
||||
version = "0.3.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad235dabf00f36301792cfe82499880ba54c6486be094d1047b02bacb67c14e8"
|
||||
checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
|
||||
dependencies = [
|
||||
"backtrace-sys",
|
||||
"cfg-if",
|
||||
@ -135,9 +135,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "backtrace-sys"
|
||||
version = "0.1.34"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca797db0057bae1a7aa2eef3283a874695455cecf08a43bfb8507ee0ebc1ed69"
|
||||
checksum = "7de8aba10a69c8e8d7622c5710229485ec32e9d55fdad160ea559c086fdcd118"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"compiler_builtins",
|
||||
|
@ -49,8 +49,6 @@
|
||||
//! user of the `DepNode` API of having to know how to compute the expected
|
||||
//! fingerprint for a given set of node parameters.
|
||||
|
||||
use crate::hir::map::DefPathHash;
|
||||
use crate::ich::Fingerprint;
|
||||
use crate::mir;
|
||||
use crate::mir::interpret::{GlobalId, LitToConstInput};
|
||||
use crate::traits;
|
||||
@ -62,7 +60,9 @@ use crate::traits::query::{
|
||||
use crate::ty::subst::SubstsRef;
|
||||
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use std::hash::Hash;
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::arena::Arena;
|
||||
use crate::hir::map::definitions::{self, DefPathHash};
|
||||
use crate::hir::map::{Entry, HirOwnerData, Map};
|
||||
use crate::hir::{Owner, OwnerNodes, ParentedNode};
|
||||
use crate::ich::StableHashingContext;
|
||||
@ -11,6 +10,7 @@ use rustc_data_structures::svh::Svh;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::CRATE_DEF_INDEX;
|
||||
use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{self, DefPathHash};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::*;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
|
@ -7,9 +7,7 @@ use rustc_ast::ast::{self, Name, NodeId};
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
pub use rustc_hir::definitions;
|
||||
pub use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
|
||||
pub use rustc_hir::definitions::{Definitions, DisambiguatedDefPathData};
|
||||
use rustc_hir::definitions::{DefKey, DefPath, Definitions};
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::print::Nested;
|
||||
@ -23,8 +21,6 @@ use rustc_target::spec::abi::Abi;
|
||||
|
||||
pub mod blocks;
|
||||
mod collector;
|
||||
mod hir_id_validator;
|
||||
pub use hir_id_validator::check_crate;
|
||||
|
||||
/// Represents an entry and its parent `HirId`.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@ -44,79 +40,42 @@ impl<'hir> Entry<'hir> {
|
||||
|
||||
fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> {
|
||||
match node {
|
||||
Node::Item(ref item) => match item.kind {
|
||||
ItemKind::Fn(ref sig, _, _) => Some(&sig.decl),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::TraitItem(ref item) => match item.kind {
|
||||
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::ImplItem(ref item) => match item.kind {
|
||||
ImplItemKind::Fn(ref sig, _) => Some(&sig.decl),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::Expr(ref expr) => match expr.kind {
|
||||
ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. })
|
||||
| Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(sig, _), .. })
|
||||
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(sig, _), .. }) => Some(&sig.decl),
|
||||
Node::Expr(Expr { kind: ExprKind::Closure(_, fn_decl, ..), .. }) => Some(fn_decl),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_sig<'hir>(node: Node<'hir>) -> Option<&'hir FnSig<'hir>> {
|
||||
match &node {
|
||||
Node::Item(item) => match &item.kind {
|
||||
ItemKind::Fn(sig, _, _) => Some(sig),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::TraitItem(item) => match &item.kind {
|
||||
TraitItemKind::Fn(sig, _) => Some(sig),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::ImplItem(item) => match &item.kind {
|
||||
ImplItemKind::Fn(sig, _) => Some(sig),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. })
|
||||
| Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(sig, _), .. })
|
||||
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(sig, _), .. }) => Some(sig),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn associated_body<'hir>(node: Node<'hir>) -> Option<BodyId> {
|
||||
match node {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body) => {
|
||||
Some(body)
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Const(_, Some(body)) | TraitItemKind::Fn(_, TraitFn::Provided(body)) => {
|
||||
Some(body)
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
|
||||
Node::ImplItem(item) => match item.kind {
|
||||
ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body) => Some(body),
|
||||
_ => None,
|
||||
},
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::Const(_, body) | ItemKind::Static(.., body) | ItemKind::Fn(.., body),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(TraitItem {
|
||||
kind:
|
||||
TraitItemKind::Const(_, Some(body)) | TraitItemKind::Fn(_, TraitFn::Provided(body)),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(ImplItem {
|
||||
kind: ImplItemKind::Const(_, body) | ImplItemKind::Fn(_, body),
|
||||
..
|
||||
})
|
||||
| Node::Expr(Expr { kind: ExprKind::Closure(.., body, _, _), .. }) => Some(*body),
|
||||
|
||||
Node::AnonConst(constant) => Some(constant.body),
|
||||
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
ExprKind::Closure(.., body, _, _) => Some(body),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -520,20 +479,21 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> {
|
||||
self.get_if_local(id).and_then(|node| match node {
|
||||
Node::ImplItem(ref impl_item) => Some(&impl_item.generics),
|
||||
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
|
||||
Node::Item(ref item) => match item.kind {
|
||||
ItemKind::Fn(_, ref generics, _)
|
||||
| ItemKind::TyAlias(_, ref generics)
|
||||
| ItemKind::Enum(_, ref generics)
|
||||
| ItemKind::Struct(_, ref generics)
|
||||
| ItemKind::Union(_, ref generics)
|
||||
| ItemKind::Trait(_, _, ref generics, ..)
|
||||
| ItemKind::TraitAlias(ref generics, _)
|
||||
| ItemKind::Impl { ref generics, .. } => Some(generics),
|
||||
_ => None,
|
||||
},
|
||||
self.get_if_local(id).and_then(|node| match &node {
|
||||
Node::ImplItem(impl_item) => Some(&impl_item.generics),
|
||||
Node::TraitItem(trait_item) => Some(&trait_item.generics),
|
||||
Node::Item(Item {
|
||||
kind:
|
||||
ItemKind::Fn(_, generics, _)
|
||||
| ItemKind::TyAlias(_, generics)
|
||||
| ItemKind::Enum(_, generics)
|
||||
| ItemKind::Struct(_, generics)
|
||||
| ItemKind::Union(_, generics)
|
||||
| ItemKind::Trait(_, _, generics, ..)
|
||||
| ItemKind::TraitAlias(generics, _)
|
||||
| ItemKind::Impl { generics, .. },
|
||||
..
|
||||
}) => Some(generics),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
@ -573,11 +533,12 @@ impl<'hir> Map<'hir> {
|
||||
_ => return false,
|
||||
}
|
||||
match self.find(self.get_parent_node(id)) {
|
||||
Some(Node::Item(_)) | Some(Node::TraitItem(_)) | Some(Node::ImplItem(_)) => true,
|
||||
Some(Node::Expr(e)) => match e.kind {
|
||||
ExprKind::Closure(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
Some(
|
||||
Node::Item(_)
|
||||
| Node::TraitItem(_)
|
||||
| Node::ImplItem(_)
|
||||
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -644,12 +605,8 @@ impl<'hir> Map<'hir> {
|
||||
if let (Some((_, next_node)), false) = (iter.peek(), ignore_tail) {
|
||||
match next_node {
|
||||
Node::Block(Block { expr: None, .. }) => return None,
|
||||
Node::Block(Block { expr: Some(expr), .. }) => {
|
||||
if hir_id != expr.hir_id {
|
||||
// The current node is not the tail expression of its parent.
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Node::Block(Block { expr: Some(e), .. }) if hir_id != e.hir_id => return None,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -659,14 +616,11 @@ impl<'hir> Map<'hir> {
|
||||
| Node::TraitItem(_)
|
||||
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. })
|
||||
| Node::ImplItem(_) => return Some(hir_id),
|
||||
Node::Expr(ref expr) => {
|
||||
match expr.kind {
|
||||
// Ignore `return`s on the first iteration
|
||||
ExprKind::Loop(..) | ExprKind::Ret(..) => return None,
|
||||
_ => {}
|
||||
Node::Expr(Expr { kind: ExprKind::Loop(..) | ExprKind::Ret(..), .. })
|
||||
| Node::Local(_) => {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Node::Local(_) => return None,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -710,17 +664,12 @@ impl<'hir> Map<'hir> {
|
||||
pub fn get_match_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> {
|
||||
for (_, node) in self.parent_iter(hir_id) {
|
||||
match node {
|
||||
Node::Item(_) | Node::ForeignItem(_) | Node::TraitItem(_) | Node::ImplItem(_) => {
|
||||
break;
|
||||
}
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
ExprKind::Match(_, _, _) => return Some(expr),
|
||||
_ => {}
|
||||
},
|
||||
Node::Stmt(stmt) => match stmt.kind {
|
||||
StmtKind::Local(_) => break,
|
||||
_ => {}
|
||||
},
|
||||
Node::Item(_)
|
||||
| Node::ForeignItem(_)
|
||||
| Node::TraitItem(_)
|
||||
| Node::ImplItem(_)
|
||||
| Node::Stmt(Stmt { kind: StmtKind::Local(_), .. }) => break,
|
||||
Node::Expr(expr @ Expr { kind: ExprKind::Match(..), .. }) => return Some(expr),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -730,32 +679,22 @@ impl<'hir> Map<'hir> {
|
||||
/// Returns the nearest enclosing scope. A scope is roughly an item or block.
|
||||
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
|
||||
for (hir_id, node) in self.parent_iter(hir_id) {
|
||||
if match node {
|
||||
Node::Item(i) => match i.kind {
|
||||
if let Node::Item(Item {
|
||||
kind:
|
||||
ItemKind::Fn(..)
|
||||
| ItemKind::Mod(..)
|
||||
| ItemKind::Enum(..)
|
||||
| ItemKind::Struct(..)
|
||||
| ItemKind::Union(..)
|
||||
| ItemKind::Trait(..)
|
||||
| ItemKind::Impl { .. } => true,
|
||||
_ => false,
|
||||
},
|
||||
Node::ForeignItem(fi) => match fi.kind {
|
||||
ForeignItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
Node::TraitItem(ti) => match ti.kind {
|
||||
TraitItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
Node::ImplItem(ii) => match ii.kind {
|
||||
ImplItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
},
|
||||
Node::Block(_) => true,
|
||||
_ => false,
|
||||
} {
|
||||
| ItemKind::Impl { .. },
|
||||
..
|
||||
})
|
||||
| Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(..), .. })
|
||||
| Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(..), .. })
|
||||
| Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(..), .. })
|
||||
| Node::Block(_) = node
|
||||
{
|
||||
return Some(hir_id);
|
||||
}
|
||||
}
|
||||
@ -771,11 +710,11 @@ impl<'hir> Map<'hir> {
|
||||
return CRATE_HIR_ID;
|
||||
}
|
||||
match self.get(scope) {
|
||||
Node::Item(i) => match i.kind {
|
||||
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
|
||||
_ => break,
|
||||
},
|
||||
Node::Block(_) => {}
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }),
|
||||
..
|
||||
})
|
||||
| Node::Block(_) => {}
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
@ -823,14 +762,11 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData<'hir> {
|
||||
match self.find(id) {
|
||||
Some(Node::Item(i)) => match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => {
|
||||
struct_def
|
||||
}
|
||||
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id)),
|
||||
},
|
||||
Some(
|
||||
Node::Ctor(vd)
|
||||
| Node::Item(Item { kind: ItemKind::Struct(vd, _) | ItemKind::Union(vd, _), .. }),
|
||||
) => vd,
|
||||
Some(Node::Variant(variant)) => &variant.data,
|
||||
Some(Node::Ctor(data)) => data,
|
||||
_ => bug!("expected struct or variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::hir::map::definitions::{DefPathHash, Definitions};
|
||||
use crate::ich::{self, CachingSourceMapView};
|
||||
use crate::ich;
|
||||
use crate::middle::cstore::CrateStore;
|
||||
use crate::ty::{fast_reject, TyCtxt};
|
||||
|
||||
@ -9,10 +8,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::definitions::{DefPathHash, Definitions};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{BytePos, SourceFile};
|
||||
use rustc_span::{BytePos, CachingSourceMapView, SourceFile};
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use std::cmp::Ord;
|
||||
|
@ -1,12 +1,13 @@
|
||||
//! This module contains `HashStable` implementations for various HIR data
|
||||
//! types in no particular order.
|
||||
|
||||
use crate::hir::map::DefPathHash;
|
||||
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use smallvec::SmallVec;
|
||||
use std::mem;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
//! This module contains `HashStable` implementations for various data types
|
||||
//! from rustc::ty in no particular order.
|
||||
|
||||
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::middle::region;
|
||||
use crate::mir;
|
||||
use crate::ty;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use std::cell::RefCell;
|
||||
|
@ -3,7 +3,6 @@
|
||||
pub use self::hcx::{
|
||||
hash_stable_trait_impls, NodeIdHashingMode, StableHashingContext, StableHashingContextProvider,
|
||||
};
|
||||
crate use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
pub use rustc_span::CachingSourceMapView;
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
pub use self::NativeLibraryKind::*;
|
||||
|
||||
use crate::hir::map::definitions::{DefKey, DefPath, DefPathHash, DefPathTable};
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
use rustc_ast::ast;
|
||||
@ -12,6 +11,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::{self, MetadataRef};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, DefPathTable};
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::search_paths::PathKind;
|
||||
pub use rustc_session::utils::NativeLibraryKind;
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::{AllocId, CheckInAllocMsg, Pointer, RawConst, ScalarMaybeUndef};
|
||||
|
||||
use crate::hir::map::definitions::DefPathData;
|
||||
use crate::mir::interpret::ConstValue;
|
||||
use crate::ty::layout::{Align, LayoutError, Size};
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
@ -11,6 +10,7 @@ use backtrace::Backtrace;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::CtfeBacktrace;
|
||||
use rustc_span::{def_id::DefId, Pos, Span};
|
||||
|
@ -1,9 +1,10 @@
|
||||
use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
|
||||
use crate::ich::{Fingerprint, NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ty::print::obsolete::DefPathBasedNames;
|
||||
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
|
||||
use rustc_attr::InlineAttr;
|
||||
use rustc_data_structures::base_n;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
|
@ -4,9 +4,6 @@ use crate::arena::Arena;
|
||||
use crate::dep_graph::DepGraph;
|
||||
use crate::dep_graph::{self, DepConstructor};
|
||||
use crate::hir::exports::Export;
|
||||
use crate::hir::map as hir_map;
|
||||
use crate::hir::map::definitions::Definitions;
|
||||
use crate::hir::map::{DefPathData, DefPathHash};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
|
||||
use crate::lint::{struct_lint_level, LintSource};
|
||||
@ -56,6 +53,7 @@ use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DefPathHash, Definitions};
|
||||
use rustc_hir::{HirId, Node, TraitCandidate};
|
||||
use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
@ -1236,7 +1234,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self.features_query(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
pub fn def_key(self, id: DefId) -> hir_map::DefKey {
|
||||
pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
|
||||
if let Some(id) = id.as_local() { self.hir().def_key(id) } else { self.cstore.def_key(id) }
|
||||
}
|
||||
|
||||
@ -1245,7 +1243,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
///
|
||||
/// Note that if `id` is not local to this crate, the result will
|
||||
/// be a non-local `DefPath`.
|
||||
pub fn def_path(self, id: DefId) -> hir_map::DefPath {
|
||||
pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath {
|
||||
if let Some(id) = id.as_local() {
|
||||
self.hir().def_path(id)
|
||||
} else {
|
||||
@ -1260,7 +1258,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
|
||||
pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
self.definitions.def_path_hash(def_id)
|
||||
} else {
|
||||
|
@ -166,7 +166,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||
/// Note that this is only a hint. See the documentation for
|
||||
/// `generates_cgu_internal_copy` for more information.
|
||||
pub fn requires_inline(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
use crate::hir::map::DefPathData;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
let def_id = match *self {
|
||||
ty::InstanceDef::Item(def_id) => def_id,
|
||||
ty::InstanceDef::DropGlue(_, Some(_)) => return false,
|
||||
|
@ -8,8 +8,6 @@ pub use self::Variance::*;
|
||||
|
||||
use crate::arena::Arena;
|
||||
use crate::hir::exports::ExportMap;
|
||||
use crate::hir::map as hir_map;
|
||||
use crate::ich::Fingerprint;
|
||||
use crate::ich::StableHashingContext;
|
||||
use crate::infer::canonical::Canonical;
|
||||
use crate::middle::cstore::CrateStoreDyn;
|
||||
@ -28,6 +26,7 @@ use rustc_ast::ast::{self, Ident, Name};
|
||||
use rustc_ast::node_id::{NodeId, NodeMap, NodeSet};
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sorted_map::SortedIndexMultiMap;
|
||||
@ -124,7 +123,7 @@ mod sty;
|
||||
// Data types
|
||||
|
||||
pub struct ResolverOutputs {
|
||||
pub definitions: hir_map::Definitions,
|
||||
pub definitions: rustc_hir::definitions::Definitions,
|
||||
pub cstore: Box<CrateStoreDyn>,
|
||||
pub extern_crate_map: NodeMap<CrateNum>,
|
||||
pub trait_map: TraitMap<NodeId>,
|
||||
@ -2986,7 +2985,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let def_key = self.def_key(id);
|
||||
match def_key.disambiguated_data.data {
|
||||
// The name of a constructor is that of its parent.
|
||||
hir_map::DefPathData::Ctor => {
|
||||
rustc_hir::definitions::DefPathData::Ctor => {
|
||||
self.item_name(DefId { krate: id.krate, index: def_key.parent.unwrap() })
|
||||
}
|
||||
_ => def_key.disambiguated_data.data.get_opt_name().unwrap_or_else(|| {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use crate::ty::subst::{GenericArg, Subst};
|
||||
use crate::ty::{self, DefIdTree, Ty, TyCtxt};
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
|
||||
// `pretty` is a separate module only for organization.
|
||||
mod pretty;
|
||||
|
@ -1,18 +1,17 @@
|
||||
use crate::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use crate::middle::cstore::{ExternCrate, ExternCrateSource};
|
||||
use crate::middle::region;
|
||||
use crate::mir::interpret::{sign_extend, truncate, AllocId, ConstValue, Pointer, Scalar};
|
||||
use crate::ty::layout::{Integer, IntegerExt, Size};
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use crate::ty::{self, DefIdTree, ParamConst, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_ast::ast;
|
||||
use rustc_attr::{SignedInt, UnsignedInt};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
|
||||
use crate::hir::map::definitions::DefPathHash;
|
||||
use crate::ich::{CachingSourceMapView, Fingerprint};
|
||||
use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
||||
use crate::mir::{self, interpret};
|
||||
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
|
||||
use crate::ty::context::TyCtxt;
|
||||
use crate::ty::{self, Ty};
|
||||
use rustc_ast::ast::Ident;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::{HashMapExt, Lock, Lrc, Once};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_serialize::{
|
||||
opaque, Decodable, Decoder, Encodable, Encoder, SpecializedDecoder, SpecializedEncoder,
|
||||
@ -20,6 +20,7 @@ use rustc_serialize::{
|
||||
use rustc_session::{CrateDisambiguator, Session};
|
||||
use rustc_span::hygiene::{ExpnId, SyntaxContext};
|
||||
use rustc_span::source_map::{SourceMap, StableSourceFileId};
|
||||
use rustc_span::CachingSourceMapView;
|
||||
use rustc_span::{BytePos, SourceFile, Span, DUMMY_SP};
|
||||
use std::mem;
|
||||
|
||||
|
@ -667,7 +667,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
dep_node: &DepNode,
|
||||
dep_node_index: DepNodeIndex,
|
||||
) {
|
||||
use crate::ich::Fingerprint;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
|
||||
assert!(
|
||||
Some(self.dep_graph.fingerprint_of(dep_node_index))
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::hir::map::definitions::DefPathData;
|
||||
use crate::ty::context::TyCtxt;
|
||||
use crate::ty::query::caches::QueryCache;
|
||||
use crate::ty::query::plumbing::QueryState;
|
||||
@ -6,6 +5,7 @@ use measureme::{StringComponent, StringId};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::profiling::SelfProfiler;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use std::fmt::Debug;
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::hir::map::DefPathHash;
|
||||
use crate::ich::{self, StableHashingContext};
|
||||
use crate::traits::specialization_graph;
|
||||
use crate::ty::fast_reject;
|
||||
@ -6,6 +5,7 @@ use crate::ty::fold::TypeFoldable;
|
||||
use crate::ty::{Ty, TyCtxt};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
use rustc_hir::HirId;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -1,6 +1,5 @@
|
||||
//! Miscellaneous type-system utilities that are too small to deserve their own modules.
|
||||
|
||||
use crate::hir::map::DefPathData;
|
||||
use crate::ich::NodeIdHashingMode;
|
||||
use crate::mir::interpret::{sign_extend, truncate};
|
||||
use crate::ty::layout::{Integer, IntegerExt, Size};
|
||||
@ -17,6 +16,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::TargetDataLayout;
|
||||
|
@ -6,8 +6,8 @@ use rustc::ty::{self, Instance};
|
||||
use crate::common::CodegenCx;
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::DIScope;
|
||||
use rustc::hir::map::DefPathData;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
|
||||
pub fn mangled_name_of_instance<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
|
@ -55,7 +55,6 @@ use crate::traits::{
|
||||
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
|
||||
};
|
||||
|
||||
use rustc::hir::map;
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::error::TypeError;
|
||||
use rustc::ty::{
|
||||
@ -549,7 +548,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
terr: &TypeError<'tcx>,
|
||||
) {
|
||||
use hir::def_id::CrateNum;
|
||||
use map::DisambiguatedDefPathData;
|
||||
use rustc_hir::definitions::DisambiguatedDefPathData;
|
||||
use ty::print::Printer;
|
||||
use ty::subst::GenericArg;
|
||||
|
||||
|
@ -5,7 +5,6 @@ use crate::util;
|
||||
use log::{info, log_enabled, warn};
|
||||
use rustc::arena::Arena;
|
||||
use rustc::dep_graph::DepGraph;
|
||||
use rustc::hir::map::Definitions;
|
||||
use rustc::middle;
|
||||
use rustc::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
|
||||
use rustc::ty::steal::Steal;
|
||||
@ -20,6 +19,7 @@ use rustc_data_structures::{box_region_allow_access, declare_box_region_type, pa
|
||||
use rustc_errors::PResult;
|
||||
use rustc_expand::base::ExtCtxt;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::Definitions;
|
||||
use rustc_hir::Crate;
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_mir as mir;
|
||||
@ -776,7 +776,7 @@ pub fn create_global_ctxt<'tcx>(
|
||||
fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
rustc::hir::map::check_crate(tcx);
|
||||
rustc_passes::hir_id_validator::check_crate(tcx);
|
||||
|
||||
let sess = tcx.sess;
|
||||
let mut entry_point = None;
|
||||
|
@ -3,7 +3,6 @@
|
||||
use crate::locator::{CrateLocator, CratePaths};
|
||||
use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob};
|
||||
|
||||
use rustc::hir::map::Definitions;
|
||||
use rustc::middle::cstore::DepKind;
|
||||
use rustc::middle::cstore::{CrateSource, ExternCrate, ExternCrateSource, MetadataLoaderDyn};
|
||||
use rustc::ty::TyCtxt;
|
||||
@ -14,6 +13,7 @@ use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::Definitions;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_session::config;
|
||||
use rustc_session::output::validate_crate_name;
|
||||
|
@ -2,7 +2,6 @@ use decoder::Metadata;
|
||||
use table::{Table, TableBuilder};
|
||||
|
||||
use rustc::hir::exports::Export;
|
||||
use rustc::hir::map;
|
||||
use rustc::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLibrary};
|
||||
use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc::middle::lang_items;
|
||||
@ -194,7 +193,7 @@ crate struct CrateRoot<'tcx> {
|
||||
native_libraries: Lazy<[NativeLibrary]>,
|
||||
foreign_modules: Lazy<[ForeignModule]>,
|
||||
source_map: Lazy<[rustc_span::SourceFile]>,
|
||||
def_path_table: Lazy<map::definitions::DefPathTable>,
|
||||
def_path_table: Lazy<rustc_hir::definitions::DefPathTable>,
|
||||
impls: Lazy<[TraitImpls]>,
|
||||
interpret_alloc_index: Lazy<[u32]>,
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc::mir::interpret::Allocation;
|
||||
use rustc::ty::{
|
||||
self,
|
||||
@ -7,6 +6,7 @@ use rustc::ty::{
|
||||
Ty, TyCtxt,
|
||||
};
|
||||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use std::fmt::Write;
|
||||
|
||||
struct AbsolutePathPrinter<'tcx> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::hir::map::Map;
|
||||
use crate::ty::TyCtxt;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator};
|
||||
use rustc_hir as hir;
|
@ -21,6 +21,7 @@ mod check_const;
|
||||
pub mod dead;
|
||||
mod diagnostic_items;
|
||||
pub mod entry;
|
||||
pub mod hir_id_validator;
|
||||
pub mod hir_stats;
|
||||
mod intrinsicck;
|
||||
mod lang_items;
|
||||
|
@ -1023,12 +1023,19 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
|
||||
span: Span, // span of the field pattern, e.g., `x: 0`
|
||||
def: &'tcx ty::AdtDef, // definition of the struct or enum
|
||||
field: &'tcx ty::FieldDef,
|
||||
in_update_syntax: bool,
|
||||
) {
|
||||
// definition of the field
|
||||
let ident = Ident::new(kw::Invalid, use_ctxt);
|
||||
let current_hir = self.current_item;
|
||||
let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did, current_hir).1;
|
||||
if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {
|
||||
let label = if in_update_syntax {
|
||||
format!("field `{}` is private", field.ident)
|
||||
} else {
|
||||
"private field".to_string()
|
||||
};
|
||||
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
span,
|
||||
@ -1038,7 +1045,7 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> {
|
||||
def.variant_descr(),
|
||||
self.tcx.def_path_str(def.did)
|
||||
)
|
||||
.span_label(span, "private field")
|
||||
.span_label(span, label)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
@ -1106,13 +1113,13 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||
Some(field) => (field.ident.span, field.span),
|
||||
None => (base.span, base.span),
|
||||
};
|
||||
self.check_field(use_ctxt, span, adt, variant_field);
|
||||
self.check_field(use_ctxt, span, adt, variant_field, true);
|
||||
}
|
||||
} else {
|
||||
for field in fields {
|
||||
let use_ctxt = field.ident.span;
|
||||
let index = self.tcx.field_index(field.hir_id, self.tables);
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1131,7 +1138,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||
for field in fields {
|
||||
let use_ctxt = field.ident.span;
|
||||
let index = self.tcx.field_index(field.hir_id, self.tables);
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index], false);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -17,7 +17,6 @@ pub use rustc_hir::def::{Namespace, PerNS};
|
||||
use Determinacy::*;
|
||||
|
||||
use rustc::hir::exports::ExportMap;
|
||||
use rustc::hir::map::{DefKey, Definitions};
|
||||
use rustc::middle::cstore::{CrateStore, MetadataLoaderDyn};
|
||||
use rustc::span_bug;
|
||||
use rustc::ty::query::Providers;
|
||||
@ -38,6 +37,7 @@ use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_hir::def::Namespace::*;
|
||||
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX};
|
||||
use rustc_hir::definitions::{DefKey, Definitions};
|
||||
use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint};
|
||||
use rustc_hir::{GlobMap, TraitMap};
|
||||
use rustc_metadata::creader::{CStore, CrateLoader};
|
||||
|
@ -20,7 +20,6 @@ use rustc_feature::is_builtin_attr_name;
|
||||
use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
|
||||
use rustc_hir::def_id;
|
||||
use rustc_session::lint::builtin::UNUSED_MACROS;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind};
|
||||
@ -397,20 +396,16 @@ impl<'a> Resolver<'a> {
|
||||
Err(Determinacy::Undetermined) => return Err(Indeterminate),
|
||||
};
|
||||
|
||||
// Report errors and enforce feature gates for the resolved macro.
|
||||
let features = self.session.features_untracked();
|
||||
// Report errors for the resolved macro.
|
||||
for segment in &path.segments {
|
||||
if let Some(args) = &segment.args {
|
||||
self.session.span_err(args.span(), "generic arguments in macro path");
|
||||
}
|
||||
if kind == MacroKind::Attr
|
||||
&& !features.rustc_attrs
|
||||
&& segment.ident.as_str().starts_with("rustc")
|
||||
{
|
||||
let msg =
|
||||
"attributes starting with `rustc` are reserved for use by the `rustc` compiler";
|
||||
feature_err(&self.session.parse_sess, sym::rustc_attrs, segment.ident.span, msg)
|
||||
.emit();
|
||||
if kind == MacroKind::Attr && segment.ident.as_str().starts_with("rustc") {
|
||||
self.session.span_err(
|
||||
segment.ident.span,
|
||||
"attributes starting with `rustc` are reserved for use by the `rustc` compiler",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc::ich::NodeIdHashingMode;
|
||||
use rustc::mir::interpret::{ConstValue, Scalar};
|
||||
use rustc::ty::print::{PrettyPrinter, Print, Printer};
|
||||
@ -7,6 +6,7 @@ use rustc::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc::util::common::record_time;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
|
||||
use log::debug;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc::ty::print::{Print, Printer};
|
||||
use rustc::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use rustc::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
|
||||
@ -7,6 +6,7 @@ use rustc_data_structures::base_n;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::fmt::Write;
|
||||
|
@ -2883,16 +2883,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let bare_fn_ty =
|
||||
ty::Binder::bind(tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, unsafety, abi));
|
||||
|
||||
if !self.allow_ty_infer() {
|
||||
if let (false, Some(ident_span)) = (self.allow_ty_infer(), ident_span) {
|
||||
// We always collect the spans for placeholder types when evaluating `fn`s, but we
|
||||
// only want to emit an error complaining about them if infer types (`_`) are not
|
||||
// allowed. `allow_ty_infer` gates this behavior.
|
||||
// allowed. `allow_ty_infer` gates this behavior. We check for the presence of
|
||||
// `ident_span` to not emit an error twice when we have `fn foo(_: fn() -> _)`.
|
||||
crate::collect::placeholder_type_error(
|
||||
tcx,
|
||||
ident_span.map(|sp| sp.shrink_to_hi()).unwrap_or(DUMMY_SP),
|
||||
ident_span.shrink_to_hi(),
|
||||
&generics.params[..],
|
||||
visitor.0,
|
||||
ident_span.is_some(),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,10 @@ crate fn placeholder_type_error(
|
||||
// `struct S<T>(T);` instead of `struct S<_, T>(T);`.
|
||||
sugg.push((arg.span, (*type_name).to_string()));
|
||||
} else {
|
||||
let last = generics.iter().last().unwrap();
|
||||
sugg.push((
|
||||
generics.iter().last().unwrap().span.shrink_to_hi(),
|
||||
// Account for bounds, we want `fn foo<T: E, K>(_: K)` not `fn foo<T, K: E>(_: K)`.
|
||||
last.bounds_span().unwrap_or(last.span).shrink_to_hi(),
|
||||
format!(", {}", type_name),
|
||||
));
|
||||
}
|
||||
@ -1501,9 +1503,13 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl, &generics, Some(ident.span))
|
||||
}
|
||||
|
||||
ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => {
|
||||
ForeignItem(&hir::ForeignItem {
|
||||
kind: ForeignItemKind::Fn(ref fn_decl, _, _),
|
||||
ident,
|
||||
..
|
||||
}) => {
|
||||
let abi = tcx.hir().get_foreign_abi(hir_id);
|
||||
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
|
||||
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi, ident)
|
||||
}
|
||||
|
||||
Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor_hir_id().is_some() => {
|
||||
@ -2116,6 +2122,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||
def_id: DefId,
|
||||
decl: &'tcx hir::FnDecl<'tcx>,
|
||||
abi: abi::Abi,
|
||||
ident: Ident,
|
||||
) -> ty::PolyFnSig<'tcx> {
|
||||
let unsafety = if abi == abi::Abi::RustIntrinsic {
|
||||
intrinsic_operation_unsafety(&tcx.item_name(def_id).as_str())
|
||||
@ -2128,7 +2135,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
||||
abi,
|
||||
decl,
|
||||
&hir::Generics::empty(),
|
||||
None,
|
||||
Some(ident.span),
|
||||
);
|
||||
|
||||
// Feature gate SIMD types in FFI, since I am not sure that the
|
||||
|
@ -27,7 +27,7 @@ hashbrown = { version = "0.6.2", default-features = false, features = ['rustc-de
|
||||
|
||||
[dependencies.backtrace_rs]
|
||||
package = "backtrace"
|
||||
version = "0.3.44"
|
||||
version = "0.3.46"
|
||||
default-features = false # without the libstd `backtrace` feature, stub out everything
|
||||
features = [ "rustc-dep-of-std" ] # enable build support for integrating into libstd
|
||||
|
||||
|
@ -2,19 +2,19 @@
|
||||
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_span;
|
||||
#[macro_use]
|
||||
extern crate rustc_lint;
|
||||
extern crate rustc_span;
|
||||
#[macro_use]
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_ast;
|
||||
|
||||
use rustc_ast::attr;
|
||||
use rustc_driver::plugin::Registry;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_ast::attr;
|
||||
|
||||
macro_rules! fake_lint_pass {
|
||||
($struct:ident, $($attr:expr),*) => {
|
||||
@ -50,17 +50,17 @@ declare_lint!(CRATE_NOT_GREEN, Warn, "crate not marked with #![crate_green]");
|
||||
|
||||
fake_lint_pass! {
|
||||
PassOkay,
|
||||
Symbol::intern("rustc_crate_okay")
|
||||
Symbol::intern("crate_okay")
|
||||
}
|
||||
|
||||
fake_lint_pass! {
|
||||
PassRedBlue,
|
||||
Symbol::intern("rustc_crate_red"), Symbol::intern("rustc_crate_blue")
|
||||
Symbol::intern("crate_red"), Symbol::intern("crate_blue")
|
||||
}
|
||||
|
||||
fake_lint_pass! {
|
||||
PassGreyGreen,
|
||||
Symbol::intern("rustc_crate_grey"), Symbol::intern("rustc_crate_green")
|
||||
Symbol::intern("crate_grey"), Symbol::intern("crate_green")
|
||||
}
|
||||
|
||||
#[plugin_registrar]
|
||||
|
@ -1,33 +0,0 @@
|
||||
// force-host
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc;
|
||||
extern crate rustc_driver;
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::{TokenTree, TokenStream};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn rustc_duplicate(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let mut new_name = Some(attr.into_iter().nth(0).unwrap());
|
||||
let mut encountered_idents = 0;
|
||||
let input = item.to_string();
|
||||
let ret = item.into_iter().map(move |token| match token {
|
||||
TokenTree::Ident(_) if encountered_idents == 1 => {
|
||||
encountered_idents += 1;
|
||||
new_name.take().unwrap()
|
||||
}
|
||||
TokenTree::Ident(_) => {
|
||||
encountered_idents += 1;
|
||||
token
|
||||
}
|
||||
_ => token
|
||||
}).collect::<TokenStream>();
|
||||
let mut input_again = input.parse::<TokenStream>().unwrap();
|
||||
input_again.extend(ret);
|
||||
input_again
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// aux-build:lint-for-crate-rpass.rs
|
||||
// ignore-stage1
|
||||
// compile-flags: -D crate-not-okay
|
||||
|
||||
#![feature(plugin, register_attr, custom_inner_attributes, rustc_attrs)]
|
||||
#![feature(plugin, register_attr, custom_inner_attributes)]
|
||||
|
||||
#![register_attr(
|
||||
rustc_crate_okay,
|
||||
rustc_crate_blue,
|
||||
rustc_crate_red,
|
||||
rustc_crate_grey,
|
||||
rustc_crate_green,
|
||||
crate_okay,
|
||||
crate_blue,
|
||||
crate_red,
|
||||
crate_grey,
|
||||
crate_green,
|
||||
)]
|
||||
|
||||
#![plugin(lint_for_crate_rpass)] //~ WARNING compiler plugins are deprecated
|
||||
#![rustc_crate_okay]
|
||||
#![rustc_crate_blue]
|
||||
#![rustc_crate_red]
|
||||
#![rustc_crate_grey]
|
||||
#![rustc_crate_green]
|
||||
#![crate_okay]
|
||||
#![crate_blue]
|
||||
#![crate_red]
|
||||
#![crate_grey]
|
||||
#![crate_green]
|
||||
|
||||
fn main() {}
|
||||
|
14
src/test/ui/async-await/issue-66312.rs
Normal file
14
src/test/ui/async-await/issue-66312.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// edition:2018
|
||||
|
||||
trait Test<T> {
|
||||
fn is_some(self: T); //~ ERROR invalid `self` parameter type
|
||||
}
|
||||
|
||||
async fn f() {
|
||||
let x = Some(2);
|
||||
if x.is_some() {
|
||||
println!("Some");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
12
src/test/ui/async-await/issue-66312.stderr
Normal file
12
src/test/ui/async-await/issue-66312.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0307]: invalid `self` parameter type: T
|
||||
--> $DIR/issue-66312.rs:4:22
|
||||
|
|
||||
LL | fn is_some(self: T);
|
||||
| ^
|
||||
|
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0307`.
|
@ -145,7 +145,7 @@ LL | fn foo<X: K<_, _>>(x: X) {}
|
||||
|
|
||||
help: use type parameters instead
|
||||
|
|
||||
LL | fn foo<X, T: K<T, T>>(x: X) {}
|
||||
LL | fn foo<X: K<T, T>, T>(x: X) {}
|
||||
| ^ ^ ^^^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
@ -167,7 +167,7 @@ LL | fn baz<F: Fn() -> _>(_: F) {}
|
||||
|
|
||||
help: use type parameters instead
|
||||
|
|
||||
LL | fn baz<F, T: Fn() -> T>(_: F) {}
|
||||
LL | fn baz<F: Fn() -> T, T>(_: F) {}
|
||||
| ^^^^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:8:3
|
||||
|
|
||||
LL | #[rustc::unknown]
|
||||
| ^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: expected attribute, found macro `rustc::unknown`
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:8:3
|
||||
@ -12,13 +10,11 @@ error: expected attribute, found macro `rustc::unknown`
|
||||
LL | #[rustc::unknown]
|
||||
| ^^^^^^^^^^^^^^ not an attribute
|
||||
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:13:12
|
||||
|
|
||||
LL | #[unknown::rustc]
|
||||
| ^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: expected attribute, found macro `unknown::rustc`
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:13:3
|
||||
@ -26,13 +22,11 @@ error: expected attribute, found macro `unknown::rustc`
|
||||
LL | #[unknown::rustc]
|
||||
| ^^^^^^^^^^^^^^ not an attribute
|
||||
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:20:3
|
||||
|
|
||||
LL | #[rustc_unknown]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: cannot find attribute `rustc_unknown` in this scope
|
||||
--> $DIR/feature-gate-rustc-attrs.rs:20:3
|
||||
|
@ -2,7 +2,7 @@ error[E0451]: field `secret_uid` of struct `foo::S` is private
|
||||
--> $DIR/functional-struct-update-respects-privacy.rs:28:49
|
||||
|
|
||||
LL | let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ...
|
||||
| ^^^ private field
|
||||
| ^^^ field `secret_uid` is private
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
32
src/test/ui/proc-macro/auxiliary/duplicate.rs
Normal file
32
src/test/ui/proc-macro/auxiliary/duplicate.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// force-host
|
||||
// no-prefer-dynamic
|
||||
|
||||
#![deny(unused)]
|
||||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
use proc_macro::*;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let mut new_name = Some(attr.into_iter().nth(0).unwrap());
|
||||
let mut encountered_idents = 0;
|
||||
let input = item.to_string();
|
||||
let ret = item
|
||||
.into_iter()
|
||||
.map(move |token| match token {
|
||||
TokenTree::Ident(_) if encountered_idents == 1 => {
|
||||
encountered_idents += 1;
|
||||
new_name.take().unwrap()
|
||||
}
|
||||
TokenTree::Ident(_) => {
|
||||
encountered_idents += 1;
|
||||
token
|
||||
}
|
||||
_ => token,
|
||||
})
|
||||
.collect::<TokenStream>();
|
||||
let mut input_again = input.parse::<TokenStream>().unwrap();
|
||||
input_again.extend(ret);
|
||||
input_again
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/expand-to-unstable-2.rs:10:10
|
||||
|
|
||||
LL | #[derive(Unstable)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,35 +1,32 @@
|
||||
// check-pass
|
||||
// aux-build:macro-crate-test.rs
|
||||
// ignore-stage1
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate macro_crate_test;
|
||||
|
||||
// The duplicate macro will create a copy of the item with the given identifier.
|
||||
|
||||
#[rustc_duplicate(MyCopy)]
|
||||
// check-pass
|
||||
// aux-build:duplicate.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate duplicate;
|
||||
|
||||
#[duplicate(MyCopy)]
|
||||
struct MyStruct {
|
||||
number: i32
|
||||
number: i32,
|
||||
}
|
||||
|
||||
trait TestTrait {
|
||||
#[rustc_duplicate(TestType2)]
|
||||
#[duplicate(TestType2)]
|
||||
type TestType;
|
||||
|
||||
#[rustc_duplicate(required_fn2)]
|
||||
#[duplicate(required_fn2)]
|
||||
fn required_fn(&self);
|
||||
|
||||
#[rustc_duplicate(provided_fn2)]
|
||||
#[duplicate(provided_fn2)]
|
||||
fn provided_fn(&self) {}
|
||||
}
|
||||
|
||||
impl TestTrait for MyStruct {
|
||||
#[rustc_duplicate(TestType2)]
|
||||
#[duplicate(TestType2)]
|
||||
type TestType = f64;
|
||||
|
||||
#[rustc_duplicate(required_fn2)]
|
||||
#[duplicate(required_fn2)]
|
||||
fn required_fn(&self) {}
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/reserved-attr-on-macro.rs:1:3
|
||||
|
|
||||
LL | #[rustc_attribute_should_be_reserved]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: cannot determine resolution for the macro `foo`
|
||||
--> $DIR/reserved-attr-on-macro.rs:10:5
|
||||
@ -22,4 +20,3 @@ LL | #[rustc_attribute_should_be_reserved]
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,10 +1,8 @@
|
||||
error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/attribute-typos.rs:11:3
|
||||
|
|
||||
LL | #[rustc_err]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
|
||||
error: cannot find attribute `rustc_err` in this scope
|
||||
--> $DIR/attribute-typos.rs:11:3
|
||||
@ -31,4 +29,3 @@ LL | #[deprcated]
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -32,7 +32,6 @@ fn test7(x: _) { let _x: usize = x; }
|
||||
|
||||
fn test8(_f: fn() -> _) { }
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
|
||||
struct Test9;
|
||||
|
||||
@ -99,7 +98,6 @@ pub fn main() {
|
||||
|
||||
fn fn_test8(_f: fn() -> _) { }
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
|
||||
struct FnTest9;
|
||||
|
||||
|
@ -1,35 +1,35 @@
|
||||
error: expected identifier, found reserved identifier `_`
|
||||
--> $DIR/typeck_type_placeholder_item.rs:154:18
|
||||
--> $DIR/typeck_type_placeholder_item.rs:152:18
|
||||
|
|
||||
LL | struct BadStruct<_>(_);
|
||||
| ^ expected identifier, found reserved identifier
|
||||
|
||||
error: expected identifier, found reserved identifier `_`
|
||||
--> $DIR/typeck_type_placeholder_item.rs:157:16
|
||||
--> $DIR/typeck_type_placeholder_item.rs:155:16
|
||||
|
|
||||
LL | trait BadTrait<_> {}
|
||||
| ^ expected identifier, found reserved identifier
|
||||
|
||||
error: expected identifier, found reserved identifier `_`
|
||||
--> $DIR/typeck_type_placeholder_item.rs:167:19
|
||||
--> $DIR/typeck_type_placeholder_item.rs:165:19
|
||||
|
|
||||
LL | struct BadStruct1<_, _>(_);
|
||||
| ^ expected identifier, found reserved identifier
|
||||
|
||||
error: expected identifier, found reserved identifier `_`
|
||||
--> $DIR/typeck_type_placeholder_item.rs:167:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:165:22
|
||||
|
|
||||
LL | struct BadStruct1<_, _>(_);
|
||||
| ^ expected identifier, found reserved identifier
|
||||
|
||||
error: expected identifier, found reserved identifier `_`
|
||||
--> $DIR/typeck_type_placeholder_item.rs:172:19
|
||||
--> $DIR/typeck_type_placeholder_item.rs:170:19
|
||||
|
|
||||
LL | struct BadStruct2<_, T>(_, T);
|
||||
| ^ expected identifier, found reserved identifier
|
||||
|
||||
error: associated constant in `impl` without body
|
||||
--> $DIR/typeck_type_placeholder_item.rs:203:5
|
||||
--> $DIR/typeck_type_placeholder_item.rs:201:5
|
||||
|
|
||||
LL | const C: _;
|
||||
| ^^^^^^^^^^-
|
||||
@ -37,7 +37,7 @@ LL | const C: _;
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters
|
||||
--> $DIR/typeck_type_placeholder_item.rs:167:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:165:22
|
||||
|
|
||||
LL | struct BadStruct1<_, _>(_);
|
||||
| - ^ already used
|
||||
@ -131,12 +131,6 @@ help: use type parameters instead
|
||||
LL | fn test7<T>(x: T) { let _x: usize = x; }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:33:22
|
||||
|
|
||||
LL | fn test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:33:22
|
||||
|
|
||||
@ -149,7 +143,7 @@ LL | fn test8<T>(_f: fn() -> T) { }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:47:26
|
||||
--> $DIR/typeck_type_placeholder_item.rs:46:26
|
||||
|
|
||||
LL | fn test11(x: &usize) -> &_ {
|
||||
| -^
|
||||
@ -158,7 +152,7 @@ LL | fn test11(x: &usize) -> &_ {
|
||||
| help: replace with the correct return type: `&&usize`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:52:52
|
||||
--> $DIR/typeck_type_placeholder_item.rs:51:52
|
||||
|
|
||||
LL | unsafe fn test12(x: *const usize) -> *const *const _ {
|
||||
| --------------^
|
||||
@ -167,7 +161,7 @@ LL | unsafe fn test12(x: *const usize) -> *const *const _ {
|
||||
| help: replace with the correct return type: `*const *const usize`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:66:8
|
||||
--> $DIR/typeck_type_placeholder_item.rs:65:8
|
||||
|
|
||||
LL | a: _,
|
||||
| ^ not allowed in type signatures
|
||||
@ -186,13 +180,13 @@ LL | b: (T, T),
|
||||
|
|
||||
|
||||
error: missing type for `static` item
|
||||
--> $DIR/typeck_type_placeholder_item.rs:72:12
|
||||
--> $DIR/typeck_type_placeholder_item.rs:71:12
|
||||
|
|
||||
LL | static A = 42;
|
||||
| ^ help: provide a type for the item: `A: i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:74:15
|
||||
--> $DIR/typeck_type_placeholder_item.rs:73:15
|
||||
|
|
||||
LL | static B: _ = 42;
|
||||
| ^
|
||||
@ -201,13 +195,13 @@ LL | static B: _ = 42;
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:76:15
|
||||
--> $DIR/typeck_type_placeholder_item.rs:75:15
|
||||
|
|
||||
LL | static C: Option<_> = Some(42);
|
||||
| ^^^^^^^^^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:79:21
|
||||
--> $DIR/typeck_type_placeholder_item.rs:78:21
|
||||
|
|
||||
LL | fn fn_test() -> _ { 5 }
|
||||
| ^
|
||||
@ -216,7 +210,7 @@ LL | fn fn_test() -> _ { 5 }
|
||||
| help: replace with the correct return type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:82:23
|
||||
--> $DIR/typeck_type_placeholder_item.rs:81:23
|
||||
|
|
||||
LL | fn fn_test2() -> (_, _) { (5, 5) }
|
||||
| -^--^-
|
||||
@ -226,7 +220,7 @@ LL | fn fn_test2() -> (_, _) { (5, 5) }
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:85:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:84:22
|
||||
|
|
||||
LL | static FN_TEST3: _ = "test";
|
||||
| ^
|
||||
@ -235,7 +229,7 @@ LL | static FN_TEST3: _ = "test";
|
||||
| help: replace `_` with the correct type: `&str`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:88:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:87:22
|
||||
|
|
||||
LL | static FN_TEST4: _ = 145;
|
||||
| ^
|
||||
@ -244,13 +238,13 @@ LL | static FN_TEST4: _ = 145;
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:91:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:90:22
|
||||
|
|
||||
LL | static FN_TEST5: (_, _) = (1, 2);
|
||||
| ^^^^^^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:94:20
|
||||
--> $DIR/typeck_type_placeholder_item.rs:93:20
|
||||
|
|
||||
LL | fn fn_test6(_: _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -261,7 +255,7 @@ LL | fn fn_test6<T>(_: T) { }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:97:20
|
||||
--> $DIR/typeck_type_placeholder_item.rs:96:20
|
||||
|
|
||||
LL | fn fn_test7(x: _) { let _x: usize = x; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -272,13 +266,7 @@ LL | fn fn_test7<T>(x: T) { let _x: usize = x; }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:100:29
|
||||
|
|
||||
LL | fn fn_test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:100:29
|
||||
--> $DIR/typeck_type_placeholder_item.rs:99:29
|
||||
|
|
||||
LL | fn fn_test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -289,7 +277,7 @@ LL | fn fn_test8<T>(_f: fn() -> T) { }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:123:12
|
||||
--> $DIR/typeck_type_placeholder_item.rs:121:12
|
||||
|
|
||||
LL | a: _,
|
||||
| ^ not allowed in type signatures
|
||||
@ -308,13 +296,13 @@ LL | b: (T, T),
|
||||
|
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/typeck_type_placeholder_item.rs:128:18
|
||||
--> $DIR/typeck_type_placeholder_item.rs:126:18
|
||||
|
|
||||
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
|
||||
| ^ cannot infer type
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:128:28
|
||||
--> $DIR/typeck_type_placeholder_item.rs:126:28
|
||||
|
|
||||
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -322,7 +310,7 @@ LL | fn fn_test11(_: _) -> (_, _) { panic!() }
|
||||
| not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:132:30
|
||||
--> $DIR/typeck_type_placeholder_item.rs:130:30
|
||||
|
|
||||
LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
|
||||
| -^--^-
|
||||
@ -332,7 +320,7 @@ LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:135:33
|
||||
--> $DIR/typeck_type_placeholder_item.rs:133:33
|
||||
|
|
||||
LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
|
||||
| ------^-
|
||||
@ -341,7 +329,7 @@ LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:154:21
|
||||
--> $DIR/typeck_type_placeholder_item.rs:152:21
|
||||
|
|
||||
LL | struct BadStruct<_>(_);
|
||||
| ^ not allowed in type signatures
|
||||
@ -352,7 +340,7 @@ LL | struct BadStruct<T>(T);
|
||||
| ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:159:15
|
||||
--> $DIR/typeck_type_placeholder_item.rs:157:15
|
||||
|
|
||||
LL | impl BadTrait<_> for BadStruct<_> {}
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -365,13 +353,13 @@ LL | impl<T> BadTrait<T> for BadStruct<T> {}
|
||||
| ^^^ ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:162:34
|
||||
--> $DIR/typeck_type_placeholder_item.rs:160:34
|
||||
|
|
||||
LL | fn impl_trait() -> impl BadTrait<_> {
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:167:25
|
||||
--> $DIR/typeck_type_placeholder_item.rs:165:25
|
||||
|
|
||||
LL | struct BadStruct1<_, _>(_);
|
||||
| ^ not allowed in type signatures
|
||||
@ -382,7 +370,7 @@ LL | struct BadStruct1<T, _>(T);
|
||||
| ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:172:25
|
||||
--> $DIR/typeck_type_placeholder_item.rs:170:25
|
||||
|
|
||||
LL | struct BadStruct2<_, T>(_, T);
|
||||
| ^ not allowed in type signatures
|
||||
@ -393,13 +381,13 @@ LL | struct BadStruct2<K, T>(K, T);
|
||||
| ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:176:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:174:14
|
||||
|
|
||||
LL | type X = Box<_>;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:43:27
|
||||
--> $DIR/typeck_type_placeholder_item.rs:42:27
|
||||
|
|
||||
LL | fn test10(&self, _x : _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -410,7 +398,7 @@ LL | fn test10<T>(&self, _x : T) { }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:140:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:138:31
|
||||
|
|
||||
LL | fn method_test1(&self, x: _);
|
||||
| ^ not allowed in type signatures
|
||||
@ -421,7 +409,7 @@ LL | fn method_test1<T>(&self, x: T);
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:142:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:140:31
|
||||
|
|
||||
LL | fn method_test2(&self, x: _) -> _;
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -434,7 +422,7 @@ LL | fn method_test2<T>(&self, x: T) -> T;
|
||||
| ^^^ ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:144:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:142:31
|
||||
|
|
||||
LL | fn method_test3(&self) -> _;
|
||||
| ^ not allowed in type signatures
|
||||
@ -445,7 +433,7 @@ LL | fn method_test3<T>(&self) -> T;
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:146:26
|
||||
--> $DIR/typeck_type_placeholder_item.rs:144:26
|
||||
|
|
||||
LL | fn assoc_fn_test1(x: _);
|
||||
| ^ not allowed in type signatures
|
||||
@ -456,7 +444,7 @@ LL | fn assoc_fn_test1<T>(x: T);
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:148:26
|
||||
--> $DIR/typeck_type_placeholder_item.rs:146:26
|
||||
|
|
||||
LL | fn assoc_fn_test2(x: _) -> _;
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -469,7 +457,7 @@ LL | fn assoc_fn_test2<T>(x: T) -> T;
|
||||
| ^^^ ^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:150:28
|
||||
--> $DIR/typeck_type_placeholder_item.rs:148:28
|
||||
|
|
||||
LL | fn assoc_fn_test3() -> _;
|
||||
| ^ not allowed in type signatures
|
||||
@ -480,7 +468,7 @@ LL | fn assoc_fn_test3<T>() -> T;
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:61:37
|
||||
--> $DIR/typeck_type_placeholder_item.rs:60:37
|
||||
|
|
||||
LL | fn clone_from(&mut self, other: _) { *self = Test9; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -491,7 +479,7 @@ LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:110:34
|
||||
--> $DIR/typeck_type_placeholder_item.rs:108:34
|
||||
|
|
||||
LL | fn fn_test10(&self, _x : _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -502,7 +490,7 @@ LL | fn fn_test10<T>(&self, _x : T) { }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:118:41
|
||||
--> $DIR/typeck_type_placeholder_item.rs:116:41
|
||||
|
|
||||
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -513,25 +501,25 @@ LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
|
||||
| ^^^ ^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:182:21
|
||||
--> $DIR/typeck_type_placeholder_item.rs:180:21
|
||||
|
|
||||
LL | type Y = impl Trait<_>;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:190:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:188:14
|
||||
|
|
||||
LL | type B = _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:192:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:190:14
|
||||
|
|
||||
LL | const C: _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:194:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:192:14
|
||||
|
|
||||
LL | const D: _ = 42;
|
||||
| ^
|
||||
@ -540,7 +528,7 @@ LL | const D: _ = 42;
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:40:24
|
||||
--> $DIR/typeck_type_placeholder_item.rs:39:24
|
||||
|
|
||||
LL | fn test9(&self) -> _ { () }
|
||||
| ^
|
||||
@ -549,7 +537,7 @@ LL | fn test9(&self) -> _ { () }
|
||||
| help: replace with the correct return type: `()`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:58:24
|
||||
--> $DIR/typeck_type_placeholder_item.rs:57:24
|
||||
|
|
||||
LL | fn clone(&self) -> _ { Test9 }
|
||||
| ^
|
||||
@ -558,7 +546,7 @@ LL | fn clone(&self) -> _ { Test9 }
|
||||
| help: replace with the correct return type: `Test9`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:107:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:105:31
|
||||
|
|
||||
LL | fn fn_test9(&self) -> _ { () }
|
||||
| ^
|
||||
@ -567,7 +555,7 @@ LL | fn fn_test9(&self) -> _ { () }
|
||||
| help: replace with the correct return type: `()`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:115:28
|
||||
--> $DIR/typeck_type_placeholder_item.rs:113:28
|
||||
|
|
||||
LL | fn clone(&self) -> _ { FnTest9 }
|
||||
| ^
|
||||
@ -576,25 +564,25 @@ LL | fn clone(&self) -> _ { FnTest9 }
|
||||
| help: replace with the correct return type: `main::FnTest9`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:199:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:197:14
|
||||
|
|
||||
LL | type A = _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:201:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:199:14
|
||||
|
|
||||
LL | type B = _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:203:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:201:14
|
||||
|
|
||||
LL | const C: _;
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:206:14
|
||||
--> $DIR/typeck_type_placeholder_item.rs:204:14
|
||||
|
|
||||
LL | const D: _ = 42;
|
||||
| ^
|
||||
@ -602,7 +590,7 @@ LL | const D: _ = 42;
|
||||
| not allowed in type signatures
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error: aborting due to 66 previous errors
|
||||
error: aborting due to 64 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0121, E0282, E0403.
|
||||
For more information about an error, try `rustc --explain E0121`.
|
||||
|
Loading…
Reference in New Issue
Block a user