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

Commit 1279b3b

Browse files
committed
Auto merge of rust-lang#81304 - jonas-schievink:rollup-d9kuugm, r=jonas-schievink
Rollup of 15 pull requests Successful merges: - rust-lang#79841 (More clear documentation for NonNull<T>) - rust-lang#81072 (PlaceRef::ty: use method call syntax) - rust-lang#81130 (Edit rustc_middle::dep_graph module documentation) - rust-lang#81170 (Avoid hash_slice in VecDeque's Hash implementation) - rust-lang#81243 (mir: Improve size_of handling when arg is unsized) - rust-lang#81245 (Update cargo) - rust-lang#81249 (Lower closure prototype after its body.) - rust-lang#81252 (Add more self-profile info to rustc_resolve) - rust-lang#81275 (Fix <unknown> queries and add more timing info to render_html) - rust-lang#81281 (Inline methods of Path and OsString) - rust-lang#81283 (Note library tracking issue template in tracking issue template.) - rust-lang#81285 (Remove special casing of rustdoc in rustc_lint) - rust-lang#81288 (rustdoc: Fix visibility of trait and impl items) - rust-lang#81298 (replace RefCell with Cell in FnCtxt) - rust-lang#81301 (Fix small typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4d0dd02 + ebeb6b8 commit 1279b3b

File tree

37 files changed

+434
-112
lines changed

37 files changed

+434
-112
lines changed

.github/ISSUE_TEMPLATE/tracking_issue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Tracking Issue for XXX
55
labels: C-tracking-issue
66
---
77
<!--
8+
NOTE: For library features, please use the "Library Tracking Issue" template instead.
9+
810
Thank you for creating a tracking issue! 📜 Tracking issues are for tracking a
911
feature from implementation to stabilisation. Make sure to include the relevant
1012
RFC for the feature if it has one. Otherwise provide a short summary of the

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ dependencies = [
427427
"remove_dir_all",
428428
"serde_json",
429429
"tar",
430+
"toml",
430431
"url 2.1.1",
431432
]
432433

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
776776
body: &Expr,
777777
fn_decl_span: Span,
778778
) -> hir::ExprKind<'hir> {
779-
// Lower outside new scope to preserve `is_in_loop_condition`.
780-
let fn_decl = self.lower_fn_decl(decl, None, false, None);
781-
782-
self.with_new_scopes(move |this| {
779+
let (body_id, generator_option) = self.with_new_scopes(move |this| {
783780
let prev = this.current_item;
784781
this.current_item = Some(fn_decl_span);
785782
let mut generator_kind = None;
@@ -791,8 +788,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
791788
let generator_option =
792789
this.generator_movability_for_fn(&decl, fn_decl_span, generator_kind, movability);
793790
this.current_item = prev;
794-
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
795-
})
791+
(body_id, generator_option)
792+
});
793+
794+
// Lower outside new scope to preserve `is_in_loop_condition`.
795+
let fn_decl = self.lower_fn_decl(decl, None, false, None);
796+
797+
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
796798
}
797799

798800
fn generator_movability_for_fn(
@@ -838,12 +840,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
838840
) -> hir::ExprKind<'hir> {
839841
let outer_decl =
840842
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
841-
// We need to lower the declaration outside the new scope, because we
842-
// have to conserve the state of being inside a loop condition for the
843-
// closure argument types.
844-
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);
845843

846-
self.with_new_scopes(move |this| {
844+
let body_id = self.with_new_scopes(|this| {
847845
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
848846
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
849847
struct_span_err!(
@@ -874,8 +872,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
874872
);
875873
this.expr(fn_decl_span, async_body, ThinVec::new())
876874
});
877-
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
878-
})
875+
body_id
876+
});
877+
878+
// We need to lower the declaration outside the new scope, because we
879+
// have to conserve the state of being inside a loop condition for the
880+
// closure argument types.
881+
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);
882+
883+
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
879884
}
880885

881886
/// Destructure the LHS of complex assignments.

compiler/rustc_codegen_ssa/src/mir/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
119119
)
120120
);
121121
if is_consume {
122-
let base_ty = mir::PlaceRef::ty(&place_base, self.fx.mir, cx.tcx());
122+
let base_ty = place_base.ty(self.fx.mir, cx.tcx());
123123
let base_ty = self.fx.monomorphize(base_ty);
124124

125125
// ZSTs don't require any actual memory access.

compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
506506

507507
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
508508
let tcx = self.cx.tcx();
509-
let place_ty = mir::PlaceRef::ty(&place_ref, self.mir, tcx);
509+
let place_ty = place_ref.ty(self.mir, tcx);
510510
self.monomorphize(place_ty.ty)
511511
}
512512
}

compiler/rustc_interface/src/passes.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,6 @@ pub fn start_codegen<'tcx>(
10171017
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
10181018
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));
10191019

