Auto merge of #62419 - Centril:rollup-82umycq, r=Centril

Rollup of 13 pull requests

Successful merges:

 - #61545 (Implement another internal lints)
 - #62110 (Improve -Ztime-passes)
 - #62133 (Feature gate `rustc` attributes harder)
 - #62158 (Add MemoryExtra in InterpretCx constructor params)
 - #62168 (The (almost) culmination of HirIdification)
 - #62193 (Create async version of the dynamic-drop test)
 - #62369 (Remove `compile-pass` from compiletest)
 - #62380 (rustc_target: avoid negative register counts in the SysV x86_64 ABI.)
 - #62381 (Fix a typo in Write::write_vectored docs)
 - #62390 (Update README.md)
 - #62396 (remove Scalar::is_null_ptr)
 - #62406 (Lint on invalid values passed to x.py --warnings)
 - #62414 (Remove last use of mem::uninitialized in SGX)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-07-05 18:27:52 +00:00
commit 481068a707
178 changed files with 1316 additions and 693 deletions

View File

@ -18,7 +18,7 @@ Read ["Installation"] from [The Book].
_Note: If you wish to contribute to the compiler, you should read
[this chapter](https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html)
of the rustc-guide instead._
of the rustc-guide instead of this section._
### Building on *nix
1. Make sure you have installed the dependencies:

View File

@ -306,7 +306,20 @@ fn main() {
}
// This is required for internal lints.
cmd.arg("-Zunstable-options");
if let Some(crate_name) = args.windows(2).find(|a| &*a[0] == "--crate-name") {
let crate_name = crate_name[1].to_string_lossy();
if crate_name != "rustc_version"
&& (crate_name.starts_with("rustc")
|| crate_name.starts_with("syntax")
|| crate_name == "arena"
|| crate_name == "fmt_macros")
{
cmd.arg("-Zunstable-options");
if stage != "0" {
cmd.arg("-Wrustc::internal");
}
}
}
// Force all crates compiled by this compiler to (a) be unstable and (b)
// allow the `rustc_private` feature to link to other unstable crates

View File

@ -405,7 +405,7 @@ impl Config {
config.incremental = flags.incremental;
config.dry_run = flags.dry_run;
config.keep_stage = flags.keep_stage;
if let Some(value) = flags.warnings {
if let Some(value) = flags.deny_warnings {
config.deny_warnings = value;
}
@ -571,7 +571,7 @@ impl Config {
config.rustc_default_linker = rust.default_linker.clone();
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);

View File

@ -33,8 +33,11 @@ pub struct Flags {
pub rustc_error_format: Option<String>,
pub dry_run: bool,
// true => deny
pub warnings: Option<bool>,
// This overrides the deny-warnings configuation option,
// which passes -Dwarnings to the compiler invocations.
//
// true => deny, false => allow
pub deny_warnings: Option<bool>,
}
pub enum Subcommand {
@ -468,7 +471,7 @@ Arguments:
.into_iter()
.map(|p| p.into())
.collect::<Vec<_>>(),
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
deny_warnings: parse_deny_warnings(&matches),
}
}
}
@ -549,3 +552,18 @@ fn split(s: &[String]) -> Vec<String> {
.map(|s| s.to_string())
.collect()
}
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
Some("deny") => Some(true),
Some("allow") => Some(false),
Some(value) => {
eprintln!(
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
value,
);
process::exit(1);
},
None => None,
}
}

@ -1 +1 @@
Subproject commit abf512fc9cc969dcbea69aa15b44586bbeb13c2d
Subproject commit b5a2b9353c661000378415ecfeb757eb7df42d66

View File

@ -12,7 +12,6 @@
test(no_crate_inject, attr(deny(warnings))))]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(core_intrinsics)]

View File

@ -74,6 +74,7 @@
#![feature(concat_idents)]
#![feature(const_fn)]
#![feature(const_fn_union)]
#![feature(custom_inner_attributes)]
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
#![feature(extern_types)]

View File

@ -9,7 +9,6 @@
test(attr(deny(warnings))))]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(nll)]

View File

@ -55,7 +55,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
///
/// ```
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
/// let item_def_id = ccx.tcx.hir().local_def_id(it.id);
/// let item_def_id = ccx.tcx.hir().local_def_id(it.hir_id);
/// ccx.tcx.item_types.memoized(item_def_id, || {
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
/// compute_type_of_item(ccx, item)

View File

