comment fixes
This commit is contained in:
parent
bb3c03049d
commit
4cb86c9089
3 changed files with 10 additions and 13 deletions
|
|
@ -1776,6 +1776,10 @@ impl<'tcx> TyS<'tcx> {
|
|||
#[inline]
|
||||
pub fn is_bool(&self) -> bool { self.kind == Bool }
|
||||
|
||||
/// Returns `true` if this type is a `str`.
|
||||
#[inline]
|
||||
pub fn is_str(&self) -> bool { self.sty == Str }
|
||||
|
||||
#[inline]
|
||||
pub fn is_param(&self, index: u32) -> bool {
|
||||
match self.kind {
|
||||
|
|
|
|||
|
|
@ -518,17 +518,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_str_ref(ty: Ty<'_>) -> bool {
|
||||
match ty.sty {
|
||||
ty::Str => true,
|
||||
ty::Ref(_, ty, _) => is_str_ref(&ty),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
if item_name.as_str() == "as_str" && is_str_ref(&actual) {
|
||||
if item_name.as_str() == "as_str" && actual.peel_refs().is_str() {
|
||||
err.span_suggestion(
|
||||
span,
|
||||
"try to remove `as_str`",
|
||||
"try removing `as_str`",
|
||||
String::new(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@ error[E0599]: no method named `as_str` found for type `&str` in the current scop
|
|||
--> $DIR/remove-as_str.rs:2:7
|
||||
|
|
||||
LL | s.as_str();
|
||||
| ^^^^^^ help: try to remove `as_str`
|
||||
| ^^^^^^ help: try removing `as_str`
|
||||
|
||||
error[E0599]: no method named `as_str` found for type `&'a str` in the current scope
|
||||
--> $DIR/remove-as_str.rs:7:7
|
||||
|
|
||||
LL | s.as_str();
|
||||
| ^^^^^^ help: try to remove `as_str`
|
||||
| ^^^^^^ help: try removing `as_str`
|
||||
|
||||
error[E0599]: no method named `as_str` found for type `&mut str` in the current scope
|
||||
--> $DIR/remove-as_str.rs:12:7
|
||||
|
|
||||
LL | s.as_str();
|
||||
| ^^^^^^ help: try to remove `as_str`
|
||||
| ^^^^^^ help: try removing `as_str`
|
||||
|
||||
error[E0599]: no method named `as_str` found for type `&&str` in the current scope
|
||||
--> $DIR/remove-as_str.rs:17:7
|
||||
|
|
||||
LL | s.as_str();
|
||||
| ^^^^^^ help: try to remove `as_str`
|
||||
| ^^^^^^ help: try removing `as_str`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue