Skip to content

Rollup of 15 pull requests #81304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jan 24, 2021
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1b09dc2
PlaceRef::ty: use method call syntax
RalfJung Jan 16, 2021
ae3a515
Avoid hash_slice in VecDeque's Hash implementation
LunaBorowska Jan 18, 2021
453ebbd
Update cargo
ehuss Jan 21, 2021
e3faeb4
mir: Improve size_of handling when arg is unsized
osa1 Jan 21, 2021
3f42abe
Lower closure prototype after its body.
cjgillot Jan 21, 2021
5f74ab4
Add more self-profile info to rustc_resolve
jyn514 Jan 21, 2021
9880560
Inline methods of Path and OsString
a1phyr Jan 22, 2021
4d7e489
Note library tracking issue template in tracking issue template.
m-ou-se Jan 22, 2021
0392085
More clear documentation for NonNull<T>
fintelia Dec 8, 2020
0679a4c
Remove special casing of rustdoc in rustc_lint
jyn514 Jan 22, 2021
b29353a
Edit rustc_middle::dep_graph module documentation
pierwill Jan 17, 2021
bf86fd5
Fix <unknown> queries
jyn514 Jan 22, 2021
93e51b1
rustdoc: Fix visibility of trait and impl items
camelid Jan 22, 2021
688cf64
replace RefCell with Cell in FnCtxt
lcnr Jan 23, 2021
1d1010f
Add more timing info to render_html
jyn514 Jan 22, 2021
ca72f9e
Calculate self-profile strings in `Compiler::enter` instead in codegen
jyn514 Jan 22, 2021
2f5ce8e
Fix small typo
davidgu Jan 23, 2021
7635462
Rollup merge of #79841 - fintelia:patch-6, r=kennytm
jonas-schievink Jan 23, 2021
3382771
Rollup merge of #81072 - RalfJung:place-ref-ty, r=oli-obk
jonas-schievink Jan 23, 2021
57d6553
Rollup merge of #81130 - pierwill:edit-depnode, r=jyn514
jonas-schievink Jan 23, 2021
05a95a4
Rollup merge of #81170 - xfix:vecdeque-bug-fix, r=sfackler
jonas-schievink Jan 23, 2021
3a3470b
Rollup merge of #81243 - osa1:fix_80742_2, r=RalfJung
jonas-schievink Jan 23, 2021
c4830da
Rollup merge of #81245 - ehuss:update-cargo, r=ehuss
jonas-schievink Jan 23, 2021
fcf1129
Rollup merge of #81249 - cjgillot:issue-79537, r=oli-obk
jonas-schievink Jan 23, 2021
7038bb1
Rollup merge of #81252 - jyn514:resolve-timing, r=petrochenkov
jonas-schievink Jan 23, 2021
81647c6
Rollup merge of #81275 - jyn514:time-render, r=wesleywiser
jonas-schievink Jan 23, 2021
44c668c
Rollup merge of #81281 - a1phyr:inline_path, r=dtolnay
jonas-schievink Jan 23, 2021
81b0c3e
Rollup merge of #81283 - m-ou-se:tracking-issue-note, r=Mark-Simulacrum
jonas-schievink Jan 23, 2021
64cf8c2
Rollup merge of #81288 - camelid:fix-trait-item-vis, r=jyn514
jonas-schievink Jan 23, 2021
be3723c
Rollup merge of #81298 - lcnr:big-money-big-prices, r=oli-obk
jonas-schievink Jan 23, 2021
ebeb6b8
Rollup merge of #81301 - davidgu:patch-1, r=jonas-schievink
jonas-schievink Jan 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/tracking_issue.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ title: Tracking Issue for XXX
labels: C-tracking-issue
---
<!--
NOTE: For library features, please use the "Library Tracking Issue" template instead.

Thank you for creating a tracking issue! 📜 Tracking issues are for tracking a
feature from implementation to stabilisation. Make sure to include the relevant
RFC for the feature if it has one. Otherwise provide a short summary of the
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -427,6 +427,7 @@ dependencies = [
"remove_dir_all",
"serde_json",
"tar",
"toml",
"url 2.1.1",
]

31 changes: 18 additions & 13 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
@@ -776,10 +776,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
body: &Expr,
fn_decl_span: Span,
) -> hir::ExprKind<'hir> {
// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = self.lower_fn_decl(decl, None, false, None);

self.with_new_scopes(move |this| {
let (body_id, generator_option) = self.with_new_scopes(move |this| {
let prev = this.current_item;
this.current_item = Some(fn_decl_span);
let mut generator_kind = None;
@@ -791,8 +788,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
let generator_option =
this.generator_movability_for_fn(&decl, fn_decl_span, generator_kind, movability);
this.current_item = prev;
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
})
(body_id, generator_option)
});

// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = self.lower_fn_decl(decl, None, false, None);

hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
}

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

self.with_new_scopes(move |this| {
let body_id = self.with_new_scopes(|this| {
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
struct_span_err!(
@@ -874,8 +872,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
this.expr(fn_decl_span, async_body, ThinVec::new())
});
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
})
body_id
});