@ -95,7 +95,7 @@ impl CheckAttrVisitor<'tcx> {
/// Checks any attribute.
fn check_attributes(&self, item: &hir::Item, target: Target) {
if target == Target::Fn || target == Target::Const {
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.hir_id));
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name(sym::target_feature)) {
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
.span_label(item.span, "not a function")

View File

@ -371,7 +371,6 @@ impl Definitions {
None
}
// FIXME(@ljedrz): replace the NodeId variant
#[inline]
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<hir::HirId> {
if def_id.krate == LOCAL_CRATE {

View File

@ -10,7 +10,8 @@ pub fn check_crate(hir_map: &hir::map::Map<'_>) {
let errors = Lock::new(Vec::new());
par_iter(&hir_map.krate().modules).for_each(|(module_id, _)| {
hir_map.visit_item_likes_in_module(hir_map.local_def_id(*module_id), &mut OuterVisitor {
let local_def_id = hir_map.local_def_id_from_node_id(*module_id);
hir_map.visit_item_likes_in_module(local_def_id, &mut OuterVisitor {
hir_map,
errors: &errors,
});
@ -79,7 +80,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
hir_id: HirId,
walk: F) {
assert!(self.owner_def_index.is_none());
let owner_def_index = self.hir_map.local_def_id_from_hir_id(hir_id).index;
let owner_def_index = self.hir_map.local_def_id(hir_id).index;
self.owner_def_index = Some(owner_def_index);
walk(self);

View File

@ -219,7 +219,7 @@ impl<'hir> Map<'hir> {
}
pub fn def_path_from_hir_id(&self, id: HirId) -> Option<DefPath> {
self.opt_local_def_id_from_hir_id(id).map(|def_id| {
self.opt_local_def_id(id).map(|def_id| {
self.def_path(def_id)
})
}
@ -230,32 +230,30 @@ impl<'hir> Map<'hir> {
}
#[inline]
pub fn local_def_id(&self, node: NodeId) -> DefId {
self.opt_local_def_id(node).unwrap_or_else(|| {
pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| {
let hir_id = self.node_to_hir_id(node);
bug!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
bug!("local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
node, self.find_entry(hir_id))
})
}
// FIXME(@ljedrz): replace the `NodeId` variant.
#[inline]
pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId {
self.opt_local_def_id_from_hir_id(hir_id).unwrap_or_else(|| {
bug!("local_def_id_from_hir_id: no entry for `{:?}`, which has a map of `{:?}`",
pub fn local_def_id(&self, hir_id: HirId) -> DefId {
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
bug!("local_def_id: no entry for `{:?}`, which has a map of `{:?}`",
hir_id, self.find_entry(hir_id))
})
}
// FIXME(@ljedrz): replace the `NodeId` variant.
#[inline]
pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option<DefId> {
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<DefId> {
let node_id = self.hir_to_node_id(hir_id);
self.definitions.opt_local_def_id(node_id)
}
#[inline]
pub fn opt_local_def_id(&self, node: NodeId) -> Option<DefId> {
pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<DefId> {
self.definitions.opt_local_def_id(node)
}
@ -264,7 +262,6 @@ impl<'hir> Map<'hir> {
self.definitions.as_local_node_id(def_id)
}
// FIXME(@ljedrz): replace the `NodeId` variant.
#[inline]
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<HirId> {
self.definitions.as_local_hir_id(def_id)
@ -429,7 +426,7 @@ impl<'hir> Map<'hir> {
}
pub fn body_owner_def_id(&self, id: BodyId) -> DefId {
self.local_def_id_from_hir_id(self.body_owner(id))
self.local_def_id(self.body_owner(id))
}
/// Given a `HirId`, returns the `BodyId` associated with it,
@ -765,7 +762,7 @@ impl<'hir> Map<'hir> {
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map.
pub fn get_module_parent(&self, id: HirId) -> DefId {
self.local_def_id_from_hir_id(self.get_module_parent_node(id))
self.local_def_id(self.get_module_parent_node(id))
}
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
@ -841,7 +838,7 @@ impl<'hir> Map<'hir> {
}
pub fn get_parent_did(&self, id: HirId) -> DefId {
self.local_def_id_from_hir_id(self.get_parent_item(id))
self.local_def_id(self.get_parent_item(id))
}
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
@ -1247,7 +1244,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
// the user-friendly path, otherwise fall back to stringifying DefPath.
crate::ty::tls::with_opt(|tcx| {
if let Some(tcx) = tcx {
let def_id = map.local_def_id_from_hir_id(id);
let def_id = map.local_def_id(id);
tcx.def_path_str(def_id)
} else if let Some(path) = map.def_path_from_hir_id(id) {
path.data.into_iter().map(|elem| {

View File

@ -83,7 +83,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
if let hir::ExprKind::Closure(..) = expr.node {
let closure_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
// Every capture of a closure expression is a local in scope,
// that is moved/copied/borrowed into the closure value, and

View File

@ -139,12 +139,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
// error. We will then search the function parameters for a bound
// region at the right depth with the same index
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
debug!(
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}",
id,
def_id
);
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
if id == def_id {
self.found_type = Some(arg);
return; // we can stop visiting now
@ -162,8 +157,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
debruijn_index
);
debug!("self.infcx.tcx.hir().local_def_id(id)={:?}", id);
debug!("def_id={:?}", def_id);
debug!("LateBound id={:?} def_id={:?}", id, def_id);
if debruijn_index == self.current_index && id == def_id {
self.found_type = Some(arg);
return; // we can stop visiting now
@ -231,12 +225,7 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
}
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
debug!(
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
def_id={:?}",
id,
def_id
);
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
if id == def_id {
self.found_it = true;
return; // we can stop visiting now

View File

@ -951,8 +951,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
let parent_def_id = self.parent_def_id;
let def_scope_default = || {
let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id);
parent_def_id
== tcx.hir().local_def_id_from_hir_id(opaque_parent_hir_id)
parent_def_id == tcx.hir()
.local_def_id(opaque_parent_hir_id)
};
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
Some(Node::Item(item)) => match item.node {

View File

@ -29,7 +29,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(arbitrary_self_types)]

View File

@ -926,7 +926,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {
{
let old_param_env = self.context.param_env;
self.context.param_env = self.context.tcx.param_env(
self.context.tcx.hir().local_def_id_from_hir_id(id)
self.context.tcx.hir().local_def_id(id)
);
f(self);
self.context.param_env = old_param_env;
@ -1341,6 +1341,7 @@ struct LateLintPassObjects<'a> {
lints: &'a mut [LateLintPassObject],
}
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
impl LintPass for LateLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()
@ -1500,7 +1501,7 @@ pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
time(tcx.sess, "module lints", || {
// Run per-module lints
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
tcx.ensure().lint_mod(tcx.hir().local_def_id(module));
tcx.ensure().lint_mod(tcx.hir().local_def_id_from_node_id(module));
});
});
});
@ -1510,6 +1511,7 @@ struct EarlyLintPassObjects<'a> {
lints: &'a mut [EarlyLintPassObject],
}
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
impl LintPass for EarlyLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()

View File

@ -7,11 +7,12 @@ use crate::lint::{
};
use errors::Applicability;
use rustc_data_structures::fx::FxHashMap;
use syntax::ast::Ident;
use syntax::ast::{Ident, Item, ItemKind};
use syntax::symbol::{sym, Symbol};
use syntax_pos::ExpnInfo;
declare_lint! {
pub DEFAULT_HASH_TYPES,
declare_tool_lint! {
pub rustc::DEFAULT_HASH_TYPES,
Allow,
"forbid HashMap and HashSet and suggest the FxHash* variants"
}
@ -22,7 +23,7 @@ pub struct DefaultHashTypes {
impl DefaultHashTypes {
// we are allowed to use `HashMap` and `HashSet` as identifiers for implementing the lint itself
#[allow(internal)]
#[cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
pub fn new() -> Self {
let mut map = FxHashMap::default();
map.insert(sym::HashMap, sym::FxHashMap);
@ -36,10 +37,7 @@ impl_lint_pass!(DefaultHashTypes => [DEFAULT_HASH_TYPES]);
impl EarlyLintPass for DefaultHashTypes {
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
if let Some(replace) = self.map.get(&ident.name) {
let msg = format!(
"Prefer {} over {}, it has better performance",
replace, ident
);
let msg = format!("Prefer {} over {}, it has better performance", replace, ident);
let mut db = cx.struct_span_lint(DEFAULT_HASH_TYPES, ident.span, &msg);
db.span_suggestion(
ident.span,
@ -47,29 +45,26 @@ impl EarlyLintPass for DefaultHashTypes {
replace.to_string(),
Applicability::MaybeIncorrect, // FxHashMap, ... needs another import
);
db.note(&format!(
"a `use rustc_data_structures::fx::{}` may be necessary",
replace
))
.emit();
db.note(&format!("a `use rustc_data_structures::fx::{}` may be necessary", replace))
.emit();
}
}
}
declare_lint! {
pub USAGE_OF_TY_TYKIND,
declare_tool_lint! {
pub rustc::USAGE_OF_TY_TYKIND,
Allow,
"usage of `ty::TyKind` outside of the `ty::sty` module"
}
declare_lint! {
pub TY_PASS_BY_REFERENCE,
declare_tool_lint! {
pub rustc::TY_PASS_BY_REFERENCE,
Allow,
"passing `Ty` or `TyCtxt` by reference"
}
declare_lint! {
pub USAGE_OF_QUALIFIED_TY,
declare_tool_lint! {
pub rustc::USAGE_OF_QUALIFIED_TY,
Allow,
"using `ty::{Ty,TyCtxt}` instead of importing it"
}
@ -137,13 +132,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind {
}
}
}
TyKind::Rptr(
_,
MutTy {
ty: inner_ty,
mutbl: Mutability::MutImmutable,
},
) => {
TyKind::Rptr(_, MutTy { ty: inner_ty, mutbl: Mutability::MutImmutable }) => {
if let Some(impl_did) = cx.tcx.impl_of_method(ty.hir_id.owner_def_id()) {
if cx.tcx.impl_trait_ref(impl_did).is_some() {
return;
@ -225,3 +214,44 @@ fn gen_args(segment: &PathSegment) -> String {
String::new()
}
declare_tool_lint! {
pub rustc::LINT_PASS_IMPL_WITHOUT_MACRO,
Allow,
"`impl LintPass` without the `declare_lint_pass!` or `impl_lint_pass!` macros"
}
declare_lint_pass!(LintPassImpl => [LINT_PASS_IMPL_WITHOUT_MACRO]);
impl EarlyLintPass for LintPassImpl {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node {
if let Some(last) = lint_pass.path.segments.last() {
if last.ident.name == sym::LintPass {
match &lint_pass.path.span.ctxt().outer_expn_info() {
Some(info) if is_lint_pass_expansion(info) => {}
_ => {
cx.struct_span_lint(
LINT_PASS_IMPL_WITHOUT_MACRO,
lint_pass.path.span,
"implementing `LintPass` by hand",
)
.help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")
.emit();
}
}
}
}
}
}
}
fn is_lint_pass_expansion(expn_info: &ExpnInfo) -> bool {
if expn_info.format.name() == sym::impl_lint_pass {
true
} else if let Some(info) = expn_info.call_site.ctxt().outer_expn_info() {
info.format.name() == sym::declare_lint_pass
} else {
false
}
}

View File

@ -161,7 +161,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
Node::Item(item) => {
match item.node {
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let def = self.tcx.adt_def(def_id);
self.repr_has_repr_c = def.repr.c();
@ -325,7 +325,7 @@ fn has_allow_dead_code_or_lang_attr(
return true;
}
let def_id = tcx.hir().local_def_id_from_hir_id(id);
let def_id = tcx.hir().local_def_id(id);
let cg_attrs = tcx.codegen_fn_attrs(def_id);
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive
@ -494,7 +494,7 @@ impl DeadVisitor<'tcx> {
}
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.hir_id));
!field.is_positional()
&& !self.symbol_is_live(field.hir_id)
&& !field_type.is_phantom_data()
@ -525,7 +525,7 @@ impl DeadVisitor<'tcx> {
// This is done to handle the case where, for example, the static
// method of a private type is used, but the type itself is never
// called directly.
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
let def_id = self.tcx.hir().local_def_id(id);
let inherent_impls = self.tcx.inherent_impls(def_id);
for &impl_did in inherent_impls.iter() {
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {

View File

@ -32,7 +32,7 @@ struct EntryContext<'a, 'tcx> {
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
fn visit_item(&mut self, item: &'tcx Item) {
let def_id = self.map.local_def_id_from_hir_id(item.hir_id);
let def_id = self.map.local_def_id(item.hir_id);
let def_key = self.map.def_key(def_id);
let at_root = def_key.parent == Some(CRATE_DEF_INDEX);
find_item(item, self, at_root);
@ -142,11 +142,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(DefId, EntryFnType)> {
if let Some((hir_id, _)) = visitor.start_fn {
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Start))
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Start))
} else if let Some((hir_id, _)) = visitor.attr_main_fn {
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Main))
} else if let Some((hir_id, _)) = visitor.main_fn {
Some((tcx.hir().local_def_id_from_hir_id(hir_id), EntryFnType::Main))
Some((tcx.hir().local_def_id(hir_id), EntryFnType::Main))
} else {
// No main function
let mut err = struct_err!(tcx.sess, E0601,

View File

@ -930,7 +930,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
debug!("walk_captures({:?})", closure_expr);
let closure_def_id = self.tcx().hir().local_def_id_from_hir_id(closure_expr.hir_id);
let closure_def_id = self.tcx().hir().local_def_id(closure_expr.hir_id);
if let Some(upvars) = self.tcx().upvars(closure_def_id) {
for (&var_id, upvar) in upvars.iter() {
let upvar_id = ty::UpvarId {

View File

@ -118,7 +118,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
match self.item_refs.get(&*value.as_str()).cloned() {
// Known lang item with attribute on correct target.
Some((item_index, expected_target)) if actual_target == expected_target => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
self.collect_item(item_index, def_id);
},
// Known lang item with attribute on incorrect target.

View File

@ -363,7 +363,7 @@ fn visit_fn<'tcx>(
debug!("visit_fn");
// swap in a new set of IR maps for this function body:
let def_id = ir.tcx.hir().local_def_id_from_hir_id(id);
let def_id = ir.tcx.hir().local_def_id(id);
let mut fn_maps = IrMaps::new(ir.tcx, def_id);
// Don't run unused pass for #[derive()]
@ -494,7 +494,7 @@ fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) {
// in better error messages than just pointing at the closure
// construction site.
let mut call_caps = Vec::new();
let closure_def_id = ir.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
let closure_def_id = ir.tcx.hir().local_def_id(expr.hir_id);
if let Some(upvars) = ir.tcx.upvars(closure_def_id) {
let parent_upvars = ir.tcx.upvars(ir.body_owner);
call_caps.extend(upvars.iter().filter_map(|(&var_id, upvar)| {

View File

@ -35,7 +35,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
match item.node {
hir::ItemKind::Impl(..) |
hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(item.hir_id));
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
generics.requires_monomorphization(tcx)
}
_ => false,
@ -48,7 +48,7 @@ fn method_might_be_inlined(
impl_src: DefId,
) -> bool {
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.hir_id));
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
return true
}
@ -222,7 +222,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
} else {
false
};
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
let is_extern = codegen_attrs.contains_extern_indicator();
let std_internal = codegen_attrs.flags.contains(
@ -243,7 +243,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::Item(item) => {
match item.node {
hir::ItemKind::Fn(.., body) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
if item_might_be_inlined(self.tcx,
&item,
self.tcx.codegen_fn_attrs(def_id)) {
@ -345,7 +345,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
// Anything which has custom linkage gets thrown on the worklist no
// matter where it is in the crate, along with "special std symbols"
// which are currently akin to allocator symbols.
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
if codegen_attrs.contains_extern_indicator() ||
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {

View File

@ -675,7 +675,7 @@ impl<'tcx> ScopeTree {
&format!("free_scope: {:?} not recognized by the \
region scope tree for {:?} / {:?}",
param_owner,
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
self.root_parent.map(|id| tcx.hir().local_def_id(id)),
self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
}

View File

@ -83,7 +83,7 @@ impl Region {
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam) -> (ParamName, Region) {
let i = *index;
*index += 1;
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
let def_id = hir_map.local_def_id(param.hir_id);
let origin = LifetimeDefOrigin::from_param(param);
debug!("Region::early: index={} def_id={:?}", i, def_id);
(param.name.modern(), Region::EarlyBound(i, def_id, origin))
@ -91,7 +91,7 @@ impl Region {
fn late(hir_map: &Map<'_>, param: &GenericParam) -> (ParamName, Region) {
let depth = ty::INNERMOST;
let def_id = hir_map.local_def_id_from_hir_id(param.hir_id);
let def_id = hir_map.local_def_id(param.hir_id);
let origin = LifetimeDefOrigin::from_param(param);
debug!(
"Region::late: param={:?} depth={:?} def_id={:?} origin={:?}",
@ -1326,7 +1326,7 @@ fn object_lifetime_defaults_for_item(
add_bounds(&mut set, &param.bounds);
let param_def_id = tcx.hir().local_def_id_from_hir_id(param.hir_id);
let param_def_id = tcx.hir().local_def_id(param.hir_id);
for predicate in &generics.where_clause.predicates {
// Look for `type: ...` where clauses.
let data = match *predicate {
@ -1370,7 +1370,7 @@ fn object_lifetime_defaults_for_item(
.enumerate()
.find(|&(_, (_, lt_name, _))| lt_name == name)
.map_or(Set1::Many, |(i, (id, _, origin))| {
let def_id = tcx.hir().local_def_id_from_hir_id(id);
let def_id = tcx.hir().local_def_id(id);
Set1::One(Region::EarlyBound(i as u32, def_id, origin))
})
}
@ -1835,7 +1835,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
node: hir::ImplItemKind::Method(..),
..
}) => {
let scope = self.tcx.hir().local_def_id_from_hir_id(fn_id);
let scope = self.tcx.hir().local_def_id(fn_id);
def = Region::Free(scope, def.id().unwrap());
}
_ => {}

View File

@ -361,7 +361,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
}
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(
let impl_def_id = self.tcx.hir().local_def_id(
self.tcx.hir().get_parent_item(ii.hir_id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.hir_id, ii.span, "item");
@ -598,7 +598,7 @@ impl<'tcx> TyCtxt<'tcx> {
// Deprecated attributes apply in-crate and cross-crate.
if let Some(id) = id {
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
let parent_def_id = self.hir().local_def_id_from_hir_id(
let parent_def_id = self.hir().local_def_id(
self.hir().get_parent_item(id));
let skip = self.lookup_deprecation_entry(parent_def_id)
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
@ -766,7 +766,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
// compiler-generated `extern crate` items have a dummy span.
if item.span.is_dummy() { return }
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
Some(cnum) => cnum,
None => return,
@ -796,7 +796,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
// There's no good place to insert stability check for non-Copy unions,
// so semi-randomly perform it here in stability.rs
hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let adt_def = self.tcx.adt_def(def_id);
let ty = self.tcx.type_of(def_id);

View File

@ -275,17 +275,6 @@ impl<'tcx, Tag> Scalar<Tag> {
}
}
#[inline]
pub fn is_null_ptr(self, cx: &impl HasDataLayout) -> bool {
match self {
Scalar::Raw { data, size } => {
assert_eq!(size as u64, cx.data_layout().pointer_size.bytes());
data == 0
},
Scalar::Ptr(_) => false,
}
}
#[inline]
pub fn from_bool(b: bool) -> Self {
Scalar::Raw { data: b as u128, size: 1 }

View File

@ -79,7 +79,7 @@ impl<'tcx> MonoItem<'tcx> {
tcx.symbol_name(Instance::mono(tcx, def_id))
}
MonoItem::GlobalAsm(hir_id) => {
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
SymbolName {
name: InternedString::intern(&format!("global_asm_{:?}", def_id))
}

View File

@ -27,6 +27,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash {
fn variant(&self) -> &Self::Variant;
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
type Variant = ty::TyKind<'tcx>;
fn variant(&self) -> &Self::Variant {
@ -159,6 +160,7 @@ where
Ok(decoder.map_encoded_cnum_to_current(cnum))
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[inline]
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
where

View File

@ -130,6 +130,7 @@ impl<'tcx> CtxtInterners<'tcx> {
}
/// Intern a type
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[inline(never)]
fn intern_ty(&self,
st: TyKind<'tcx>
@ -1251,15 +1252,15 @@ impl<'tcx> TyCtxt<'tcx> {
maybe_unused_trait_imports:
resolutions.maybe_unused_trait_imports
.into_iter()
.map(|id| hir.local_def_id(id))
.map(|id| hir.local_def_id_from_node_id(id))
.collect(),
maybe_unused_extern_crates:
resolutions.maybe_unused_extern_crates
.into_iter()
.map(|(id, sp)| (hir.local_def_id(id), sp))
.map(|(id, sp)| (hir.local_def_id_from_node_id(id), sp))
.collect(),
glob_map: resolutions.glob_map.into_iter().map(|(id, names)| {
(hir.local_def_id(id), names)
(hir.local_def_id_from_node_id(id), names)
}).collect(),
extern_prelude: resolutions.extern_prelude,
hir_map: hir,
@ -2107,6 +2108,7 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
}
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
&self.0.sty
@ -2321,6 +2323,7 @@ impl<'tcx> TyCtxt<'tcx> {
self.mk_fn_ptr(converted_sig)
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
#[inline]
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
self.interners.intern_ty(st)

View File

@ -18,6 +18,7 @@ impl FlagComputation {
}
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
pub fn for_sty(st: &ty::TyKind<'_>) -> FlagComputation {
let mut result = FlagComputation::new();
result.add_sty(st);
@ -61,6 +62,7 @@ impl FlagComputation {
} // otherwise, this binder captures nothing
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
fn add_sty(&mut self, st: &ty::TyKind<'_>) {
match st {
&ty::Bool |

View File

@ -33,7 +33,7 @@ impl<'tcx> DefIdForest {
/// crate.
#[inline]
pub fn full(tcx: TyCtxt<'tcx>) -> DefIdForest {
let crate_id = tcx.hir().local_def_id_from_hir_id(CRATE_HIR_ID);
let crate_id = tcx.hir().local_def_id(CRATE_HIR_ID);
DefIdForest::from_id(crate_id)
}

View File

@ -1,7 +1,5 @@
// ignore-tidy-filelength
#![allow(usage_of_ty_tykind)]
pub use self::Variance::*;
pub use self::AssocItemContainer::*;
pub use self::BorrowKind::*;
@ -484,6 +482,7 @@ bitflags! {
}
}
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
pub struct TyS<'tcx> {
pub sty: TyKind<'tcx>,
pub flags: TypeFlags,
@ -541,29 +540,29 @@ impl<'tcx> Hash for TyS<'tcx> {
impl<'tcx> TyS<'tcx> {
pub fn is_primitive_ty(&self) -> bool {
match self.sty {
TyKind::Bool |
TyKind::Char |
TyKind::Int(_) |
TyKind::Uint(_) |
TyKind::Float(_) |
TyKind::Infer(InferTy::IntVar(_)) |
TyKind::Infer(InferTy::FloatVar(_)) |
TyKind::Infer(InferTy::FreshIntTy(_)) |
TyKind::Infer(InferTy::FreshFloatTy(_)) => true,
TyKind::Ref(_, x, _) => x.is_primitive_ty(),
Bool |
Char |
Int(_) |
Uint(_) |
Float(_) |
Infer(InferTy::IntVar(_)) |
Infer(InferTy::FloatVar(_)) |
Infer(InferTy::FreshIntTy(_)) |
Infer(InferTy::FreshFloatTy(_)) => true,
Ref(_, x, _) => x.is_primitive_ty(),
_ => false,
}
}
pub fn is_suggestable(&self) -> bool {
match self.sty {
TyKind::Opaque(..) |
TyKind::FnDef(..) |
TyKind::FnPtr(..) |
TyKind::Dynamic(..) |
TyKind::Closure(..) |
TyKind::Infer(..) |
TyKind::Projection(..) => false,
Opaque(..) |
FnDef(..) |
FnPtr(..) |
Dynamic(..) |
Closure(..) |
Infer(..) |
Projection(..) => false,
_ => true,
}
}
@ -2816,7 +2815,7 @@ impl<'tcx> TyCtxt<'tcx> {
parent_vis: &hir::Visibility,
trait_item_ref: &hir::TraitItemRef)
-> AssocItem {
let def_id = self.hir().local_def_id_from_hir_id(trait_item_ref.id.hir_id);
let def_id = self.hir().local_def_id(trait_item_ref.id.hir_id);
let (kind, has_self) = match trait_item_ref.kind {
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
hir::AssocItemKind::Method { has_self } => {
@ -2842,7 +2841,7 @@ impl<'tcx> TyCtxt<'tcx> {
parent_def_id: DefId,
impl_item_ref: &hir::ImplItemRef)
-> AssocItem {
let def_id = self.hir().local_def_id_from_hir_id(impl_item_ref.id.hir_id);
let def_id = self.hir().local_def_id(impl_item_ref.id.hir_id);
let (kind, has_self) = match impl_item_ref.kind {
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
hir::AssocItemKind::Method { has_self } => {
@ -3114,7 +3113,7 @@ impl Iterator for AssocItemsIterator<'_> {
fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let parent_id = tcx.hir().get_parent_item(id);
let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id);
let parent_def_id = tcx.hir().local_def_id(parent_id);
let parent_item = tcx.hir().expect_item(parent_id);
match parent_item.node {
hir::ItemKind::Impl(.., ref impl_item_refs) => {
@ -3178,14 +3177,14 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
tcx.arena.alloc_from_iter(
trait_item_refs.iter()
.map(|trait_item_ref| trait_item_ref.id)
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
.map(|id| tcx.hir().local_def_id(id.hir_id))
)
}
hir::ItemKind::Impl(.., ref impl_item_refs) => {
tcx.arena.alloc_from_iter(
impl_item_refs.iter()
.map(|impl_item_ref| impl_item_ref.id)
.map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id))
.map(|id| tcx.hir().local_def_id(id.hir_id))
)
}
hir::ItemKind::TraitAlias(..) => &[],

View File

@ -1,5 +1,7 @@
//! This module contains `TyKind` and its major components.
#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
use crate::hir;
use crate::hir::def_id::DefId;
use crate::infer::canonical::Canonical;

View File

@ -186,7 +186,7 @@ pub(super) fn trait_impls_of_provider(
}
for &hir_id in tcx.hir().trait_impls(trait_id) {
add_impl(tcx.hir().local_def_id_from_hir_id(hir_id));
add_impl(tcx.hir().local_def_id(hir_id));
}
}

View File

@ -170,7 +170,7 @@ pub fn time_ext<T, F>(do_it: bool, sess: Option<&Session>, what: &str, f: F) ->
}
}
print_time_passes_entry_internal(what, dur);
print_time_passes_entry(true, what, dur);
TIME_DEPTH.with(|slot| slot.set(old));
@ -182,18 +182,6 @@ pub fn print_time_passes_entry(do_it: bool, what: &str, dur: Duration) {
return
}
let old = TIME_DEPTH.with(|slot| {
let r = slot.get();
slot.set(r + 1);
r
});
print_time_passes_entry_internal(what, dur);
TIME_DEPTH.with(|slot| slot.set(old));
}
fn print_time_passes_entry_internal(what: &str, dur: Duration) {
let indentation = TIME_DEPTH.with(|slot| slot.get());
let mem_string = match get_resident() {

View File

@ -2,7 +2,6 @@
#![feature(rustc_private)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
pub mod expand;

View File

@ -198,7 +198,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
cfg: &cfg::CFG,
) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>) {
let owner_id = tcx.hir().body_owner(body_id);
let owner_def_id = tcx.hir().local_def_id_from_hir_id(owner_id);
let owner_def_id = tcx.hir().local_def_id(owner_id);
let tables = tcx.typeck_tables_of(owner_def_id);
let region_scope_tree = tcx.region_scope_tree(owner_def_id);
let body = tcx.hir().body(body_id);

View File

@ -2,7 +2,6 @@
#![allow(non_camel_case_types)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(in_band_lifetimes)]

View File

@ -23,7 +23,6 @@
#![feature(trusted_len)]
#![feature(mem_take)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
use back::write::{create_target_machine, create_informational_target_machine};

View File

@ -84,7 +84,7 @@ fn reachable_non_generics_provider(
// let it through if it's included statically.
match tcx.hir().get(hir_id) {
Node::ForeignItem(..) => {
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
if tcx.is_statically_included_foreign_item(def_id) {
Some(def_id)
} else {
@ -104,7 +104,7 @@ fn reachable_non_generics_provider(
node: hir::ImplItemKind::Method(..),
..
}) => {
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
let generics = tcx.generics_of(def_id);
if !generics.requires_monomorphization(tcx) &&
// Functions marked with #[inline] are only ever codegened

View File

@ -1554,7 +1554,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
let total_llvm_time = Instant::now().duration_since(llvm_start_time);
// This is the top-level timing for all of LLVM, set the time-depth
// to zero.
set_time_depth(0);
set_time_depth(1);
print_time_passes_entry(cgcx.time_passes,
"LLVM passes",
total_llvm_time);

View File

@ -25,7 +25,7 @@ use rustc::ty::{self, Ty, TyCtxt, Instance};
use rustc::ty::layout::{self, Align, TyLayout, LayoutOf, VariantIdx, HasTyCtxt};
use rustc::ty::query::Providers;
use rustc::middle::cstore::{self, LinkagePreference};
use rustc::util::common::{time, print_time_passes_entry};
use rustc::util::common::{time, print_time_passes_entry, set_time_depth, time_depth};
use rustc::session::config::{self, EntryFnType, Lto};
use rustc::session::Session;
use rustc::util::nodemap::FxHashMap;
@ -639,9 +639,12 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
// Since the main thread is sometimes blocked during codegen, we keep track
// -Ztime-passes output manually.
let time_depth = time_depth();
set_time_depth(time_depth + 1);
print_time_passes_entry(tcx.sess.time_passes(),
"codegen to LLVM IR",
total_codegen_time);
set_time_depth(time_depth);
::rustc_incremental::assert_module_sources::assert_module_sources(tcx);

View File

@ -14,7 +14,6 @@
#![allow(unused_attributes)]
#![allow(dead_code)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![recursion_limit="256"]

View File

@ -17,7 +17,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use]

View File

@ -33,7 +33,7 @@ impl SymbolNamesTest<'tcx> {
fn process_attrs(&mut self,
hir_id: hir::HirId) {
let tcx = self.tcx;
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
for attr in tcx.get_attrs(def_id).iter() {
if attr.check_name(SYMBOL_NAME) {
// for now, can only use on monomorphic names

View File

@ -27,6 +27,7 @@
#![cfg_attr(test, feature(test))]
#![deny(rust_2018_idioms)]
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
#[macro_use]
extern crate log;

View File

@ -17,7 +17,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
pub extern crate getopts;
@ -38,7 +37,8 @@ use rustc::session::{early_error, early_warn};
use rustc::lint::Lint;
use rustc::lint;
use rustc::hir::def_id::LOCAL_CRATE;
use rustc::util::common::{time, ErrorReported, install_panic_hook};
use rustc::util::common::{ErrorReported, install_panic_hook, print_time_passes_entry};
use rustc::util::common::{set_time_depth, time};
use rustc_metadata::locator;
use rustc_metadata::cstore::CStore;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
@ -54,11 +54,12 @@ use std::default::Default;
use std::env;
use std::ffi::OsString;
use std::io::{self, Read, Write};
use std::mem;
use std::panic::{self, catch_unwind};
use std::path::PathBuf;
use std::process::{self, Command, Stdio};
use std::str;
use std::mem;
use std::time::Instant;
use syntax::ast;
use syntax::source_map::FileLoader;
@ -72,7 +73,7 @@ pub mod pretty;
/// Exit status code used for successful compilation and help output.
pub const EXIT_SUCCESS: i32 = 0;
/// Exit status code used for compilation failures and invalid flags.
/// Exit status code used for compilation failures and invalid flags.
pub const EXIT_FAILURE: i32 = 1;
const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\
@ -118,6 +119,18 @@ pub struct DefaultCallbacks;
impl Callbacks for DefaultCallbacks {}
#[derive(Default)]
pub struct TimePassesCallbacks {
time_passes: bool,
}
impl Callbacks for TimePassesCallbacks {
fn config(&mut self, config: &mut interface::Config) {
self.time_passes =
config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time;
}
}
// Parse args and run the compiler. This is the primary entry point for rustc.
// See comments on CompilerCalls below for details about the callbacks argument.
// The FileLoader provides a way to load files from sources other than the file system.
@ -1169,7 +1182,9 @@ pub fn init_rustc_env_logger() {
}
pub fn main() {
let start = Instant::now();
init_rustc_env_logger();
let mut callbacks = TimePassesCallbacks::default();
let result = report_ices_to_stderr_if_any(|| {
let args = env::args_os().enumerate()
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
@ -1177,10 +1192,14 @@ pub fn main() {
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
}))
.collect::<Vec<_>>();
run_compiler(&args, &mut DefaultCallbacks, None, None)
run_compiler(&args, &mut callbacks, None, None)
}).and_then(|result| result);
process::exit(match result {
let exit_code = match result {
Ok(_) => EXIT_SUCCESS,
Err(_) => EXIT_FAILURE,
});
};
// The extra `\t` is necessary to align this label with the others.
set_time_depth(0);
print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed());
process::exit(exit_code);
}

View File

@ -465,7 +465,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
}
fn node_path(&self, id: hir::HirId) -> Option<String> {
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id_from_hir_id(id)))
Some(self.tcx.def_path_str(self.tcx.hir().local_def_id(id)))
}
}
@ -877,7 +877,7 @@ fn print_with_analysis(
let mut print = || match ppm {
PpmMir | PpmMirCFG => {
if let Some(nodeid) = nodeid {
let def_id = tcx.hir().local_def_id(nodeid);
let def_id = tcx.hir().local_def_id_from_node_id(nodeid);
match ppm {
PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out),
PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out),

View File

@ -10,7 +10,6 @@
#![feature(nll)]
#![feature(optin_builtin_traits)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[allow(unused_extern_crates)]

View File

@ -111,7 +111,7 @@ impl IfThisChanged<'tcx> {
}
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = self.tcx.hir().local_def_id(hir_id);
let def_path_hash = self.tcx.def_path_hash(def_id);
for attr in attrs {
if attr.check_name(ATTR_IF_THIS_CHANGED) {

View File

@ -9,7 +9,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use] extern crate rustc;

View File

@ -500,7 +500,7 @@ impl DirtyCleanVisitor<'tcx> {
}
fn check_item(&mut self, item_id: hir::HirId, item_span: Span) {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
let def_id = self.tcx.hir().local_def_id(item_id);
for attr in self.tcx.get_attrs(def_id).iter() {
let assertion = match self.assertion_maybe(item_id, attr) {
Some(a) => a,

View File

@ -7,7 +7,6 @@
#![cfg_attr(unix, feature(libc))]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![allow(unused_imports)]

View File

@ -899,9 +899,10 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
});
}, {
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
tcx.ensure().check_mod_loops(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_attrs(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_unstable_api_usage(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_loops(tcx.hir().local_def_id_from_node_id(module));
tcx.ensure().check_mod_attrs(tcx.hir().local_def_id_from_node_id(module));
tcx.ensure().check_mod_unstable_api_usage(
tcx.hir().local_def_id_from_node_id(module));
});
});
});
@ -924,9 +925,9 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
// "not all control paths return a value" is reported here.
//
// maybe move the check to a MIR pass?
tcx.ensure().check_mod_liveness(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_liveness(tcx.hir().local_def_id_from_node_id(module));
tcx.ensure().check_mod_intrinsics(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_intrinsics(tcx.hir().local_def_id_from_node_id(module));
});
});
});
@ -986,7 +987,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
}, {
time(sess, "privacy checking modules", || {
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
tcx.ensure().check_mod_privacy(tcx.hir().local_def_id(module));
tcx.ensure().check_mod_privacy(tcx.hir().local_def_id_from_node_id(module));
});
});
});

View File

@ -16,7 +16,7 @@ fn proc_macro_decls_static(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
let mut finder = Finder { decls: None };
tcx.hir().krate().visit_all_item_likes(&mut finder);
finder.decls.map(|id| tcx.hir().local_def_id_from_hir_id(id))
finder.decls.map(|id| tcx.hir().local_def_id(id))
}
struct Finder {

View File

@ -114,7 +114,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) => {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
let def_id = cx.tcx.hir().local_def_id(it.hir_id);
self.check_heap_type(cx, it.span, cx.tcx.type_of(def_id))
}
_ => ()
@ -125,7 +125,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemKind::Union(ref struct_def, _) => {
for struct_field in struct_def.fields() {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(struct_field.hir_id);
let def_id = cx.tcx.hir().local_def_id(struct_field.hir_id);
self.check_heap_type(cx, struct_field.span,
cx.tcx.type_of(def_id));
}
@ -500,21 +500,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
if !ast_generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.hir_id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
}
hir::ItemKind::Union(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.hir_id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
}
hir::ItemKind::Enum(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.hir_id));
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
}
_ => return,
@ -792,7 +792,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
_ => return,
};
let def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
let def_id = cx.tcx.hir().local_def_id(it.hir_id);
let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) {
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
None => {
@ -973,7 +973,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
if let hir::ItemKind::Union(ref vdata, _) = item.node {
for field in vdata.fields() {
let field_ty = ctx.tcx.type_of(
ctx.tcx.hir().local_def_id_from_hir_id(field.hir_id));
ctx.tcx.hir().local_def_id(field.hir_id));
if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
field.span,
@ -1216,7 +1216,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints {
use rustc::ty::Predicate::*;
if cx.tcx.features().trivial_bounds {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
let predicates = cx.tcx.predicates_of(def_id);
for &(predicate, span) in &predicates.predicates {
let predicate_kind_name = match predicate {
@ -1541,7 +1541,7 @@ impl ExplicitOutlivesRequirements {
ty_generics: &'tcx ty::Generics,
) -> Vec<ty::Region<'tcx>> {
let index = ty_generics.param_def_id_to_index[
&tcx.hir().local_def_id_from_hir_id(param.hir_id)];
&tcx.hir().local_def_id(param.hir_id)];
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {
@ -1659,7 +1659,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
use rustc::middle::resolve_lifetime::Region;
let infer_static = cx.tcx.features().infer_static_outlives_requirements;
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
if let hir::ItemKind::Struct(_, ref hir_generics)
| hir::ItemKind::Enum(_, ref hir_generics)
| hir::ItemKind::Union(_, ref hir_generics) = item.node

View File

@ -20,7 +20,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use]
@ -487,15 +486,17 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {
store.register_early_pass(sess, false, false, box DefaultHashTypes::new());
store.register_early_pass(sess, false, false, box LintPassImpl);
store.register_late_pass(sess, false, false, false, box TyTyKind);
store.register_group(
sess,
false,
"internal",
"rustc::internal",
None,
vec![
LintId::of(DEFAULT_HASH_TYPES),
LintId::of(USAGE_OF_TY_TYKIND),
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
LintId::of(TY_PASS_BY_REFERENCE),
LintId::of(USAGE_OF_QUALIFIED_TY),
],

View File

@ -20,7 +20,7 @@ pub enum MethodLateContext {
}
pub fn method_context(cx: &LateContext<'_, '_>, id: hir::HirId) -> MethodLateContext {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(id);
let def_id = cx.tcx.hir().local_def_id(id);
let item = cx.tcx.associated_item(def_id);
match item.container {
ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,

View File

@ -888,7 +888,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
}
fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl) {
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
let def_id = self.cx.tcx.hir().local_def_id(id);
let sig = self.cx.tcx.fn_sig(def_id);
let sig = self.cx.tcx.erase_late_bound_regions(&sig);
let inputs = if sig.c_variadic {
@ -912,7 +912,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
}
fn check_foreign_static(&mut self, id: hir::HirId, span: Span) {
let def_id = self.cx.tcx.hir().local_def_id_from_hir_id(id);
let def_id = self.cx.tcx.hir().local_def_id(id);
let ty = self.cx.tcx.type_of(def_id);
self.check_type_for_ffi_and_report_errors(span, ty);
}
@ -941,7 +941,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(it.hir_id);
let item_def_id = cx.tcx.hir().local_def_id(it.hir_id);
let t = cx.tcx.type_of(item_def_id);
let ty = cx.tcx.erase_regions(&t);
let layout = match cx.layout_of(ty) {

View File

@ -1,5 +1,6 @@
#![feature(proc_macro_hygiene)]
#![deny(rust_2018_idioms)]
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
#![recursion_limit="128"]

View File

@ -667,7 +667,7 @@ impl EncodeContext<'tcx> {
(id, md, attrs, vis): (hir::HirId, &hir::Mod, &[ast::Attribute], &hir::Visibility),
) -> Entry<'tcx> {
let tcx = self.tcx;
let def_id = tcx.hir().local_def_id_from_hir_id(id);
let def_id = tcx.hir().local_def_id(id);
debug!("EncodeContext::encode_info_for_mod({:?})", def_id);
let data = ModData {
@ -683,7 +683,7 @@ impl EncodeContext<'tcx> {
span: self.lazy(&tcx.def_span(def_id)),
attributes: self.encode_attributes(attrs),
children: self.lazy_seq(md.item_ids.iter().map(|item_id| {
tcx.hir().local_def_id_from_hir_id(item_id.id).index
tcx.hir().local_def_id(item_id.id).index
})),
stability: self.encode_stability(def_id),
deprecation: self.encode_deprecation(def_id),
@ -1105,7 +1105,7 @@ impl EncodeContext<'tcx> {
// for methods, write all the stuff get_trait_method
// needs to know
let ctor = struct_def.ctor_hir_id()
.map(|ctor_hir_id| tcx.hir().local_def_id_from_hir_id(ctor_hir_id).index);
.map(|ctor_hir_id| tcx.hir().local_def_id(ctor_hir_id).index);
let repr_options = get_repr_options(tcx, def_id);
@ -1194,7 +1194,7 @@ impl EncodeContext<'tcx> {
hir::ItemKind::ForeignMod(ref fm) => {
self.lazy_seq(fm.items
.iter()
.map(|foreign_item| tcx.hir().local_def_id_from_hir_id(
.map(|foreign_item| tcx.hir().local_def_id(
foreign_item.hir_id).index))
}
hir::ItemKind::Enum(..) => {
@ -1313,7 +1313,7 @@ impl EncodeContext<'tcx> {
/// Serialize the text of exported macros
fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> {
use syntax::print::pprust;
let def_id = self.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id);
Entry {
kind: EntryKind::MacroDef(self.lazy(&MacroDef {
body: pprust::tts_to_string(&macro_def.body.trees().collect::<Vec<_>>()),
@ -1656,7 +1656,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
}
fn visit_item(&mut self, item: &'tcx hir::Item) {
intravisit::walk_item(self, item);
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
match item.node {
hir::ItemKind::ExternCrate(_) |
hir::ItemKind::Use(..) => {} // ignore these
@ -1666,7 +1666,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
}
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
intravisit::walk_foreign_item(self, ni);
let def_id = self.tcx.hir().local_def_id_from_hir_id(ni.hir_id);
let def_id = self.tcx.hir().local_def_id(ni.hir_id);
self.record(def_id,
EncodeContext::encode_info_for_foreign_item,
(def_id, ni));
@ -1678,7 +1678,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
intravisit::walk_variant(self, v, g, id);
if let Some(ref discr) = v.node.disr_expr {
let def_id = self.tcx.hir().local_def_id_from_hir_id(discr.hir_id);
let def_id = self.tcx.hir().local_def_id(discr.hir_id);
self.record(def_id, EncodeContext::encode_info_for_anon_const, def_id);
}
}
@ -1691,7 +1691,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
self.encode_info_for_ty(ty);
}
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) {
let def_id = self.tcx.hir().local_def_id_from_hir_id(macro_def.hir_id);
let def_id = self.tcx.hir().local_def_id(macro_def.hir_id);
self.record(def_id, EncodeContext::encode_info_for_macro_def, macro_def);
}
}
@ -1710,7 +1710,7 @@ impl EncodeContext<'tcx> {
fn encode_info_for_generics(&mut self, generics: &hir::Generics) {
for param in &generics.params {
let def_id = self.tcx.hir().local_def_id_from_hir_id(param.hir_id);
let def_id = self.tcx.hir().local_def_id(param.hir_id);
match param.kind {
GenericParamKind::Lifetime { .. } => continue,
GenericParamKind::Type { ref default, .. } => {
@ -1730,7 +1730,7 @@ impl EncodeContext<'tcx> {
fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
match ty.node {
hir::TyKind::Array(_, ref length) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(length.hir_id);
let def_id = self.tcx.hir().local_def_id(length.hir_id);
self.record(def_id, EncodeContext::encode_info_for_anon_const, def_id);
}
_ => {}
@ -1740,7 +1740,7 @@ impl EncodeContext<'tcx> {
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
match expr.node {
hir::ExprKind::Closure(..) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
let def_id = self.tcx.hir().local_def_id(expr.hir_id);
self.record(def_id, EncodeContext::encode_info_for_closure, def_id);
}
_ => {}
@ -1752,7 +1752,7 @@ impl EncodeContext<'tcx> {
/// so it's easier to do that here then to wait until we would encounter
/// normally in the visitor walk.
fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
match item.node {
hir::ItemKind::Static(..) |
hir::ItemKind::Const(..) |
@ -1788,7 +1788,7 @@ impl EncodeContext<'tcx> {
// If the struct has a constructor, encode it.
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
let ctor_def_id = self.tcx.hir().local_def_id_from_hir_id(ctor_hir_id);
let ctor_def_id = self.tcx.hir().local_def_id(ctor_hir_id);
self.record(ctor_def_id,
EncodeContext::encode_struct_ctor,
(def_id, ctor_def_id));
@ -1823,7 +1823,7 @@ struct ImplVisitor<'tcx> {
impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
fn visit_item(&mut self, item: &hir::Item) {
if let hir::ItemKind::Impl(..) = item.node {
let impl_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let impl_id = self.tcx.hir().local_def_id(item.hir_id);
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
self.impls
.entry(trait_ref.def_id)

View File

@ -25,11 +25,11 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
};
let foreign_items = fm.items.iter()
.map(|it| self.tcx.hir().local_def_id_from_hir_id(it.hir_id))
.map(|it| self.tcx.hir().local_def_id(it.hir_id))
.collect();
self.modules.push(ForeignModule {
foreign_items,
def_id: self.tcx.hir().local_def_id_from_hir_id(it.hir_id),
def_id: self.tcx.hir().local_def_id(it.hir_id),
});
}

View File

@ -15,7 +15,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
extern crate libc;

View File

@ -56,7 +56,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
name: None,
kind: cstore::NativeUnknown,
cfg: None,
foreign_module: Some(self.tcx.hir().local_def_id_from_hir_id(it.hir_id)),
foreign_module: Some(self.tcx.hir().local_def_id(it.hir_id)),
wasm_import_module: None,
};
let mut kind_specified = false;

View File

@ -20,7 +20,7 @@ use rustc::mir::{
ConstraintCategory, Local, Location,
};
use rustc::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
use rustc::util::common::{self, ErrorReported};
use rustc::util::common::ErrorReported;
use rustc_data_structures::binary_search_util;
use rustc_data_structures::bit_set::BitSet;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@ -468,22 +468,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
upvars: &[Upvar],
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>,
) -> Option<ClosureRegionRequirements<'tcx>> {
common::time_ext(
infcx.tcx.sess.time_extended(),
Some(infcx.tcx.sess),
&format!("solve_nll_region_constraints({:?})", mir_def_id),
|| self.solve_inner(infcx, body, upvars, mir_def_id, errors_buffer),
)
}
fn solve_inner(
&mut self,
infcx: &InferCtxt<'_, 'tcx>,
body: &Body<'tcx>,
upvars: &[Upvar],
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>,
) -> Option<ClosureRegionRequirements<'tcx>> {
self.propagate_constraints(body);

View File

@ -768,7 +768,7 @@ fn for_each_late_bound_region_defined_on<'tcx>(
local_id: *late_bound,
};
let name = tcx.hir().name(hir_id).as_interned_str();
let region_def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let region_def_id = tcx.hir().local_def_id(hir_id);
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: fn_def_id,
bound_region: ty::BoundRegion::BrNamed(region_def_id, name),

View File

@ -69,7 +69,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
let fn_sig = cx.tables().liberated_fn_sigs()[id].clone();
let fn_def_id = tcx.hir().local_def_id_from_hir_id(id);
let fn_def_id = tcx.hir().local_def_id(id);
let ty = tcx.type_of(fn_def_id);
let mut abi = fn_sig.abi;
@ -534,7 +534,7 @@ where
let span = tcx_hir.span(fn_id);
let hir_tables = hir.tables();
let fn_def_id = tcx_hir.local_def_id_from_hir_id(fn_id);
let fn_def_id = tcx_hir.local_def_id(fn_id);
// Gather the upvars of a closure, if any.
let mut upvar_mutbls = vec![];

View File

@ -47,7 +47,7 @@ pub(crate) fn mk_eval_cx<'mir, 'tcx>(
param_env: ty::ParamEnv<'tcx>,
) -> CompileTimeEvalContext<'mir, 'tcx> {
debug!("mk_eval_cx: {:?}", param_env);
InterpCx::new(tcx.at(span), param_env, CompileTimeInterpreter::new())
InterpCx::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), Default::default())
}
pub(crate) fn eval_promoted<'mir, 'tcx>(
@ -632,7 +632,12 @@ pub fn const_eval_raw_provider<'tcx>(
}
let span = tcx.def_span(cid.instance.def_id());
let mut ecx = InterpCx::new(tcx.at(span), key.param_env, CompileTimeInterpreter::new());
let mut ecx = InterpCx::new(
tcx.at(span),
key.param_env,
CompileTimeInterpreter::new(),
Default::default()
);
let res = ecx.load_mir(cid.instance.def);
res.map(|body| {

View File

@ -331,7 +331,7 @@ An if-let pattern attempts to match the pattern, and enters the body if the
match was successful. If the match is irrefutable (when it cannot fail to
match), use a regular `let`-binding instead. For instance:
```compile_pass
```
struct Irrefutable(i32);
let irr = Irrefutable(0);
@ -360,7 +360,7 @@ A while-let pattern attempts to match the pattern, and enters the body if the
match was successful. If the match is irrefutable (when it cannot fail to
match), use a regular `let`-binding inside a `loop` instead. For instance:
```compile_pass,no_run
```no_run
struct Irrefutable(i32);
let irr = Irrefutable(0);

View File

@ -542,7 +542,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
// Now comes the rote stuff:
hir::ExprKind::Repeat(ref v, ref count) => {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(count.hir_id);
let def_id = cx.tcx.hir().local_def_id(count.hir_id);
let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id);
let instance = ty::Instance::resolve(
cx.tcx.global_tcx(),
@ -910,9 +910,9 @@ fn convert_path_expr<'a, 'tcx>(
Res::Def(DefKind::ConstParam, def_id) => {
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
let item_id = cx.tcx.hir().get_parent_node(hir_id);
let item_def_id = cx.tcx.hir().local_def_id_from_hir_id(item_id);
let item_def_id = cx.tcx.hir().local_def_id(item_id);
let generics = cx.tcx.generics_of(item_def_id);
let local_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
let local_def_id = cx.tcx.hir().local_def_id(hir_id);
let index = generics.param_def_id_to_index[&local_def_id];
let name = cx.tcx.hir().name(hir_id).as_interned_str();
let val = ConstValue::Param(ty::ParamConst::new(index, name));
@ -1191,7 +1191,7 @@ fn capture_upvar<'tcx>(
) -> ExprRef<'tcx> {
let upvar_id = ty::UpvarId {
var_path: ty::UpvarPath { hir_id: var_hir_id },
closure_expr_id: cx.tcx.hir().local_def_id_from_hir_id(closure_expr.hir_id).to_local(),
closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.hir_id).to_local(),
};
let upvar_capture = cx.tables().upvar_capture(upvar_id);
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);

View File

@ -54,7 +54,7 @@ pub struct Cx<'a, 'tcx> {
impl<'a, 'tcx> Cx<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>, src_id: hir::HirId) -> Cx<'a, 'tcx> {
let tcx = infcx.tcx;
let src_def_id = tcx.hir().local_def_id_from_hir_id(src_id);
let src_def_id = tcx.hir().local_def_id(src_id);
let tables = tcx.typeck_tables_of(src_def_id);
let body_owner_kind = tcx.hir().body_owner_kind(src_id);

View File

@ -196,12 +196,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
}
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
pub fn new(tcx: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M) -> Self {
pub fn new(
tcx: TyCtxtAt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
machine: M,
memory_extra: M::MemoryExtra,
) -> Self {
InterpCx {
machine,
tcx,
param_env,
memory: Memory::new(tcx),
memory: Memory::new(tcx, memory_extra),
stack: Vec::new(),
vtables: FxHashMap::default(),
}

View File

@ -73,7 +73,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
/// Extra data stored in memory. A reference to this is available when `AllocExtra`
/// gets initialized, so you can e.g., have an `Rc` here if there is global state you
/// need access to in the `AllocExtra` hooks.
type MemoryExtra: Default;
type MemoryExtra;
/// Extra data stored in every allocation.
type AllocExtra: AllocationExtra<Self::PointerTag> + 'static;

View File

@ -106,11 +106,11 @@ where
}
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
pub fn new(tcx: TyCtxtAt<'tcx>) -> Self {
pub fn new(tcx: TyCtxtAt<'tcx>, extra: M::MemoryExtra) -> Self {
Memory {
alloc_map: M::MemoryMap::default(),
dead_alloc_map: FxHashMap::default(),
extra: M::MemoryExtra::default(),
extra,
tcx,
}
}

View File

@ -29,7 +29,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use] extern crate log;

View File

@ -989,7 +989,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
hir::ItemKind::Union(_, ref generics) => {
if generics.params.is_empty() {
if self.mode == MonoItemCollectionMode::Eager {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
debug!("RootCollector: ADT drop-glue for {}",
def_id_to_string(self.tcx, def_id));
@ -1001,11 +1001,11 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
hir::ItemKind::GlobalAsm(..) => {
debug!("RootCollector: ItemKind::GlobalAsm({})",
def_id_to_string(self.tcx,
self.tcx.hir().local_def_id_from_hir_id(item.hir_id)));
self.tcx.hir().local_def_id(item.hir_id)));
self.output.push(MonoItem::GlobalAsm(item.hir_id));
}
hir::ItemKind::Static(..) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
debug!("RootCollector: ItemKind::Static({})",
def_id_to_string(self.tcx, def_id));
self.output.push(MonoItem::Static(def_id));
@ -1015,7 +1015,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
// actually used somewhere. Just declaring them is insufficient.
// but even just declaring them must collect the items they refer to
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
let instance = Instance::mono(self.tcx, def_id);
let cid = GlobalId {
@ -1029,7 +1029,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
}
}
hir::ItemKind::Fn(..) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let def_id = self.tcx.hir().local_def_id(item.hir_id);
self.push_if_root(def_id);
}
}
@ -1043,7 +1043,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
match ii.node {
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
let def_id = self.tcx.hir().local_def_id_from_hir_id(ii.hir_id);
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
self.push_if_root(def_id);
}
_ => { /* Nothing to do here */ }
@ -1136,7 +1136,7 @@ fn create_mono_items_for_default_impls<'tcx>(
}
}
let impl_def_id = tcx.hir().local_def_id_from_hir_id(item.hir_id);
let impl_def_id = tcx.hir().local_def_id(item.hir_id);
debug!("create_mono_items_for_default_impls(item={})",
def_id_to_string(tcx, impl_def_id));

View File

@ -55,7 +55,7 @@ pub trait MonoItemExt<'tcx>: fmt::Debug {
tcx.symbol_name(Instance::mono(tcx, def_id))
}
MonoItem::GlobalAsm(hir_id) => {
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
ty::SymbolName {
name: InternedString::intern(&format!("global_asm_{:?}", def_id))
}

View File

@ -314,7 +314,7 @@ fn mono_item_visibility(
};
}
MonoItem::GlobalAsm(hir_id) => {
let def_id = tcx.hir().local_def_id_from_hir_id(*hir_id);
let def_id = tcx.hir().local_def_id(*hir_id);
return if tcx.is_reachable_non_generic(def_id) {
*can_be_internalized = false;
default_visibility(tcx, def_id, false)
@ -698,7 +698,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
Some(def_id)
}
MonoItem::Static(def_id) => Some(def_id),
MonoItem::GlobalAsm(hir_id) => Some(tcx.hir().local_def_id_from_hir_id(hir_id)),
MonoItem::GlobalAsm(hir_id) => Some(tcx.hir().local_def_id(hir_id)),
}
}

View File

@ -78,7 +78,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet {
_: hir::HirId,
_: Span) {
if let hir::VariantData::Tuple(_, hir_id) = *v {
self.set.insert(self.tcx.hir().local_def_id_from_hir_id(hir_id));
self.set.insert(self.tcx.hir().local_def_id(hir_id));
}
intravisit::walk_struct_def(self, v)
}

View File

@ -29,7 +29,7 @@ struct VarianceTest<'tcx> {
impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item) {
let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let item_def_id = self.tcx.hir().local_def_id(item.hir_id);
if let ItemKind::Ty(..) = item.node {
for attr in self.tcx.get_attrs(item_def_id).iter() {

View File

@ -14,7 +14,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use]

View File

@ -165,7 +165,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability {
let item_id = self.tcx.hir().body_owner(body_id);
let item_def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
let item_def_id = self.tcx.hir().local_def_id(item_id);
let outer_in_fn = self.in_fn;
let outer_tables = self.tables;
@ -451,7 +451,7 @@ fn check_expr_kind<'a, 'tcx>(
let nested_body_promotable = v.check_nested_body(body_id);
// Paths in constant contexts cannot refer to local variables,
// as there are none, and thus closures can't have upvars there.
let closure_def_id = v.tcx.hir().local_def_id_from_hir_id(e.hir_id);
let closure_def_id = v.tcx.hir().local_def_id(e.hir_id);
if !v.tcx.upvars(closure_def_id).map_or(true, |v| v.is_empty()) {
NotPromotable
} else {

View File

@ -44,7 +44,7 @@ fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
0 => None,
1 => {
let (hir_id, _) = finder.registrars.pop().unwrap();
Some(tcx.hir().local_def_id_from_hir_id(hir_id))
Some(tcx.hir().local_def_id(hir_id))
},
_ => {
let diagnostic = tcx.sess.diagnostic();

View File

@ -1,7 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(in_band_lifetimes)]
@ -250,13 +249,13 @@ fn def_id_visibility<'tcx>(
let parent_hir_id = tcx.hir().get_parent_node(hir_id);
match tcx.hir().get(parent_hir_id) {
Node::Variant(..) => {
let parent_did = tcx.hir().local_def_id_from_hir_id(parent_hir_id);
let parent_did = tcx.hir().local_def_id(parent_hir_id);
let (mut ctor_vis, mut span, mut descr) = def_id_visibility(
tcx, parent_did,
);
let adt_def = tcx.adt_def(tcx.hir().get_parent_did(hir_id));
let ctor_did = tcx.hir().local_def_id_from_hir_id(
let ctor_did = tcx.hir().local_def_id(
vdata.ctor_hir_id().unwrap());
let variant = adt_def.variant_with_ctor_id(ctor_did);
@ -333,7 +332,7 @@ fn item_tables<'a, 'tcx>(
hir_id: hir::HirId,
empty_tables: &'a ty::TypeckTables<'tcx>,
) -> &'a ty::TypeckTables<'tcx> {
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables }
}
@ -394,7 +393,7 @@ trait VisibilityLike: Sized {
access_levels: &AccessLevels,
) -> Self {
let mut find = FindMin { tcx, access_levels, min: Self::MAX };
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = tcx.hir().local_def_id(hir_id);
find.visit(tcx.type_of(def_id));
if let Some(trait_ref) = tcx.impl_trait_ref(def_id) {
find.visit_trait(trait_ref);
@ -475,7 +474,7 @@ impl EmbargoVisitor<'tcx> {
) -> ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
ReachEverythingInTheInterfaceVisitor {
access_level: cmp::min(access_level, Some(AccessLevel::Reachable)),
item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
item_def_id: self.tcx.hir().local_def_id(item_id),
ev: self,
}
}
@ -506,7 +505,7 @@ impl EmbargoVisitor<'tcx> {
if let hir::ItemKind::Mod(m) = &item.node {
for item_id in m.item_ids.as_ref() {
let item = self.tcx.hir().expect_item(item_id.id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id.id);
let def_id = self.tcx.hir().local_def_id(item_id.id);
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
if let hir::ItemKind::Use(..) = item.node {
self.update(item.hir_id, Some(AccessLevel::Exported));
@ -726,7 +725,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_level.is_some() {
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
let def_id = self.tcx.hir().local_def_id(id);
if let Some(exports) = self.tcx.module_exports(def_id) {
for export in exports.iter() {
if export.vis == ty::Visibility::Public {
@ -751,7 +750,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
let module_did = ty::DefIdTree::parent(
self.tcx,
self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
self.tcx.hir().local_def_id(md.hir_id)
).unwrap();
let mut module_id = self.tcx.hir().as_local_hir_id(module_did).unwrap();
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
@ -772,7 +771,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
for id in &module.item_ids {
self.update(id.id, level);
}
let def_id = self.tcx.hir().local_def_id_from_hir_id(module_id);
let def_id = self.tcx.hir().local_def_id(module_id);
if let Some(exports) = self.tcx.module_exports(def_id) {
for export in exports.iter() {
if let Some(hir_id) = self.tcx.hir().as_local_hir_id(export.res.def_id()) {
@ -1163,7 +1162,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
// Check types in item interfaces.
fn visit_item(&mut self, item: &'tcx hir::Item) {
let orig_current_item = mem::replace(&mut self.current_item,
self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
self.tcx.hir().local_def_id(item.hir_id));
let orig_in_body = mem::replace(&mut self.in_body, false);
let orig_tables =
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
@ -1689,7 +1688,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
SearchInterfaceForPrivateItemsVisitor {
tcx: self.tcx,
item_id,
item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
item_def_id: self.tcx.hir().local_def_id(item_id),
span: self.tcx.hir().span(item_id),
required_visibility,
has_pub_restricted: self.has_pub_restricted,

View File

@ -11,7 +11,6 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
pub use rustc::hir::def::{Namespace, PerNS};

View File

@ -19,9 +19,8 @@ use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::expand::{AstFragment, Invocation, InvocationKind};
use syntax::ext::hygiene::Mark;
use syntax::ext::tt::macro_rules;
use syntax::feature_gate::{
feature_err, is_builtin_attr_name, AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES,
};
use syntax::feature_gate::{feature_err, emit_feature_err, is_builtin_attr_name};
use syntax::feature_gate::{AttributeGate, GateIssue, Stability, BUILTIN_ATTRIBUTES};
use syntax::symbol::{Symbol, kw, sym};
use syntax::visit::Visitor;
use syntax::util::lev_distance::find_best_match_for_name;
@ -298,12 +297,25 @@ impl<'a> Resolver<'a> {
let res = self.resolve_macro_to_res_inner(path, kind, parent_scope, trace, force);
// Report errors and enforce feature gates for the resolved macro.
let features = self.session.features_untracked();
if res != Err(Determinacy::Undetermined) {
// Do not report duplicated errors on every undetermined resolution.
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";
emit_feature_err(
&self.session.parse_sess,
sym::rustc_attrs,
segment.ident.span,
GateIssue::Language,
msg,
);
}
}
}
@ -320,24 +332,15 @@ impl<'a> Resolver<'a> {
}
Res::NonMacroAttr(attr_kind) => {
if kind == MacroKind::Attr {
let features = self.session.features_untracked();
if attr_kind == NonMacroAttrKind::Custom {
assert!(path.segments.len() == 1);
let name = path.segments[0].ident.as_str();
if name.starts_with("rustc_") {
if !features.rustc_attrs {
let msg = "unless otherwise specified, attributes with the prefix \
`rustc_` are reserved for internal compiler diagnostics";
self.report_unknown_attribute(path.span, &name, msg,
sym::rustc_attrs);
}
} else if !features.custom_attribute {
if !features.custom_attribute {
let msg = format!("The attribute `{}` is currently unknown to the \
compiler and may have meaning added to it in the \
future", path);
self.report_unknown_attribute(
path.span,
&name,
&path.segments[0].ident.as_str(),
&msg,
sym::custom_attribute,
);

View File

@ -123,7 +123,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
where
F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, O>),
{
let item_def_id = self.tcx.hir().local_def_id(item_id);
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
if self.tcx.has_typeck_tables(item_def_id) {
let tables = self.tcx.typeck_tables_of(item_def_id);
let old_tables = self.save_ctxt.tables;
@ -436,7 +436,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
attrs: &'l [Attribute],
) {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
if !self.span.filter_generated(ident.span) {
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
@ -481,7 +481,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
debug!("process_struct {:?} {:?}", item, item.span);
let name = item.ident.to_string();
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
let kind = match item.node {
ast::ItemKind::Struct(_, _) => DefKind::Struct,
@ -683,7 +683,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
self.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
let map = &self.tcx.hir();
self.process_impl_item(impl_item, map.local_def_id(item.id));
self.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id));
}
}
@ -696,7 +696,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
) {
let name = item.ident.to_string();
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
let mut val = name.clone();
if !generics.params.is_empty() {
val.push_str(&generic_params_to_string(&generics.params));
@ -764,7 +764,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
self.process_generic_params(generics, &qualname, item.id);
for method in methods {
let map = &self.tcx.hir();
self.process_trait_item(method, map.local_def_id(item.id))
self.process_trait_item(method, map.local_def_id_from_node_id(item.id))
}
}
@ -1109,7 +1109,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
// FIXME do something with _bounds (for type refs)
let name = trait_item.ident.name.to_string();
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(trait_item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(trait_item.id)));
if !self.span.filter_generated(trait_item.ident.span) {
let span = self.span_from_span(trait_item.ident.span);
@ -1217,7 +1217,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
let access = access_from!(self.save_ctxt, root_item, hir_id);
// The parent `DefId` of a given use tree is always the enclosing item.
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id)
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(id)
.and_then(|id| self.save_ctxt.tcx.parent(id))
.map(id_from_def_id);
@ -1261,7 +1261,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
};
// Make a comma-separated list of names of imported modules.
let def_id = self.tcx.hir().local_def_id(id);
let def_id = self.tcx.hir().local_def_id_from_node_id(id);
let names = self.tcx.names_imported_by_glob_use(def_id);
let names: Vec<_> = names.iter().map(|n| n.to_string()).collect();
@ -1318,7 +1318,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
assert_eq!(id, ast::CRATE_NODE_ID);
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id)));
let cm = self.tcx.sess.source_map();
let filename = cm.span_to_filename(span);
@ -1367,7 +1367,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
let name_span = item.ident.span;
if !self.span.filter_generated(name_span) {
let span = self.span_from_span(name_span);
let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id)
let parent = self.save_ctxt.tcx.hir().opt_local_def_id_from_node_id(item.id)
.and_then(|id| self.save_ctxt.tcx.parent(id))
.map(id_from_def_id);
self.dumper.import(
@ -1408,7 +1408,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
}
Ty(ref ty, ref ty_params) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
let value = ty_to_string(&ty);
if !self.span.filter_generated(item.ident.span) {
let span = self.span_from_span(item.ident.span);
@ -1439,7 +1439,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
}
Existential(ref _bounds, ref ty_params) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
// FIXME do something with _bounds
let value = String::new();
if !self.span.filter_generated(item.ident.span) {

View File

@ -1,7 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(nll)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![allow(unused_attributes)]
@ -135,7 +134,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
match item.node {
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
filter!(self.span_utils, item.ident.span);
@ -186,7 +185,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
match item.node {
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
filter!(self.span_utils, item.ident.span);
Some(Data::DefData(Def {
kind: DefKind::Function,
@ -205,7 +204,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
ast::ItemKind::Static(ref typ, ..) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
filter!(self.span_utils, item.ident.span);
@ -229,7 +228,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
ast::ItemKind::Const(ref typ, _) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
filter!(self.span_utils, item.ident.span);
let id = id_from_node_id(item.id, self);
@ -252,7 +251,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
}
ast::ItemKind::Mod(ref m) => {
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
let cm = self.tcx.sess.source_map();
let filename = cm.span_to_filename(m.inner);
@ -280,7 +279,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
ast::ItemKind::Enum(ref def, _) => {
let name = item.ident.to_string();
let qualname = format!("::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(item.id)));
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
filter!(self.span_utils, item.ident.span);
let variants_str = def.variants
.iter()
@ -365,10 +364,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
if let Some(ident) = field.ident {
let name = ident.to_string();
let qualname = format!("::{}::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id(scope)),
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(scope)),
ident);
filter!(self.span_utils, ident.span);
let def_id = self.tcx.hir().local_def_id(field.id);
let def_id = self.tcx.hir().local_def_id_from_node_id(field.id);
let typ = self.tcx.type_of(def_id).to_string();
@ -400,7 +399,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
// The qualname for a method is the trait name or name of the struct in an impl in
// which the method is declared in, followed by the method's name.
let (qualname, parent_scope, decl_id, docs, attributes) =
match self.tcx.impl_of_method(self.tcx.hir().local_def_id(id)) {
match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) {
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
Some(Node::Item(item)) => match item.node {
hir::ItemKind::Impl(.., ref ty, _) => {
@ -451,7 +450,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
);
}
},
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id(id)) {
None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id_from_node_id(id)) {
Some(def_id) => {
let mut docs = String::new();
let mut attrs = vec![];
@ -1193,7 +1192,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id {
}
fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
let def_id = scx.tcx.hir().opt_local_def_id(id);
let def_id = scx.tcx.hir().opt_local_def_id_from_node_id(id);
def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| {
// Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId`
// out of the maximum u32 value. This will work unless you have *billions*

View File

@ -167,20 +167,23 @@ fn cast_target(cls: &[Option<Class>], size: Size) -> CastTarget {
target
}
const MAX_INT_REGS: usize = 6; // RDI, RSI, RDX, RCX, R8, R9
const MAX_SSE_REGS: usize = 8; // XMM0-7
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
{
let mut int_regs = 6; // RDI, RSI, RDX, RCX, R8, R9
let mut sse_regs = 8; // XMM0-7
let mut int_regs = MAX_INT_REGS;
let mut sse_regs = MAX_SSE_REGS;
let mut x86_64_ty = |arg: &mut ArgType<'a, Ty>, is_arg: bool| {
let mut cls_or_mem = classify_arg(cx, arg);
let mut needed_int = 0;
let mut needed_sse = 0;
if is_arg {
if let Ok(cls) = cls_or_mem {
let mut needed_int = 0;
let mut needed_sse = 0;
for &c in &cls {
match c {
Some(Class::Int) => needed_int += 1,
@ -188,8 +191,20 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
_ => {}
}
}
if arg.layout.is_aggregate() && (int_regs < needed_int || sse_regs < needed_sse) {
cls_or_mem = Err(Memory);
match (int_regs.checked_sub(needed_int), sse_regs.checked_sub(needed_sse)) {
(Some(left_int), Some(left_sse)) => {
int_regs = left_int;
sse_regs = left_sse;
}
_ => {
// Not enough registers for this argument, so it will be
// passed on the stack, but we only mark aggregates
// explicitly as indirect `byval` arguments, as LLVM will
// automatically put immediates on the stack itself.
if arg.layout.is_aggregate() {
cls_or_mem = Err(Memory);
}
}
}
}
}
@ -201,14 +216,14 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
} else {
// `sret` parameter thus one less integer register available
arg.make_indirect();
// NOTE(eddyb) return is handled first, so no registers
// should've been used yet.
assert_eq!(int_regs, MAX_INT_REGS);
int_regs -= 1;
}
}
Ok(ref cls) => {
// split into sized chunks passed individually
int_regs -= needed_int;
sse_regs -= needed_sse;
if arg.layout.is_aggregate() {
let size = arg.layout.size;
arg.cast_to(cast_target(cls, size))

View File

@ -16,7 +16,6 @@
#![feature(step_trait)]
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#[macro_use] extern crate log;

View File

@ -2,7 +2,6 @@
//! the guts are broken up into modules; see the comments in those modules.
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
#![feature(crate_visibility_modifier)]

View File

@ -628,7 +628,7 @@ struct ClauseDumper<'tcx> {
impl ClauseDumper<'tcx> {
fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
let def_id = self.tcx.hir().local_def_id(hir_id);
for attr in attrs {
let mut clauses = None;

View File

@ -1999,7 +1999,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
let item_id = tcx.hir().get_parent_node(hir_id);
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
let item_def_id = tcx.hir().local_def_id(item_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id];
tcx.mk_ty_param(index, tcx.hir().name(hir_id).as_interned_str())
@ -2091,7 +2091,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.res_to_ty(opt_self_ty, path, false)
}
hir::TyKind::Def(item_id, ref lifetimes) => {
let did = tcx.hir().local_def_id_from_hir_id(item_id.id);
let did = tcx.hir().local_def_id(item_id.id);
self.impl_trait_ty_to_ty(did, lifetimes)
}
hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
@ -2173,7 +2173,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
debug!("ast_const_to_const(id={:?}, ast_const={:?})", ast_const.hir_id, ast_const);
let tcx = self.tcx();
let def_id = tcx.hir().local_def_id_from_hir_id(ast_const.hir_id);
let def_id = tcx.hir().local_def_id(ast_const.hir_id);
let mut const_ = ty::Const {
val: ConstValue::Unevaluated(
@ -2189,9 +2189,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// parent item and construct a `ParamConst`.
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
let item_id = tcx.hir().get_parent_node(hir_id);
let item_def_id = tcx.hir().local_def_id_from_hir_id(item_id);
let item_def_id = tcx.hir().local_def_id(item_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&tcx.hir().local_def_id_from_hir_id(hir_id)];
let index = generics.param_def_id_to_index[&tcx.hir().local_def_id(hir_id)];
let name = tcx.hir().name(hir_id).as_interned_str();
const_.val = ConstValue::Param(ty::ParamConst::new(index, name));
}

View File

@ -72,7 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
opt_kind, expected_sig
);
let expr_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
let expr_def_id = self.tcx.hir().local_def_id(expr.hir_id);
let ClosureSignatures {
bound_sig,

View File

@ -901,7 +901,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr: &'tcx hir::Expr,
) -> Ty<'tcx> {
let tcx = self.tcx;
let count_def_id = tcx.hir().local_def_id_from_hir_id(count.hir_id);
let count_def_id = tcx.hir().local_def_id(count.hir_id);
let count = if self.const_param_def_id(count).is_some() {
Ok(self.to_const(count, tcx.type_of(count_def_id)))
} else {

View File

@ -22,7 +22,7 @@ fn equate_intrinsic_type<'tcx>(
inputs: Vec<Ty<'tcx>>,
output: Ty<'tcx>,
) {
let def_id = tcx.hir().local_def_id_from_hir_id(it.hir_id);
let def_id = tcx.hir().local_def_id(it.hir_id);
match it.node {
hir::ForeignItemKind::Fn(..) => {}

View File

@ -196,7 +196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
)?;
for import_id in &pick.import_ids {
let import_def_id = self.tcx.hir().local_def_id_from_hir_id(*import_id);
let import_def_id = self.tcx.hir().local_def_id(*import_id);
debug!("used_trait_import: {:?}", import_def_id);
Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
.unwrap().insert(import_def_id);
@ -434,7 +434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self_ty, expr_id, ProbeScope::TraitsInScope)?;
debug!("resolve_ufcs: pick={:?}", pick);
for import_id in pick.import_ids {
let import_def_id = tcx.hir().local_def_id_from_hir_id(import_id);
let import_def_id = tcx.hir().local_def_id(import_id);
debug!("resolve_ufcs: used_trait_import: {:?}", import_def_id);
Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports)
.unwrap().insert(import_def_id);

Some files were not shown because too many files have changed in this diff Show More