migrate: methods.rs
This commit is contained in:
parent
3f69c1b523
commit
95d3e0cb78
2 changed files with 15 additions and 9 deletions
|
@ -6,6 +6,16 @@ use rustc_span::{symbol::Ident, Span, Symbol};
|
||||||
|
|
||||||
use crate::LateContext;
|
use crate::LateContext;
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(lint_cstring_ptr)]
|
||||||
|
#[note]
|
||||||
|
#[help]
|
||||||
|
pub struct CStringPtr {
|
||||||
|
#[label(as_ptr_label)]
|
||||||
|
pub as_ptr: Span,
|
||||||
|
#[label(unwrap_label)]
|
||||||
|
pub unwrap: Span,
|
||||||
|
}
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(lint_identifier_non_ascii_char)]
|
#[diag(lint_identifier_non_ascii_char)]
|
||||||
pub struct IdentifierNonAsciiChar;
|
pub struct IdentifierNonAsciiChar;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
use crate::lints::CStringPtr;
|
||||||
use crate::LateContext;
|
use crate::LateContext;
|
||||||
use crate::LateLintPass;
|
use crate::LateLintPass;
|
||||||
use crate::LintContext;
|
use crate::LintContext;
|
||||||
use rustc_errors::fluent;
|
|
||||||
use rustc_hir::{Expr, ExprKind, PathSegment};
|
use rustc_hir::{Expr, ExprKind, PathSegment};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::{symbol::sym, ExpnKind, Span};
|
use rustc_span::{symbol::sym, ExpnKind, Span};
|
||||||
|
@ -90,16 +92,10 @@ fn lint_cstring_as_ptr(
|
||||||
if cx.tcx.is_diagnostic_item(sym::Result, def.did()) {
|
if cx.tcx.is_diagnostic_item(sym::Result, def.did()) {
|
||||||
if let ty::Adt(adt, _) = substs.type_at(0).kind() {
|
if let ty::Adt(adt, _) = substs.type_at(0).kind() {
|
||||||
if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did()) {
|
if cx.tcx.is_diagnostic_item(sym::cstring_type, adt.did()) {
|
||||||
cx.struct_span_lint(
|
cx.emit_spanned_lint(
|
||||||
TEMPORARY_CSTRING_AS_PTR,
|
TEMPORARY_CSTRING_AS_PTR,
|
||||||
as_ptr_span,
|
as_ptr_span,
|
||||||
fluent::lint_cstring_ptr,
|
CStringPtr { as_ptr: as_ptr_span, unwrap: unwrap.span },
|
||||||
|diag| {
|
|
||||||
diag.span_label(as_ptr_span, fluent::as_ptr_label)
|
|
||||||
.span_label(unwrap.span, fluent::unwrap_label)
|
|
||||||
.note(fluent::note)
|
|
||||||
.help(fluent::help)
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue