Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
492826a
Add a note about the panic behavior of math operations on time objects
poliorcetics Sep 5, 2020
a6ff925
Reduce boilerplate with the matches! macro
LingMan Sep 21, 2020
b4e77d2
rewrite old test so that its attributes are consistent with what we w…
pnkfelix Jun 15, 2020
9601724
Avoid unchecked casts in net parser
tamird Oct 4, 2020
f78a7ad
Inline "eof" methods
tamird Oct 4, 2020
afa2a67
Prevent forbid from being ignored if overriden at the same level.
pnkfelix Jun 15, 2020
5ab1967
Remove extra indirection in LitKind::ByteStr
rschoon Sep 17, 2020
62f7712
Change clippy's Constant back to refcount clone byte strings
rschoon Oct 4, 2020
b205436
Allow anyone to set regression labels
camelid Oct 4, 2020
afe83d4
Rename bootstrap/defaults/{config.toml.PROFILE => config.PROFILE.toml}
thomcc Oct 5, 2020
5388eb4
Add changelog entry mentioning the renamed profile files
thomcc Oct 5, 2020
daf48b8
inliner: use caller param_env
lcnr Oct 5, 2020
b1ce619
Add missing examples for MaybeUninit
GuillaumeGomez Sep 26, 2020
9704911
Use matches! for core::char methods
pickfire Oct 5, 2020
35192ff
Fix span for unicode escape suggestion.
ehuss Oct 5, 2020
7c2dd01
Rollup merge of #76388 - poliorcetics:system-time-document-panic, r=K…
jonas-schievink Oct 5, 2020
886e030
Rollup merge of #76995 - LingMan:middle_matches, r=varkor
jonas-schievink Oct 5, 2020
01d45ec
Rollup merge of #77228 - GuillaumeGomez:maybeuninit-examples, r=pickfire
jonas-schievink Oct 5, 2020
5b97a70
Rollup merge of #77528 - tamird:avoid-cast-net-parser, r=dtolnay
jonas-schievink Oct 5, 2020
8f33841
Rollup merge of #77534 - Mark-Simulacrum:issue-70819-disallow-overrid…
jonas-schievink Oct 5, 2020
2e185c7
Rollup merge of #77555 - camelid:patch-8, r=Mark-Simulacrum
jonas-schievink Oct 5, 2020
5b56541
Rollup merge of #77558 - thomcc:defaults-toml-extension, r=jyn514
jonas-schievink Oct 5, 2020
04d9ae4
Rollup merge of #77560 - rschoon:fix-litkind-rc-bytebuf, r=lcnr
jonas-schievink Oct 5, 2020
6d1cc0d
Rollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse
jonas-schievink Oct 5, 2020
6fbda95
Rollup merge of #77571 - pickfire:patch-6, r=cramertj
jonas-schievink Oct 5, 2020
7af4959
Rollup merge of #77587 - ehuss:unicode-escape-span, r=ecstatic-morse
jonas-schievink Oct 5, 2020
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
16 changes: 8 additions & 8 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,15 @@ impl<'hir> Map<'hir> {
Some(Node::Binding(_)) => (),
_ => return false,
}
match self.find(self.get_parent_node(id)) {
matches!(
self.find(self.get_parent_node(id)),
Some(
Node::Item(_)
| Node::TraitItem(_)
| Node::ImplItem(_)
| Node::Expr(Expr { kind: ExprKind::Closure(..), .. }),
) => true,
_ => false,
}
)
)
}

/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
Expand All @@ -554,10 +554,10 @@ impl<'hir> Map<'hir> {

/// Whether `hir_id` corresponds to a `mod` or a crate.
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool {
match self.get_entry(hir_id).node {
Node::Item(Item { kind: ItemKind::Mod(_), .. }) | Node::Crate(..) => true,
_ => false,
}
matches!(
self.get_entry(hir_id).node,
Node::Item(Item { kind: ItemKind::Mod(_), .. }) | Node::Crate(..)
)
}

/// Retrieves the `HirId` for `id`'s enclosing method, unless there's a
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ impl<'tcx> TyCtxt<'tcx> {
// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
// However, formatting code relies on function identity (see #58320), so we only do
// this for generic functions. Lifetime parameters are ignored.
let is_generic = instance.substs.into_iter().any(|kind| match kind.unpack() {
GenericArgKind::Lifetime(_) => false,
_ => true,
});
let is_generic = instance
.substs
.into_iter()
.any(|kind| !matches!(kind.unpack(), GenericArgKind::Lifetime(_)));
if is_generic {
// Get a fresh ID.
let mut alloc_map = self.alloc_map.lock();
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_middle/src/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,19 +445,13 @@ impl<'tcx, Tag> Scalar<Tag> {
/// Do not call this method! Dispatch based on the type instead.
#[inline]
pub fn is_bits(self) -> bool {
match self {
Scalar::Raw { .. } => true,
_ => false,
}
matches!(self, Scalar::Raw { .. })
}

/// Do not call this method! Dispatch based on the type instead.
#[inline]
pub fn is_ptr(self) -> bool {
match self {
Scalar::Ptr(_) => true,
_ => false,
}
matches!(self, Scalar::Ptr(_))
}

pub fn to_bool(self) -> InterpResult<'tcx, bool> {
Expand Down
73 changes: 31 additions & 42 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,67 +971,59 @@ impl<'tcx> LocalDecl<'tcx> {
/// - `let x = ...`,
/// - or `match ... { C(x) => ... }`
pub fn can_be_made_mutable(&self) -> bool {
match self.local_info {
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm {
binding_mode: ty::BindingMode::BindByValue(_),
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})))) => true,

Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(
ImplicitSelfKind::Imm,
)))) => true,

