Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 40624dd

Browse files
committed
Auto merge of rust-lang#79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievink
Rollup of 10 pull requests Successful merges: - rust-lang#76829 (stabilize const_int_pow) - rust-lang#79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct) - rust-lang#79236 (const_generics: assert resolve hack causes an error) - rust-lang#79287 (Allow using generic trait methods in `const fn`) - rust-lang#79324 (Use Option::and_then instead of open-coding it) - rust-lang#79325 (Reduce boilerplate with the `?` operator) - rust-lang#79330 (Fix typo in comment) - rust-lang#79333 (doc typo) - rust-lang#79337 (Use Option::map instead of open coding it) - rust-lang#79343 (Add my (`@flip1995)` work mail to the mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 40cf721 + ea3c269 commit 40624dd

File tree

39 files changed

+283
-101
lines changed

39 files changed

+283
-101
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ Phil Dawes <phil@phildawes.net> Phil Dawes <pdawes@drw.com>
230230
Philipp Brüschweiler <blei42@gmail.com> <blei42@gmail.com>
231231
Philipp Brüschweiler <blei42@gmail.com> <bruphili@student.ethz.ch>
232232
Philipp Krones <hello@philkrones.com> flip1995 <hello@philkrones.com>
233+
Philipp Krones <hello@philkrones.com> <philipp.krones@embecosm.com>
233234
Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de>
234235
Przemysław Wesołek <jest@go.art.pl> Przemek Wesołek <jest@go.art.pl>
235236
Rafael Ávila de Espíndola <respindola@mozilla.com> Rafael Avila de Espindola <espindola@dream.(none)>

