Skip to content

Commit c5dabe8

Browse files
committed
Auto merge of #148412 - matthiaskrgr:rollup-59a302x, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #146573 (Constify Range functions) - #146699 (Add `is_ascii` function optimized for LoongArch64 for [u8]) - #148026 (std: don't leak the thread closure if destroying the thread attributes fails) - #148135 (Ignore unix socket related tests for VxWorks) - #148211 (clippy fixes and code simplification) - #148395 (Generalize branch references) - #148405 (Fix suggestion when there were a colon already in generics) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b15a874 + 285cb31 commit c5dabe8

File tree

113 files changed

+565
-433
lines changed

Some content is hidden

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

113 files changed

+565
-433
lines changed

.github/ISSUE_TEMPLATE/tracking_issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ for larger features an implementation could be broken up into multiple PRs.
5050
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
5151
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
5252
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/main/nightly-style-procedure.md
53-
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide
53+
[Style Guide]: https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide
5454

5555
### Unresolved Questions
5656
<!--

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ jobs:
323323
# If a some dependent job has failed, this exits with 1.
324324
- name: calculate the correct exit status
325325
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
326-
# Publish the toolstate if an auto build succeeds (just before push to master)
326+
# Publish the toolstate if an auto build succeeds (just before push to the default branch)
327327
- name: publish toolstate
328328
run: src/ci/publish_toolstate.sh
329329
shell: bash

.github/workflows/post-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Workflow that runs after a merge to master, analyses changes in test executions
1+
# Workflow that runs after a merge to the default branch, analyses changes in test executions
22
# and posts the result to the merged PR.
33

44
name: Post merge analysis

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
213213
///
214214
/// Check the current rustc fork of LLVM in the repo at
215215
/// <https://github.com/rust-lang/llvm-project/>. The commit in use can be found via the
216-
/// `llvm-project` submodule in <https://github.com/rust-lang/rust/tree/master/src> Though note that
216+
/// `llvm-project` submodule in <https://github.com/rust-lang/rust/tree/HEAD/src> Though note that
217217
/// Rust can also be build with an external precompiled version of LLVM which might lead to failures
218218
/// if the oldest tested / supported LLVM version doesn't yet support the relevant intrinsics.
219219
pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFeature<'a>> {

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9494