_ => false,
}
matches!(
self.local_info,
Some(box LocalInfo::User(ClearCrossCrate::Set(
BindingForm::Var(VarBindingForm {
binding_mode: ty::BindingMode::BindByValue(_),
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})
| BindingForm::ImplicitSelf(ImplicitSelfKind::Imm),
)))
)
}

/// Returns `true` if local is definitely not a `ref ident` or
/// `ref mut ident` binding. (Such bindings cannot be made into
/// mutable bindings, but the inverse does not necessarily hold).
pub fn is_nonref_binding(&self) -> bool {
match self.local_info {
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm {
binding_mode: ty::BindingMode::BindByValue(_),
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})))) => true,

Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(_)))) => true,

_ => false,
}
matches!(
self.local_info,
Some(box LocalInfo::User(ClearCrossCrate::Set(
BindingForm::Var(VarBindingForm {
binding_mode: ty::BindingMode::BindByValue(_),
opt_ty_info: _,
opt_match_place: _,
pat_span: _,
})
| BindingForm::ImplicitSelf(_),
)))
)
}

/// Returns `true` if this variable is a named variable or function
/// parameter declared by the user.
#[inline]
pub fn is_user_variable(&self) -> bool {
match self.local_info {
Some(box LocalInfo::User(_)) => true,
_ => false,
}
matches!(self.local_info, Some(box LocalInfo::User(_)))
}

/// Returns `true` if this is a reference to a variable bound in a `match`
/// expression that is used to access said variable for the guard of the
/// match arm.
pub fn is_ref_for_guard(&self) -> bool {
match self.local_info {
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::RefForGuard))) => true,
_ => false,
}
matches!(
self.local_info,
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::RefForGuard)))
)
}

/// Returns `Some` if this is a reference to a static item that is used to
/// access that static
pub fn is_ref_to_static(&self) -> bool {
match self.local_info {
Some(box LocalInfo::StaticRef { .. }) => true,
_ => false,
}
matches!(self.local_info, Some(box LocalInfo::StaticRef { .. }))
}

