Skip to content

Commit f875143

Browse files
committed
Auto merge of #89683 - GuillaumeGomez:rollup-q2mjd9m, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #86506 (Don't normalize xform_ret_ty during method candidate assembly ) - #89538 (Make rustdoc not highlight `->` and `=>` as operators) - #89649 (clippy::complexity fixes) - #89668 (Cfg hide more conditions for core and alloc) - #89669 (Remove special-casing of never primitive in rustdoc-json-types) - #89672 (Remove unwrap_or! macro) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 54bb4fe + cda07c7 commit f875143

File tree

36 files changed

+166
-84
lines changed

36 files changed

+166
-84
lines changed

compiler/rustc_ast/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
#[macro_use]
2121
extern crate rustc_macros;
2222

23-
#[macro_export]
24-
macro_rules! unwrap_or {
25-
($opt:expr, $default:expr) => {
26-
match $opt {
27-
Some(x) => x,
28-
None => $default,
29-
}
30-
};
31-
}
32-
3323
pub mod util {
3424
pub mod classify;
3525
pub mod comments;

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13451345
generics
13461346
.params
13471347
.iter()
1348-
.find(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
1349-
.is_some()
1348+
.any(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
13501349
}
13511350
// Either the `bounded_ty` is not a plain type parameter, or
13521351
// it's not found in the generic type parameters list.

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> {
201201
let bb_data = &self.body[bb];
202202
debug_assert!(hi == bb_data.statements.len());
203203
for &succ_bb in bb_data.terminator().successors() {
204-
if self.visited.insert(succ_bb) == false {
204+
if !self.visited.insert(succ_bb) {
205205
if succ_bb == location.block && first_lo > 0 {
206206
// `succ_bb` has been seen before. If it wasn't
207207
// fully processed, add its first part to `stack`

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,7 @@ fn suggest_ampmut<'tcx>(
972972
if let Some(assignment_rhs_span) = opt_assignment_rhs_span {
973973
if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) {
974974
let is_mutbl = |ty: &str| -> bool {
975-
if ty.starts_with("mut") {
976-
let rest = &ty[3..];
975+
if let Some(rest) = ty.strip_prefix("mut") {
977976
match rest.chars().next() {
978977
// e.g. `&mut x`
979978
Some(c) if c.is_whitespace() => true,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl<'a> TraitDef<'a> {
594594
GenericParamKind::Const { ty, kw_span, .. } => {
595595
let const_nodefault_kind = GenericParamKind::Const {
596596
ty: ty.clone(),
597-
kw_span: kw_span.clone(),
597+
kw_span: *kw_span,
598598

599599
// We can't have default values inside impl block
600600
default: None,

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
130130
.tcx()
131131
.sess
132132
.struct_span_err(span, &format!("`impl` associated type signature for `{}` doesn't match `trait` associated type signature", item_name));
133-
err.span_label(impl_sp, &format!("found"));
134-
err.span_label(trait_sp, &format!("expected"));
133+
err.span_label(impl_sp, "found");
134+
err.span_label(trait_sp, "expected");
135135

136136
err.emit();
137137
}

compiler/rustc_lint/src/levels.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::context::{CheckLintNameResult, LintStore};
22
use crate::late::unerased_lint_store;
33
use rustc_ast as ast;
4-
use rustc_ast::unwrap_or;
54
use rustc_ast_pretty::pprust;
65
use rustc_data_structures::fx::FxHashMap;
76
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
@@ -233,7 +232,10 @@ impl<'s> LintLevelsBuilder<'s> {
233232
Some(lvl) => lvl,
234233
};
235234

236-
let mut metas = unwrap_or!(attr.meta_item_list(), continue);
235+
let mut metas = match attr.meta_item_list() {
236+
Some(x) => x,
237+
None => continue,
238+
};
237239

238240
if metas.is_empty() {
239241
// FIXME (#55112): issue unused-attributes lint for `#[level()]`

compiler/rustc_lint/src/non_fmt_panic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ fn check_panic_str<'tcx>(
230230
Err(_) => (None, None),
231231
};
232232

233-
let mut fmt_parser =
234-
Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format);
233+
let mut fmt_parser = Parser::new(fmt, style, snippet.clone(), false, ParseMode::Format);
235234
let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count();
236235

237236
if n_arguments > 0 && fmt_parser.errors.is_empty() {

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl Collector<'tcx> {
363363
.collect::<Vec<_>>();
364364
if existing.is_empty() {
365365
// Add if not found
366-
let new_name = passed_lib.new_name.as_ref().map(|s| &**s); // &Option<String> -> Option<&str>
366+
let new_name: Option<&str> = passed_lib.new_name.as_deref();
367367
let lib = NativeLib {
368368
name: Some(Symbol::intern(new_name.unwrap_or(&passed_lib.name))),
369369
kind: passed_lib.kind,

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
986986
let niche = if def.repr.hide_niche() {
987987
None
988988
} else {
989-
Niche::from_scalar(dl, Size::ZERO, scalar.clone())
989+
Niche::from_scalar(dl, Size::ZERO, *scalar)
990990
};
991991
if let Some(niche) = niche {
992992
match st.largest_niche {
@@ -2273,7 +2273,7 @@ where
22732273
) -> TyMaybeWithLayout<'tcx> {
22742274
let tcx = cx.tcx();
22752275
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
2276-
let layout = Layout::scalar(cx, tag.clone());
2276+
let layout = Layout::scalar(cx, tag);
22772277
TyAndLayout { layout: tcx.intern_layout(layout), ty: tag.value.to_ty(tcx) }
22782278
};
22792279

0 commit comments

Comments
 (0)