9595
let find_param_matching = |matches: &dyn Fn(ParamTerm) -> bool| {
9696
predicate_args.iter().find_map(|arg| {
97-
arg.walk().find_map(|arg| {
98-
if let ty::GenericArgKind::Type(ty) = arg.kind()
99-
&& let ty::Param(param_ty) = *ty.kind()
100-
&& matches(ParamTerm::Ty(param_ty))
101-
{
102-
Some(arg)
103-
} else if let ty::GenericArgKind::Const(ct) = arg.kind()
104-
&& let ty::ConstKind::Param(param_ct) = ct.kind()
105-
&& matches(ParamTerm::Const(param_ct))
97+
arg.walk().find(|arg| match arg.kind() {
98+
ty::GenericArgKind::Type(ty) if let ty::Param(param_ty) = ty.kind() => {
99+
matches(ParamTerm::Ty(*param_ty))
100+
}
101+
ty::GenericArgKind::Const(ct)
102+
if let ty::ConstKind::Param(param_ct) = ct.kind() =>
106103
{
107-
Some(arg)
108-
} else {
109-
None
104+
matches(ParamTerm::Const(param_ct))
110105
}
106+
_ => false,
111107
})
112108
})
113109
};
@@ -162,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
162158
.into_iter()
163159
.flatten()
164160
{
165-
if self.point_at_path_if_possible(error, def_id, param, &qpath) {
161+
if self.point_at_path_if_possible(error, def_id, param, qpath) {
166162
return true;
167163
}
168164
}
@@ -194,7 +190,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
194190
args,
195191
) => {
196192
if let Some(param) = predicate_self_type_to_point_at
197-
&& self.point_at_path_if_possible(error, callee_def_id, param, &qpath)
193+
&& self.point_at_path_if_possible(error, callee_def_id, param, qpath)
198194
{
199195
return true;
200196
}
@@ -225,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
225221
.into_iter()
226222
.flatten()
227223
{
228-
if self.point_at_path_if_possible(error, callee_def_id, param, &qpath) {
224+
if self.point_at_path_if_possible(error, callee_def_id, param, qpath) {
229225
return true;
230226
}
231227
}
@@ -543,10 +539,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
543539
}
544540

545541
/// - `blame_specific_*` means that the function will recursively traverse the expression,
546-
/// looking for the most-specific-possible span to blame.
542+
/// looking for the most-specific-possible span to blame.
547543
///
548544
/// - `point_at_*` means that the function will only go "one level", pointing at the specific
549-
/// expression mentioned.
545+
/// expression mentioned.
550546
///
551547
/// `blame_specific_arg_if_possible` will find the most-specific expression anywhere inside
552548
/// the provided function call expression, and mark it as responsible for the fulfillment
@@ -609,6 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
609605
* - want `Vec<i32>: Copy`
610606
* - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`
611607
* - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)`
608+
*
612609
* then if you pass in `(Some(vec![1, 2, 3]), false)`, this helper `point_at_specific_expr_if_possible`
613610
* will find the expression `vec![1, 2, 3]` as the "most blameable" reason for this missing constraint.
614611
*
@@ -749,6 +746,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
749746
/// - expr: `(Some(vec![1, 2, 3]), false)`
750747
/// - param: `T`
751748
/// - in_ty: `(Option<Vec<T>, bool)`
749+
///
752750
/// we would drill until we arrive at `vec![1, 2, 3]`.
753751
///
754752
/// If successful, we return `Ok(refined_expr)`. If unsuccessful, we return `Err(partially_refined_expr`),
@@ -1016,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10161014
.variant_with_id(variant_def_id)
10171015
.fields
10181016
.iter()
1019-
.map(|field| field.ty(self.tcx, *in_ty_adt_generic_args))
1017+
.map(|field| field.ty(self.tcx, in_ty_adt_generic_args))
10201018
.enumerate()
10211019
.filter(|(_index, field_type)| find_param_in_ty((*field_type).into(), param)),
10221020
) else {

compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'tcx> ArgMatrix<'tcx> {
174174
return Some(Issue::Missing(next_unmatched_idx));
175175
}
176176
// If we eliminate the last column, any left-over inputs are extra
177-
if mat[i].len() == 0 {
177+
if mat[i].is_empty() {
178178
return Some(Issue::Extra(next_unmatched_idx));
179179
}
180180

@@ -187,28 +187,18 @@ impl<'tcx> ArgMatrix<'tcx> {
187187
continue;
188188
}
189189

190-
let mut useless = true;
191-
let mut unsatisfiable = true;
192-
if is_arg {
193-
for j in 0..ii.len() {
194-
// If we find at least one input this argument could satisfy
195-
// this argument isn't unsatisfiable
196-
if matches!(mat[j][i], Compatibility::Compatible) {
197-
unsatisfiable = false;
198-
break;
199-
}
200-
}
201-
}
202-
if is_input {
203-
for j in 0..ai.len() {
204-
// If we find at least one argument that could satisfy this input
205-
// this input isn't useless
206-
if matches!(mat[i][j], Compatibility::Compatible) {
207-
useless = false;
208-
break;
209-
}
210-
}
211-
}
190+
// If this argument can satisfy some input, then this argument is satisfiable
191+
let unsatisfiable = if is_arg {
192+
!mat.iter().take(ii.len()).any(|c| matches!(c[i], Compatibility::Compatible))
193+
} else {
194+
true
195+
};
196+
// If this input can be satisfied by some argument, then this input is useful
197+
let useless = if is_input {
198+
!mat[i].iter().take(ai.len()).any(|c| matches!(c, Compatibility::Compatible))
199+
} else {
200+
true
201+
};
212202

213203
match (is_input, is_arg, useless, unsatisfiable) {
214204
// If an argument is unsatisfied, and the input in its position is useless

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
777777
}
778778
_ => bug!("unexpected type: {:?}", ty.normalized),
779779
},
780-
Res::Def(
781-
DefKind::Struct | DefKind::Union | DefKind::TyAlias { .. } | DefKind::AssocTy,
782-
_,
783-
)
780+
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
784781
| Res::SelfTyParam { .. }
785782
| Res::SelfTyAlias { .. } => match ty.normalized.ty_adt_def() {
786783
Some(adt) if !adt.is_enum() => {
@@ -868,7 +865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
868865
let decl_ty = self.local_ty(decl.span, decl.hir_id);
869866

870867
// Type check the initializer.
871-
if let Some(ref init) = decl.init {
868+
if let Some(init) = decl.init {
872869
let init_ty = self.check_decl_initializer(decl.hir_id, decl.pat, init);
873870
self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, init_ty);
874871
}
@@ -932,7 +929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
932929
}
933930
// Ignore for now.
934931
hir::StmtKind::Item(_) => {}
935-
hir::StmtKind::Expr(ref expr) => {
932+
hir::StmtKind::Expr(expr) => {
936933
// Check with expected type of `()`.
937934
self.check_expr_has_type_or_error(expr, self.tcx.types.unit, |err| {
938935
if self.is_next_stmt_expr_continuation(stmt.hir_id)
@@ -1766,10 +1763,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17661763
let params =
17671764
params.get(is_method as usize..params.len() - sig.decl.c_variadic as usize)?;
17681765
debug_assert_eq!(params.len(), fn_inputs.len());
1769-
Some((
1770-
fn_inputs.zip(params.iter().map(|param| FnParam::Param(param))).collect(),
1771-
generics,
1772-
))
1766+
Some((fn_inputs.zip(params.iter().map(FnParam::Param)).collect(), generics))
17731767
}
17741768
(None, Some(params)) => {
17751769
let params =
@@ -2632,7 +2626,7 @@ impl<'a, 'b, 'tcx> FnCallDiagCtxt<'a, 'b, 'tcx> {
26322626
suggestions: Vec<(Span, String)>,
26332627
suggestion_text: SuggestionText,
26342628
) -> Option<String> {
2635-
let suggestion_text = match suggestion_text {
2629+
match suggestion_text {
26362630
SuggestionText::None => None,
26372631
SuggestionText::Provide(plural) => {
26382632
Some(format!("provide the argument{}", if plural { "s" } else { "" }))
@@ -2648,8 +2642,7 @@ impl<'a, 'b, 'tcx> FnCallDiagCtxt<'a, 'b, 'tcx> {
26482642
SuggestionText::Swap => Some("swap these arguments".to_string()),
26492643
SuggestionText::Reorder => Some("reorder these arguments".to_string()),
26502644
SuggestionText::DidYouMean => Some("did you mean".to_string()),
2651-
};
2652-
suggestion_text
2645+
}
26532646
}
26542647

26552648
fn arguments_formatting(&self, suggestion_span: Span) -> ArgumentsFormatting {
@@ -2947,7 +2940,7 @@ impl<'a, 'b, 'tcx> ArgsCtxt<'a, 'b, 'tcx> {
29472940
.fn_ctxt
29482941
.typeck_results
29492942
.borrow()
2950-
.expr_ty_adjusted_opt(*expr)
2943+
.expr_ty_adjusted_opt(expr)
29512944
.unwrap_or_else(|| Ty::new_misc_error(self.call_ctxt.fn_ctxt.tcx));
29522945
(
29532946
self.call_ctxt.fn_ctxt.resolve_vars_if_possible(ty),

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11321132
})
11331133
.collect::<Vec<String>>();
11341134

1135-
if all_matching_bounds_strs.len() == 0 {
1135+
if all_matching_bounds_strs.is_empty() {
11361136
return;
11371137
}
11381138

@@ -1336,7 +1336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13361336
expected_ty = *inner_expected_ty;
13371337
}
13381338
(hir::ExprKind::Block(blk, _), _, _) => {
1339-
self.suggest_block_to_brackets(diag, *blk, expr_ty, expected_ty);
1339+
self.suggest_block_to_brackets(diag, blk, expr_ty, expected_ty);
13401340
break true;
13411341
}
13421342
_ => break false,
@@ -1463,7 +1463,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14631463
{
14641464
let span = expr
14651465
.span
1466-
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
1466+
.find_ancestor_not_from_extern_macro(self.tcx.sess.source_map())
14671467
.unwrap_or(expr.span);
14681468

14691469
let mut sugg = if self.precedence(expr) >= ExprPrecedence::Unambiguous {
@@ -2144,7 +2144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21442144

21452145
let span = expr
21462146
.span
2147-
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
2147+
.find_ancestor_not_from_extern_macro(self.tcx.sess.source_map())
21482148
.unwrap_or(expr.span);
21492149
err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders);
21502150
true
@@ -2257,7 +2257,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22572257

22582258
let src_map = tcx.sess.source_map();
22592259
let suggestion = if src_map.is_multiline(expr.span) {
2260-
let indentation = src_map.indentation_before(span).unwrap_or_else(String::new);
2260+
let indentation = src_map.indentation_before(span).unwrap_or_default();
22612261
format!("\n{indentation}/* {suggestion} */")
22622262
} else {
22632263
// If the entire expr is on a single line
@@ -2289,7 +2289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22892289
// Check if `expr` is contained in array of two elements
22902290
if let hir::Node::Expr(array_expr) = self.tcx.parent_hir_node(expr.hir_id)
22912291
&& let hir::ExprKind::Array(elements) = array_expr.kind
2292-
&& let [first, second] = &elements[..]
2292+
&& let [first, second] = elements
22932293
&& second.hir_id == expr.hir_id
22942294
{
22952295
// Span between the two elements of the array

compiler/rustc_hir_typeck/src/gather_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
135135
/// again during type checking by querying [`FnCtxt::local_ty`] for the same hir_id.
136136
fn declare(&mut self, decl: Declaration<'tcx>) {
137137
let local_ty = match decl.ty {
138-
Some(ref ty) => {
138+
Some(ty) => {
139139
let o_ty = self.fcx.lower_ty(ty);
140140

141141
let c_ty = self.fcx.infcx.canonicalize_user_type_annotation(

compiler/rustc_hir_typeck/src/loops.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,15 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
147147
}
148148
}
149149
}
150-
hir::ExprKind::Loop(ref b, _, source, _) => {
150+
hir::ExprKind::Loop(b, _, source, _) => {
151151
let cx = match self.is_loop_match(e, b) {
152152
Some(labeled_block) => LoopMatch { labeled_block },
153153
None => Loop(source),
154154
};
155155

156156
self.with_context(cx, |v| v.visit_block(b));
157157
}
158-
hir::ExprKind::Closure(&hir::Closure {
159-
ref fn_decl, body, fn_decl_span, kind, ..
160-
}) => {
158+
hir::ExprKind::Closure(&hir::Closure { fn_decl, body, fn_decl_span, kind, .. }) => {
161159
let cx = match kind {
162160
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(kind, source)) => {
163161
Coroutine { coroutine_span: fn_decl_span, kind, source }
@@ -167,16 +165,16 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
167165
self.visit_fn_decl(fn_decl);
168166
self.with_context(cx, |v| v.visit_nested_body(body));
169167
}
170-
hir::ExprKind::Block(ref b, Some(_label)) => {
168+
hir::ExprKind::Block(b, Some(_label)) => {
171169
self.with_context(LabeledBlock, |v| v.visit_block(b));
172170
}
173-
hir::ExprKind::Block(ref b, None)
171+
hir::ExprKind::Block(b, None)
174172
if matches!(self.cx_stack.last(), Some(&Fn) | Some(&ConstBlock)) =>
175173
{
176174
self.with_context(Normal, |v| v.visit_block(b));
177175
}
178176
hir::ExprKind::Block(
179-
ref b @ hir::Block { rules: hir::BlockCheckMode::DefaultBlock, .. },
177+
b @ hir::Block { rules: hir::BlockCheckMode::DefaultBlock, .. },
180178
None,
181179
) if matches!(
182180
self.cx_stack.last(),
@@ -431,10 +429,7 @@ impl<'hir> CheckLoopVisitor<'hir> {
431429

432430
// Accept either `state = expr` or `state = expr;`.
433431
let loop_body_expr = match body.stmts {
434-
[] => match body.expr {
435-
Some(expr) => expr,
436-
None => return None,
437-
},
432+
[] => body.expr?,
438433
[single] if body.expr.is_none() => match single.kind {
439434
hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => expr,
440435
_ => return None,

0 commit comments

Comments
 (0)