Skip to content

Commit b8a52e3

Browse files
committed
Auto merge of rust-lang#105218 - matthiaskrgr:rollup-8d3k08n, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#104199 (Keep track of the start of the argument block of a closure) - rust-lang#105050 (Remove useless borrows and derefs) - rust-lang#105153 (Create a hacky fail-fast mode that stops tests at the first failure) - rust-lang#105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`) - rust-lang#105193 (Disable coverage instrumentation for naked functions) - rust-lang#105200 (Remove useless filter in unused extern crate check.) - rust-lang#105201 (Do not call fn_sig on non-functions.) - rust-lang#105208 (Add AmbiguityError for inconsistent resolution for an import) - rust-lang#105214 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2341517 + 8be329d commit b8a52e3

File tree

116 files changed

+1470
-1141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1470
-1141
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -5356,9 +5356,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
53565356

53575357
[[package]]
53585358
name = "ui_test"
5359-
version = "0.4.0"
5359+
version = "0.5.0"
53605360
source = "registry+https://github.com/rust-lang/crates.io-index"
5361-
checksum = "bf4559da3fe6b481f8674a29379677cb9606cd6f75fc254a2c9834c55638503d"
5361+
checksum = "54ddb6f31025943e2f9d59237f433711c461a43d9415974c3eb3a4902edc1c1f"
53625362
dependencies = [
53635363
"bstr 1.0.1",
53645364
"cargo_metadata 0.15.0",

compiler/rustc_abi/src/layout.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub trait LayoutCalculator {
354354
if !always_sized { StructKind::MaybeUnsized } else { StructKind::AlwaysSized }
355355
};
356356

357-
let mut st = self.univariant(dl, &variants[v], &repr, kind)?;
357+
let mut st = self.univariant(dl, &variants[v], repr, kind)?;
358358
st.variants = Variants::Single { index: v };
359359

360360
if is_unsafe_cell {
@@ -457,7 +457,7 @@ pub trait LayoutCalculator {
457457
let mut variant_layouts = variants
458458
.iter_enumerated()
459459
.map(|(j, v)| {
460-
let mut st = self.univariant(dl, v, &repr, StructKind::AlwaysSized)?;
460+
let mut st = self.univariant(dl, v, repr, StructKind::AlwaysSized)?;
461461
st.variants = Variants::Single { index: j };
462462

463463
align = align.max(st.align);
@@ -647,8 +647,8 @@ pub trait LayoutCalculator {
647647
.map(|(i, field_layouts)| {
648648
let mut st = self.univariant(
649649
dl,
650-
&field_layouts,
651-
&repr,
650+
field_layouts,
651+
repr,
652652
StructKind::Prefixed(min_ity.size(), prefix_align),
653653
)?;
654654
st.variants = Variants::Single { index: i };
@@ -755,7 +755,7 @@ pub trait LayoutCalculator {
755755
// Try to use a ScalarPair for all tagged enums.
756756
let mut common_prim = None;
757757
let mut common_prim_initialized_in_all_variants = true;
758-
for (field_layouts, layout_variant) in iter::zip(&*variants, &layout_variants) {
758+
for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) {
759759
let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else {
760760
panic!();
761761
};

compiler/rustc_ast/src/ast.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ impl Expr {
11791179
pub fn peel_parens(&self) -> &Expr {
11801180
let mut expr = self;
11811181
while let ExprKind::Paren(inner) = &expr.kind {
1182-
expr = &inner;
1182+
expr = inner;
11831183
}
11841184
expr
11851185
}
@@ -1312,8 +1312,10 @@ pub struct Closure {
13121312
pub movability: Movability,
13131313
pub fn_decl: P<FnDecl>,
13141314
pub body: P<Expr>,
1315-
/// The span of the argument block `|...|`.
1315+
/// The span of the declaration block: 'move |...| -> ...'
13161316
pub fn_decl_span: Span,
1317+
/// The span of the argument block `|...|`
1318+
pub fn_arg_span: Span,
13171319
}
13181320

13191321
/// Limit types of a range (inclusive or exclusive)
@@ -2027,7 +2029,7 @@ impl Ty {
20272029
pub fn peel_refs(&self) -> &Self {
20282030
let mut final_ty = self;
20292031
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
2030-
final_ty = &ty;
2032+
final_ty = ty;
20312033
}
20322034
final_ty
20332035
}

compiler/rustc_ast/src/mut_visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,7 @@ pub fn visit_token<T: MutVisitor>(t: &mut Token, vis: &mut T) {
736736
return; // Avoid visiting the span for the second time.
737737
}
738738
token::Interpolated(nt) => {
739-
let mut nt = Lrc::make_mut(nt);
740-
visit_nonterminal(&mut nt, vis);
739+
visit_nonterminal(Lrc::make_mut(nt), vis);
741740
}
742741
_ => {}
743742
}
@@ -1368,6 +1367,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
13681367
fn_decl,
13691368
body,
13701369
fn_decl_span,
1370+
fn_arg_span: _,
13711371
}) => {
13721372
vis.visit_closure_binder(binder);
13731373
vis.visit_asyncness(asyncness);

compiler/rustc_ast/src/tokenstream.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl TokenTree {
6464
match (self, other) {
6565
(TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind,
6666
(TokenTree::Delimited(_, delim, tts), TokenTree::Delimited(_, delim2, tts2)) => {
67-
delim == delim2 && tts.eq_unspanned(&tts2)
67+
delim == delim2 && tts.eq_unspanned(tts2)
6868
}
6969
_ => false,
7070
}
@@ -402,7 +402,7 @@ impl TokenStream {
402402
let mut t1 = self.trees();
403403
let mut t2 = other.trees();
404404
for (t1, t2) in iter::zip(&mut t1, &mut t2) {
405-
if !t1.eq_unspanned(&t2) {
405+
if !t1.eq_unspanned(t2) {
406406
return false;
407407
}
408408
}
@@ -475,7 +475,7 @@ impl TokenStream {
475475
token::Interpolated(nt) => TokenTree::Delimited(
476476
DelimSpan::from_single(token.span),
477477
Delimiter::Invisible,
478-
TokenStream::from_nonterminal_ast(&nt).flattened(),
478+
TokenStream::from_nonterminal_ast(nt).flattened(),
479479
),
480480
_ => TokenTree::Token(token.clone(), spacing),
481481
}
@@ -511,7 +511,7 @@ impl TokenStream {
511511
fn try_glue_to_last(vec: &mut Vec<TokenTree>, tt: &TokenTree) -> bool {
512512
if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = vec.last()
513513
&& let TokenTree::Token(tok, spacing) = tt
514-
&& let Some(glued_tok) = last_tok.glue(&tok)
514+
&& let Some(glued_tok) = last_tok.glue(tok)
515515
{
516516
// ...then overwrite the last token tree in `vec` with the
517517
// glued token, and skip the first token tree from `stream`.

compiler/rustc_ast/src/util/comments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
110110
} else {
111111
&mut lines
112112
};
113-
if let Some(horizontal) = get_horizontal_trim(&lines, kind) {
113+
if let Some(horizontal) = get_horizontal_trim(lines, kind) {
114114
changes = true;
115115
// remove a "[ \t]*\*" block from each line, if possible
116116
for line in lines.iter_mut() {
@@ -147,7 +147,7 @@ fn all_whitespace(s: &str, col: CharPos) -> Option<usize> {
147147

148148
fn trim_whitespace_prefix(s: &str, col: CharPos) -> &str {
149149
let len = s.len();
150-
match all_whitespace(&s, col) {
150+
match all_whitespace(s, col) {
151151
Some(col) => {
152152
if col < len {
153153
&s[col..]

compiler/rustc_ast/src/util/literal.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ impl LitKind {
5252
// new symbol because the string in the LitKind is different to the
5353
// string in the token.
5454
let s = symbol.as_str();
55-
let symbol = if s.contains(&['\\', '\r']) {
55+
let symbol = if s.contains(['\\', '\r']) {
5656
let mut buf = String::with_capacity(s.len());
5757
let mut error = Ok(());
5858
// Force-inlining here is aggressive but the closure is
5959
// called on every char in the string, so it can be
6060
// hot in programs with many long strings.
6161
unescape_literal(
62-
&s,
62+
s,
6363
Mode::Str,
6464
&mut #[inline(always)]
6565
|_, unescaped_char| match unescaped_char {
@@ -85,7 +85,7 @@ impl LitKind {
8585
if s.contains('\r') {
8686
let mut buf = String::with_capacity(s.len());
8787
let mut error = Ok(());
88-
unescape_literal(&s, Mode::RawStr, &mut |_, unescaped_char| {
88+
unescape_literal(s, Mode::RawStr, &mut |_, unescaped_char| {
8989
match unescaped_char {
9090
Ok(c) => buf.push(c),
9191
Err(err) => {
@@ -106,7 +106,7 @@ impl LitKind {
106106
let s = symbol.as_str();
107107
let mut buf = Vec::with_capacity(s.len());
108108
let mut error = Ok(());
109-
unescape_literal(&s, Mode::ByteStr, &mut |_, c| match c {
109+
unescape_literal(s, Mode::ByteStr, &mut |_, c| match c {
110110
Ok(c) => buf.push(byte_from_char(c)),
111111
Err(err) => {
112112
if err.is_fatal() {
@@ -122,7 +122,7 @@ impl LitKind {
122122
let bytes = if s.contains('\r') {
123123
let mut buf = Vec::with_capacity(s.len());
124124
let mut error = Ok(());
125-
unescape_literal(&s, Mode::RawByteStr, &mut |_, c| match c {
125+
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
126126
Ok(c) => buf.push(byte_from_char(c)),
127127
Err(err) => {
128128
if err.is_fatal() {

compiler/rustc_ast/src/util/parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
384384
| ast::ExprKind::AssignOp(_, lhs, rhs)
385385
| ast::ExprKind::Binary(_, lhs, rhs) => {
386386
// X { y: 1 } + X { y: 2 }
387-
contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs)
387+
contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs)
388388
}
389389
ast::ExprKind::Await(x)
390390
| ast::ExprKind::Unary(_, x)
@@ -393,12 +393,12 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
393393
| ast::ExprKind::Field(x, _)
394394
| ast::ExprKind::Index(x, _) => {
395395
// &X { y: 1 }, X { y: 1 }.y
396-
contains_exterior_struct_lit(&x)
396+
contains_exterior_struct_lit(x)
397397
}
398398

399399
ast::ExprKind::MethodCall(box ast::MethodCall { receiver, .. }) => {
400400
// X { y: 1 }.bar(...)
401-
contains_exterior_struct_lit(&receiver)
401+
contains_exterior_struct_lit(receiver)
402402
}
403403

404404
_ => false,

compiler/rustc_ast/src/util/unicode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn contains_text_flow_control_chars(s: &str) -> bool {
1717
// U+2069 - E2 81 A9
1818
let mut bytes = s.as_bytes();
1919
loop {
20-
match core::slice::memchr::memchr(0xE2, &bytes) {
20+
match core::slice::memchr::memchr(0xE2, bytes) {
2121
Some(idx) => {
2222
// bytes are valid UTF-8 -> E2 must be followed by two bytes
2323
let ch = &bytes[idx..idx + 3];

compiler/rustc_ast/src/visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
840840
fn_decl,
841841
body,
842842
fn_decl_span: _,
843+
fn_arg_span: _,
843844
}) => {
844845
visitor.visit_fn(FnKind::Closure(binder, fn_decl, body), expression.span, expression.id)
845846
}

compiler/rustc_ast_lowering/src/expr.rs

+8
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
176176
fn_decl,
177177
body,
178178
fn_decl_span,
179+
fn_arg_span,
179180
}) => {
180181
if let Async::Yes { closure_id, .. } = asyncness {
181182
self.lower_expr_async_closure(
@@ -186,6 +187,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
186187
fn_decl,
187188
body,
188189
*fn_decl_span,
190+
*fn_arg_span,
189191
)
190192
} else {
191193
self.lower_expr_closure(
@@ -196,6 +198,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
196198
fn_decl,
197199
body,
198200
*fn_decl_span,
201+
*fn_arg_span,
199202
)
200203
}
201204
}
@@ -642,6 +645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
642645
fn_decl,
643646
body,
644647
fn_decl_span: self.lower_span(span),
648+
fn_arg_span: None,
645649
movability: Some(hir::Movability::Static),
646650
});
647651

@@ -898,6 +902,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
898902
decl: &FnDecl,
899903
body: &Expr,
900904
fn_decl_span: Span,
905+
fn_arg_span: Span,
901906
) -> hir::ExprKind<'hir> {
902907
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
903908

@@ -928,6 +933,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
928933
fn_decl,
929934
body: body_id,
930935
fn_decl_span: self.lower_span(fn_decl_span),
936+
fn_arg_span: Some(self.lower_span(fn_arg_span)),
931937
movability: generator_option,
932938
});
933939

@@ -984,6 +990,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
984990
decl: &FnDecl,
985991
body: &Expr,
986992
fn_decl_span: Span,
993+
fn_arg_span: Span,
987994
) -> hir::ExprKind<'hir> {
988995
if let &ClosureBinder::For { span, .. } = binder {
989996
self.tcx.sess.emit_err(NotSupportedForLifetimeBinderAsyncClosure { span });
@@ -1038,6 +1045,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10381045
fn_decl,
10391046
body,
10401047
fn_decl_span: self.lower_span(fn_decl_span),
1048+
fn_arg_span: Some(self.lower_span(fn_arg_span)),
10411049
movability: None,
10421050
});
10431051
hir::ExprKind::Closure(c)

0 commit comments

Comments
 (0)