Rollup merge of #58300 - taiki-e:librustc_typeck-2018, r=petrochenkov

librustc_typeck => 2018

Transitions `librustc_typeck` to Rust 2018; cc #58099

TODO: elided_lifetimes_in_paths

r? @Centril
This commit is contained in:
Mazdak Farrokhzad 2019-02-12 04:42:21 +01:00 committed by GitHub
commit a84c93324c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 98 additions and 100 deletions

View File

@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "rustc_typeck"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_typeck"
@ -14,7 +15,7 @@ arena = { path = "../libarena" }
log = "0.4"
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }

View File

@ -3,13 +3,13 @@
//! instance of `AstConv`.
use errors::{Applicability, DiagnosticId};
use hir::{self, GenericArg, GenericArgs};
use hir::def::Def;
use hir::def_id::DefId;
use hir::HirVec;
use lint;
use middle::resolve_lifetime as rl;
use namespace::Namespace;
use crate::hir::{self, GenericArg, GenericArgs};
use crate::hir::def::Def;
use crate::hir::def_id::DefId;
use crate::hir::HirVec;
use crate::lint;
use crate::middle::resolve_lifetime as rl;
use crate::namespace::Namespace;
use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc::traits;
use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable};
@ -18,15 +18,15 @@ use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::ty::wf::object_region_bounds;
use rustc_data_structures::sync::Lrc;
use rustc_target::spec::abi;
use require_c_abi_if_variadic;
use crate::require_c_abi_if_variadic;
use smallvec::SmallVec;
use syntax::ast;
use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::ptr::P;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::{DUMMY_SP, Span, MultiSpan};
use util::common::ErrorReported;
use util::nodemap::FxHashMap;
use crate::util::common::ErrorReported;
use crate::util::nodemap::FxHashMap;
use std::collections::BTreeSet;
use std::iter;

View File

@ -1,5 +1,6 @@
use check::{FnCtxt, Expectation, Diverges, Needs};
use check::coercion::CoerceMany;
use crate::check::{FnCtxt, Expectation, Diverges, Needs};
use crate::check::coercion::CoerceMany;
use crate::util::nodemap::FxHashMap;
use errors::Applicability;
use rustc::hir::{self, PatKind};
use rustc::hir::def::{Def, CtorKind};
@ -13,7 +14,6 @@ use syntax::source_map::Spanned;
use syntax::ptr::P;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::Span;
use util::nodemap::FxHashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::cmp;

View File