// We need to lower the declaration outside the new scope, because we
// have to conserve the state of being inside a loop condition for the
// closure argument types.
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);

hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
}

/// Destructure the LHS of complex assignments.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
)
);
if is_consume {
let base_ty = mir::PlaceRef::ty(&place_base, self.fx.mir, cx.tcx());
let base_ty = place_base.ty(self.fx.mir, cx.tcx());
let base_ty = self.fx.monomorphize(base_ty);

// ZSTs don't require any actual memory access.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
@@ -506,7 +506,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
let tcx = self.cx.tcx();
let place_ty = mir::PlaceRef::ty(&place_ref, self.mir, tcx);
let place_ty = place_ref.ty(self.mir, tcx);
self.monomorphize(place_ty.ty)
}
}
7 changes: 0 additions & 7 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
@@ -1017,13 +1017,6 @@ pub fn start_codegen<'tcx>(
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));

// We assume that no queries are run past here. If there are new queries
// after this point, they'll show up as "<unknown>" in self-profiling data.
{
let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings");
tcx.alloc_self_profile_query_strings();
}

info!("Post-codegen\n{:?}", tcx.debug_stats());

if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
16 changes: 13 additions & 3 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
@@ -417,9 +417,19 @@ impl Compiler {
let queries = Queries::new(&self);
let ret = f(&queries);

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

if self.session().opts.debugging_opts.query_stats {
gcx.print_stats();
}
}

