Skip to content

Commit

Permalink
some minor code simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Mar 17, 2024
1 parent ecdea9e commit 49a651c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
/// suppressed. Needless to say, this must only be set with great care! Cannot be nested.
pub(super) fn run_for_validation<R>(&self, f: impl FnOnce() -> R) -> R {
assert!(
self.memory.validation_in_progress.replace(true) == false,
!self.memory.validation_in_progress.replace(true),
"`validation_in_progress` was already set"
);
let res = f();
assert!(
self.memory.validation_in_progress.replace(false) == true,
self.memory.validation_in_progress.replace(false),
"`validation_in_progress` was unset by someone else"
);
res
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = callee_expr.kind
&& let Res::Local(_) = path.res
&& let [segment] = &path.segments[..]
&& let [segment] = &path.segments
{
for id in self.tcx.hir().items() {
if let Some(node) = self.tcx.hir().get_if_local(id.owner_id.into())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub(super) fn extract_branch_mappings(
let (span, _) = unexpand_into_body_span_with_visible_macro(raw_span, body_span)?;

let bcb_from_marker = |marker: BlockMarkerId| {
Some(basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)?)
basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)
};

let true_bcb = bcb_from_marker(true_marker)?;
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,12 @@ pub enum InstrumentCoverage {
}

/// Individual flag values controlled by `-Z coverage-options`.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
pub struct CoverageOptions {
/// Add branch coverage instrumentation.
pub branch: bool,
}

impl Default for CoverageOptions {
fn default() -> Self {
Self { branch: false }
}
}

/// Settings for `-Z instrument-xray` flag.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ fn first_non_private<'tcx>(
path: &hir::Path<'tcx>,
) -> Option<Path> {
let target_def_id = path.res.opt_def_id()?;
let (parent_def_id, ident) = match &path.segments[..] {
let (parent_def_id, ident) = match &path.segments {
[] => return None,
// Relative paths are available in the same scope as the owner.
[leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').filter(|c| !c.is_empty()).next().unwrap());
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());

/// Render a sequence of macro arms in a format suitable for displaying to the user
/// as part of an item declaration.
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ impl RenderType {
string.push('{');
write_optional_id(self.id, string);
string.push('{');
for generic in &self.generics.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
for generic in &self.generics.as_deref().unwrap_or_default()[..] {
generic.write_to_string(string);
}
string.push('}');
if self.bindings.is_some() {
string.push('{');
for binding in &self.bindings.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
for binding in &self.bindings.as_deref().unwrap_or_default()[..] {
string.push('{');
binding.0.write_to_string(string);
string.push('{');
Expand Down

0 comments on commit 49a651c

Please sign in to comment.