Skip to content

Commit 8a778ca

Browse files
committed
Auto merge of #110405 - fee1-dead-contrib:rollup-9rkree6, r=fee1-dead
Rollup of 4 pull requests Successful merges: - #110397 (Move some utils out of `rustc_const_eval`) - #110398 (use matches! macro in more places) - #110400 (more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_defau…) - #110402 (Remove the loop in `Align::from_bytes`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1b50ea9 + 38215fb commit 8a778ca

File tree

33 files changed

+91
-114
lines changed

33 files changed

+91
-114
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4421,7 +4421,6 @@ dependencies = [
44214421
"either",
44224422
"itertools",
44234423
"polonius-engine",
4424-
"rustc_const_eval",
44254424
"rustc_data_structures",
44264425
"rustc_errors",
44274426
"rustc_graphviz",

compiler/rustc_abi/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,15 +665,12 @@ impl Align {
665665
format!("`{}` is too large", align)
666666
}
667667

668-
let mut bytes = align;
669-
let mut pow2: u8 = 0;
670-
while (bytes & 1) == 0 {
671-
pow2 += 1;
672-
bytes >>= 1;
673-
}
674-
if bytes != 1 {
668+
let tz = align.trailing_zeros();
669+
if align != (1 << tz) {
675670
return Err(not_power_of_2(align));
676671
}
672+
673+
let pow2 = tz as u8;
677674
if pow2 > Self::MAX.pow2 {
678675
return Err(too_large(align));
679676
}

compiler/rustc_ast/src/ast.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,17 +1298,17 @@ impl Expr {
12981298

12991299
/// To a first-order approximation, is this a pattern?
13001300
pub fn is_approximately_pattern(&self) -> bool {
1301-
match &self.peel_parens().kind {
1301+
matches!(
1302+
&self.peel_parens().kind,
13021303
ExprKind::Array(_)
1303-
| ExprKind::Call(_, _)
1304-
| ExprKind::Tup(_)
1305-
| ExprKind::Lit(_)
1306-
| ExprKind::Range(_, _, _)
1307-
| ExprKind::Underscore
1308-
| ExprKind::Path(_, _)
1309-
| ExprKind::Struct(_) => true,
1310-
_ => false,
1311-
}
1304+
| ExprKind::Call(_, _)
1305+
| ExprKind::Tup(_)
1306+
| ExprKind::Lit(_)
1307+
| ExprKind::Range(_, _, _)
1308+
| ExprKind::Underscore
1309+
| ExprKind::Path(_, _)
1310+
| ExprKind::Struct(_)
1311+
)
13121312
}
13131313
}
13141314

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,7 @@ enum FnDeclKind {
332332

333333
impl FnDeclKind {
334334
fn param_impl_trait_allowed(&self) -> bool {
335-
match self {
336-
FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => true,
337-
_ => false,
338-
}
335+
matches!(self, FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait)
339336
}
340337

341338
fn return_impl_trait_allowed(&self, tcx: TyCtxt<'_>) -> bool {

compiler/rustc_borrowck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ rustc_infer = { path = "../rustc_infer" }
2020
rustc_lexer = { path = "../rustc_lexer" }
2121
rustc_macros = { path = "../rustc_macros" }
2222
rustc_middle = { path = "../rustc_middle" }
23-
rustc_const_eval = { path = "../rustc_const_eval" }
2423
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
2524
rustc_serialize = { path = "../rustc_serialize" }
2625
rustc_session = { path = "../rustc_session" }

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use either::Either;
2-
use rustc_const_eval::util::CallKind;
32
use rustc_data_structures::captures::Captures;
43
use rustc_data_structures::fx::FxIndexSet;
54
use rustc_errors::{
@@ -18,6 +17,7 @@ use rustc_middle::mir::{
1817
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
1918
};
2019
use rustc_middle::ty::{self, suggest_constraining_type_params, PredicateKind, Ty};
20+
use rustc_middle::util::CallKind;
2121
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
2222
use rustc_span::def_id::LocalDefId;
2323
use rustc_span::hygiene::DesugaringKind;
@@ -2424,7 +2424,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
24242424
Some((method_did, method_substs)),
24252425
) = (
24262426
&self.body[loan.reserve_location.block].terminator,
2427-
rustc_const_eval::util::find_self_call(
2427+
rustc_middle::util::find_self_call(
24282428
tcx,
24292429
self.body,
24302430
loan.assigned_place.local,

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Borrow checker diagnostics.
22
33
use itertools::Itertools;
4-
use rustc_const_eval::util::{call_kind, CallDesugaringKind};
54
use rustc_errors::{Applicability, Diagnostic};
65
use rustc_hir as hir;
76
use rustc_hir::def::{CtorKind, Namespace};
@@ -15,6 +14,7 @@ use rustc_middle::mir::{
1514
};
1615
use rustc_middle::ty::print::Print;
1716
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
17+
use rustc_middle::util::{call_kind, CallDesugaringKind};
1818
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
1919
use rustc_span::def_id::LocalDefId;
2020
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
@@ -45,7 +45,7 @@ pub(crate) use mutability_errors::AccessKind;
4545
pub(crate) use outlives_suggestion::OutlivesSuggestionBuilder;
4646
pub(crate) use region_errors::{ErrorConstraintInfo, RegionErrorKind, RegionErrors};
4747
pub(crate) use region_name::{RegionName, RegionNameSource};
48-
pub(crate) use rustc_const_eval::util::CallKind;
48+
pub(crate) use rustc_middle::util::CallKind;
4949

5050
pub(super) struct DescribePlaceOpt {
5151
pub including_downcast: bool,
@@ -874,7 +874,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
874874
}) = &self.body[location.block].terminator
875875
{
876876
let Some((method_did, method_substs)) =
877-
rustc_const_eval::util::find_self_call(
877+
rustc_middle::util::find_self_call(
878878
self.infcx.tcx,
879879
&self.body,
880880
target_temp,

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_span::{sym, BytePos, Span};
1515
use rustc_target::abi::FieldIdx;
1616

1717
use crate::diagnostics::BorrowedContentSource;
18+
use crate::util::FindAssignments;
1819
use crate::MirBorrowckCtxt;
19-
use rustc_const_eval::util::collect_writes::FindAssignments;
2020

2121
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2222
pub(crate) enum AccessKind {

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ mod session_diagnostics;
8888
mod type_check;
8989
mod universal_regions;
9090
mod used_muts;
91+
mod util;
9192

9293
/// A public API provided for the Rust compiler consumers.
9394
pub mod consumers;

0 commit comments

Comments
 (0)