Merge remote-tracking branch 'upstream/master' into rustup
This commit is contained in:
commit
669fddab37
168 changed files with 2906 additions and 1457 deletions
|
|
@ -155,13 +155,7 @@ where
|
|||
});
|
||||
}
|
||||
|
||||
pub fn span_lint_hir(
|
||||
cx: &LateContext<'_>,
|
||||
lint: &'static Lint,
|
||||
hir_id: HirId,
|
||||
sp: Span,
|
||||
msg: &str,
|
||||
) {
|
||||
pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: &str) {
|
||||
cx.tcx.struct_span_lint_hir(lint, hir_id, sp, |diag| {
|
||||
let mut diag = diag.build(msg);
|
||||
docs_link(&mut diag, lint);
|
||||
|
|
@ -278,14 +272,9 @@ pub fn span_lint_and_sugg_for_edges(
|
|||
let sugg_lines_count = sugg.lines().count();
|
||||
if sugg_lines_count > MAX_SUGGESTION_HIGHLIGHT_LINES {
|
||||
let sm = cx.sess().source_map();
|
||||
if let (Ok(line_upper), Ok(line_bottom)) =
|
||||
(sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi()))
|
||||
{
|
||||
if let (Ok(line_upper), Ok(line_bottom)) = (sm.lookup_line(sp.lo()), sm.lookup_line(sp.hi())) {
|
||||
let split_idx = MAX_SUGGESTION_HIGHLIGHT_LINES / 2;
|
||||
let span_upper = sm.span_until_char(
|
||||
sp.with_hi(line_upper.sf.lines[line_upper.line + split_idx]),
|
||||
'\n',
|
||||
);
|
||||
let span_upper = sm.span_until_char(sp.with_hi(line_upper.sf.lines[line_upper.line + split_idx]), '\n');
|
||||
let span_bottom = sp.with_lo(line_bottom.sf.lines[line_bottom.line - split_idx]);
|
||||
|
||||
let sugg_lines_vec = sugg.lines().collect::<Vec<&str>>();
|
||||
|
|
|
|||
|
|
@ -77,19 +77,22 @@ use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
|
|||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_hir::LangItem::{OptionNone, ResultErr, ResultOk};
|
||||
use rustc_hir::{
|
||||
def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Constness, Destination, Expr,
|
||||
ExprKind, FnDecl, ForeignItem, HirId, Impl, ImplItem, ImplItemKind, IsAsync, Item, ItemKind, LangItem, Local,
|
||||
MatchSource, Mutability, Node, Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind,
|
||||
TraitItem, TraitItemKind, TraitRef, TyKind, UnOp,
|
||||
def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Constness, Destination, Expr, ExprKind, FnDecl,
|
||||
ForeignItem, HirId, Impl, ImplItem, ImplItemKind, IsAsync, Item, ItemKind, LangItem, Local, MatchSource,
|
||||
Mutability, Node, Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind,
|
||||
TraitRef, TyKind, UnOp,
|
||||
};
|
||||
use rustc_lint::{LateContext, Level, Lint, LintContext};
|
||||
use rustc_middle::hir::place::PlaceBase;
|
||||
use rustc_middle::ty as rustc_ty;
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
|
||||
use rustc_middle::ty::binding::BindingMode;
|
||||
use rustc_middle::ty::{IntTy, UintTy, FloatTy};
|
||||
use rustc_middle::ty::fast_reject::SimplifiedTypeGen::*;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedTypeGen::{
|
||||
ArraySimplifiedType, BoolSimplifiedType, CharSimplifiedType, FloatSimplifiedType, IntSimplifiedType,
|
||||
PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType,
|
||||
};
|
||||
use rustc_middle::ty::{layout::IntegerExt, BorrowKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeFoldable, UpvarCapture};
|
||||
use rustc_middle::ty::{FloatTy, IntTy, UintTy};
|
||||
use rustc_semver::RustcVersion;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
|
|
@ -522,7 +525,7 @@ pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
|
|||
let tcx = cx.tcx;
|
||||
let starts = find_primitive(tcx, base)
|
||||
.chain(find_crate(tcx, base))
|
||||
.flat_map(|id| item_child_by_name(tcx, id, first));
|
||||
.filter_map(|id| item_child_by_name(tcx, id, first));
|
||||
|
||||
for first in starts {
|
||||
let last = path
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ msrv_aliases! {
|
|||
1,34,0 { TRY_FROM }
|
||||
1,30,0 { ITERATOR_FIND_MAP, TOOL_ATTRIBUTES }
|
||||
1,28,0 { FROM_BOOL }
|
||||
1,17,0 { FIELD_INIT_SHORTHAND, STATIC_IN_CONST }
|
||||
1,17,0 { FIELD_INIT_SHORTHAND, STATIC_IN_CONST, EXPECT_ERR }
|
||||
1,16,0 { STR_REPEAT }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ pub const PTR_READ_UNALIGNED: [&str; 3] = ["core", "ptr", "read_unaligned"];
|
|||
pub const PTR_READ_VOLATILE: [&str; 3] = ["core", "ptr", "read_volatile"];
|
||||
pub const PTR_REPLACE: [&str; 3] = ["core", "ptr", "replace"];
|
||||
pub const PTR_SWAP: [&str; 3] = ["core", "ptr", "swap"];
|
||||
pub const PTR_UNALIGNED_VOLATILE_LOAD: [&str; 3] = ["core", "intrinsics", "unaligned_volatile_load"];
|
||||
pub const PTR_UNALIGNED_VOLATILE_STORE: [&str; 3] = ["core", "intrinsics", "unaligned_volatile_store"];
|
||||
pub const PTR_WRITE: [&str; 3] = ["core", "ptr", "write"];
|
||||
pub const PTR_WRITE_BYTES: [&str; 3] = ["core", "intrinsics", "write_bytes"];
|
||||
pub const PTR_WRITE_UNALIGNED: [&str; 3] = ["core", "ptr", "write_unaligned"];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue