Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/tracking_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for larger features an implementation could be broken up into multiple PRs.
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/main/nightly-style-procedure.md
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide
[Style Guide]: https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide

### Unresolved Questions
<!--
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ jobs:
# If a some dependent job has failed, this exits with 1.
- name: calculate the correct exit status
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
# Publish the toolstate if an auto build succeeds (just before push to master)
# Publish the toolstate if an auto build succeeds (just before push to the default branch)
- name: publish toolstate
run: src/ci/publish_toolstate.sh
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow that runs after a merge to master, analyses changes in test executions
# Workflow that runs after a merge to the default branch, analyses changes in test executions
# and posts the result to the merged PR.

name: Post merge analysis
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
///
/// Check the current rustc fork of LLVM in the repo at
/// <https://github.com/rust-lang/llvm-project/>. The commit in use can be found via the
/// `llvm-project` submodule in <https://github.com/rust-lang/rust/tree/master/src> Though note that
/// `llvm-project` submodule in <https://github.com/rust-lang/rust/tree/HEAD/src> Though note that
/// Rust can also be build with an external precompiled version of LLVM which might lead to failures
/// if the oldest tested / supported LLVM version doesn't yet support the relevant intrinsics.
pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFeature<'a>> {
Expand Down
34 changes: 16 additions & 18 deletions compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let find_param_matching = |matches: &dyn Fn(ParamTerm) -> bool| {
predicate_args.iter().find_map(|arg| {
arg.walk().find_map(|arg| {
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Param(param_ty) = *ty.kind()
&& matches(ParamTerm::Ty(param_ty))
{
Some(arg)
} else if let ty::GenericArgKind::Const(ct) = arg.kind()
&& let ty::ConstKind::Param(param_ct) = ct.kind()
&& matches(ParamTerm::Const(param_ct))
arg.walk().find(|arg| match arg.kind() {
ty::GenericArgKind::Type(ty) if let ty::Param(param_ty) = ty.kind() => {
matches(ParamTerm::Ty(*param_ty))
}
ty::GenericArgKind::Const(ct)
if let ty::ConstKind::Param(param_ct) = ct.kind() =>
{
Some(arg)
} else {
None
matches(ParamTerm::Const(param_ct))
}
_ => false,
})
})
};
Expand Down Expand Up @@ -162,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.into_iter()
.flatten()
{
if self.point_at_path_if_possible(error, def_id, param, &qpath) {
if self.point_at_path_if_possible(error, def_id, param, qpath) {
return true;
}
}
Expand Down Expand Up @@ -194,7 +190,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args,
) => {
if let Some(param) = predicate_self_type_to_point_at
&& self.point_at_path_if_possible(error, callee_def_id, param, &qpath)
&& self.point_at_path_if_possible(error, callee_def_id, param, qpath)
{
return true;
}
Expand Down Expand Up @@ -225,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.into_iter()
.flatten()
{
if self.point_at_path_if_possible(error, callee_def_id, param, &qpath) {
if self.point_at_path_if_possible(error, callee_def_id, param, qpath) {
return true;
}
}
Expand Down Expand Up @@ -543,10 +539,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

/// - `blame_specific_*` means that the function will recursively traverse the expression,
/// looking for the most-specific-possible span to blame.
/// looking for the most-specific-possible span to blame.
///
/// - `point_at_*` means that the function will only go "one level", pointing at the specific
/// expression mentioned.
/// expression mentioned.
///
/// `blame_specific_arg_if_possible` will find the most-specific expression anywhere inside
/// the provided function call expression, and mark it as responsible for the fulfillment
Expand Down Expand Up @@ -609,6 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
* - want `Vec<i32>: Copy`
* - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`
* - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)`
*
* then if you pass in `(Some(vec![1, 2, 3]), false)`, this helper `point_at_specific_expr_if_possible`
* will find the expression `vec![1, 2, 3]` as the "most blameable" reason for this missing constraint.
*
Expand Down Expand Up @@ -749,6 +746,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// - expr: `(Some(vec![1, 2, 3]), false)`
/// - param: `T`
/// - in_ty: `(Option<Vec<T>, bool)`
///
/// we would drill until we arrive at `vec![1, 2, 3]`.
///
/// If successful, we return `Ok(refined_expr)`. If unsuccessful, we return `Err(partially_refined_expr`),
Expand Down Expand Up @@ -1016,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.variant_with_id(variant_def_id)
.fields
.iter()
.map(|field| field.ty(self.tcx, *in_ty_adt_generic_args))
.map(|field| field.ty(self.tcx, in_ty_adt_generic_args))
.enumerate()
.filter(|(_index, field_type)| find_param_in_ty((*field_type).into(), param)),
) else {
Expand Down
36 changes: 13 additions & 23 deletions compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<'tcx> ArgMatrix<'tcx> {
return Some(Issue::Missing(next_unmatched_idx));
}
// If we eliminate the last column, any left-over inputs are extra
if mat[i].len() == 0 {
if mat[i].is_empty() {
return Some(Issue::Extra(next_unmatched_idx));
}

Expand All @@ -187,28 +187,18 @@ impl<'tcx> ArgMatrix<'tcx> {
continue;
}

let mut useless = true;
let mut unsatisfiable = true;
if is_arg {
for j in 0..ii.len() {
// If we find at least one input this argument could satisfy
// this argument isn't unsatisfiable
if matches!(mat[j][i], Compatibility::Compatible) {
unsatisfiable = false;
break;
}
}
}
if is_input {
for j in 0..ai.len() {
// If we find at least one argument that could satisfy this input
// this input isn't useless
if matches!(mat[i][j], Compatibility::Compatible) {
useless = false;
break;
}
}
}
// If this argument can satisfy some input, then this argument is satisfiable
let unsatisfiable = if is_arg {
!mat.iter().take(ii.len()).any(|c| matches!(c[i], Compatibility::Compatible))
} else {
true
};
// If this input can be satisfied by some argument, then this input is useful
let useless = if is_input {
!mat[i].iter().take(ai.len()).any(|c| matches!(c, Compatibility::Compatible))
} else {
true
};

match (is_input, is_arg, useless, unsatisfiable) {
// If an argument is unsatisfied, and the input in its position is useless
Expand Down
21 changes: 7 additions & 14 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
_ => bug!("unexpected type: {:?}", ty.normalized),
},
Res::Def(
DefKind::Struct | DefKind::Union | DefKind::TyAlias { .. } | DefKind::AssocTy,
_,
)
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
| Res::SelfTyParam { .. }
| Res::SelfTyAlias { .. } => match ty.normalized.ty_adt_def() {
Some(adt) if !adt.is_enum() => {
Expand Down Expand Up @@ -868,7 +865,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let decl_ty = self.local_ty(decl.span, decl.hir_id);

// Type check the initializer.
if let Some(ref init) = decl.init {
if let Some(init) = decl.init {
let init_ty = self.check_decl_initializer(decl.hir_id, decl.pat, init);
self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, init_ty);
}
Expand Down Expand Up @@ -932,7 +929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
// Ignore for now.
hir::StmtKind::Item(_) => {}
hir::StmtKind::Expr(ref expr) => {
hir::StmtKind::Expr(expr) => {
// Check with expected type of `()`.
self.check_expr_has_type_or_error(expr, self.tcx.types.unit, |err| {
if self.is_next_stmt_expr_continuation(stmt.hir_id)
Expand Down Expand Up @@ -1766,10 +1763,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let params =
params.get(is_method as usize..params.len() - sig.decl.c_variadic as usize)?;
debug_assert_eq!(params.len(), fn_inputs.len());
Some((
fn_inputs.zip(params.iter().map(|param| FnParam::Param(param))).collect(),
generics,
))
Some((fn_inputs.zip(params.iter().map(FnParam::Param)).collect(), generics))
}
(None, Some(params)) => {
let params =
Expand Down Expand Up @@ -2632,7 +2626,7 @@ impl<'a, 'b, 'tcx> FnCallDiagCtxt<'a, 'b, 'tcx> {
suggestions: Vec<(Span, String)>,
suggestion_text: SuggestionText,
) -> Option<String> {
let suggestion_text = match suggestion_text {
match suggestion_text {
SuggestionText::None => None,
SuggestionText::Provide(plural) => {
Some(format!("provide the argument{}", if plural { "s" } else { "" }))
Expand All @@ -2648,8 +2642,7 @@ impl<'a, 'b, 'tcx> FnCallDiagCtxt<'a, 'b, 'tcx> {
SuggestionText::Swap => Some("swap these arguments".to_string()),
SuggestionText::Reorder => Some("reorder these arguments".to_string()),
SuggestionText::DidYouMean => Some("did you mean".to_string()),
};
suggestion_text
}
}

fn arguments_formatting(&self, suggestion_span: Span) -> ArgumentsFormatting {
Expand Down Expand Up @@ -2947,7 +2940,7 @@ impl<'a, 'b, 'tcx> ArgsCtxt<'a, 'b, 'tcx> {
.fn_ctxt
.typeck_results
.borrow()
.expr_ty_adjusted_opt(*expr)
.expr_ty_adjusted_opt(expr)
.unwrap_or_else(|| Ty::new_misc_error(self.call_ctxt.fn_ctxt.tcx));
(
self.call_ctxt.fn_ctxt.resolve_vars_if_possible(ty),
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
})
.collect::<Vec<String>>();

if all_matching_bounds_strs.len() == 0 {
if all_matching_bounds_strs.is_empty() {
return;
}

Expand Down Expand Up @@ -1336,7 +1336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected_ty = *inner_expected_ty;
}
(hir::ExprKind::Block(blk, _), _, _) => {
self.suggest_block_to_brackets(diag, *blk, expr_ty, expected_ty);
self.suggest_block_to_brackets(diag, blk, expr_ty, expected_ty);
break true;
}
_ => break false,
Expand Down Expand Up @@ -1463,7 +1463,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let span = expr
.span
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
.find_ancestor_not_from_extern_macro(self.tcx.sess.source_map())
.unwrap_or(expr.span);

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

let span = expr
.span
.find_ancestor_not_from_extern_macro(&self.tcx.sess.source_map())
.find_ancestor_not_from_extern_macro(self.tcx.sess.source_map())
.unwrap_or(expr.span);
err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders);
true
Expand Down Expand Up @@ -2257,7 +2257,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let src_map = tcx.sess.source_map();
let suggestion = if src_map.is_multiline(expr.span) {
let indentation = src_map.indentation_before(span).unwrap_or_else(String::new);
let indentation = src_map.indentation_before(span).unwrap_or_default();
format!("\n{indentation}/* {suggestion} */")
} else {
// If the entire expr is on a single line
Expand Down Expand Up @@ -2289,7 +2289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Check if `expr` is contained in array of two elements
if let hir::Node::Expr(array_expr) = self.tcx.parent_hir_node(expr.hir_id)
&& let hir::ExprKind::Array(elements) = array_expr.kind
&& let [first, second] = &elements[..]
&& let [first, second] = elements
&& second.hir_id == expr.hir_id
{
// Span between the two elements of the array
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/gather_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
/// again during type checking by querying [`FnCtxt::local_ty`] for the same hir_id.
fn declare(&mut self, decl: Declaration<'tcx>) {
let local_ty = match decl.ty {
Some(ref ty) => {
Some(ty) => {
let o_ty = self.fcx.lower_ty(ty);

let c_ty = self.fcx.infcx.canonicalize_user_type_annotation(
Expand Down
17 changes: 6 additions & 11 deletions compiler/rustc_hir_typeck/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
}
}
}
hir::ExprKind::Loop(ref b, _, source, _) => {
hir::ExprKind::Loop(b, _, source, _) => {
let cx = match self.is_loop_match(e, b) {
Some(labeled_block) => LoopMatch { labeled_block },
None => Loop(source),
};

self.with_context(cx, |v| v.visit_block(b));
}
hir::ExprKind::Closure(&hir::Closure {
ref fn_decl, body, fn_decl_span, kind, ..
}) => {
hir::ExprKind::Closure(&hir::Closure { fn_decl, body, fn_decl_span, kind, .. }) => {
let cx = match kind {
hir::ClosureKind::Coroutine(hir::CoroutineKind::Desugared(kind, source)) => {
Coroutine { coroutine_span: fn_decl_span, kind, source }
Expand All @@ -167,16 +165,16 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
self.visit_fn_decl(fn_decl);
self.with_context(cx, |v| v.visit_nested_body(body));
}
hir::ExprKind::Block(ref b, Some(_label)) => {
hir::ExprKind::Block(b, Some(_label)) => {
self.with_context(LabeledBlock, |v| v.visit_block(b));
}
hir::ExprKind::Block(ref b, None)
hir::ExprKind::Block(b, None)
if matches!(self.cx_stack.last(), Some(&Fn) | Some(&ConstBlock)) =>
{
self.with_context(Normal, |v| v.visit_block(b));
}
hir::ExprKind::Block(
ref b @ hir::Block { rules: hir::BlockCheckMode::DefaultBlock, .. },
b @ hir::Block { rules: hir::BlockCheckMode::DefaultBlock, .. },
None,
) if matches!(
self.cx_stack.last(),
Expand Down Expand Up @@ -431,10 +429,7 @@ impl<'hir> CheckLoopVisitor<'hir> {

// Accept either `state = expr` or `state = expr;`.
let loop_body_expr = match body.stmts {
[] => match body.expr {
Some(expr) => expr,
None => return None,
},
[] => body.expr?,
[single] if body.expr.is_none() => match single.kind {
hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => expr,
_ => return None,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
BitMatrix {
num_rows,
num_columns,
words: iter::repeat(&row.words).take(num_rows).flatten().cloned().collect(),
words: iter::repeat_n(&row.words, num_rows).flatten().cloned().collect(),
marker: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//! Only valid for queries returning `Result<_, ErrorGuaranteed>`.
//!
//! For the up-to-date list, see the `QueryModifiers` struct in
//! [`rustc_macros/src/query.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_macros/src/query.rs)
//! [`rustc_macros/src/query.rs`](https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_macros/src/query.rs)
//! and for more details in incremental compilation, see the
//! [Query modifiers in incremental compilation](https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation-in-detail.html#query-modifiers) section of the rustc-dev-guide.
//!
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_transform/src/impossible_predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
//! parameters, so this filtering serves two purposes:
//!
//! 1. We skip evaluating any predicates that we would
//! never be able prove are unsatisfiable (e.g. `<T as Foo>`
//! never be able prove are unsatisfiable (e.g. `<T as Foo>`
//! 2. We avoid trying to normalize predicates involving generic
//! parameters (e.g. `<T as Foo>::MyItem`). This can confuse
//! the normalization code (leading to cycle errors), since
//! it's usually never invoked in this way.
//! parameters (e.g. `<T as Foo>::MyItem`). This can confuse
//! the normalization code (leading to cycle errors), since
//! it's usually never invoked in this way.

use rustc_middle::mir::{Body, START_BLOCK, TerminatorKind};
use rustc_middle::ty::{TyCtxt, TypeFlags, TypeVisitableExt};
Expand Down
Loading
Loading