14 changes: 3 additions & 11 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
@@ -379,17 +379,9 @@ pub fn check_ast_crate<T: EarlyLintPass>(
// All of the buffered lints should have been emitted at this point.
// If not, that means that we somehow buffered a lint for a node id
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
//
// Rustdoc runs everybody-loops before the early lints and removes
// function bodies, so it's totally possible for linted
// node ids to not exist (e.g., macros defined within functions for the
// unused_macro lint) anymore. So we only run this check
// when we're not in rustdoc mode. (see issue #47639)
if !sess.opts.actually_rustdoc {
for (_id, lints) in buffered.map {
for early_lint in lints {
sess.delay_span_bug(early_lint.span, "failed to process buffered lint here");
}
for (_id, lints) in buffered.map {
for early_lint in lints {
sess.delay_span_bug(early_lint.span, "failed to process buffered lint here");
}
}
}
17 changes: 10 additions & 7 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//! This module defines the `DepNode` type which the compiler uses to represent
//! nodes in the dependency graph.
//! Nodes in the dependency graph.
//!
//! A `DepNode` consists of a `DepKind` (which
//! specifies the kind of thing it represents, like a piece of HIR, MIR, etc)
//! and a `Fingerprint`, a 128-bit hash value the exact meaning of which
//! A node in the [dependency graph] is represented by a [`DepNode`].
//! A `DepNode` consists of a [`DepKind`] (which
//! specifies the kind of thing it represents, like a piece of HIR, MIR, etc.)
//! and a [`Fingerprint`], a 128-bit hash value, the exact meaning of which
//! depends on the node's `DepKind`. Together, the kind and the fingerprint
//! fully identify a dependency node, even across multiple compilation sessions.
//! In other words, the value of the fingerprint does not depend on anything
//! that is specific to a given compilation session, like an unpredictable
//! interning key (e.g., NodeId, DefId, Symbol) or the numeric value of a
//! interning key (e.g., `NodeId`, `DefId`, `Symbol`) or the numeric value of a
//! pointer. The concept behind this could be compared to how git commit hashes
//! uniquely identify a given commit and has a few advantages:
//! uniquely identify a given commit. The fingerprinting approach has
//! a few advantages:
//!
//! * A `DepNode` can simply be serialized to disk and loaded in another session
//! without the need to do any "rebasing" (like we have to do for Spans and
@@ -51,6 +52,8 @@
//! than a zeroed out fingerprint. More generally speaking, it relieves the
//! user of the `DepNode` API of having to know how to compute the expected
//! fingerprint for a given set of node parameters.
//!
//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html

use crate::ty::TyCtxt;

3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
@@ -127,6 +127,8 @@ pub enum InvalidProgramInfo<'tcx> {
Layout(layout::LayoutError<'tcx>),
/// An invalid transmute happened.
TransmuteSizeDiff(Ty<'tcx>, Ty<'tcx>),
/// SizeOf of unsized type was requested.
SizeOfUnsizedType(Ty<'tcx>),
}

impl fmt::Display for InvalidProgramInfo<'_> {
@@ -144,6 +146,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
"transmuting `{}` to `{}` is not possible, because these types do not have the same size",
from_ty, to_ty
),
SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{}`", ty),
}
}
}
Original file line number Diff line number Diff line change
@@ -289,7 +289,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
}

let ty = PlaceRef::ty(&used_place, self.body, self.infcx.tcx).ty;
let ty = used_place.ty(self.body, self.infcx.tcx).ty;
let needs_note = match ty.kind() {
ty::Closure(id, _) => {
let tables = self.infcx.tcx.typeck(id.expect_local());
@@ -728,6 +728,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// Define a small closure that we can use to check if the type of a place
// is a union.
let union_ty = |place_base| {
// Need to use fn call syntax `PlaceRef::ty` to determine the type of `place_base`;
// using a type annotation in the closure argument instead leads to a lifetime error.
let ty = PlaceRef::ty(&place_base, self.body, self.infcx.tcx).ty;
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
};
8 changes: 4 additions & 4 deletions compiler/rustc_mir/src/borrow_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1743,7 +1743,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if let Some((place_base, ProjectionElem::Subslice { from, to, from_end: false })) =
place_span.0.last_projection()
{
let place_ty = PlaceRef::ty(&place_base, self.body(), self.infcx.tcx);
let place_ty = place_base.ty(self.body(), self.infcx.tcx);
if let ty::Array(..) = place_ty.ty.kind() {
self.check_if_subslice_element_is_moved(
location,
@@ -1854,7 +1854,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// assigning to `P.f` requires `P` itself
// be already initialized
let tcx = self.infcx.tcx;
let base_ty = PlaceRef::ty(&place_base, self.body(), tcx).ty;
let base_ty = place_base.ty(self.body(), tcx).ty;
match base_ty.kind() {
ty::Adt(def, _) if def.has_dtor(tcx) => {
self.check_if_path_or_subpath_is_moved(
@@ -1951,7 +1951,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// no move out from an earlier location) then this is an attempt at initialization
// of the union - we should error in that case.
let tcx = this.infcx.tcx;
if let ty::Adt(def, _) = PlaceRef::ty(&base, this.body(), tcx).ty.kind() {
if let ty::Adt(def, _) = base.ty(this.body(), tcx).ty.kind() {
if def.is_union() {
if this.move_data.path_map[mpi].iter().any(|moi| {
this.move_data.moves[*moi].source.is_predecessor_of(location, this.body)
@@ -2173,7 +2173,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
Some((place_base, elem)) => {
match elem {
ProjectionElem::Deref => {
let base_ty = PlaceRef::ty(&place_base, self.body(), self.infcx.tcx).ty;
let base_ty = place_base.ty(self.body(), self.infcx.tcx).ty;

// Check the kind of deref to decide
match base_ty.kind() {
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/borrow_check/prefixes.rs
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
// derefs, except we stop at the deref of a shared
// reference.

let ty = PlaceRef::ty(&cursor_base, self.body, self.tcx).ty;
let ty = cursor_base.ty(self.body, self.tcx).ty;
match ty.kind() {
ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
// don't continue traversing over derefs of raw pointers or shared
1 change: 1 addition & 0 deletions compiler/rustc_mir/src/interpret/step.rs
Original file line number Diff line number Diff line change
@@ -270,6 +270,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.frame().current_span(),
&format!("SizeOf nullary MIR operator called for unsized type {}", ty),
);
throw_inval!(SizeOfUnsizedType(ty));
}
self.write_scalar(Scalar::from_machine_usize(layout.size.bytes(), self), dest)?;
}
18 changes: 8 additions & 10 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1465,16 +1465,14 @@ impl<'a> Resolver<'a> {

/// Entry point to crate resolution.
pub fn resolve_crate(&mut self, krate: &Crate) {
let _prof_timer = self.session.prof.generic_activity("resolve_crate");

ImportResolver { r: self }.finalize_imports();
self.finalize_macro_resolutions();

self.late_resolve_crate(krate);

self.check_unused(krate);
self.report_errors(krate);
self.crate_loader.postprocess(krate);
self.session.time("resolve_crate", || {
self.session.time("finalize_imports", || ImportResolver { r: self }.finalize_imports());
self.session.time("finalize_macro_resolutions", || self.finalize_macro_resolutions());
self.session.time("late_resolve_crate", || self.late_resolve_crate(krate));
self.session.time("resolve_check_unused", || self.check_unused(krate));
self.session.time("resolve_report_errors", || self.report_errors(krate));
self.session.time("resolve_postprocess", || self.crate_loader.postprocess(krate));
});
}

pub fn traits_in_scope(
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ pub(super) fn check_fn<'a, 'tcx>(
// Create the function context. This is either derived from scratch or,
// in the case of closures, based on the outer context.
let mut fcx = FnCtxt::new(inherited, param_env, body.value.hir_id);
*fcx.ps.borrow_mut() = UnsafetyState::function(fn_sig.unsafety, fn_id);
fcx.ps.set(UnsafetyState::function(fn_sig.unsafety, fn_id));

let tcx = fcx.tcx;
let sess = tcx.sess;
10 changes: 5 additions & 5 deletions compiler/rustc_typeck/src/check/coercion.rs
Original file line number Diff line number Diff line change
@@ -1472,22 +1472,22 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
fn_output = Some(&fn_decl.output); // `impl Trait` return type
}
}
if let (Some(sp), Some(fn_output)) = (fcx.ret_coercion_span.borrow().as_ref(), fn_output) {
self.add_impl_trait_explanation(&mut err, cause, fcx, expected, *sp, fn_output);
if let (Some(sp), Some(fn_output)) = (fcx.ret_coercion_span.get(), fn_output) {
self.add_impl_trait_explanation(&mut err, cause, fcx, expected, sp, fn_output);
}

if let Some(sp) = fcx.ret_coercion_span.borrow().as_ref() {
if let Some(sp) = fcx.ret_coercion_span.get() {
// If the closure has an explicit return type annotation,
// then a type error may occur at the first return expression we
// see in the closure (if it conflicts with the declared
// return type). Skip adding a note in this case, since it
// would be incorrect.
if !err.span.primary_spans().iter().any(|span| span == sp) {
if !err.span.primary_spans().iter().any(|&span| span == sp) {
let hir = fcx.tcx.hir();
let body_owner = hir.body_owned_by(hir.enclosing_body_owner(fcx.body_id));
if fcx.tcx.is_closure(hir.body_owner_def_id(body_owner).to_def_id()) {
err.span_note(
*sp,
sp,
&format!(
"return type inferred to be `{}` here",
fcx.resolve_vars_if_possible(expected)
8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
@@ -680,14 +680,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if self.ret_coercion.is_none() {
self.tcx.sess.emit_err(ReturnStmtOutsideOfFnBody { span: expr.span });
} else if let Some(ref e) = expr_opt {
if self.ret_coercion_span.borrow().is_none() {
*self.ret_coercion_span.borrow_mut() = Some(e.span);
if self.ret_coercion_span.get().is_none() {
self.ret_coercion_span.set(Some(e.span));
}
self.check_return_expr(e);
} else {
let mut coercion = self.ret_coercion.as_ref().unwrap().borrow_mut();
if self.ret_coercion_span.borrow().is_none() {
*self.ret_coercion_span.borrow_mut() = Some(expr.span);
if self.ret_coercion_span.get().is_none() {
self.ret_coercion_span.set(Some(expr.span));
}
let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression);
if let Some((fn_decl, _)) = self.get_fn_decl(expr.hir_id) {
9 changes: 2 additions & 7 deletions compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ use rustc_span::{self, MultiSpan, Span};
use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression};

use crate::structured_errors::StructuredDiagnostic;
use std::mem::replace;
use std::slice;

impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -589,11 +588,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
blk: &'tcx hir::Block<'tcx>,
expected: Expectation<'tcx>,
) -> Ty<'tcx> {
let prev = {
let mut fcx_ps = self.ps.borrow_mut();
let unsafety_state = fcx_ps.recurse(blk);
replace(&mut *fcx_ps, unsafety_state)
};
let prev = self.ps.replace(self.ps.get().recurse(blk));

// In some cases, blocks have just one exit, but other blocks
// can be targeted by multiple breaks. This can happen both
@@ -709,7 +704,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

self.write_ty(blk.hir_id, ty);

*self.ps.borrow_mut() = prev;
self.ps.set(prev);
ty
}

8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/check/fn_ctxt/mod.rs
Original file line number Diff line number Diff line change
@@ -66,11 +66,11 @@ pub struct FnCtxt<'a, 'tcx> {
pub(super) in_tail_expr: bool,

/// First span of a return site that we find. Used in error messages.
pub(super) ret_coercion_span: RefCell<Option<Span>>,
pub(super) ret_coercion_span: Cell<Option<Span>>,

pub(super) resume_yield_tys: Option<(Ty<'tcx>, Ty<'tcx>)>,

pub(super) ps: RefCell<UnsafetyState>,
pub(super) ps: Cell<UnsafetyState>,

/// Whether the last checked node generates a divergence (e.g.,
/// `return` will set this to `Always`). In general, when entering
@@ -127,9 +127,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ret_coercion_impl_trait: None,
ret_type_span: None,
in_tail_expr: false,
ret_coercion_span: RefCell::new(None),
ret_coercion_span: Cell::new(None),
resume_yield_tys: None,
ps: RefCell::new(UnsafetyState::function(hir::Unsafety::Normal, hir::CRATE_HIR_ID)),
ps: Cell::new(UnsafetyState::function(hir::Unsafety::Normal, hir::CRATE_HIR_ID)),
diverges: Cell::new(Diverges::Maybe),
has_errors: Cell::new(false),
enclosing_breakables: RefCell::new(EnclosingBreakables {
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/mod.rs
Original file line number Diff line number Diff line change
@@ -184,14 +184,14 @@ impl UnsafetyState {
UnsafetyState { def, unsafety, unsafe_push_count: 0, from_fn: true }
}

pub fn recurse(&mut self, blk: &hir::Block<'_>) -> UnsafetyState {
pub fn recurse(self, blk: &hir::Block<'_>) -> UnsafetyState {
use hir::BlockCheckMode;
match self.unsafety {
// If this unsafe, then if the outer function was already marked as
// unsafe we shouldn't attribute the unsafe'ness to the block. This
// way the block can be warned about instead of ignoring this
// extraneous block (functions are never warned about).
hir::Unsafety::Unsafe if self.from_fn => *self,
hir::Unsafety::Unsafe if self.from_fn => self,

unsafety => {
let (unsafety, def, count) = match blk.rules {
10 changes: 7 additions & 3 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
@@ -2646,9 +2646,13 @@ impl<A: Ord> Ord for VecDeque<A> {
impl<A: Hash> Hash for VecDeque<A> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.len().hash(state);
let (a, b) = self.as_slices();
Hash::hash_slice(a, state);
Hash::hash_slice(b, state);
// It's not possible to use Hash::hash_slice on slices
// returned by as_slices method as their length can vary
// in otherwise identical deques.
//
// Hasher only guarantees equivalence for the exact same
// set of calls to its methods.
self.iter().for_each(|elem| elem.hash(state));
}
}

40 changes: 40 additions & 0 deletions library/alloc/src/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
@@ -599,3 +599,43 @@ fn issue_53529() {
assert_eq!(*a, 2);
}
}

#[test]
fn issue_80303() {
use core::iter;
use core::num::Wrapping;

// This is a valid, albeit rather bad hash function implementation.
struct SimpleHasher(Wrapping<u64>);

impl Hasher for SimpleHasher {
fn finish(&self) -> u64 {
self.0.0
}

fn write(&mut self, bytes: &[u8]) {
// This particular implementation hashes value 24 in addition to bytes.
// Such an implementation is valid as Hasher only guarantees equivalence
// for the exact same set of calls to its methods.
for &v in iter::once(&24).chain(bytes) {
self.0 = Wrapping(31) * self.0 + Wrapping(u64::from(v));
}
}
}

fn hash_code(value: impl Hash) -> u64 {
let mut hasher = SimpleHasher(Wrapping(1));
value.hash(&mut hasher);
hasher.finish()
}

// This creates two deques for which values returned by as_slices
// method differ.
let vda: VecDeque<u8> = (0..10).collect();
let mut vdb = VecDeque::with_capacity(10);
vdb.extend(5..10);
(0..5).rev().for_each(|elem| vdb.push_front(elem));
assert_ne!(vda.as_slices(), vdb.as_slices());
assert_eq!(vda, vdb);
assert_eq!(hash_code(vda), hash_code(vdb));
}
2 changes: 1 addition & 1 deletion library/core/src/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
//! # Problem statement
//!
//! We are given a decimal string such as `12.34e56`. This string consists of integral (`12`),
//! fractional (`45`), and exponent (`56`) parts. All parts are optional and interpreted as zero
//! fractional (`34`), and exponent (`56`) parts. All parts are optional and interpreted as zero
//! when missing.
//!
//! We seek the IEEE 754 floating point number that is closest to the exact value of the decimal
19 changes: 13 additions & 6 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
@@ -19,12 +19,19 @@ use crate::slice::{self, SliceIndex};
/// as a discriminant -- `Option<NonNull<T>>` has the same size as `*mut T`.
/// However the pointer may still dangle if it isn't dereferenced.
///
/// Unlike `*mut T`, `NonNull<T>` is covariant over `T`. If this is incorrect
/// for your use case, you should include some [`PhantomData`] in your type to
/// provide invariance, such as `PhantomData<Cell<T>>` or `PhantomData<&'a mut T>`.
/// Usually this won't be necessary; covariance is correct for most safe abstractions,
/// such as `Box`, `Rc`, `Arc`, `Vec`, and `LinkedList`. This is the case because they
/// provide a public API that follows the normal shared XOR mutable rules of Rust.
/// Unlike `*mut T`, `NonNull<T>` was chosen to be covariant over `T`. This makes it
/// possible to use `NonNull<T>` when building covariant types, but introduces the
/// risk of unsoundness if used in a type that shouldn't actually be covariant.
/// (The opposite choice was made for `*mut T` even though technically the unsoundness
/// could only be caused by calling unsafe functions.)
///
/// Covariance is correct for most safe abstractions, such as `Box`, `Rc`, `Arc`, `Vec`,
/// and `LinkedList`. This is the case because they provide a public API that follows the
/// normal shared XOR mutable rules of Rust.
///
/// If your type cannot safely be covariant, you must ensure it contains some
/// additional field to provide invariance. Often this field will be a [`PhantomData`]
/// type like `PhantomData<Cell<T>>` or `PhantomData<&'a mut T>`.
///
/// Notice that `NonNull<T>` has a `From` instance for `&T`. However, this does
/// not change the fact that mutating through a (pointer derived from a) shared
34 changes: 34 additions & 0 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
@@ -111,6 +111,7 @@ impl OsString {
/// let os_string = OsString::new();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn new() -> OsString {
OsString { inner: Buf::from_string(String::new()) }
}
@@ -127,6 +128,7 @@ impl OsString {
/// assert_eq!(os_string.as_os_str(), os_str);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn as_os_str(&self) -> &OsStr {
self
}
@@ -145,6 +147,7 @@ impl OsString {
/// assert_eq!(string, Ok(String::from("foo")));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn into_string(self) -> Result<String, OsString> {
self.inner.into_string().map_err(|buf| OsString { inner: buf })
}
@@ -163,6 +166,7 @@ impl OsString {
/// assert_eq!(&os_string, "foobar");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn push<T: AsRef<OsStr>>(&mut self, s: T) {
self.inner.push_slice(&s.as_ref().inner)
}
@@ -189,6 +193,7 @@ impl OsString {
/// assert_eq!(capacity, os_string.capacity());
/// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn with_capacity(capacity: usize) -> OsString {
OsString { inner: Buf::with_capacity(capacity) }
}
@@ -207,6 +212,7 @@ impl OsString {
/// assert_eq!(&os_string, "");
/// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn clear(&mut self) {
self.inner.clear()
}
@@ -224,6 +230,7 @@ impl OsString {
/// assert!(os_string.capacity() >= 10);
/// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn capacity(&self) -> usize {
self.inner.capacity()
}
@@ -243,6 +250,7 @@ impl OsString {
/// assert!(s.capacity() >= 10);
/// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn reserve(&mut self, additional: usize) {
self.inner.reserve(additional)
}
@@ -265,6 +273,7 @@ impl OsString {
/// assert!(s.capacity() >= 10);
/// ```
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn reserve_exact(&mut self, additional: usize) {
self.inner.reserve_exact(additional)
}
@@ -285,6 +294,7 @@ impl OsString {
/// assert_eq!(3, s.capacity());
/// ```
#[stable(feature = "osstring_shrink_to_fit", since = "1.19.0")]
#[inline]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
@@ -342,6 +352,7 @@ impl From<String> for OsString {
/// Converts a [`String`] into a [`OsString`].
///
/// The conversion copies the data, and includes an allocation on the heap.
#[inline]
fn from(s: String) -> OsString {
OsString { inner: Buf::from_string(s) }
}
@@ -408,34 +419,39 @@ impl fmt::Debug for OsString {

#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for OsString {
#[inline]
fn eq(&self, other: &OsString) -> bool {
&**self == &**other
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq<str> for OsString {
#[inline]
fn eq(&self, other: &str) -> bool {
&**self == other
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq<OsString> for str {
#[inline]
fn eq(&self, other: &OsString) -> bool {
&**other == self
}
}

#[stable(feature = "os_str_str_ref_eq", since = "1.29.0")]
impl PartialEq<&str> for OsString {
#[inline]
fn eq(&self, other: &&str) -> bool {
**self == **other
}
}

#[stable(feature = "os_str_str_ref_eq", since = "1.29.0")]
impl<'a> PartialEq<OsString> for &'a str {
#[inline]
fn eq(&self, other: &OsString) -> bool {
**other == **self
}
@@ -539,6 +555,7 @@ impl OsStr {
/// assert_eq!(os_str.to_str(), Some("foo"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn to_str(&self) -> Option<&str> {
self.inner.to_str()
}
@@ -589,6 +606,7 @@ impl OsStr {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn to_string_lossy(&self) -> Cow<'_, str> {
self.inner.to_string_lossy()
}
@@ -605,6 +623,7 @@ impl OsStr {
/// assert_eq!(os_string, OsString::from("foo"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn to_os_string(&self) -> OsString {
OsString { inner: self.inner.to_owned() }
}
@@ -655,6 +674,7 @@ impl OsStr {
/// ```
#[doc(alias = "length")]
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
#[inline]
pub fn len(&self) -> usize {
self.inner.inner.len()
}
@@ -696,6 +716,7 @@ impl OsStr {
/// assert_eq!("grÜße, jÜrgen ❤", s);
/// ```
#[unstable(feature = "osstring_ascii", issue = "70516")]
#[inline]
pub fn make_ascii_lowercase(&mut self) {
self.inner.make_ascii_lowercase()
}
@@ -721,6 +742,7 @@ impl OsStr {
/// assert_eq!("GRüßE, JüRGEN ❤", s);
/// ```
#[unstable(feature = "osstring_ascii", issue = "70516")]
#[inline]
pub fn make_ascii_uppercase(&mut self) {
self.inner.make_ascii_uppercase()
}
@@ -784,6 +806,7 @@ impl OsStr {
/// assert!(!non_ascii.is_ascii());
/// ```
#[unstable(feature = "osstring_ascii", issue = "70516")]
#[inline]
pub fn is_ascii(&self) -> bool {
self.inner.is_ascii()
}
@@ -811,6 +834,7 @@ impl OsStr {

#[stable(feature = "box_from_os_str", since = "1.17.0")]
impl From<&OsStr> for Box<OsStr> {
#[inline]
fn from(s: &OsStr) -> Box<OsStr> {
let rw = Box::into_raw(s.inner.into_box()) as *mut OsStr;
unsafe { Box::from_raw(rw) }
@@ -832,6 +856,7 @@ impl From<Cow<'_, OsStr>> for Box<OsStr> {
impl From<Box<OsStr>> for OsString {
/// Converts a [`Box`]`<`[`OsStr`]`>` into a `OsString` without copying or
/// allocating.
#[inline]
fn from(boxed: Box<OsStr>) -> OsString {
boxed.into_os_string()
}
@@ -840,6 +865,7 @@ impl From<Box<OsStr>> for OsString {
#[stable(feature = "box_from_os_string", since = "1.20.0")]
impl From<OsString> for Box<OsStr> {
/// Converts a [`OsString`] into a [`Box`]`<OsStr>` without copying or allocating.
#[inline]
fn from(s: OsString) -> Box<OsStr> {
s.into_boxed_os_str()
}
@@ -925,6 +951,7 @@ impl<'a> From<Cow<'a, OsStr>> for OsString {

#[stable(feature = "box_default_extra", since = "1.17.0")]
impl Default for Box<OsStr> {
#[inline]
fn default() -> Box<OsStr> {
let rw = Box::into_raw(Slice::empty_box()) as *mut OsStr;
unsafe { Box::from_raw(rw) }
@@ -1075,6 +1102,7 @@ impl OsStr {

#[stable(feature = "rust1", since = "1.0.0")]
impl Borrow<OsStr> for OsString {
#[inline]
fn borrow(&self) -> &OsStr {
&self[..]
}
@@ -1083,16 +1111,19 @@ impl Borrow<OsStr> for OsString {
#[stable(feature = "rust1", since = "1.0.0")]
impl ToOwned for OsStr {
type Owned = OsString;
#[inline]
fn to_owned(&self) -> OsString {
self.to_os_string()
}
#[inline]
fn clone_into(&self, target: &mut OsString) {
self.inner.clone_into(&mut target.inner)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl AsRef<OsStr> for OsStr {
#[inline]
fn as_ref(&self) -> &OsStr {
self
}
@@ -1123,12 +1154,14 @@ impl AsRef<OsStr> for String {
}

impl FromInner<Buf> for OsString {
#[inline]
fn from_inner(buf: Buf) -> OsString {
OsString { inner: buf }
}
}

impl IntoInner<Buf> for OsString {
#[inline]
fn into_inner(self) -> Buf {
self.inner
}
@@ -1145,6 +1178,7 @@ impl AsInner<Slice> for OsStr {
impl FromStr for OsString {
type Err = core::convert::Infallible;

#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(OsString::from(s))
}
69 changes: 69 additions & 0 deletions library/std/src/path.rs

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -1096,7 +1096,10 @@ impl Clean<Item> for hir::TraitItem<'_> {
AssocTypeItem(bounds.clean(cx), default.clean(cx))
}
};
Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx)
let what_rustc_thinks =
Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx);
// Trait items always inherit the trait's visibility -- we don't want to show `pub`.
Item { visibility: Inherited, ..what_rustc_thinks }
})
}
}
@@ -1131,7 +1134,21 @@ impl Clean<Item> for hir::ImplItem<'_> {
)
}
};
Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx)

let what_rustc_thinks =
Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx);
let parent_item = cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(self.hir_id));
if let hir::ItemKind::Impl(impl_) = &parent_item.kind {
if impl_.of_trait.is_some() {
// Trait impl items always inherit the impl's visibility --
// we don't want to show `pub`.
Item { visibility: Inherited, ..what_rustc_thinks }
} else {
what_rustc_thinks
}
} else {
panic!("found impl item with non-impl parent {:?}", parent_item);
}
})
}
}
36 changes: 23 additions & 13 deletions src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ use crate::formats::cache::{Cache, CACHE_KEY};
/// backend renderer has hooks for initialization, documenting an item, entering and exiting a
/// module, and cleanup/finalizing output.
crate trait FormatRenderer<'tcx>: Clone {
/// Gives a description of the renderer. Used for performance profiling.
fn descr() -> &'static str;

/// Sets up any state required for the renderer. When this is called the cache has already been
/// populated.
fn init(
@@ -57,16 +60,20 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
edition: Edition,
tcx: TyCtxt<'tcx>,
) -> Result<(), Error> {
let (krate, mut cache) = Cache::from_krate(
render_info.clone(),
options.document_private,
&options.extern_html_root_urls,
&options.output,
krate,
);

let (mut format_renderer, mut krate) =
T::init(krate, options, render_info, edition, &mut cache, tcx)?;
let (krate, mut cache) = tcx.sess.time("create_format_cache", || {
Cache::from_krate(
render_info.clone(),
options.document_private,
&options.extern_html_root_urls,
&options.output,
krate,
)
});
let prof = &tcx.sess.prof;

let (mut format_renderer, mut krate) = prof
.extra_verbose_generic_activity("create_renderer", T::descr())
.run(|| T::init(krate, options, render_info, edition, &mut cache, tcx))?;

let cache = Arc::new(cache);
// Freeze the cache now that the index has been built. Put an Arc into TLS for future
@@ -83,6 +90,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
// Render the crate documentation
let mut work = vec![(format_renderer.clone(), item)];

let unknown = rustc_span::Symbol::intern("<unknown item>");
while let Some((mut cx, item)) = work.pop() {
if item.is_mod() {
// modules are special because they add a namespace. We also need to
@@ -91,6 +99,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
if name.is_empty() {
panic!("Unexpected module with empty name");
}
let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str());

cx.mod_item_in(&item, &name, &cache)?;
let module = match *item.kind {
@@ -104,9 +113,10 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(

cx.mod_item_out(&name)?;
} else if item.name.is_some() {
cx.item(item, &cache)?;
prof.generic_activity_with_arg("render_item", &*item.name.unwrap_or(unknown).as_str())
.run(|| cx.item(item, &cache))?;
}
}

format_renderer.after_krate(&krate, &cache, diag)
prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
.run(|| format_renderer.after_krate(&krate, &cache, diag))
}
4 changes: 4 additions & 0 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
@@ -383,6 +383,10 @@ crate fn initial_ids() -> Vec<String> {

/// Generates the documentation for `crate` into the directory `dst`
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
fn descr() -> &'static str {
"html"
}

fn init(
mut krate: clean::Crate,
options: RenderOptions,
4 changes: 4 additions & 0 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
@@ -125,6 +125,10 @@ impl JsonRenderer<'_> {
}

impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
fn descr() -> &'static str {
"json"
}

fn init(
krate: clean::Crate,
options: RenderOptions,
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
@@ -540,7 +540,7 @@ fn main_options(options: config::Options) -> MainResult {
sess.fatal("Compilation failed, aborting rustdoc");
}

let mut global_ctxt = abort_on_err(queries.global_ctxt(), sess).take();
let mut global_ctxt = abort_on_err(queries.global_ctxt(), sess).peek_mut();

global_ctxt.enter(|tcx| {
let (mut krate, render_info, render_opts) = sess.time("run_global_ctxt", || {
32 changes: 32 additions & 0 deletions src/test/rustdoc/visibility.rs
Original file line number Diff line number Diff line change
@@ -42,3 +42,35 @@ mod a {
struct FooBPriv;
}
}

// @has 'foo/trait.PubTrait.html' '//pre' 'pub trait PubTrait'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'type Type;'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub type Type;'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'const CONST: usize;'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub const CONST: usize;'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'fn function();'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();'

pub trait PubTrait {
type Type;
const CONST: usize;
fn function();
}

// @has 'foo/struct.FooPublic.html' '//code' 'type Type'
// @!has 'foo/struct.FooPublic.html' '//code' 'pub type Type'
//
// @has 'foo/struct.FooPublic.html' '//code' 'const CONST: usize'
// @!has 'foo/struct.FooPublic.html' '//code' 'pub const CONST: usize'
//
// @has 'foo/struct.FooPublic.html' '//code' 'fn function()'
// @!has 'foo/struct.FooPublic.html' '//code' 'pub fn function()'

impl PubTrait for FooPublic {
type Type = usize;
const CONST: usize = 0;
fn function() {}
}
17 changes: 17 additions & 0 deletions src/test/ui/closures/local-type-mix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Check that using the parameter name in its type does not ICE.
// edition:2018

#![feature(async_closure)]

fn main() {
let _ = |x: x| x; //~ ERROR expected type
let _ = |x: bool| -> x { x }; //~ ERROR expected type
let _ = async move |x: x| x; //~ ERROR expected type
let _ = async move |x: bool| -> x { x }; //~ ERROR expected type
}

fn foo(x: x) {} //~ ERROR expected type
fn foo_ret(x: bool) -> x {} //~ ERROR expected type

async fn async_foo(x: x) {} //~ ERROR expected type
async fn async_foo_ret(x: bool) -> x {} //~ ERROR expected type
51 changes: 51 additions & 0 deletions src/test/ui/closures/local-type-mix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:7:17
|
LL | let _ = |x: x| x;
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:8:26
|
LL | let _ = |x: bool| -> x { x };
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:9:28
|
LL | let _ = async move |x: x| x;
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:10:37
|
LL | let _ = async move |x: bool| -> x { x };
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:13:11
|
LL | fn foo(x: x) {}
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:14:24
|
LL | fn foo_ret(x: bool) -> x {}
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:16:23
|
LL | async fn async_foo(x: x) {}
| ^ not a type

error[E0573]: expected type, found local variable `x`
--> $DIR/local-type-mix.rs:17:36
|
LL | async fn async_foo_ret(x: bool) -> x {}
| ^ not a type

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0573`.
34 changes: 31 additions & 3 deletions src/test/ui/mir/issue-80742.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| size_of called on unsized type `dyn Debug`
| inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
::: $DIR/issue-80742.rs:23:10
|
LL | [u8; size_of::<T>() + 1]: ,
| -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:23:10

error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope
--> $DIR/issue-80742.rs:31:36
|
@@ -21,6 +35,20 @@ LL | pub trait Debug {
= note: the method `new` exists but the following trait bounds were not satisfied:
`dyn Debug: Sized`

error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| size_of called on unsized type `dyn Debug`
| inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
::: $DIR/issue-80742.rs:15:10
|
LL | [u8; size_of::<T>() + 1]: ,
| -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:15:10

error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
--> $DIR/issue-80742.rs:31:15
|
@@ -36,7 +64,7 @@ help: consider relaxing the implicit `Sized` restriction
LL | struct Inline<T: ?Sized>
| ^^^^^^^^

error: aborting due to 2 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
Some errors have detailed explanations: E0080, E0277, E0599.
For more information about an error, try `rustc --explain E0080`.