@ -31,8 +31,8 @@
use super::FnCtxt;
use errors::{DiagnosticBuilder,Applicability};
use hir::def_id::DefId;
use lint;
use crate::hir::def_id::DefId;
use crate::lint;
use rustc::hir;
use rustc::session::Session;
use rustc::traits;
@ -43,7 +43,7 @@ use rustc::ty::subst::Substs;
use rustc::middle::lang_items;
use syntax::ast;
use syntax_pos::Span;
use util::common::ErrorReported;
use crate::util::common::ErrorReported;
/// Reifies a cast check to be checked once we have full type information for
/// a function context.
@ -294,7 +294,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
.emit();
}
CastError::SizedUnsizedCast => {
use structured_errors::{SizedUnsizedCastError, StructuredDiagnostic};
use crate::structured_errors::{SizedUnsizedCastError, StructuredDiagnostic};
SizedUnsizedCastError::new(&fcx.tcx.sess,
self.span,
self.expr_ty,

View File

@ -2,8 +2,8 @@
use super::{check_fn, Expectation, FnCtxt, GeneratorTypes};
use astconv::AstConv;
use middle::region;
use crate::astconv::AstConv;
use crate::middle::region;
use rustc::hir::def_id::DefId;
use rustc::infer::{InferOk, InferResult};
use rustc::infer::LateBoundRegionConversionTime;

View File

@ -50,7 +50,7 @@
//! sort of a minor point so I've opted to leave it for later---after all
//! we may want to adjust precisely when coercions occur.
use check::{FnCtxt, Needs};
use crate::check::{FnCtxt, Needs};
use errors::DiagnosticBuilder;
use rustc::hir;
use rustc::hir::def_id::DefId;

View File

@ -1,4 +1,4 @@
use check::FnCtxt;
use crate::check::FnCtxt;
use rustc::infer::InferOk;
use rustc::traits::{ObligationCause, ObligationCauseCode};

View File

@ -1,13 +1,13 @@
use check::regionck::RegionCtxt;
use crate::check::regionck::RegionCtxt;
use hir::def_id::DefId;
use crate::hir::def_id::DefId;
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::infer::{self, InferOk, SuppressRegionErrors};
use rustc::middle::region;
use rustc::traits::{ObligationCause, TraitEngine, TraitEngineExt};
use rustc::ty::subst::{Subst, Substs, UnpackedKind};
use rustc::ty::{self, Ty, TyCtxt};
use util::common::ErrorReported;
use crate::util::common::ErrorReported;
use syntax::ast;
use syntax_pos::Span;

View File

@ -11,7 +11,7 @@ use rustc::ty::{self, Ty};
use rustc_data_structures::sync::Lrc;
use syntax_pos::Span;
use super::FnCtxt;
use util::nodemap::FxHashMap;
use crate::util::nodemap::FxHashMap;
struct InteriorVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,

View File

@ -4,7 +4,7 @@
use rustc::traits::{ObligationCause, ObligationCauseCode};
use rustc::ty::{self, TyCtxt, Ty};
use rustc::ty::subst::Subst;
use require_same_types;
use crate::require_same_types;
use rustc_target::spec::abi::Abi;
use syntax::symbol::Symbol;

View File

@ -1,9 +1,9 @@
use super::{probe, MethodCallee};
use astconv::AstConv;
use check::{FnCtxt, PlaceOp, callee, Needs};
use hir::GenericArg;
use hir::def_id::DefId;
use crate::astconv::AstConv;
use crate::check::{FnCtxt, PlaceOp, callee, Needs};
use crate::hir::GenericArg;
use crate::hir::def_id::DefId;
use rustc::ty::subst::Substs;
use rustc::traits;
use rustc::ty::{self, Ty, GenericParamDefKind};

View File

@ -10,9 +10,9 @@ pub use self::MethodError::*;
pub use self::CandidateSource::*;
pub use self::suggest::{SelfSource, TraitInfo};
use check::FnCtxt;
use crate::check::FnCtxt;
use crate::namespace::Namespace;
use errors::{Applicability, DiagnosticBuilder};
use namespace::Namespace;
use rustc_data_structures::sync::Lrc;
use rustc::hir;
use rustc::hir::def::Def;
@ -29,7 +29,7 @@ use syntax_pos::Span;
use crate::{check_type_alias_enum_variants_enabled};
use self::probe::{IsSuggestion, ProbeScope};
pub fn provide(providers: &mut ty::query::Providers) {
pub fn provide(providers: &mut ty::query::Providers<'_>) {
suggest::provide(providers);
probe::provide(providers);
}

View File

@ -3,11 +3,11 @@ use super::NoMatchData;
use super::{CandidateSource, ImplSource, TraitSource};
use super::suggest;
use check::autoderef::{self, Autoderef};
use check::FnCtxt;
use hir::def_id::DefId;
use hir::def::Def;
use namespace::Namespace;
use crate::check::autoderef::{self, Autoderef};
use crate::check::FnCtxt;
use crate::hir::def_id::DefId;
use crate::hir::def::Def;
use crate::namespace::Namespace;
use rustc_data_structures::sync::Lrc;
use rustc::hir;

View File

@ -1,10 +1,11 @@
//! Give useful errors and suggestions to users when an item can't be
//! found or is otherwise invalid.
use check::FnCtxt;
use crate::check::FnCtxt;
use crate::middle::lang_items::FnOnceTraitLangItem;
use crate::namespace::Namespace;
use crate::util::nodemap::FxHashSet;
use errors::{Applicability, DiagnosticBuilder};
use middle::lang_items::FnOnceTraitLangItem;
use namespace::Namespace;
use rustc_data_structures::sync::Lrc;
use rustc::hir::{self, ExprKind, Node, QPath};
use rustc::hir::def::Def;
@ -15,7 +16,6 @@ use rustc::infer::type_variable::TypeVariableOrigin;
use rustc::traits::Obligation;
use rustc::ty::{self, Adt, Ty, TyCtxt, ToPolyTraitRef, ToPredicate, TypeFoldable};
use rustc::ty::item_path::with_crate_prefix;
use util::nodemap::FxHashSet;
use syntax_pos::{Span, FileName};
use syntax::ast;
use syntax::util::lev_distance::find_best_match_for_name;

View File

@ -83,15 +83,15 @@ mod generator_interior;
pub mod intrinsic;
mod op;
use astconv::{AstConv, PathSeg};
use crate::astconv::{AstConv, PathSeg};
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath};
use rustc::hir::def::{CtorKind, Def};
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use middle::lang_items;
use namespace::Namespace;
use crate::middle::lang_items;
use crate::namespace::Namespace;
use rustc::infer::{self, InferCtxt, InferOk, InferResult, RegionVariableOrigin};
use rustc::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse};
use rustc_data_structures::indexed_vec::Idx;
@ -130,14 +130,14 @@ use std::mem::replace;
use std::ops::{self, Deref};
use std::slice;
use require_c_abi_if_variadic;
use session::{CompileIncomplete, Session};
use session::config::EntryFnType;
use TypeAndSubsts;
use lint;
use util::captures::Captures;
use util::common::{ErrorReported, indenter};
use util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
use crate::require_c_abi_if_variadic;
use crate::session::{CompileIncomplete, Session};
use crate::session::config::EntryFnType;
use crate::TypeAndSubsts;
use crate::lint;
use crate::util::captures::Captures;
use crate::util::common::{ErrorReported, indenter};
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
pub use self::Expectation::*;
use self::autoderef::Autoderef;
@ -3044,7 +3044,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// arguments which we skipped above.
if variadic {
fn variadic_error<'tcx>(s: &Session, span: Span, t: Ty<'tcx>, cast_ty: &str) {
use structured_errors::{VariadicError, StructuredDiagnostic};
use crate::structured_errors::{VariadicError, StructuredDiagnostic};
VariadicError::new(s, span, t, cast_ty).diagnostic().emit();
}
@ -3685,8 +3685,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
display
}
fn no_such_field_err<T: Display>(&self, span: Span, field: T, expr_t: &ty::TyS)
-> DiagnosticBuilder {
fn no_such_field_err<T: Display>(&self, span: Span, field: T, expr_t: &ty::TyS<'_>)
-> DiagnosticBuilder<'_> {
type_error_struct!(self.tcx().sess, span, expr_t, E0609,
"no field `{}` on type `{}`",
field, expr_t)
@ -5257,7 +5257,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
&self,
blk: &'gcx hir::Block,
expected_ty: Ty<'tcx>,
err: &mut DiagnosticBuilder,
err: &mut DiagnosticBuilder<'_>,
) {
if let Some(span_semi) = self.could_remove_semicolon(blk, expected_ty) {
err.span_suggestion(
@ -5725,7 +5725,7 @@ fn fatally_break_rust(sess: &Session) {
);
handler.note_without_error(&format!("rustc {} running on {}",
option_env!("CFG_VERSION").unwrap_or("unknown_version"),
::session::config::host_triple(),
crate::session::config::host_triple(),
));
}

View File

@ -72,11 +72,11 @@
//! relation, except that a borrowed pointer never owns its
//! contents.
use check::dropck;
use check::FnCtxt;
use middle::mem_categorization as mc;
use middle::mem_categorization::Categorization;
use middle::region;
use crate::check::dropck;
use crate::check::FnCtxt;
use crate::middle::mem_categorization as mc;
use crate::middle::mem_categorization::Categorization;
use crate::middle::region;
use rustc::hir::def_id::DefId;
use rustc::infer::outlives::env::OutlivesEnvironment;
use rustc::infer::{self, RegionObligation, SuppressRegionErrors};

View File

@ -32,9 +32,9 @@
use super::FnCtxt;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::mem_categorization::Categorization;
use crate::middle::expr_use_visitor as euv;
use crate::middle::mem_categorization as mc;
use crate::middle::mem_categorization::Categorization;
use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::LocalDefId;

View File

@ -1,7 +1,7 @@
use check::{Inherited, FnCtxt};
use constrained_type_params::{identify_constrained_type_params, Parameter};
use crate::check::{Inherited, FnCtxt};
use crate::constrained_type_params::{identify_constrained_type_params, Parameter};
use hir::def_id::DefId;
use crate::hir::def_id::DefId;
use rustc::traits::{self, ObligationCauseCode};
use rustc::ty::{self, Lift, Ty, TyCtxt, TyKind, GenericParamDefKind, TypeFoldable, ToPredicate};
use rustc::ty::subst::{Subst, Substs};

View File

@ -2,7 +2,7 @@
// unresolved type variables and replaces "ty_var" types with their
// substitutions.
use check::FnCtxt;
use crate::check::FnCtxt;
use errors::DiagnosticBuilder;
use rustc::hir;
use rustc::hir::def_id::{DefId, DefIndex};

View File

@ -1,4 +1,4 @@
use lint;
use crate::lint;
use rustc::ty::TyCtxt;
use errors::Applicability;

View File

@ -1,11 +1,11 @@
use namespace::Namespace;
use crate::namespace::Namespace;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::traits::{self, IntercrateMode};
use rustc::ty::TyCtxt;
use lint;
use crate::lint;
pub fn crate_inherent_impls_overlap_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
crate_num: CrateNum) {

View File

@ -5,7 +5,7 @@
// done by the orphan and overlap modules. Then we build up various
// mappings. That mapping code resides here.
use hir::def_id::{DefId, LOCAL_CRATE};
use crate::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::traits;
use rustc::ty::{self, TyCtxt, TypeFoldable};
use rustc::ty::query::Providers;

View File

@ -14,13 +14,13 @@
//! At present, however, we do run collection across all items in the
//! crate as a kind of pass. This should eventually be factored away.
use astconv::{AstConv, Bounds};
use constrained_type_params as ctp;
use check::intrinsic::intrisic_operation_unsafety;
use lint;
use middle::lang_items::SizedTraitLangItem;
use middle::resolve_lifetime as rl;
use middle::weak_lang_items;
use crate::astconv::{AstConv, Bounds};
use crate::constrained_type_params as ctp;
use crate::check::intrinsic::intrisic_operation_unsafety;
use crate::lint;
use crate::middle::lang_items::SizedTraitLangItem;
use crate::middle::resolve_lifetime as rl;
use crate::middle::weak_lang_items;
use rustc::mir::mono::Linkage;
use rustc::ty::query::Providers;
use rustc::ty::subst::Substs;
@ -68,7 +68,7 @@ fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefI
);
}
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
type_of,
generics_of,

View File

@ -124,7 +124,7 @@ pub fn identify_constrained_type_params<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>,
/// which is determined by 1, which requires `U`, that is determined
/// by 0. I should probably pick a less tangled example, but I can't
/// think of any.
pub fn setup_constraining_predicates<'tcx>(tcx: TyCtxt,
pub fn setup_constraining_predicates<'tcx>(tcx: TyCtxt<'_, '_, '_>,
predicates: &mut [(ty::Predicate<'tcx>, Span)],
impl_trait_ref: Option<ty::TraitRef<'tcx>>,
input_parameters: &mut FxHashSet<Parameter>)

View File

@ -8,7 +8,7 @@
//! specialization errors. These things can (and probably should) be
//! fixed, but for the moment it's easier to do these checks early.
use constrained_type_params as ctp;
use crate::constrained_type_params as ctp;
use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::def_id::DefId;
@ -162,7 +162,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// used elsewhere are not projected back out.
}
fn report_unused_parameter(tcx: TyCtxt,
fn report_unused_parameter(tcx: TyCtxt<'_, '_, '_>,
span: Span,
kind: &str,
name: &str)

View File

@ -72,17 +72,15 @@ This API is completely unstable and subject to change.
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![allow(explicit_outlives_requirements)]
#![allow(elided_lifetimes_in_paths)] // WIP
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;
extern crate arena;
#[macro_use] extern crate rustc;
extern crate rustc_data_structures;
extern crate rustc_errors as errors;
extern crate rustc_target;
extern crate smallvec;
// N.B., this module needs to be declared first so diagnostics are
// registered before they are used.
@ -141,7 +139,7 @@ fn check_type_alias_enum_variants_enabled<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx,
}
}
fn require_c_abi_if_variadic(tcx: TyCtxt,
fn require_c_abi_if_variadic(tcx: TyCtxt<'_, '_, '_>,
decl: &hir::FnDecl,
abi: Abi,
span: Span) {
@ -310,7 +308,7 @@ fn check_for_entry_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
}
}
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
collect::provide(providers);
coherence::provide(providers);
check::provide(providers);

View File

@ -1,6 +1,6 @@
use rustc::hir::def_id::DefId;
use rustc::ty::{self, OutlivesPredicate, TyCtxt};
use util::nodemap::FxHashMap;
use crate::util::nodemap::FxHashMap;
use super::utils::*;

View File

@ -1,5 +1,4 @@
use rustc::hir;
use hir::Node;
use rustc::hir::{self, Node};
use rustc::hir::def_id::DefId;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::subst::{Kind, Subst, UnpackedKind};

View File

@ -12,7 +12,7 @@ mod implicit_infer;
pub mod test;
mod utils;
pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
inferred_outlives_of,
inferred_outlives_crate,

View File

@ -15,7 +15,7 @@ use std::fmt;
use syntax::ast;
use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use util::nodemap::NodeMap;
use crate::util::nodemap::NodeMap;
use self::VarianceTerm::*;