1020-
// We assume that no queries are run past here. If there are new queries
1021-
// after this point, they'll show up as "<unknown>" in self-profiling data.
1022-
{
1023-
let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings");
1024-
tcx.alloc_self_profile_query_strings();
1025-
}
1026-
10271020
info!("Post-codegen\n{:?}", tcx.debug_stats());
10281021

10291022
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {

compiler/rustc_interface/src/queries.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,19 @@ impl Compiler {
417417
let queries = Queries::new(&self);
418418
let ret = f(&queries);
419419

420-
if self.session().opts.debugging_opts.query_stats {
421-
if let Ok(gcx) = queries.global_ctxt() {
422-
gcx.peek_mut().print_stats();
420+
// NOTE: intentionally does not compute the global context if it hasn't been built yet,
421+
// since that likely means there was a parse error.
422+
if let Some(Ok(gcx)) = &mut *queries.global_ctxt.result.borrow_mut() {
423+
// We assume that no queries are run past here. If there are new queries
424+
// after this point, they'll show up as "<unknown>" in self-profiling data.
425+
{
426+
let _prof_timer =
427+
queries.session().prof.generic_activity("self_profile_alloc_query_strings");
428+
gcx.enter(|tcx| tcx.alloc_self_profile_query_strings());
429+
}
430+
431+
if self.session().opts.debugging_opts.query_stats {
432+
gcx.print_stats();
423433
}
424434
}
425435

compiler/rustc_lint/src/early.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,9 @@ pub fn check_ast_crate<T: EarlyLintPass>(
379379
// All of the buffered lints should have been emitted at this point.
380380
// If not, that means that we somehow buffered a lint for a node id
381381
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
382-
//
383-
// Rustdoc runs everybody-loops before the early lints and removes
384-
// function bodies, so it's totally possible for linted
385-
// node ids to not exist (e.g., macros defined within functions for the
386-
// unused_macro lint) anymore. So we only run this check
387-
// when we're not in rustdoc mode. (see issue #47639)
388-
if !sess.opts.actually_rustdoc {
389-
for (_id, lints) in buffered.map {
390-
for early_lint in lints {
391-
sess.delay_span_bug(early_lint.span, "failed to process buffered lint here");
392-
}
382+
for (_id, lints) in buffered.map {
383+
for early_lint in lints {
384+
sess.delay_span_bug(early_lint.span, "failed to process buffered lint here");
393385
}
394386
}
395387
}

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
//! This module defines the `DepNode` type which the compiler uses to represent
2-
//! nodes in the dependency graph.
1+
//! Nodes in the dependency graph.
32
//!
4-
//! A `DepNode` consists of a `DepKind` (which
5-
//! specifies the kind of thing it represents, like a piece of HIR, MIR, etc)
6-
//! and a `Fingerprint`, a 128-bit hash value the exact meaning of which
3+
//! A node in the [dependency graph] is represented by a [`DepNode`].
4+
//! A `DepNode` consists of a [`DepKind`] (which
5+
//! specifies the kind of thing it represents, like a piece of HIR, MIR, etc.)
6+
//! and a [`Fingerprint`], a 128-bit hash value, the exact meaning of which
77
//! depends on the node's `DepKind`. Together, the kind and the fingerprint
88
//! fully identify a dependency node, even across multiple compilation sessions.
99
//! In other words, the value of the fingerprint does not depend on anything
1010
//! that is specific to a given compilation session, like an unpredictable
11-
//! interning key (e.g., NodeId, DefId, Symbol) or the numeric value of a
11+
//! interning key (e.g., `NodeId`, `DefId`, `Symbol`) or the numeric value of a
1212
//! pointer. The concept behind this could be compared to how git commit hashes
13-
//! uniquely identify a given commit and has a few advantages:
13+
//! uniquely identify a given commit. The fingerprinting approach has
14+
//! a few advantages:
1415
//!
1516
//! * A `DepNode` can simply be serialized to disk and loaded in another session
1617
//! without the need to do any "rebasing" (like we have to do for Spans and
@@ -51,6 +52,8 @@
5152
//! than a zeroed out fingerprint. More generally speaking, it relieves the
5253
//! user of the `DepNode` API of having to know how to compute the expected
5354
//! fingerprint for a given set of node parameters.
55+
//!
56+
//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html
5457
5558
use crate::ty::TyCtxt;
5659

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub enum InvalidProgramInfo<'tcx> {
127127
Layout(layout::LayoutError<'tcx>),
128128
/// An invalid transmute happened.
129129
TransmuteSizeDiff(Ty<'tcx>, Ty<'tcx>),
130+
/// SizeOf of unsized type was requested.
131+
SizeOfUnsizedType(Ty<'tcx>),
130132
}
131133

132134
impl fmt::Display for InvalidProgramInfo<'_> {
@@ -144,6 +146,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
144146
"transmuting `{}` to `{}` is not possible, because these types do not have the same size",
145147
from_ty, to_ty
146148
),
149+
SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{}`", ty),
147150
}
148151
}
149152
}

0 commit comments

Comments
 (0)