Skip to content

Commit b21e6de

Browse files
committed
some minor code simplifications
1 parent ecdea9e commit b21e6de

File tree

6 files changed

+7
-12
lines changed

6 files changed

+7
-12
lines changed

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
755755

756756
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = callee_expr.kind
757757
&& let Res::Local(_) = path.res
758-
&& let [segment] = &path.segments[..]
758+
&& let [segment] = &path.segments
759759
{
760760
for id in self.tcx.hir().items() {
761761
if let Some(node) = self.tcx.hir().get_if_local(id.owner_id.into())

compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub(super) fn extract_branch_mappings(
402402
let (span, _) = unexpand_into_body_span_with_visible_macro(raw_span, body_span)?;
403403

404404
let bcb_from_marker = |marker: BlockMarkerId| {
405-
Some(basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)?)
405+
basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)
406406
};
407407

408408
let true_bcb = bcb_from_marker(true_marker)?;

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,12 @@ pub enum InstrumentCoverage {
144144
}
145145

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

153-
impl Default for CoverageOptions {
154-
fn default() -> Self {
155-
Self { branch: false }
156-
}
157-
}
158153

159154
/// Settings for `-Z instrument-xray` flag.
160155
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ fn first_non_private<'tcx>(
15721572
path: &hir::Path<'tcx>,
15731573
) -> Option<Path> {
15741574
let target_def_id = path.res.opt_def_id()?;
1575-
let (parent_def_id, ident) = match &path.segments[..] {
1575+
let (parent_def_id, ident) = match &path.segments {
15761576
[] => return None,
15771577
// Relative paths are available in the same scope as the owner.
15781578
[leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident),

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
598598
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
599599
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
600600
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
601-
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').filter(|c| !c.is_empty()).next().unwrap());
601+
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());
602602

603603
/// Render a sequence of macro arms in a format suitable for displaying to the user
604604
/// as part of an item declaration.

src/librustdoc/html/render/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ impl RenderType {
150150
string.push('{');
151151
write_optional_id(self.id, string);
152152
string.push('{');
153-
for generic in &self.generics.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
153+
for generic in &self.generics.as_deref().unwrap_or_default()[..] {
154154
generic.write_to_string(string);
155155
}
156156
string.push('}');
157157
if self.bindings.is_some() {
158158
string.push('{');
159-
for binding in &self.bindings.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
159+
for binding in &self.bindings.as_deref().unwrap_or_default()[..] {
160160
string.push('{');
161161
binding.0.write_to_string(string);
162162
string.push('{');

0 commit comments

Comments
 (0)