compiler/rustc_builtin_macros/src/format_foreign.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,13 @@ pub mod shell {
649649
impl<'a> Iterator for Substitutions<'a> {
650650
type Item = Substitution<'a>;
651651
fn next(&mut self) -> Option<Self::Item> {
652-
match parse_next_substitution(self.s) {
653-
Some((mut sub, tail)) => {
654-
self.s = tail;
655-
if let Some(InnerSpan { start, end }) = sub.position() {
656-
sub.set_position(start + self.pos, end + self.pos);
657-
self.pos += end;
658-
}
659-
Some(sub)
660-
}
661-
None => None,
652+
let (mut sub, tail) = parse_next_substitution(self.s)?;
653+
self.s = tail;
654+
if let Some(InnerSpan { start, end }) = sub.position() {
655+
sub.set_position(start + self.pos, end + self.pos);
656+
self.pos += end;
662657
}
658+
Some(sub)
663659
}
664660

665661
fn size_hint(&self) -> (usize, Option<usize>) {

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,7 @@ impl<'ll> MemberDescription<'ll> {
11521152
self.size.bits(),
11531153
self.align.bits() as u32,
11541154
self.offset.bits(),
1155-
match self.discriminant {
1156-
None => None,
1157-
Some(value) => Some(cx.const_u64(value)),
1158-
},
1155+
self.discriminant.map(|v| cx.const_u64(v)),
11591156
self.flags,
11601157
self.type_metadata,
11611158
)

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
3737
/// `funclet_bb` member if it is not `None`.
3838
fn funclet<'b, Bx: BuilderMethods<'a, 'tcx>>(
3939
&self,
40-
fx: &'b mut FunctionCx<'a, 'tcx, Bx>,
40+
fx: &'b FunctionCx<'a, 'tcx, Bx>,
4141
) -> Option<&'b Bx::Funclet> {
42-
match self.funclet_bb {
43-
Some(funcl) => fx.funclets[funcl].as_ref(),
44-
None => None,
45-
}
42+
self.funclet_bb.and_then(|funcl| fx.funclets[funcl].as_ref())
4643
}
4744

4845
fn lltarget<Bx: BuilderMethods<'a, 'tcx>>(

compiler/rustc_infer/src/traits/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'tcx, I: Iterator<Item = PredicateObligation<'tcx>>> Iterator for FilterToT
309309
fn next(&mut self) -> Option<ty::PolyTraitRef<'tcx>> {
310310
while let Some(obligation) = self.base_iterator.next() {
311311
if let Some(data) = obligation.predicate.to_opt_poly_trait_ref() {
312-
return Some(data);
312+
return Some(data.value);
313313
}
314314
}
315315
None

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,14 @@ macro_rules! visit_place_fns {
10171017
let mut context = context;
10181018

10191019
if !place.projection.is_empty() {
1020-
context = if context.is_mutating_use() {
1021-
PlaceContext::MutatingUse(MutatingUseContext::Projection)
1022-
} else {
1023-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
1024-
};
1020+
if context.is_use() {
1021+
// ^ Only change the context if it is a real use, not a "use" in debuginfo.
1022+
context = if context.is_mutating_use() {
1023+
PlaceContext::MutatingUse(MutatingUseContext::Projection)
1024+
} else {
1025+
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
1026+
};
1027+
}
10251028
}
10261029

10271030
self.visit_local(&place.local, context, location);

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::ty::{self, AdtKind, Ty, TyCtxt};
1616
use rustc_errors::{Applicability, DiagnosticBuilder};
1717
use rustc_hir as hir;
1818
use rustc_hir::def_id::DefId;
19+
use rustc_hir::Constness;
1920
use rustc_span::symbol::Symbol;
2021
use rustc_span::{Span, DUMMY_SP};
2122
use smallvec::SmallVec;
@@ -457,7 +458,7 @@ pub enum ImplSource<'tcx, N> {
457458
/// for some type parameter. The `Vec<N>` represents the
458459
/// obligations incurred from normalizing the where-clause (if
459460
/// any).
460-
Param(Vec<N>),
461+
Param(Vec<N>, Constness),
461462

462463
/// Virtual calls through an object.
463464
Object(ImplSourceObjectData<'tcx, N>),
@@ -487,7 +488,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
487488
pub fn nested_obligations(self) -> Vec<N> {
488489
match self {
489490
ImplSource::UserDefined(i) => i.nested,
490-
ImplSource::Param(n) => n,
491+
ImplSource::Param(n, _) => n,
491492
ImplSource::Builtin(i) => i.nested,
492493
ImplSource::AutoImpl(d) => d.nested,
493494
ImplSource::Closure(c) => c.nested,
@@ -502,7 +503,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
502503
pub fn borrow_nested_obligations(&self) -> &[N] {
503504
match &self {
504505
ImplSource::UserDefined(i) => &i.nested[..],
505-
ImplSource::Param(n) => &n[..],
506+
ImplSource::Param(n, _) => &n[..],
506507
ImplSource::Builtin(i) => &i.nested[..],
507508
ImplSource::AutoImpl(d) => &d.nested[..],
508509
ImplSource::Closure(c) => &c.nested[..],
@@ -524,7 +525,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
524525
substs: i.substs,
525526
nested: i.nested.into_iter().map(f).collect(),
526527
}),
527-
ImplSource::Param(n) => ImplSource::Param(n.into_iter().map(f).collect()),
528+
ImplSource::Param(n, ct) => ImplSource::Param(n.into_iter().map(f).collect(), ct),
528529
ImplSource::Builtin(i) => ImplSource::Builtin(ImplSourceBuiltinData {
529530
nested: i.nested.into_iter().map(f).collect(),
530531
}),

compiler/rustc_middle/src/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub enum SelectionCandidate<'tcx> {
101101
/// `false` if there are no *further* obligations.
102102
has_nested: bool,
103103
},
104-
ParamCandidate(ty::PolyTraitRef<'tcx>),
104+
ParamCandidate(ty::ConstnessAnd<ty::PolyTraitRef<'tcx>>),
105105
ImplCandidate(DefId),
106106
AutoImplCandidate(DefId),
107107

compiler/rustc_middle/src/traits/structural_impls.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
2121

2222
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
2323

24-
super::ImplSource::Param(ref n) => write!(f, "ImplSourceParamData({:?})", n),
24+
super::ImplSource::Param(ref n, ct) => {
25+
write!(f, "ImplSourceParamData({:?}, {:?})", n, ct)
26+
}
2527

2628
super::ImplSource::Builtin(ref d) => write!(f, "{:?}", d),
2729

compiler/rustc_middle/src/ty/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
4242
use rustc_hir::definitions::{DefPathHash, Definitions};
4343
use rustc_hir::intravisit::Visitor;
4444
use rustc_hir::lang_items::LangItem;
45-
use rustc_hir::{HirId, ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet, Node, TraitCandidate};
45+
use rustc_hir::{
46+
Constness, HirId, ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet, Node, TraitCandidate,
47+
};
4648
use rustc_index::vec::{Idx, IndexVec};
4749
use rustc_macros::HashStable;
4850
use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
@@ -1635,6 +1637,8 @@ nop_list_lift! {projs; ProjectionKind => ProjectionKind}
16351637
// This is the impl for `&'a InternalSubsts<'a>`.
16361638
nop_list_lift! {substs; GenericArg<'a> => GenericArg<'tcx>}
16371639

1640+
CloneLiftImpls! { for<'tcx> { Constness, } }
1641+
16381642
pub mod tls {
16391643
use super::{ptr_eq, GlobalCtxt, TyCtxt};
16401644

0 commit comments

Comments
 (0)