Skip to content

Commit 1588d9b

Browse files
authored
Rollup merge of #122636 - matthiaskrgr:compl3, r=compiler-errors
some minor code simplifications
2 parents 0589ffb + 0437a0c commit 1588d9b

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

compiler/rustc_hir_typeck/src/callee.rs

+1-1
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

+2-3
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,8 @@ pub(super) fn extract_branch_mappings(
401401
}
402402
let (span, _) = unexpand_into_body_span_with_visible_macro(raw_span, body_span)?;
403403

404-
let bcb_from_marker = |marker: BlockMarkerId| {
405-
Some(basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)?)
406-
};
404+
let bcb_from_marker =
405+
|marker: BlockMarkerId| basic_coverage_blocks.bcb_from_bb(block_markers[marker]?);
407406

408407
let true_bcb = bcb_from_marker(true_marker)?;
409408
let false_bcb = bcb_from_marker(false_marker)?;

compiler/rustc_session/src/config.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -144,18 +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-
}
158-
159153
/// Settings for `-Z instrument-xray` flag.
160154
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
161155
pub struct InstrumentXRay {

src/librustdoc/clean/mod.rs

+1-1
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

+1-1
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

+2-2
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)