Skip to content

Commit

Permalink
Auto merge of rust-lang#135754 - jieyouxu:rollup-j4q1hpr, r=jieyouxu
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#135542 (Add the concrete syntax for precise capturing to 1.82 release notes.)
 - rust-lang#135700 (Emit single privacy error for struct literal with multiple private fields and add test for `default_field_values` privacy)
 - rust-lang#135722 (make it possible to use ci-rustc on tarball sources)
 - rust-lang#135729 (Add debug assertions to compiler profile)
 - rust-lang#135736 (rustdoc: Fix flaky doctest test)
 - rust-lang#135738 (Replace usages of `map_or(bool, ...)` with `is_{some_and|none_or|ok_and}`)
 - rust-lang#135747 (Rename FileName::QuoteExpansion to CfgSpec)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 20, 2025
2 parents 9a1d156 + 82a239c commit d039b7f
Show file tree
Hide file tree
Showing 60 changed files with 367 additions and 138 deletions.
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Language
- [`addr_of(_mut)!` macros and the newly stabilized `&raw (const|mut)` are now safe to use with all static items](https://github.com/rust-lang/rust/pull/125834)
- [size_of_val_raw: for length 0 this is safe to call](https://github.com/rust-lang/rust/pull/126152/)
- [Reorder trait bound modifiers *after* `for<...>` binder in trait bounds](https://github.com/rust-lang/rust/pull/127054/)
- [Stabilize opaque type precise capturing (RFC 3617)](https://github.com/rust-lang/rust/pull/127672)
- [Stabilize `+ use<'lt>` opaque type precise capturing (RFC 3617)](https://github.com/rust-lang/rust/pull/127672)
- [Stabilize `&raw const` and `&raw mut` operators (RFC 2582)](https://github.com/rust-lang/rust/pull/127679)
- [Stabilize unsafe extern blocks (RFC 3484)](https://github.com/rust-lang/rust/pull/127921)
- [Stabilize nested field access in `offset_of!`](https://github.com/rust-lang/rust/pull/128284)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
if let Some(local_sig_id) = def_id.as_local() {
// The value may be missing due to recursive delegation.
// Error will be emitted later during HIR ty lowering.
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
self.resolver.delegation_fn_sigs.get(&local_sig_id).is_some_and(|sig| sig.has_self)
} else {
match self.tcx.def_kind(def_id) {
DefKind::Fn => false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'a> PostExpansionVisitor<'a> {
feature_err_issue(&self.sess, feature, span, GateIssue::Language, explain).emit();
}
Err(abi::AbiDisabled::Unrecognized) => {
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
if self.sess.opts.pretty.is_none_or(|ppm| ppm.needs_hir()) {
self.sess.dcx().span_delayed_bug(
span,
format!(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &impl AttributeExt) -> Vec<ReprAttr
// the `check_mod_attrs` pass, but this pass doesn't always run
// (e.g. if we only pretty-print the source), so we have to gate
// the `span_delayed_bug` call as follows:
if sess.opts.pretty.map_or(true, |pp| pp.needs_analysis()) {
if sess.opts.pretty.is_none_or(|pp| pp.needs_analysis()) {
dcx.span_delayed_bug(item.span(), "unrecognized representation hint");
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2480,7 +2480,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// To support cases like `|| { v.call(|this| v.get()) }`
// FIXME: actually support such cases (need to figure out how to move from the
// capture place to original local).
&& self.res.as_ref().map_or(true, |(prev_res, _)| prev_res.span.contains(ex.span))
&& self.res.as_ref().is_none_or(|(prev_res, _)| prev_res.span.contains(ex.span))
{
self.res = Some((ex, closure));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl<'tcx> BorrowExplanation<'tcx> {
&& let Ok(pat) = tcx.sess.source_map().span_to_snippet(pat.span)
{
suggest_rewrite_if_let(tcx, expr, &pat, init, conseq, alt, err);
} else if path_span.map_or(true, |path_span| path_span == var_or_use_span) {
} else if path_span.is_none_or(|path_span| path_span == var_or_use_span) {
// We can use `var_or_use_span` if either `path_span` is not present, or both
// spans are the same.
if borrow_span.map_or(true, |sp| !sp.overlaps(var_or_use_span)) {
if borrow_span.is_none_or(|sp| !sp.overlaps(var_or_use_span)) {
err.span_label(
var_or_use_span,
format!("{borrow_desc}borrow later {message}"),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) ->
// (or if there is no allocator argument).
ty::Adt(def, args)
if def.is_box()
&& args.get(1).map_or(true, |arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
&& args.get(1).is_none_or(|arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
{
build_pointer_or_reference_di_node(cx, t, t.expect_boxed_ty(), unique_type_id)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3146,7 +3146,7 @@ impl FileWithAnnotatedLines {
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
}
let line_end = ann.line_end - 1;
let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| !filter(&s));
let end_is_empty = file.get_line(line_end - 1).is_some_and(|s| !filter(&s));
if middle < line_end && !end_is_empty {
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ impl DiagnosticSpan {
// is an empty string, increase the length to include the newline so we don't
// leave an empty line
if start.col.0 == 0
&& suggestion.map_or(false, |(s, _)| s.is_empty())
&& let Some((suggestion, _)) = suggestion
&& suggestion.is_empty()
&& let Ok(after) = je.sm.span_to_next_source(span)
&& after.starts_with('\n')
{
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::backtrace::{Backtrace, BacktraceStatus};
use std::borrow::Cow;
use std::cell::Cell;
use std::error::Report;
use std::ffi::OsStr;
use std::hash::Hash;
use std::io::Write;
use std::num::NonZero;
Expand Down Expand Up @@ -1717,7 +1718,7 @@ impl DiagCtxtInner {
let bugs: Vec<_> =
std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect();

let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0");
let backtrace = std::env::var_os("RUST_BACKTRACE").as_deref() != Some(OsStr::new("0"));
let decorate = backtrace || self.ice_file.is_none();
let mut out = self
.ice_file
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl<'a> StripUnconfigured<'a> {
validate_attr::deny_builtin_meta_unsafety(&self.sess.psess, &meta_item);

(
parse_cfg(&meta_item, self.sess).map_or(true, |meta_item| {
parse_cfg(&meta_item, self.sess).is_none_or(|meta_item| {
attr::cfg_matches(meta_item, &self.sess, self.lint_node_id, self.features)
}),
Some(meta_item),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'match
if self
.best_failure
.as_ref()
.map_or(true, |failure| failure.is_better_position(*approx_position))
.is_none_or(|failure| failure.is_better_position(*approx_position))
{
self.best_failure = Some(BestFailure {
token: token.clone(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ impl<Id> Res<Id> {

/// Always returns `true` if `self` is `Res::Err`
pub fn matches_ns(&self, ns: Namespace) -> bool {
self.ns().map_or(true, |actual_ns| actual_ns == ns)
self.ns().is_none_or(|actual_ns| actual_ns == ns)
}

/// Returns whether such a resolved path can occur in a tuple struct/variant pattern
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// - foo((), "current", 42u32, "next")
// + foo((), 42u32)
{
prev_extra_idx.map_or(true, |prev_extra_idx| {
prev_extra_idx.is_none_or(|prev_extra_idx| {
prev_extra_idx + 1 == arg_idx.index()
})
}
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.may_coerce(found, ty)
}
hir::FnRetTy::DefaultReturn(_) if in_closure => {
self.ret_coercion.as_ref().map_or(false, |ret| {
self.ret_coercion.as_ref().is_some_and(|ret| {
let ret_ty = ret.borrow().expected_ty();
self.may_coerce(found, ret_ty)
})
Expand Down Expand Up @@ -1784,14 +1784,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let results = self.typeck_results.borrow();
// First, look for a `Clone::clone` call
if segment.ident.name == sym::clone
&& results.type_dependent_def_id(expr.hir_id).map_or(
false,
|did| {
&& results.type_dependent_def_id(expr.hir_id).is_some_and(|did| {
let assoc_item = self.tcx.associated_item(did);
assoc_item.container == ty::AssocItemContainer::Trait
&& assoc_item.container_id(self.tcx) == clone_trait_did
},
)
})
// If that clone call hasn't already dereferenced the self type (i.e. don't give this
// diagnostic in cases where we have `(&&T).clone()` and we expect `T`).
&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..)))
Expand Down
25 changes: 13 additions & 12 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3761,18 +3761,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::TraitFn::Required([ident, ..]) => {
ident.name == kw::SelfLower
}
hir::TraitFn::Provided(body_id) => {
self.tcx.hir().body(*body_id).params.first().map_or(
false,
|param| {
matches!(
param.pat.kind,
hir::PatKind::Binding(_, _, ident, _)
if ident.name == kw::SelfLower
)
},
)
}
hir::TraitFn::Provided(body_id) => self
.tcx
.hir()
.body(*body_id)
.params
.first()
.is_some_and(|param| {
matches!(
param.pat.kind,
hir::PatKind::Binding(_, _, ident, _)
if ident.name == kw::SelfLower
)
}),
_ => false,
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<I: Idx> IntervalSet<I> {
}
current = Some(*end);
}
current.map_or(true, |x| x < self.domain as u32)
current.is_none_or(|x| x < self.domain as u32)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
let expect_id = canonicalize_id(expect_id);

if !fulfilled_expectations.contains(&expect_id)
&& tool_filter.map_or(true, |filter| expectation.lint_tool == Some(filter))
&& tool_filter.is_none_or(|filter| expectation.lint_tool == Some(filter))
{
let rationale = expectation.reason.map(|rationale| ExpectationNote { rationale });
let note = expectation.is_unfulfilled_lint_expectations;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
// Any descendants of `std` should be private. These crates are usually not marked
// private in metadata, so we ignore that field.
if extern_private.is_none()
&& dep_root.map_or(false, |d| STDLIB_STABLE_CRATES.contains(&d.name))
&& let Some(dep) = dep_root
&& STDLIB_STABLE_CRATES.contains(&dep.name)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
debug_assert!(prov.len() <= 1);
if let Some(entry) = prov.first() {
// If it overlaps with this byte, it is on this byte.
debug_assert!(self.bytes.as_ref().map_or(true, |b| b.get(&offset).is_none()));
debug_assert!(self.bytes.as_ref().is_none_or(|b| !b.contains_key(&offset)));
Some(entry.1)
} else {
// Look up per-byte provenance.
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
// For really small copies, make sure we don't start before `src` does.
let entry_start = cmp::max(entry.0, src.start);
for offset in entry_start..src.end() {
if bytes.last().map_or(true, |bytes_entry| bytes_entry.0 < offset) {
if bytes.last().is_none_or(|bytes_entry| bytes_entry.0 < offset) {
// The last entry, if it exists, has a lower offset than us.
bytes.push((offset, entry.1));
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>(
// A parent matches a child if they share the same prefix of projections.
// The child may have more, if it is capturing sub-fields out of
// something that is captured by-move in the parent closure.
while child_captures.peek().map_or(false, |(_, child_capture)| {
while child_captures.peek().is_some_and(|(_, child_capture)| {
child_prefix_matches_parent_projections(parent_capture, child_capture)
}) {
let (child_field_idx, child_capture) = child_captures.next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn suggest_constraining_type_params<'a>(
.collect();

constraints
.retain(|(_, def_id, _)| def_id.map_or(true, |def| !bound_trait_defs.contains(&def)));
.retain(|(_, def_id, _)| def_id.is_none_or(|def| !bound_trait_defs.contains(&def)));

if constraints.is_empty() {
continue;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl<'tcx> InstanceKind<'tcx> {
// We include enums without destructors to allow, say, optimizing
// drops of `Option::None` before LTO. We also respect the intent of
// `#[inline]` on `Drop::drop` implementations.
return ty.ty_adt_def().map_or(true, |adt_def| {
return ty.ty_adt_def().is_none_or(|adt_def| {
match *self {
ty::InstanceKind::DropGlue(..) => adt_def.destructor(tcx).map(|dtor| dtor.did),
ty::InstanceKind::AsyncDropGlueCtorShim(..) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,11 +1894,11 @@ impl<'tcx> Ty<'tcx> {

ty::Str | ty::Slice(_) | ty::Dynamic(_, _, ty::Dyn) | ty::Foreign(..) => false,

ty::Tuple(tys) => tys.last().map_or(true, |ty| ty.is_trivially_sized(tcx)),
ty::Tuple(tys) => tys.last().is_none_or(|ty| ty.is_trivially_sized(tcx)),

ty::Adt(def, args) => def
.sized_constraint(tcx)
.map_or(true, |ty| ty.instantiate(tcx, args).is_trivially_sized(tcx)),
.is_none_or(|ty| ty.instantiate(tcx, args).is_trivially_sized(tcx)),

ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) | ty::Bound(..) => false,

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ fn find_item_ty_spans(
if let Res::Def(kind, def_id) = path.res
&& matches!(kind, DefKind::Enum | DefKind::Struct | DefKind::Union)
{
let check_params = def_id.as_local().map_or(true, |def_id| {
let check_params = def_id.as_local().is_none_or(|def_id| {
if def_id == needle {
spans.push(ty.span);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for LayoutConstrainedPlaceVisitor<'a, 'tcx> {
// place, i.e. the expression is a place expression and not a dereference
// (since dereferencing something leads us to a different place).
ExprKind::Deref { .. } => {}
ref kind if ExprCategory::of(kind).map_or(true, |cat| cat == ExprCategory::Place) => {
ref kind if ExprCategory::of(kind).is_none_or(|cat| cat == ExprCategory::Place) => {
visit::walk_expr(self, expr);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/framework/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ where
let before = diffs_before.as_mut().map(next_in_dataflow_order);

assert!(diffs_after.is_empty());
assert!(diffs_before.as_ref().map_or(true, ExactSizeIterator::is_empty));
assert!(diffs_before.as_ref().is_none_or(ExactSizeIterator::is_empty));

let terminator = self.cursor.body()[block].terminator();
let mut terminator_str = String::new();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/coverage/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl CoverageGraph {
bb_to_bcb[bb] = Some(bcb);
}

let is_out_summable = basic_blocks.last().map_or(false, |&bb| {
let is_out_summable = basic_blocks.last().is_some_and(|&bb| {
bcb_filtered_successors(mir_body[bb].terminator()).is_out_summable()
});
let bcb_data = BasicCoverageBlockData { basic_blocks, is_out_summable };
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
//
// For this we set `next_orig_uv` to the next smallest, not yet compressed,
// universe of the input.
if next_orig_uv.map_or(true, |curr_next_uv| uv.cannot_name(curr_next_uv)) {
if next_orig_uv.is_none_or(|curr_next_uv| uv.cannot_name(curr_next_uv)) {
next_orig_uv = Some(uv);
}
}
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 @@ -2095,7 +2095,7 @@ impl<'a> Parser<'a> {
// point literal here, since there's no use of the exponent
// syntax that also constitutes a valid integer, so we need
// not check for that.
if suffix.map_or(true, |s| s == sym::f32 || s == sym::f64)
if suffix.is_none_or(|s| s == sym::f32 || s == sym::f64)
&& symbol.as_str().chars().all(|c| c.is_numeric() || c == '_')
&& self.token.span.hi() == next_token.span.lo()
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
continue;
}

let is_positional = variant.fields.raw.first().map_or(false, |field| {
let is_positional = variant.fields.raw.first().is_some_and(|field| {
field.name.as_str().starts_with(|c: char| c.is_ascii_digit())
});
let report_on =
Expand Down
Loading

0 comments on commit d039b7f

Please sign in to comment.