Skip to content

Commit 5a8b288

Browse files
committed
Auto merge of rust-lang#108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#107573 (Update the minimum external LLVM to 14) - rust-lang#107626 (Fix `x fix` on the standard library itself) - rust-lang#107673 (update ICU4X to 1.1.0) - rust-lang#107733 (Store metrics from `metrics.json` to CI PGO timer) - rust-lang#108007 (Use `is_str` instead of string kind comparison) - rust-lang#108033 (add an unstable `#[rustc_coinductive]` attribute) - rust-lang#108039 (Refactor refcounted structural_impls via functors) - rust-lang#108040 (Use derive attributes for uninteresting traversals) - rust-lang#108044 (interpret: rename Pointer::from_addr → from_addr_invalid) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e3a739a + b8c3642 commit 5a8b288

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

clippy_lints/src/methods/expect_fun_call.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn check<'tcx>(
3333
if (method_name.ident.name == sym::as_str || method_name.ident.name == sym::as_ref) && {
3434
let arg_type = cx.typeck_results().expr_ty(receiver);
3535
let base_type = arg_type.peel_refs();
36-
*base_type.kind() == ty::Str || is_type_lang_item(cx, base_type, hir::LangItem::String)
36+
base_type.is_str() || is_type_lang_item(cx, base_type, hir::LangItem::String)
3737
} {
3838
receiver
3939
} else {
@@ -54,7 +54,7 @@ pub(super) fn check<'tcx>(
5454
return false;
5555
}
5656
if let ty::Ref(_, ty, ..) = arg_ty.kind() {
57-
if *ty.kind() == ty::Str && can_be_static_str(cx, arg) {
57+
if ty.is_str() && can_be_static_str(cx, arg) {
5858
return false;
5959
}
6060
};

clippy_lints/src/methods/search_is_some.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_errors::Applicability;
88
use rustc_hir as hir;
99
use rustc_hir::PatKind;
1010
use rustc_lint::LateContext;
11-
use rustc_middle::ty;
1211
use rustc_span::source_map::Span;
1312
use rustc_span::symbol::sym;
1413

@@ -108,7 +107,7 @@ pub(super) fn check<'tcx>(
108107
if is_type_lang_item(cx, self_ty, hir::LangItem::String) {
109108
true
110109
} else {
111-
*self_ty.kind() == ty::Str
110+
self_ty.is_str()
112111
}
113112
};
114113
if_chain! {

clippy_lints/src/methods/single_char_pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(super) fn check(
4747
for &(method, pos) in &PATTERN_METHODS {
4848
if_chain! {
4949
if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(receiver).kind();
50-
if *ty.kind() == ty::Str;
50+
if ty.is_str();
5151
if method_name.as_str() == method && args.len() > pos;
5252
let arg = &args[pos];
5353
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/methods/string_extend_chars.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use clippy_utils::ty::is_type_lang_item;
55
use rustc_errors::Applicability;
66
use rustc_hir as hir;
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty;
98

109
use super::STRING_EXTEND_CHARS;
1110

@@ -17,7 +16,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
1716
if let Some(arglists) = method_chain_args(arg, &["chars"]) {
1817
let target = &arglists[0].0;
1918
let self_ty = cx.typeck_results().expr_ty(target).peel_refs();
20-
let ref_str = if *self_ty.kind() == ty::Str {
19+
let ref_str = if self_ty.is_str() {
2120
if matches!(target.kind, hir::ExprKind::Index(..)) {
2221
"&"
2322
} else {

clippy_lints/src/strings.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'tcx> LateLintPass<'tcx> for StringAdd {
190190
},
191191
ExprKind::Index(target, _idx) => {
192192
let e_ty = cx.typeck_results().expr_ty(target).peel_refs();
193-
if matches!(e_ty.kind(), ty::Str) || is_type_lang_item(cx, e_ty, LangItem::String) {
193+
if e_ty.is_str() || is_type_lang_item(cx, e_ty, LangItem::String) {
194194
span_lint(
195195
cx,
196196
STRING_SLICE,
@@ -407,7 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for StrToString {
407407
if path.ident.name == sym::to_string;
408408
let ty = cx.typeck_results().expr_ty(self_arg);
409409
if let ty::Ref(_, ty, ..) = ty.kind();
410-
if *ty.kind() == ty::Str;
410+
if ty.is_str();
411411
then {
412412
span_lint_and_help(
413413
cx,

clippy_lints/src/transmute/transmute_ref_to_ref.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ pub(super) fn check<'tcx>(
2222

2323
if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (&from_ty.kind(), &to_ty.kind()) {
2424
if_chain! {
25-
if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind());
25+
if let ty::Slice(slice_ty) = *ty_from.kind();
26+
if ty_to.is_str();
2627
if let ty::Uint(ty::UintTy::U8) = slice_ty.kind();
2728
if from_mutbl == to_mutbl;
2829
then {

clippy_utils/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn is_non_aggregate_primitive_type(ty: Ty<'_>) -> bool {
346346
pub fn is_recursively_primitive_type(ty: Ty<'_>) -> bool {
347347
match *ty.kind() {
348348
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str => true,
349-
ty::Ref(_, inner, _) if *inner.kind() == ty::Str => true,
349+
ty::Ref(_, inner, _) if inner.is_str() => true,
350350
ty::Array(inner_type, _) | ty::Slice(inner_type) => is_recursively_primitive_type(inner_type),
351351
ty::Tuple(inner_types) => inner_types.iter().all(is_recursively_primitive_type),
352352
_ => false,

0 commit comments

Comments
 (0)