/// Returns `Some` if this is a reference to a static item that is used to
Expand Down Expand Up @@ -2164,10 +2156,7 @@ pub enum BinOp {
impl BinOp {
pub fn is_checkable(self) -> bool {
use self::BinOp::*;
match self {
Add | Sub | Mul | Shl | Shr => true,
_ => false,
}
matches!(self, Add | Sub | Mul | Shl | Shr)
}
}

Expand Down
63 changes: 22 additions & 41 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,82 +1164,63 @@ pub enum PlaceContext {
impl PlaceContext {
/// Returns `true` if this place context represents a drop.
pub fn is_drop(&self) -> bool {
match *self {
PlaceContext::MutatingUse(MutatingUseContext::Drop) => true,
_ => false,
}
matches!(self, PlaceContext::MutatingUse(MutatingUseContext::Drop))
}

/// Returns `true` if this place context represents a borrow.
pub fn is_borrow(&self) -> bool {
match *self {
matches!(
self,
PlaceContext::NonMutatingUse(
NonMutatingUseContext::SharedBorrow
| NonMutatingUseContext::ShallowBorrow
| NonMutatingUseContext::UniqueBorrow,
)
| PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
_ => false,
}
| NonMutatingUseContext::ShallowBorrow
| NonMutatingUseContext::UniqueBorrow
) | PlaceContext::MutatingUse(MutatingUseContext::Borrow)
)
}

/// Returns `true` if this place context represents a storage live or storage dead marker.
pub fn is_storage_marker(&self) -> bool {
match *self {
PlaceContext::NonUse(NonUseContext::StorageLive | NonUseContext::StorageDead) => true,
_ => false,
}
matches!(
self,
PlaceContext::NonUse(NonUseContext::StorageLive | NonUseContext::StorageDead)
)
}

/// Returns `true` if this place context represents a storage live marker.
pub fn is_storage_live_marker(&self) -> bool {
match *self {
PlaceContext::NonUse(NonUseContext::StorageLive) => true,
_ => false,
}
matches!(self, PlaceContext::NonUse(NonUseContext::StorageLive))
}

/// Returns `true` if this place context represents a storage dead marker.
pub fn is_storage_dead_marker(&self) -> bool {
match *self {
PlaceContext::NonUse(NonUseContext::StorageDead) => true,
_ => false,
}
matches!(self, PlaceContext::NonUse(NonUseContext::StorageDead))
}

/// Returns `true` if this place context represents a use that potentially changes the value.
pub fn is_mutating_use(&self) -> bool {
match *self {
PlaceContext::MutatingUse(..) => true,
_ => false,
}
matches!(self, PlaceContext::MutatingUse(..))
}

/// Returns `true` if this place context represents a use that does not change the value.
pub fn is_nonmutating_use(&self) -> bool {
match *self {
PlaceContext::NonMutatingUse(..) => true,
_ => false,
}
matches!(self, PlaceContext::NonMutatingUse(..))
}

/// Returns `true` if this place context represents a use.
pub fn is_use(&self) -> bool {
match *self {
PlaceContext::NonUse(..) => false,
_ => true,
}
!matches!(self, PlaceContext::NonUse(..))
}

/// Returns `true` if this place context represents an assignment statement.
pub fn is_place_assignment(&self) -> bool {
match *self {
matches!(
self,
PlaceContext::MutatingUse(
MutatingUseContext::Store
| MutatingUseContext::Call
| MutatingUseContext::AsmOutput,
) => true,
_ => false,
}
| MutatingUseContext::Call
| MutatingUseContext::AsmOutput,
)
)
}
}
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/traits/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ pub enum Node {

impl<'tcx> Node {
pub fn is_from_trait(&self) -> bool {
match *self {
Node::Trait(..) => true,
_ => false,
}
matches!(self, Node::Trait(..))
}

/// Iterate over the items defined directly by the given (impl or trait) node.
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/ty/adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ pub struct Adjustment<'tcx> {

impl Adjustment<'tcx> {
pub fn is_region_borrow(&self) -> bool {
match self.kind {
Adjust::Borrow(AutoBorrow::Ref(..)) => true,
_ => false,
}
matches!(self.kind, Adjust::Borrow(AutoBorrow::Ref(..)))
}
}

Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,7 @@ impl<'tcx> TypeckResults<'tcx> {
return false;
}

match self.type_dependent_defs().get(expr.hir_id) {
Some(Ok((DefKind::AssocFn, _))) => true,
_ => false,
}
matches!(self.type_dependent_defs().get(expr.hir_id), Some(Ok((DefKind::AssocFn, _))))
}

pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> {
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ use rustc_hir::{QPath, TyKind, WhereBoundPredicate, WherePredicate};
impl<'tcx> TyS<'tcx> {
/// Similar to `TyS::is_primitive`, but also considers inferred numeric values to be primitive.
pub fn is_primitive_ty(&self) -> bool {
match self.kind() {
Bool
| Char
| Str
| Int(_)
| Uint(_)
| Float(_)
matches!(
self.kind(),
Bool | Char | Str | Int(_) | Uint(_) | Float(_)
| Infer(
InferTy::IntVar(_)
| InferTy::FloatVar(_)
| InferTy::FreshIntTy(_)
| InferTy::FreshFloatTy(_),
) => true,
_ => false,
}
| InferTy::FreshFloatTy(_)
)
)
}

/// Whether the type is succinctly representable as a type instead of just referred to with a
Expand Down Expand Up @@ -64,11 +59,16 @@ impl<'tcx> TyS<'tcx> {

/// Whether the type can be safely suggested during error recovery.
pub fn is_suggestable(&self) -> bool {
match self.kind() {
Opaque(..) | FnDef(..) | FnPtr(..) | Dynamic(..) | Closure(..) | Infer(..)
| Projection(..) => false,
_ => true,
}
!matches!(
self.kind(),
Opaque(..)
| FnDef(..)
| FnPtr(..)
| Dynamic(..)
| Closure(..)
| Infer(..)
| Projection(..)
)
}
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ impl<'tcx> InstanceDef<'tcx> {
ty::InstanceDef::DropGlue(_, Some(_)) => return false,
_ => return true,
};
match tcx.def_key(def_id).disambiguated_data.data {
DefPathData::Ctor | DefPathData::ClosureExpr => true,
_ => false,
}
matches!(
tcx.def_key(def_id).disambiguated_data.data,
DefPathData::Ctor | DefPathData::ClosureExpr
)
}

/// Returns `true` if the machine code for this instance is instantiated in
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2610,10 +2610,7 @@ where
target.target_os == "linux" && target.arch == "sparc64" && target_env_gnu_like;
let linux_powerpc_gnu_like =
target.target_os == "linux" && target.arch == "powerpc" && target_env_gnu_like;
let rust_abi = match sig.abi {
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true,
_ => false,
};
let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall);

// Handle safe Rust thin and fat pointers.
let adjust_for_rust_scalar = |attrs: &mut ArgAttributes,
Expand Down
Loading