Skip to content
Merged
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 compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
let mut transient = DenseBitSet::new_filled(ccx.body.local_decls.len());
// Make sure to only visit reachable blocks, the dataflow engine can ICE otherwise.
for (bb, data) in traversal::reachable(&ccx.body) {
if matches!(data.terminator().kind, TerminatorKind::Return) {
if data.terminator().kind == TerminatorKind::Return {
let location = ccx.body.terminator_loc(bb);
maybe_storage_live.seek_after_primary_effect(location);
// If a local may be live here, it is definitely not transient.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ where
// i.e., we treat all qualifs as non-structural for deref projections. Generally,
// we can say very little about `*ptr` even if we know that `ptr` satisfies all
// sorts of properties.
if matches!(elem, ProjectionElem::Deref) {
if elem == ProjectionElem::Deref {
// We have to assume that this qualifies.
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
'tcx: 'y,
{
assert_eq!(callee_ty, callee_abi.layout.ty);
if matches!(callee_abi.mode, PassMode::Ignore) {
if callee_abi.mode == PassMode::Ignore {
// This one is skipped. Still must be made live though!
if !already_live {
self.storage_live(callee_arg.as_local().unwrap())?;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
}
} else {
// unsigned
if matches!(mir_op, BinOp::Add) {
if mir_op == BinOp::Add {
// max unsigned
Scalar::from_uint(size.unsigned_int_max(), size)
} else {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
return Err(ConstEvalErrKind::ConstMakeGlobalWithOffset(ptr)).into();
}

if matches!(self.tcx.try_get_global_alloc(alloc_id), Some(_)) {
if self.tcx.try_get_global_alloc(alloc_id).is_some() {
// This points to something outside the current interpreter.
return Err(ConstEvalErrKind::ConstMakeGlobalPtrIsNonHeap(ptr)).into();
}
Expand Down Expand Up @@ -981,7 +981,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
msg: CheckInAllocMsg,
) -> InterpResult<'tcx, (Size, Align)> {
let info = self.get_alloc_info(id);
if matches!(info.kind, AllocKind::Dead) {
if info.kind == AllocKind::Dead {
throw_ub!(PointerUseAfterFree(id, msg))
}
interp_ok((info.size, info.align))
Expand Down Expand Up @@ -1072,7 +1072,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Recurse, if there is data here.
// Do this *before* invoking the callback, as the callback might mutate the
// allocation and e.g. replace all provenance by wildcards!
if matches!(info.kind, AllocKind::LiveData) {
if info.kind == AllocKind::LiveData {
let alloc = self.get_alloc_raw(id)?;
for prov in alloc.provenance().provenances() {
if let Some(id) = prov.get_alloc_id() {
Expand Down Expand Up @@ -1605,7 +1605,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
match self.ptr_try_get_alloc_id(ptr, 0) {
Ok((alloc_id, offset, _)) => {
let info = self.get_alloc_info(alloc_id);
if matches!(info.kind, AllocKind::TypeId) {
if info.kind == AllocKind::TypeId {
// We *could* actually precisely answer this question since here,
// the offset *is* the integer value. But the entire point of making
// this a pointer is not to leak the integer value, so we say everything
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ pub(crate) fn check_trait_item<'tcx>(

let mut res = Ok(());

if matches!(tcx.def_kind(def_id), DefKind::AssocFn) {
if tcx.def_kind(def_id) == DefKind::AssocFn {
for &assoc_ty_def_id in
tcx.associated_types_for_impl_traits_in_associated_fn(def_id.to_def_id())
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
}
}
} else {
if matches!(def_kind, DefKind::AnonConst)
if def_kind == DefKind::AnonConst
&& tcx.features().generic_const_exprs()
&& let Some(defaulted_param_def_id) =
tcx.hir_opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Don't write user type annotations for const param types, since we give them
// identity args just so that we can trivially substitute their `EarlyBinder`.
// We enforce that they match their type in MIR later on.
if matches!(self.tcx.def_kind(def_id), DefKind::ConstParam) {
if self.tcx.def_kind(def_id) == DefKind::ConstParam {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'tcx> Statement<'tcx> {
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
/// invalidating statement indices in `Location`s.
pub fn make_nop(&mut self, drop_debuginfo: bool) {
if matches!(self.kind, StatementKind::Nop) {
if self.kind == StatementKind::Nop {
return;
}
let replaced_stmt = std::mem::replace(&mut self.kind, StatementKind::Nop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'tcx> InhabitedPredicate<'tcx> {
pub fn all(tcx: TyCtxt<'tcx>, iter: impl IntoIterator<Item = Self>) -> Self {
let mut result = Self::True;
for pred in iter {
if matches!(pred, Self::False) {
if pred == Self::False {
return Self::False;
}
result = result.and(tcx, pred);
Expand All @@ -171,7 +171,7 @@ impl<'tcx> InhabitedPredicate<'tcx> {
pub fn any(tcx: TyCtxt<'tcx>, iter: impl IntoIterator<Item = Self>) -> Self {
let mut result = Self::False;
for pred in iter {
if matches!(pred, Self::True) {
if pred == Self::True {
return Self::True;
}
result = result.or(tcx, pred);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3381,7 +3381,7 @@ define_print_and_forward_display! {
fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, Namespace, DefId)) {
// Iterate all (non-anonymous) local crate items no matter where they are defined.
for id in tcx.hir_free_items() {
if matches!(tcx.def_kind(id.owner_id), DefKind::Use) {
if tcx.def_kind(id.owner_id) == DefKind::Use {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ impl<'v> RootCollector<'_, 'v> {
}

fn process_impl_item(&mut self, id: hir::ImplItemId) {
if matches!(self.tcx.def_kind(id.owner_id), DefKind::AssocFn) {
if self.tcx.def_kind(id.owner_id) == DefKind::AssocFn {
self.push_if_root(id.owner_id.def_id);
}
}
Expand Down Expand Up @@ -1720,7 +1720,7 @@ fn create_mono_items_for_default_impls<'tcx>(
) {
let impl_ = tcx.impl_trait_header(item.owner_id);

if matches!(impl_.polarity, ty::ImplPolarity::Negative) {
if impl_.polarity == ty::ImplPolarity::Negative {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn eat_operand_keyword<'a>(
exp: ExpKeywordPair,
asm_macro: AsmMacro,
) -> PResult<'a, bool> {
if matches!(asm_macro, AsmMacro::Asm) {
if asm_macro == AsmMacro::Asm {
Ok(p.eat_keyword(exp))
} else {
let span = p.token.span;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,7 @@ impl<'a> Parser<'a> {
pub(crate) fn eat_label(&mut self) -> Option<Label> {
if let Some((ident, is_raw)) = self.token.lifetime() {
// Disallow `'fn`, but with a better error message than `expect_lifetime`.
if matches!(is_raw, IdentIsRaw::No) && ident.without_first_quote().is_reserved() {
if is_raw == IdentIsRaw::No && ident.without_first_quote().is_reserved() {
self.dcx().emit_err(errors::KeywordLabel { span: ident.span });
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ impl<'a> Parser<'a> {
/// for better diagnostics and suggestions.
fn parse_field_ident(&mut self, adt_ty: &str, lo: Span) -> PResult<'a, Ident> {
let (ident, is_raw) = self.ident_or_err(true)?;
if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() {
if is_raw == IdentIsRaw::No && ident.is_reserved() {
let snapshot = self.create_snapshot_for_diagnostic();
let err = if self.check_fn_front_matter(false, Case::Sensitive) {
let inherited_vis =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<'a> Parser<'a> {
fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> {
let (ident, is_raw) = self.ident_or_err(recover)?;

if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() {
if is_raw == IdentIsRaw::No && ident.is_reserved() {
let err = self.expected_ident_found_err();
if recover {
err.emit();
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1551,9 +1551,7 @@ impl<'a> Parser<'a> {
/// Parses a single lifetime `'a` or panics.
pub(super) fn expect_lifetime(&mut self) -> Lifetime {
if let Some((ident, is_raw)) = self.token.lifetime() {
if matches!(is_raw, IdentIsRaw::No)
&& ident.without_first_quote().is_reserved_lifetime()
{
if is_raw == IdentIsRaw::No && ident.without_first_quote().is_reserved_lifetime() {
self.dcx().emit_err(errors::KeywordLifetime { span: ident.span });
}

Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
target: Target,
item: Option<ItemLike<'_>>,
) {
if matches!(target, Target::Impl { of_trait: true }) {
if target == (Target::Impl { of_trait: true }) {
match item.unwrap() {
ItemLike::Item(it) => match it.expect_impl().constness {
Constness::Const => {}
Expand Down Expand Up @@ -1553,10 +1553,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
fn check_deprecated(&self, hir_id: HirId, attr_span: Span, target: Target) {
match target {
Target::AssocConst | Target::Method(..) | Target::AssocTy
if matches!(
self.tcx.def_kind(self.tcx.local_parent(hir_id.owner.def_id)),
DefKind::Impl { of_trait: true }
) =>
if self.tcx.def_kind(self.tcx.local_parent(hir_id.owner.def_id))
== DefKind::Impl { of_trait: true } =>
{
self.tcx.emit_node_span_lint(
UNUSED_ATTRIBUTES,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
hir::ItemKind::Trait(.., trait_item_refs) => {
// mark assoc ty live if the trait is live
for trait_item in trait_item_refs {
if matches!(self.tcx.def_kind(trait_item.owner_id), DefKind::AssocTy) {
if self.tcx.def_kind(trait_item.owner_id) == DefKind::AssocTy {
self.check_def_id(trait_item.owner_id.to_def_id());
}
}
Expand Down Expand Up @@ -1179,7 +1179,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
// we have diagnosed them in the trait if they are unused,
// for unused assoc items in unused trait,
// we have diagnosed the unused trait.
if matches!(def_kind, DefKind::Impl { of_trait: false })
if def_kind == (DefKind::Impl { of_trait: false })
|| (def_kind == DefKind::Trait && live_symbols.contains(&item.owner_id.def_id))
{
for &def_id in tcx.associated_item_def_ids(item.owner_id.def_id) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ impl Target {
Arch::AArch64 | Arch::Arm64EC => {
// Aarch64 has no sane ABI specifier, and LLVM doesn't even have a way to force
// the use of soft-float, so all we can do here is some crude hacks.
if matches!(self.abi, Abi::SoftFloat) {
if self.abi == Abi::SoftFloat {
// LLVM will use float registers when `fp-armv8` is available, e.g. for
// calls to built-ins. The only way to ensure a consistent softfloat ABI
// on aarch64 is to never enable `fp-armv8`, so we enforce that.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
let (def_id, args) = match *ty.kind() {
ty::Alias(_, ty::AliasTy { def_id, args, .. })
if matches!(self.tcx.def_kind(def_id), DefKind::OpaqueTy) =>
if self.tcx.def_kind(def_id) == DefKind::OpaqueTy =>
{
(def_id, args)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn evaluate_host_effect_obligation<'tcx>(
selcx: &mut SelectionContext<'_, 'tcx>,
obligation: &HostEffectObligation<'tcx>,
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
if matches!(selcx.infcx.typing_mode(), TypingMode::Coherence) {
if selcx.infcx.typing_mode() == TypingMode::Coherence {
span_bug!(
obligation.cause.span,
"should not select host obligation in old solver in intercrate mode"
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// share the same type as `self_ty`. This is because for truly rigid
// projections, we will never be able to equate, e.g. `<T as Tr>::A`
// with `<<T as Tr>::A as Tr>::A`.
let relevant_bounds = if matches!(alias_bound_kind, AliasBoundKind::NonSelfBounds) {
let relevant_bounds = if alias_bound_kind == AliasBoundKind::NonSelfBounds {
self.tcx().item_non_self_bounds(alias_ty.def_id)
} else {
self.tcx().item_self_bounds(alias_ty.def_id)
Expand Down Expand Up @@ -2855,7 +2855,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
}

// Register any outlives obligations from the trait here, cc #124336.
if matches!(tcx.def_kind(def_id), DefKind::Impl { of_trait: true }) {
if tcx.def_kind(def_id) == (DefKind::Impl { of_trait: true }) {
for clause in tcx.impl_super_outlives(def_id).iter_instantiated(tcx, args) {
let clause = normalize_with_depth_to(
self,
Expand Down
14 changes: 14 additions & 0 deletions src/doc/rustc/src/remap-source-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ The replacement is purely textual, with no consideration of the current system's

When multiple remappings are given and several of them match, the **last** matching one is applied.

### Relative paths

Some build systems, such as Cargo, may compile crates using relative paths (for example,
`src/main.rs` instead of `/home/user/project/src/main.rs)`.

`rustc` preserves these relative paths where possible. However, certain inputs
(like `#[path = "..."]`) and outputs (such as debug information) may still contain absolute paths.

To ensure consistency, it’s recommended to remap both relative and absolute paths.

```bash
rustc --remap-path-prefix "src/=/redacted/src" --remap-path-prefix "/home/user/project=/redacted"
```

### Example

```bash
Expand Down
Loading