Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fallout in other crates.
  • Loading branch information
cjgillot committed Dec 26, 2019
commit 82840353726668c624e46627ac11a1fec18d6d09
2 changes: 1 addition & 1 deletion src/librustc_lint/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare_lint_pass!(
);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIntoIter {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'tcx>) {
// We only care about method call expressions.
if let hir::ExprKind::MethodCall(call, span, args) = &expr.kind {
if call.ident.name != sym::into_iter {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
}
}

fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr<'_>) {
let ty = cx.tables.node_type(e.hir_id);
self.check_heap_type(cx, e.span, ty);
}
Expand All @@ -157,8 +157,8 @@ declare_lint! {
declare_lint_pass!(NonShorthandFieldPatterns => [NON_SHORTHAND_FIELD_PATTERNS]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>) {
if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind {
let variant = cx
.tables
.pat_ty(pat)
Expand Down Expand Up @@ -901,7 +901,7 @@ declare_lint! {
declare_lint_pass!(MutableTransmutes => [MUTABLE_TRANSMUTES]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) {
use rustc_target::spec::abi::Abi::RustIntrinsic;

let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
Expand All @@ -917,7 +917,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {

fn get_transmute_from_to<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
) -> Option<(Ty<'tcx>, Ty<'tcx>)> {
let def = if let hir::ExprKind::Path(ref qpath) = expr.kind {
cx.tables.qpath_res(qpath, expr.hir_id)
Expand Down Expand Up @@ -1840,7 +1840,7 @@ declare_lint! {
declare_lint_pass!(InvalidValue => [INVALID_VALUE]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &hir::Expr<'_>) {
#[derive(Debug, Copy, Clone, PartialEq)]
enum InitKind {
Zeroed,
Expand All @@ -1852,7 +1852,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
type InitError = (String, Option<Span>);

/// Test if this constant is all-0.
fn is_zero(expr: &hir::Expr) -> bool {
fn is_zero(expr: &hir::Expr<'_>) -> bool {
use hir::ExprKind::*;
use syntax::ast::LitKind::*;
match &expr.kind {
Expand All @@ -1869,7 +1869,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
}

/// Determine if this expression is a "dangerous initialization".
fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option<InitKind> {
fn is_dangerous_init(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>) -> Option<InitKind> {
// `transmute` is inside an anonymous module (the `extern` block?);
// `Invalid` represents the empty string and matches that.
// FIXME(#66075): use diagnostic items. Somehow, that does not seem to work
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
}
}

fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat<'_>) {
if let &PatKind::Binding(_, _, ident, _) = &p.kind {
self.check_snake_case(cx, "variable", &ident);
}
Expand Down Expand Up @@ -410,7 +410,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
}
}

fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat<'_>) {
// Lint for constants that look like binding identifiers (#7526)
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind {
if let Res::Def(DefKind::Const, _) = path.res {
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
lit: &hir::Lit,
lit_val: u128,
max: u128,
expr: &'tcx hir::Expr,
parent_expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
parent_expr: &'tcx hir::Expr<'tcx>,
ty: &str,
) -> bool {
// We only want to handle exclusive (`..`) ranges,
Expand Down Expand Up @@ -150,7 +150,7 @@ fn get_bin_hex_repr(cx: &LateContext<'_, '_>, lit: &hir::Lit) -> Option<String>

fn report_bin_hex_error(
cx: &LateContext<'_, '_>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
ty: attr::IntType,
repr_str: String,
val: u128,
Expand Down Expand Up @@ -244,7 +244,7 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static
fn lint_int_literal<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
type_limits: &TypeLimits,
e: &'tcx hir::Expr,
e: &'tcx hir::Expr<'tcx>,
lit: &hir::Lit,
t: ast::IntTy,
v: u128,
Expand Down Expand Up @@ -284,7 +284,7 @@ fn lint_int_literal<'a, 'tcx>(

fn lint_uint_literal<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
e: &'tcx hir::Expr,
e: &'tcx hir::Expr<'tcx>,
lit: &hir::Lit,
t: ast::UintTy,
) {
Expand Down Expand Up @@ -342,7 +342,7 @@ fn lint_uint_literal<'a, 'tcx>(
fn lint_literal<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
type_limits: &TypeLimits,
e: &'tcx hir::Expr,
e: &'tcx hir::Expr<'tcx>,
lit: &hir::Lit,
) {
match cx.tables.node_type(e.hir_id).kind {
Expand Down Expand Up @@ -377,7 +377,7 @@ fn lint_literal<'a, 'tcx>(
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr<'tcx>) {
match e.kind {
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
// propagate negation, if the negation itself isn't negated
Expand Down Expand Up @@ -425,8 +425,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
fn check_limits(
cx: &LateContext<'_, '_>,
binop: hir::BinOp,
l: &hir::Expr,
r: &hir::Expr,
l: &hir::Expr<'_>,
r: &hir::Expr<'_>,
) -> bool {
let (lit, expr, swap) = match (&l.kind, &r.kind) {
(&hir::ExprKind::Lit(_), _) => (l, r, true),
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare_lint! {
declare_lint_pass!(UnusedResults => [UNUSED_MUST_USE, UNUSED_RESULTS]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt<'_>) {
let expr = match s.kind {
hir::StmtKind::Semi(ref expr) => &**expr,
_ => return,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
fn check_must_use_ty<'tcx>(
cx: &LateContext<'_, 'tcx>,
ty: Ty<'tcx>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
span: Span,
descr_pre: &str,
descr_post: &str,
Expand Down Expand Up @@ -245,7 +245,7 @@ declare_lint! {
declare_lint_pass!(PathStatements => [PATH_STATEMENTS]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt<'_>) {
if let hir::StmtKind::Semi(ref expr) = s.kind {
if let hir::ExprKind::Path(_) = expr.kind {
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
Expand Down Expand Up @@ -637,7 +637,7 @@ declare_lint! {
declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr<'_>) {
match e.kind {
hir::ExprKind::Box(_) => {}
_ => return,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
intravisit::walk_expr(self, ex);
self.encode_info_for_expr(ex);
}
Expand Down Expand Up @@ -1587,7 +1587,7 @@ impl EncodeContext<'tcx> {
}
}

fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
fn encode_info_for_expr(&mut self, expr: &hir::Expr<'_>) {
match expr.kind {
hir::ExprKind::Closure(..) => {
let def_id = self.tcx.hir().local_def_id(expr.hir_id);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self,
destination: &Place<'tcx>,
block: BasicBlock,
ast_block: &'tcx hir::Block,
ast_block: &'tcx hir::Block<'tcx>,
source_info: SourceInfo,
) -> BlockAnd<()> {
let Block {
Expand Down
15 changes: 11 additions & 4 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {

// Figure out what primary body this item has.
let (body_id, return_ty_span) = match tcx.hir().get(id) {
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
| Node::Item(hir::Item {
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) => {
(*body_id, decl.output.span())
}
Node::Item(hir::Item {
kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id),
..
})
Expand Down Expand Up @@ -529,7 +531,12 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, _abi: Abi) -> bool {
///////////////////////////////////////////////////////////////////////////
/// the main entry point for building MIR for a function

struct ArgInfo<'tcx>(Ty<'tcx>, Option<Span>, Option<&'tcx hir::Param>, Option<ImplicitSelfKind>);
struct ArgInfo<'tcx>(
Ty<'tcx>,
Option<Span>,
Option<&'tcx hir::Param<'tcx>>,
Option<ImplicitSelfKind>,
);

fn construct_fn<'a, 'tcx, A>(
hir: Cx<'a, 'tcx>,
Expand Down Expand Up @@ -738,7 +745,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn_def_id: DefId,
arguments: &[ArgInfo<'tcx>],
argument_scope: region::Scope,
ast_body: &'tcx hir::Expr,
ast_body: &'tcx hir::Expr<'tcx>,
) -> BlockAnd<()> {
// Allocate locals for the function arguments
for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() {
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_mir/hair/cx/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc::ty;

use rustc_index::vec::Idx;

impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
impl<'tcx> Mirror<'tcx> for &'tcx hir::Block<'tcx> {
type Output = Block<'tcx>;

fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Block<'tcx> {
Expand Down Expand Up @@ -37,7 +37,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
fn mirror_stmts<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
block_id: hir::ItemLocalId,
stmts: &'tcx [hir::Stmt],
stmts: &'tcx [hir::Stmt<'tcx>],
) -> Vec<StmtRef<'tcx>> {
let mut result = vec![];
for (index, stmt) in stmts.iter().enumerate() {
Expand Down Expand Up @@ -101,7 +101,10 @@ fn mirror_stmts<'a, 'tcx>(
return result;
}

pub fn to_expr_ref<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, block: &'tcx hir::Block) -> ExprRef<'tcx> {
pub fn to_expr_ref<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
block: &'tcx hir::Block<'tcx>,
) -> ExprRef<'tcx> {
let block_ty = cx.tables().node_type(block.hir_id);
let temp_lifetime = cx.region_scope_tree.temporary_scope(block.hir_id.local_id);
let expr = Expr {
Expand Down
25 changes: 14 additions & 11 deletions src/librustc_mir/hair/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc::ty::{self, AdtKind, Ty};
use rustc_index::vec::Idx;
use syntax_pos::Span;

impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr<'tcx> {
type Output = Expr<'tcx>;

fn make_mirror(self, cx: &mut Cx<'_, 'tcx>) -> Expr<'tcx> {
Expand Down Expand Up @@ -65,7 +65,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {

fn apply_adjustment<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
hir_expr: &'tcx hir::Expr,
hir_expr: &'tcx hir::Expr<'tcx>,
mut expr: Expr<'tcx>,
adjustment: &Adjustment<'tcx>,
) -> Expr<'tcx> {
Expand Down Expand Up @@ -129,7 +129,10 @@ fn apply_adjustment<'a, 'tcx>(
Expr { temp_lifetime, ty: adjustment.target, span, kind }
}

fn make_mirror_unadjusted<'a, 'tcx>(cx: &mut Cx<'a, 'tcx>, expr: &'tcx hir::Expr) -> Expr<'tcx> {
fn make_mirror_unadjusted<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
expr: &'tcx hir::Expr<'tcx>,
) -> Expr<'tcx> {
let expr_ty = cx.tables().expr_ty(expr);
let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);

Expand Down Expand Up @@ -608,7 +611,7 @@ fn user_substs_applied_to_res(

fn method_callee<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
expr: &hir::Expr,
expr: &hir::Expr<'_>,
span: Span,
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
) -> Expr<'tcx> {
Expand Down Expand Up @@ -662,7 +665,7 @@ impl ToBorrowKind for hir::Mutability {
}
}

fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> {
fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm<'tcx>) -> Arm<'tcx> {
Arm {
pattern: cx.pattern_from_hir(&arm.pat),
guard: match arm.guard {
Expand All @@ -678,7 +681,7 @@ fn convert_arm<'tcx>(cx: &mut Cx<'_, 'tcx>, arm: &'tcx hir::Arm) -> Arm<'tcx> {

fn convert_path_expr<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
res: Res,
) -> ExprKind<'tcx> {
let substs = cx.tables().node_substs(expr.hir_id);
Expand Down Expand Up @@ -771,7 +774,7 @@ fn convert_path_expr<'a, 'tcx>(

fn convert_var(
cx: &mut Cx<'_, 'tcx>,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
var_hir_id: hir::HirId,
) -> ExprKind<'tcx> {
let upvar_index = cx
Expand Down Expand Up @@ -914,7 +917,7 @@ fn bin_op(op: hir::BinOpKind) -> BinOp {

fn overloaded_operator<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
args: Vec<ExprRef<'tcx>>,
) -> ExprKind<'tcx> {
let fun = method_callee(cx, expr, expr.span, None);
Expand All @@ -923,7 +926,7 @@ fn overloaded_operator<'a, 'tcx>(

fn overloaded_place<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
expr: &'tcx hir::Expr,
expr: &'tcx hir::Expr<'tcx>,
place_ty: Ty<'tcx>,
overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
args: Vec<ExprRef<'tcx>>,
Expand Down Expand Up @@ -963,7 +966,7 @@ fn overloaded_place<'a, 'tcx>(

fn capture_upvar<'tcx>(
cx: &mut Cx<'_, 'tcx>,
closure_expr: &'tcx hir::Expr,
closure_expr: &'tcx hir::Expr<'tcx>,
var_hir_id: hir::HirId,
upvar_ty: Ty<'tcx>,
) -> ExprRef<'tcx> {
Expand Down Expand Up @@ -1002,7 +1005,7 @@ fn capture_upvar<'tcx>(
/// Converts a list of named fields (i.e., for struct-like struct/enum ADTs) into FieldExprRef.
fn field_refs<'a, 'tcx>(
cx: &mut Cx<'a, 'tcx>,
fields: &'tcx [hir::Field],
fields: &'tcx [hir::Field<'tcx>],
) -> Vec<FieldExprRef<'tcx>> {
fields
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
}
}

pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pat<'tcx> {
pub fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> {
let p = match self.tcx.hir().get(p.hir_id) {
Node::Pat(p) | Node::Binding(p) => p,
node => bug!("pattern became {:?}", node),
Expand Down
Loading