mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
rm diag item, use lang item
This commit is contained in:
parent
a49570fd20
commit
d5e7206ca6
@ -79,7 +79,6 @@ use crate::str;
|
||||
///
|
||||
/// [str]: prim@str "str"
|
||||
#[derive(Hash)]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "CStr")]
|
||||
#[stable(feature = "core_c_str", since = "1.64.0")]
|
||||
#[rustc_has_incoherent_inherent_impls]
|
||||
#[cfg_attr(not(bootstrap), lang = "CStr")]
|
||||
|
@ -1,11 +1,11 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::snippet_with_context;
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
|
||||
use clippy_utils::visitors::is_expr_unsafe;
|
||||
use clippy_utils::{get_parent_node, match_libc_symbol};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, Node, UnsafeSource};
|
||||
use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, LangItem, Node, UnsafeSource};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::sym;
|
||||
@ -67,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for StrlenOnCStrings {
|
||||
let val_name = snippet_with_context(cx, self_arg.span, ctxt, "..", &mut app).0;
|
||||
let method_name = if is_type_diagnostic_item(cx, ty, sym::cstring_type) {
|
||||
"as_bytes"
|
||||
} else if is_type_diagnostic_item(cx, ty, sym::CStr) {
|
||||
} else if is_type_lang_item(cx, ty, LangItem::CStr) {
|
||||
"to_bytes"
|
||||
} else {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user