"proc-macro2",
"quote",
"rand_core 0.5.1",
+ "regex",
"serde",
"serde_json",
"smallvec",
"atty",
"rustc_data_structures",
"rustc_error_messages",
+ "rustc_hir",
"rustc_lint_defs",
"rustc_macros",
"rustc_serialize",
version = "0.0.0"
dependencies = [
"odht",
+ "rustc_arena",
"rustc_ast",
"rustc_data_structures",
"rustc_error_messages",
pub fn is_unit(&self) -> bool {
matches!(self, TyKind::Tup(tys) if tys.is_empty())
}
+
+ pub fn is_simple_path(&self) -> Option<Symbol> {
+ if let TyKind::Path(None, Path { segments, .. }) = &self && segments.len() == 1 {
+ Some(segments[0].ident.name)
+ } else {
+ None
+ }
+ }
}
/// Syntax used to declare a trait object.
) -> &'hir hir::InlineAsm<'hir> {
// Rustdoc needs to support asm! from foreign architectures: don't try
// lowering the register constraints in this case.
- let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
- if asm_arch.is_none() && !self.sess.opts.actually_rustdoc {
- struct_span_err!(self.sess, sp, E0472, "inline assembly is unsupported on this target")
- .emit();
+ let asm_arch =
+ if self.tcx.sess.opts.actually_rustdoc { None } else { self.tcx.sess.asm_arch };
+ if asm_arch.is_none() && !self.tcx.sess.opts.actually_rustdoc {
+ struct_span_err!(
+ self.tcx.sess,
+ sp,
+ E0472,
+ "inline assembly is unsupported on this target"
+ )
+ .emit();
}
if let Some(asm_arch) = asm_arch {
// Inline assembly is currently only stable for these architectures.
| asm::InlineAsmArch::RiscV32
| asm::InlineAsmArch::RiscV64
);
- if !is_stable && !self.sess.features_untracked().asm_experimental_arch {
+ if !is_stable && !self.tcx.features().asm_experimental_arch {
feature_err(
- &self.sess.parse_sess,
+ &self.tcx.sess.parse_sess,
sym::asm_experimental_arch,
sp,
"inline assembly is not stable yet on this architecture",
}
if asm.options.contains(InlineAsmOptions::ATT_SYNTAX)
&& !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
- && !self.sess.opts.actually_rustdoc
+ && !self.tcx.sess.opts.actually_rustdoc
{
- self.sess
+ self.tcx
+ .sess
.struct_span_err(sp, "the `att_syntax` option is only supported on x86")
.emit();
}
- if asm.options.contains(InlineAsmOptions::MAY_UNWIND)
- && !self.sess.features_untracked().asm_unwind
- {
+ if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
feature_err(
- &self.sess.parse_sess,
+ &self.tcx.sess.parse_sess,
sym::asm_unwind,
sp,
"the `may_unwind` option is unstable",
let mut clobber_abis = FxHashMap::default();
if let Some(asm_arch) = asm_arch {
for (abi_name, abi_span) in &asm.clobber_abis {
- match asm::InlineAsmClobberAbi::parse(asm_arch, &self.sess.target, *abi_name) {
+ match asm::InlineAsmClobberAbi::parse(asm_arch, &self.tcx.sess.target, *abi_name) {
Ok(abi) => {
// If the abi was already in the list, emit an error
match clobber_abis.get(&abi) {
Some((prev_name, prev_sp)) => {
- let mut err = self.sess.struct_span_err(
+ let mut err = self.tcx.sess.struct_span_err(
*abi_span,
&format!("`{}` ABI specified multiple times", prev_name),
);
// Multiple different abi names may actually be the same ABI
// If the specified ABIs are not the same name, alert the user that they resolve to the same ABI
- let source_map = self.sess.source_map();
+ let source_map = self.tcx.sess.source_map();
if source_map.span_to_snippet(*prev_sp)
!= source_map.span_to_snippet(*abi_span)
{
}
}
Err(&[]) => {
- self.sess
+ self.tcx
+ .sess
.struct_span_err(
*abi_span,
"`clobber_abi` is not supported on this target",
.emit();
}
Err(supported_abis) => {
- let mut err =
- self.sess.struct_span_err(*abi_span, "invalid ABI for `clobber_abi`");
+ let mut err = self
+ .tcx
+ .sess
+ .struct_span_err(*abi_span, "invalid ABI for `clobber_abi`");
let mut abis = format!("`{}`", supported_abis[0]);
for m in &supported_abis[1..] {
let _ = write!(abis, ", `{}`", m);
// Lower operands to HIR. We use dummy register classes if an error
// occurs during lowering because we still need to be able to produce a
// valid HIR.
- let sess = self.sess;
+ let sess = self.tcx.sess;
let mut operands: Vec<_> = asm
.operands
.iter()
}
}
InlineAsmOperand::Const { ref anon_const } => {
- if !self.sess.features_untracked().asm_const {
+ if !self.tcx.features().asm_const {
feature_err(
- &self.sess.parse_sess,
+ &sess.parse_sess,
sym::asm_const,
*op_sp,
"const operands for inline assembly are unstable",
}
}
InlineAsmOperand::Sym { ref sym } => {
- if !self.sess.features_untracked().asm_sym {
+ if !self.tcx.features().asm_sym {
feature_err(
- &self.sess.parse_sess,
+ &sess.parse_sess,
sym::asm_sym,
*op_sp,
"sym operands for inline assembly are unstable",
span,
kind: hir::ExprKind::If(let_expr, then_expr, Some(else_expr)),
});
- if !self.sess.features_untracked().let_else {
+ if !self.tcx.features().let_else {
feature_err(
- &self.sess.parse_sess,
+ &self.tcx.sess.parse_sess,
sym::let_else,
local.span,
"`let...else` statements are unstable",
let hir_id = self.lower_node_id(e.id);
return hir::Expr { hir_id, kind, span: self.lower_span(e.span) };
} else {
- self.sess
+ self.tcx.sess
.struct_span_err(
e.span,
"#[rustc_box] requires precisely one argument \
self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), lims)
}
ExprKind::Underscore => {
- self.sess
- .struct_span_err(
+ self.tcx
+ .sess.struct_span_err(
e.span,
"in expressions, `_` can only be used on the left-hand side of an assignment",
)
let rest = match &se.rest {
StructRest::Base(e) => Some(self.lower_expr(e)),
StructRest::Rest(sp) => {
- self.sess
+ self.tcx
+ .sess
.struct_span_err(*sp, "base expression required after `..`")
.span_label(*sp, "add a base expression here")
.emit();
} else {
let try_span = this.mark_span_with_reason(
DesugaringKind::TryBlock,
- this.sess.source_map().end_point(body.span),
+ this.tcx.sess.source_map().end_point(body.span),
this.allow_try_trait.clone(),
);
Some(hir::GeneratorKind::Async(_)) => {}
Some(hir::GeneratorKind::Gen) | None => {
let mut err = struct_span_err!(
- self.sess,
+ self.tcx.sess,
dot_await_span,
E0728,
"`await` is only allowed inside `async` functions and blocks"
Some(hir::GeneratorKind::Gen) => {
if decl.inputs.len() > 1 {
struct_span_err!(
- self.sess,
+ self.tcx.sess,
fn_decl_span,
E0628,
"too many parameters for a generator (expected 0 or 1 parameters)"
}
None => {
if movability == Movability::Static {
- struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static")
- .emit();
+ struct_span_err!(
+ self.tcx.sess,
+ fn_decl_span,
+ E0697,
+ "closures cannot be static"
+ )
+ .emit();
}
None
}
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
struct_span_err!(
- this.sess,
+ this.tcx.sess,
fn_decl_span,
E0708,
"`async` non-`move` closures with parameters are not currently supported",
);
let fields_omitted = match &se.rest {
StructRest::Base(e) => {
- self.sess
+ self.tcx
+ .sess
.struct_span_err(
e.span,
"functional record updates are not allowed in destructuring \
Some(hir::GeneratorKind::Gen) => {}
Some(hir::GeneratorKind::Async(_)) => {
struct_span_err!(
- self.sess,
+ self.tcx.sess,
span,
E0727,
"`async` generators are not yet supported"
span,
self.allow_try_trait.clone(),
);
- let try_span = self.sess.source_map().end_point(span);
+ let try_span = self.tcx.sess.source_map().end_point(span);
let try_span = self.mark_span_with_reason(
DesugaringKind::QuestionMark,
try_span,
use super::ResolverAstLoweringExt;
use super::{AstOwner, ImplTraitContext, ImplTraitPosition};
-use super::{LoweringContext, ParamMode};
-use crate::{Arena, FnDeclKind};
+use super::{FnDeclKind, LoweringContext, ParamMode};
use rustc_ast::ptr::P;
use rustc_ast::visit::AssocCtxt;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
-use rustc_hir::definitions::Definitions;
use rustc_hir::PredicateOrigin;
use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::ty::{ResolverAstLowering, ResolverOutputs};
-use rustc_session::cstore::CrateStoreDyn;
-use rustc_session::Session;
+use rustc_middle::ty::{DefIdTree, ResolverAstLowering, TyCtxt};
use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use std::iter;
pub(super) struct ItemLowerer<'a, 'hir> {
- pub(super) sess: &'a Session,
- pub(super) definitions: &'a mut Definitions,
- pub(super) cstore: &'a CrateStoreDyn,
- pub(super) resolutions: &'a ResolverOutputs,
+ pub(super) tcx: TyCtxt<'hir>,
pub(super) resolver: &'a mut ResolverAstLowering,
- pub(super) arena: &'hir Arena<'hir>,
pub(super) ast_index: &'a IndexVec<LocalDefId, AstOwner<'a>>,
pub(super) owners: &'a mut IndexVec<LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>>,
}
) {
let mut lctx = LoweringContext {
// Pseudo-globals.
- sess: &self.sess,
- definitions: self.definitions,
- cstore: self.cstore,
- resolutions: self.resolutions,
+ tcx: self.tcx,
resolver: self.resolver,
- arena: self.arena,
+ arena: self.tcx.hir_arena,
// HirId handling.
bodies: Vec::new(),
fn lower_assoc_item(&mut self, item: &AssocItem, ctxt: AssocCtxt) {
let def_id = self.resolver.node_id_to_def_id[&item.id];
- let parent_id = {
- let parent = self.definitions.def_key(def_id).parent;
- let local_def_index = parent.unwrap();
- LocalDefId { local_def_index }
- };
-
+ let parent_id = self.tcx.local_parent(def_id);
let parent_hir = self.lower_node(parent_id).unwrap();
self.with_lctx(item.id, |lctx| {
// Evaluate with the lifetimes in `params` in-scope.
}
fn error_on_invalid_abi(&self, abi: StrLit) {
- struct_span_err!(self.sess, abi.span, E0703, "invalid ABI: found `{}`", abi.symbol)
+ struct_span_err!(self.tcx.sess, abi.span, E0703, "invalid ABI: found `{}`", abi.symbol)
.span_label(abi.span, "invalid ABI")
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
.emit();
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
-use rustc_errors::{struct_span_err, Applicability};
+use rustc_errors::{struct_span_err, Applicability, Handler};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
-use rustc_hir::definitions::{DefPathData, Definitions};
+use rustc_hir::definitions::DefPathData;
use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::ty::{ResolverAstLowering, ResolverOutputs};
-use rustc_query_system::ich::StableHashingContext;
-use rustc_session::cstore::CrateStoreDyn;
+use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::parse::feature_err;
-use rustc_session::Session;
use rustc_span::hygiene::MacroKind;
use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
mod pat;
mod path;
-rustc_hir::arena_types!(rustc_arena::declare_arena);
-
-struct LoweringContext<'a, 'hir: 'a> {
- /// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
- sess: &'a Session,
-
- definitions: &'a mut Definitions,
- cstore: &'a CrateStoreDyn,
- resolutions: &'a ResolverOutputs,
+struct LoweringContext<'a, 'hir> {
+ tcx: TyCtxt<'hir>,
resolver: &'a mut ResolverAstLowering,
/// Used to allocate HIR nodes.
- arena: &'hir Arena<'hir>,
+ arena: &'hir hir::Arena<'hir>,
/// Bodies inside the owner being lowered.
bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
/// Compute the hash for the HIR of the full crate.
/// This hash will then be part of the crate_hash which is stored in the metadata.
fn compute_hir_hash(
- sess: &Session,
- definitions: &Definitions,
- cstore: &CrateStoreDyn,
- resolver: &ResolverOutputs,
+ tcx: TyCtxt<'_>,
owners: &IndexVec<LocalDefId, hir::MaybeOwner<&hir::OwnerInfo<'_>>>,
) -> Fingerprint {
let mut hir_body_nodes: Vec<_> = owners
.iter_enumerated()
.filter_map(|(def_id, info)| {
let info = info.as_owner()?;
- let def_path_hash = definitions.def_path_hash(def_id);
+ let def_path_hash = tcx.hir().def_path_hash(def_id);
Some((def_path_hash, info))
})
.collect();
hir_body_nodes.sort_unstable_by_key(|bn| bn.0);
- let mut stable_hasher = StableHasher::new();
- let mut hcx = StableHashingContext::new(sess, definitions, cstore, &resolver.source_span);
- hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher);
- stable_hasher.finish()
+ tcx.with_stable_hashing_context(|mut hcx| {
+ let mut stable_hasher = StableHasher::new();
+ hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher);
+ stable_hasher.finish()
+ })
}
-pub fn lower_crate<'hir>(
- sess: &Session,
- krate: &Crate,
- definitions: &mut Definitions,
- cstore: &CrateStoreDyn,
- resolutions: &ResolverOutputs,
- mut resolver: ResolverAstLowering,
- arena: &'hir Arena<'hir>,
-) -> &'hir hir::Crate<'hir> {
- let _prof_timer = sess.prof.verbose_generic_activity("hir_lowering");
+pub fn lower_to_hir<'hir>(tcx: TyCtxt<'hir>, (): ()) -> hir::Crate<'hir> {
+ let sess = tcx.sess;
+ let krate = tcx.untracked_crate.steal();
+ let mut resolver = tcx.resolver_for_lowering(()).steal();
- let ast_index = index_crate(&resolver.node_id_to_def_id, krate);
-
- let mut owners =
- IndexVec::from_fn_n(|_| hir::MaybeOwner::Phantom, definitions.def_index_count());
+ let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
+ let mut owners = IndexVec::from_fn_n(
+ |_| hir::MaybeOwner::Phantom,
+ tcx.definitions_untracked().def_index_count(),
+ );
for def_id in ast_index.indices() {
item::ItemLowerer {
- sess,
- definitions,
- cstore,
- resolutions,
+ tcx,
resolver: &mut resolver,
- arena,
ast_index: &ast_index,
owners: &mut owners,
}
.lower_node(def_id);
}
- let hir_hash = compute_hir_hash(sess, definitions, cstore, resolutions, &owners);
- let krate = hir::Crate { owners, hir_hash };
- arena.alloc(krate)
+ // Drop AST to free memory
+ std::mem::drop(ast_index);
+ sess.time("drop_ast", || std::mem::drop(krate));
+
+ // Discard hygiene data, which isn't required after lowering to HIR.
+ if !sess.opts.debugging_opts.keep_hygiene_data {
+ rustc_span::hygiene::clear_syntax_context_map();
+ }
+
+ let hir_hash = compute_hir_hash(tcx, &owners);
+ hir::Crate { owners, hir_hash }
}
#[derive(Copy, Clone, PartialEq, Debug)]
}
impl<'a, 'hir> LoweringContext<'a, 'hir> {
- fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
- StableHashingContext::new(
- self.sess,
- self.definitions,
- self.cstore,
- &self.resolutions.source_span,
- )
- }
-
fn create_def(
&mut self,
parent: LocalDefId,
node_id: ast::NodeId,
data: DefPathData,
) -> LocalDefId {
+ debug_assert_ne!(node_id, ast::DUMMY_NODE_ID);
assert!(
self.opt_local_def_id(node_id).is_none(),
"adding a def'n for node-id {:?} and data {:?} but a previous def'n exists: {:?}",
node_id,
data,
- self.definitions.def_key(self.local_def_id(node_id)),
+ self.tcx.hir().def_key(self.local_def_id(node_id)),
);
- let def_id = self.definitions.create_def(parent, data);
+ let def_id = self.tcx.create_def(parent, data);
- // Some things for which we allocate `LocalDefId`s don't correspond to
- // anything in the AST, so they don't have a `NodeId`. For these cases
- // we don't need a mapping from `NodeId` to `LocalDefId`.
- if node_id != ast::DUMMY_NODE_ID {
- debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
- self.resolver.node_id_to_def_id.insert(node_id, def_id);
- }
+ debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
+ self.resolver.node_id_to_def_id.insert(node_id, def_id);
def_id
}
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
}
+ /// Freshen the `LoweringContext` and ready it to lower a nested item.
+ /// The lowered item is registered into `self.children`.
+ ///
+ /// This function sets up `HirId` lowering infrastructure,
+ /// and stashes the shared mutable state to avoid pollution by the closure.
#[instrument(level = "debug", skip(self, f))]
fn with_hir_id_owner(
&mut self,
std::mem::replace(&mut self.item_local_id_counter, hir::ItemLocalId::new(1));
let current_impl_trait_defs = std::mem::take(&mut self.impl_trait_defs);
let current_impl_trait_bounds = std::mem::take(&mut self.impl_trait_bounds);
- // Do not reset `next_node_id` and `node_id_to_def_id` as we want to refer to the
- // subdefinitions' nodes.
+
+ // Do not reset `next_node_id` and `node_id_to_def_id`:
+ // we want `f` to be able to refer to the `LocalDefId`s that the caller created.
+ // and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
// Always allocate the first `HirId` for the owner itself.
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
bodies.sort_by_key(|(k, _)| *k);
let bodies = SortedMap::from_presorted_elements(bodies);
let (hash_including_bodies, hash_without_bodies) = self.hash_owner(node, &bodies);
- let (nodes, parenting) = index::index_hir(self.sess, self.definitions, node, &bodies);
+ let (nodes, parenting) =
+ index::index_hir(self.tcx.sess, &*self.tcx.definitions_untracked(), node, &bodies);
let nodes = hir::OwnerNodes {
hash_including_bodies,
hash_without_bodies,
local_id_to_def_id,
};
let attrs = {
- let mut hcx = self.create_stable_hashing_context();
- let mut stable_hasher = StableHasher::new();
- attrs.hash_stable(&mut hcx, &mut stable_hasher);
- let hash = stable_hasher.finish();
+ let hash = self.tcx.with_stable_hashing_context(|mut hcx| {
+ let mut stable_hasher = StableHasher::new();
+ attrs.hash_stable(&mut hcx, &mut stable_hasher);
+ stable_hasher.finish()
+ });
hir::AttributeMap { map: attrs, hash }
};
node: hir::OwnerNode<'hir>,
bodies: &SortedMap<hir::ItemLocalId, &'hir hir::Body<'hir>>,
) -> (Fingerprint, Fingerprint) {
- let mut hcx = self.create_stable_hashing_context();
- let mut stable_hasher = StableHasher::new();
- hcx.with_hir_bodies(true, node.def_id(), bodies, |hcx| {
- node.hash_stable(hcx, &mut stable_hasher)
- });
- let hash_including_bodies = stable_hasher.finish();
- let mut stable_hasher = StableHasher::new();
- hcx.with_hir_bodies(false, node.def_id(), bodies, |hcx| {
- node.hash_stable(hcx, &mut stable_hasher)
- });
- let hash_without_bodies = stable_hasher.finish();
- (hash_including_bodies, hash_without_bodies)
+ self.tcx.with_stable_hashing_context(|mut hcx| {
+ let mut stable_hasher = StableHasher::new();
+ hcx.with_hir_bodies(true, node.def_id(), bodies, |hcx| {
+ node.hash_stable(hcx, &mut stable_hasher)
+ });
+ let hash_including_bodies = stable_hasher.finish();
+ let mut stable_hasher = StableHasher::new();
+ hcx.with_hir_bodies(false, node.def_id(), bodies, |hcx| {
+ node.hash_stable(hcx, &mut stable_hasher)
+ });
+ let hash_without_bodies = stable_hasher.finish();
+ (hash_including_bodies, hash_without_bodies)
+ })
}
/// This method allocates a new `HirId` for the given `NodeId` and stores it in
}
}
+ /// Generate a new `HirId` without a backing `NodeId`.
fn next_id(&mut self) -> hir::HirId {
- let node_id = self.next_node_id();
- self.lower_node_id(node_id)
+ let owner = self.current_hir_id_owner;
+ let local_id = self.item_local_id_counter;
+ assert_ne!(local_id, hir::ItemLocalId::new(0));
+ self.item_local_id_counter.increment_by(1);
+ hir::HirId { owner, local_id }
}
#[instrument(level = "trace", skip(self))]
self.resolver.get_import_res(id).present_items()
}
- fn diagnostic(&self) -> &rustc_errors::Handler {
- self.sess.diagnostic()
+ fn diagnostic(&self) -> &Handler {
+ self.tcx.sess.diagnostic()
}
/// Reuses the span but adds information like the kind of the desugaring and features that are
span: Span,
allow_internal_unstable: Option<Lrc<[Symbol]>>,
) -> Span {
- span.mark_with_reason(
- allow_internal_unstable,
- reason,
- self.sess.edition(),
- self.create_stable_hashing_context(),
- )
+ self.tcx.with_stable_hashing_context(|hcx| {
+ span.mark_with_reason(allow_internal_unstable, reason, self.tcx.sess.edition(), hcx)
+ })
}
/// Intercept all spans entering HIR.
/// Mark a span as relative to the current owning item.
fn lower_span(&self, span: Span) -> Span {
- if self.sess.opts.debugging_opts.incremental_relative_spans {
+ if self.tcx.sess.opts.debugging_opts.incremental_relative_spans {
span.with_parent(Some(self.current_hir_id_owner))
} else {
// Do not make spans relative when not using incremental compilation.
}
fn emit_bad_parenthesized_trait_in_assoc_ty(&self, data: &ParenthesizedArgs) {
- let mut err = self.sess.struct_span_err(
+ let mut err = self.tcx.sess.struct_span_err(
data.span,
"parenthesized generic arguments cannot be used in associated type constraints",
);
ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)),
ast::GenericArg::Type(ty) => {
match ty.kind {
- TyKind::Infer if self.sess.features_untracked().generic_arg_infer => {
+ TyKind::Infer if self.tcx.features().generic_arg_infer => {
return GenericArg::Infer(hir::InferArg {
hir_id: self.lower_node_id(ty.id),
span: self.lower_span(ty.span),
} else {
self.next_node_id()
};
- let span = self.sess.source_map().next_point(t.span.shrink_to_lo());
+ let span = self.tcx.sess.source_map().next_point(t.span.shrink_to_lo());
Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id }
});
let lifetime = self.lower_lifetime(®ion);
}
ImplTraitContext::Disallowed(position) => {
let mut err = struct_span_err!(
- self.sess,
+ self.tcx.sess,
t.span,
E0562,
"`impl Trait` only allowed in function and inherent method return types, not in {}",
}
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
TyKind::CVarArgs => {
- self.sess.delay_span_bug(
+ self.tcx.sess.delay_span_bug(
t.span,
"`TyKind::CVarArgs` should have been handled elsewhere",
);
hir_id,
name,
span: self.lower_span(param.span()),
- pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle),
+ pure_wrt_drop: self.tcx.sess.contains_name(¶m.attrs, sym::may_dangle),
kind,
colon_span: param.colon_span.map(|s| self.lower_span(s)),
}
fn lower_array_length(&mut self, c: &AnonConst) -> hir::ArrayLen {
match c.value.kind {
ExprKind::Underscore => {
- if self.sess.features_untracked().generic_arg_infer {
+ if self.tcx.features().generic_arg_infer {
hir::ArrayLen::Infer(self.lower_node_id(c.id), c.value.span)
} else {
feature_err(
- &self.sess.parse_sess,
+ &self.tcx.sess.parse_sess,
sym::generic_arg_infer,
c.value.span,
"using `_` for array lengths is unstable",
// We should've returned in the for loop above.
- self.sess.diagnostic().span_bug(
+ self.diagnostic().span_bug(
p.span,
&format!(
"lower_qpath: no final extension segment in {}..{}",
GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
ParenthesizedGenericArgs::Err => {
- let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
+ let mut err = struct_span_err!(self.tcx.sess, data.span, E0214, "{}", msg);
err.span_label(data.span, "only `Fn` traits may use parentheses");
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
if !data.inputs.is_empty() {
err
}
- pub(crate) fn cannot_act_on_uninitialized_variable(
- &self,
- span: Span,
- verb: &str,
- desc: &str,
- ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
- struct_span_err!(
- self,
- span,
- E0381,
- "{} of possibly-uninitialized variable: `{}`",
- verb,
- desc,
- )
- }
-
pub(crate) fn cannot_mutably_borrow_multiply(
&self,
new_loan_span: Span,
self,
new_loan_span,
E0501,
- "cannot borrow {}{} as {} because previous closure \
- requires unique access",
+ "cannot borrow {}{} as {} because previous closure requires unique access",
desc_new,
opt_via,
kind_new,
self,
closure_span,
E0373,
- "{} may outlive the current function, \
- but it borrows {}, \
- which is owned by the current function",
+ "{} may outlive the current function, but it borrows {}, which is owned by the current \
+ function",
closure_kind,
borrowed_path,
);
}
#[rustc_lint_diagnostics]
- fn struct_span_err_with_code<S: Into<MultiSpan>>(
+ pub(crate) fn struct_span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
use rustc_const_eval::util::CallKind;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
-use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
+use rustc_errors::{
+ struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan,
+};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
+use rustc_hir::intravisit::{walk_expr, Visitor};
use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::ObligationCause;
self, subst::Subst, suggest_constraining_type_params, EarlyBinder, PredicateKind, Ty,
};
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
+use rustc_span::hygiene::DesugaringKind;
use rustc_span::symbol::sym;
use rustc_span::{BytePos, Span};
use rustc_trait_selection::infer::InferCtxtExt;
return;
}
- let item_msg =
- match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
- Some(name) => format!("`{}`", name),
- None => "value".to_owned(),
- };
- let mut err = self.cannot_act_on_uninitialized_variable(
+ let err = self.report_use_of_uninitialized(
+ mpi,
+ used_place,
+ moved_place,
+ desired_action,
span,
- desired_action.as_noun(),
- &self
- .describe_place_with_options(moved_place, IncludingDowncast(true))
- .unwrap_or_else(|| "_".to_owned()),
+ use_spans,
);
- err.span_label(span, format!("use of possibly-uninitialized {}", item_msg));
-
- use_spans.var_span_label_path_only(
- &mut err,
- format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
- );
-
self.buffer_error(err);
} else {
if let Some((reported_place, _)) = self.has_move_error(&move_out_indices) {
if self.prefixes(*reported_place, PrefixSet::All).any(|p| p == used_place) {
debug!(
- "report_use_of_moved_or_uninitialized place: error suppressed \
- mois={:?}",
+ "report_use_of_moved_or_uninitialized place: error suppressed mois={:?}",
move_out_indices
);
return;
}
}
+ fn report_use_of_uninitialized(
+ &self,
+ mpi: MovePathIndex,
+ used_place: PlaceRef<'tcx>,
+ moved_place: PlaceRef<'tcx>,
+ desired_action: InitializationRequiringAction,
+ span: Span,
+ use_spans: UseSpans<'tcx>,
+ ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
+ // We need all statements in the body where the binding was assigned to to later find all
+ // the branching code paths where the binding *wasn't* assigned to.
+ let inits = &self.move_data.init_path_map[mpi];
+ let move_path = &self.move_data.move_paths[mpi];
+ let decl_span = self.body.local_decls[move_path.place.local].source_info.span;
+ let mut spans = vec![];
+ for init_idx in inits {
+ let init = &self.move_data.inits[*init_idx];
+ let span = init.span(&self.body);
+ if !span.is_dummy() {
+ spans.push(span);
+ }
+ }
+
+ let (name, desc) =
+ match self.describe_place_with_options(moved_place, IncludingDowncast(true)) {
+ Some(name) => (format!("`{name}`"), format!("`{name}` ")),
+ None => ("the variable".to_string(), String::new()),
+ };
+ let path = match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
+ Some(name) => format!("`{name}`"),
+ None => "value".to_string(),
+ };
+
+ // We use the statements were the binding was initialized, and inspect the HIR to look
+ // for the branching codepaths that aren't covered, to point at them.
+ let hir_id = self.mir_hir_id();
+ let map = self.infcx.tcx.hir();
+ let body_id = map.body_owned_by(hir_id);
+ let body = map.body(body_id);
+
+ let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] };
+ visitor.visit_body(&body);
+
+ let isnt_initialized = if let InitializationRequiringAction::PartialAssignment
+ | InitializationRequiringAction::Assignment = desired_action
+ {
+ // The same error is emitted for bindings that are *sometimes* initialized and the ones
+ // that are *partially* initialized by assigning to a field of an uninitialized
+ // binding. We differentiate between them for more accurate wording here.
+ "isn't fully initialized"
+ } else if spans
+ .iter()
+ .filter(|i| {
+ // We filter these to avoid misleading wording in cases like the following,
+ // where `x` has an `init`, but it is in the same place we're looking at:
+ // ```
+ // let x;
+ // x += 1;
+ // ```
+ !i.contains(span)
+ // We filter these to avoid incorrect main message on `match-cfg-fake-edges.rs`
+ && !visitor
+ .errors
+ .iter()
+ .map(|(sp, _)| *sp)
+ .any(|sp| span < sp && !sp.contains(span))
+ })
+ .count()
+ == 0
+ {
+ "isn't initialized"
+ } else {
+ "is possibly-uninitialized"
+ };
+
+ let used = desired_action.as_general_verb_in_past_tense();
+ let mut err =
+ struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
+ use_spans.var_span_label_path_only(
+ &mut err,
+ format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
+ );
+
+ if let InitializationRequiringAction::PartialAssignment
+ | InitializationRequiringAction::Assignment = desired_action
+ {
+ err.help(
+ "partial initialization isn't supported, fully initialize the binding with a \
+ default value and mutate it, or use `std::mem::MaybeUninit`",
+ );
+ }
+ err.span_label(span, format!("{path} {used} here but it {isnt_initialized}"));
+
+ let mut shown = false;
+ for (sp, label) in visitor.errors {
+ if sp < span && !sp.overlaps(span) {
+ // When we have a case like `match-cfg-fake-edges.rs`, we don't want to mention
+ // match arms coming after the primary span because they aren't relevant:
+ // ```
+ // let x;
+ // match y {
+ // _ if { x = 2; true } => {}
+ // _ if {
+ // x; //~ ERROR
+ // false
+ // } => {}
+ // _ => {} // We don't want to point to this.
+ // };
+ // ```
+ err.span_label(sp, &label);
+ shown = true;
+ }
+ }
+ if !shown {
+ for sp in &spans {
+ if *sp < span && !sp.overlaps(span) {
+ err.span_label(*sp, "binding initialized here in some conditions");
+ }
+ }
+ }
+ err.span_label(decl_span, "binding declared here but left uninitialized");
+ err
+ }
+
fn suggest_borrow_fn_like(
&self,
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
}
}
}
+
+/// Detect whether one of the provided spans is a statement nested within the top-most visited expr
+struct ReferencedStatementsVisitor<'a>(&'a [Span], bool);
+
+impl<'a, 'v> Visitor<'v> for ReferencedStatementsVisitor<'a> {
+ fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) {
+ match s.kind {
+ hir::StmtKind::Semi(expr) if self.0.contains(&expr.span) => {
+ self.1 = true;
+ }
+ _ => {}
+ }
+ }
+}
+
+/// Given a set of spans representing statements initializing the relevant binding, visit all the
+/// function expressions looking for branching code paths that *do not* initialize the binding.
+struct ConditionVisitor<'b> {
+ spans: &'b [Span],
+ name: &'b str,
+ errors: Vec<(Span, String)>,
+}
+
+impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
+ fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
+ match ex.kind {
+ hir::ExprKind::If(cond, body, None) => {
+ // `if` expressions with no `else` that initialize the binding might be missing an
+ // `else` arm.
+ let mut v = ReferencedStatementsVisitor(self.spans, false);
+ v.visit_expr(body);
+ if v.1 {
+ self.errors.push((
+ cond.span,
+ format!(
+ "if this `if` condition is `false`, {} is not initialized",
+ self.name,
+ ),
+ ));
+ self.errors.push((
+ ex.span.shrink_to_hi(),
+ format!("an `else` arm might be missing here, initializing {}", self.name),
+ ));
+ }
+ }
+ hir::ExprKind::If(cond, body, Some(other)) => {
+ // `if` expressions where the binding is only initialized in one of the two arms
+ // might be missing a binding initialization.
+ let mut a = ReferencedStatementsVisitor(self.spans, false);
+ a.visit_expr(body);
+ let mut b = ReferencedStatementsVisitor(self.spans, false);
+ b.visit_expr(other);
+ match (a.1, b.1) {
+ (true, true) | (false, false) => {}
+ (true, false) => {
+ if other.span.is_desugaring(DesugaringKind::WhileLoop) {
+ self.errors.push((
+ cond.span,
+ format!(
+ "if this condition isn't met and the `while` loop runs 0 \
+ times, {} is not initialized",
+ self.name
+ ),
+ ));
+ } else {
+ self.errors.push((
+ body.span.shrink_to_hi().until(other.span),
+ format!(
+ "if the `if` condition is `false` and this `else` arm is \
+ executed, {} is not initialized",
+ self.name
+ ),
+ ));
+ }
+ }
+ (false, true) => {
+ self.errors.push((
+ cond.span,
+ format!(
+ "if this condition is `true`, {} is not initialized",
+ self.name
+ ),
+ ));
+ }
+ }
+ }
+ hir::ExprKind::Match(e, arms, loop_desugar) => {
+ // If the binding is initialized in one of the match arms, then the other match
+ // arms might be missing an initialization.
+ let results: Vec<bool> = arms
+ .iter()
+ .map(|arm| {
+ let mut v = ReferencedStatementsVisitor(self.spans, false);
+ v.visit_arm(arm);
+ v.1
+ })
+ .collect();
+ if results.iter().any(|x| *x) && !results.iter().all(|x| *x) {
+ for (arm, seen) in arms.iter().zip(results) {
+ if !seen {
+ if loop_desugar == hir::MatchSource::ForLoopDesugar {
+ self.errors.push((
+ e.span,
+ format!(
+ "if the `for` loop runs 0 times, {} is not initialized ",
+ self.name
+ ),
+ ));
+ } else if let Some(guard) = &arm.guard {
+ self.errors.push((
+ arm.pat.span.to(guard.body().span),
+ format!(
+ "if this pattern and condition are matched, {} is not \
+ initialized",
+ self.name
+ ),
+ ));
+ } else {
+ self.errors.push((
+ arm.pat.span,
+ format!(
+ "if this pattern is matched, {} is not initialized",
+ self.name
+ ),
+ ));
+ }
+ }
+ }
+ }
+ }
+ // FIXME: should we also account for binops, particularly `&&` and `||`? `try` should
+ // also be accounted for. For now it is fine, as if we don't find *any* relevant
+ // branching code paths, we point at the places where the binding *is* initialized for
+ // *some* context.
+ _ => {}
+ }
+ walk_expr(self, ex);
+ }
+}
let arg_pos = args
.iter()
.enumerate()
- .filter(|(_, arg)| arg.span == self.body.span)
+ .filter(|(_, arg)| arg.hir_id == closure_id)
.map(|(pos, _)| pos)
.next();
let def_id = hir.local_def_id(item_id);
if let Some(span) = arg {
err.span_label(span, "change this to accept `FnMut` instead of `Fn`");
err.span_label(func.span, "expects `Fn` instead of `FnMut`");
- if self.infcx.tcx.sess.source_map().is_multiline(self.body.span) {
- err.span_label(self.body.span, "in this closure");
- }
+ err.span_label(self.body.span, "in this closure");
look_at_return = false;
}
}
InitializationRequiringAction::PartialAssignment => "partially assigned",
}
}
+
+ fn as_general_verb_in_past_tense(self) -> &'static str {
+ match self {
+ InitializationRequiringAction::Borrow
+ | InitializationRequiringAction::MatchOn
+ | InitializationRequiringAction::Use => "used",
+ InitializationRequiringAction::Assignment => "assigned",
+ InitializationRequiringAction::PartialAssignment => "partially assigned",
+ }
+ }
}
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}
- NllRegionVariableOrigin::RootEmptyRegion
- | NllRegionVariableOrigin::Existential { .. } => {
+ NllRegionVariableOrigin::Existential { .. } => {
// For existential, regions, nothing to do.
}
}
self.check_bound_universal_region(fr, placeholder, errors_buffer);
}
- NllRegionVariableOrigin::RootEmptyRegion
- | NllRegionVariableOrigin::Existential { .. } => {
+ NllRegionVariableOrigin::Existential { .. } => {
// nothing to check here
}
}
self.check_bound_universal_region(fr, placeholder, errors_buffer);
}
- NllRegionVariableOrigin::RootEmptyRegion
- | NllRegionVariableOrigin::Existential { .. } => {
+ NllRegionVariableOrigin::Existential { .. } => {
// nothing to check here
}
}
universe1.cannot_name(placeholder.universe)
}
- NllRegionVariableOrigin::RootEmptyRegion
- | NllRegionVariableOrigin::FreeRegion
- | NllRegionVariableOrigin::Existential { .. } => false,
+ NllRegionVariableOrigin::FreeRegion | NllRegionVariableOrigin::Existential { .. } => {
+ false
+ }
}
}
let blame_source = match from_region_origin {
NllRegionVariableOrigin::FreeRegion
| NllRegionVariableOrigin::Existential { from_forall: false } => true,
- NllRegionVariableOrigin::RootEmptyRegion
- | NllRegionVariableOrigin::Placeholder(_)
+ NllRegionVariableOrigin::Placeholder(_)
| NllRegionVariableOrigin::Existential { from_forall: true } => false,
};
+use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::vec_map::VecMap;
use rustc_hir::def_id::DefId;
use rustc_hir::OpaqueTyOrigin;
+use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
use rustc_infer::infer::InferCtxt;
+use rustc_infer::infer::TyCtxtInferExt as _;
+use rustc_infer::traits::{Obligation, ObligationCause, TraitEngine};
+use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable};
+use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts};
+use rustc_middle::ty::visit::TypeVisitable;
use rustc_middle::ty::{
- self, OpaqueHiddenType, OpaqueTypeKey, TyCtxt, TypeFoldable, TypeVisitable,
+ self, OpaqueHiddenType, OpaqueTypeKey, ToPredicate, Ty, TyCtxt, TypeFoldable,
};
-use rustc_trait_selection::opaque_types::InferCtxtExt;
+use rustc_span::Span;
+use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _;
+use rustc_trait_selection::traits::TraitEngineExt as _;
use super::RegionInferenceContext;
})
}
}
+
+pub trait InferCtxtExt<'tcx> {
+ fn infer_opaque_definition_from_instantiation(
+ &self,
+ opaque_type_key: OpaqueTypeKey<'tcx>,
+ instantiated_ty: OpaqueHiddenType<'tcx>,
+ origin: OpaqueTyOrigin,
+ ) -> Ty<'tcx>;
+}
+
+impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
+ /// Given the fully resolved, instantiated type for an opaque
+ /// type, i.e., the value of an inference variable like C1 or C2
+ /// (*), computes the "definition type" for an opaque type
+ /// definition -- that is, the inferred value of `Foo1<'x>` or
+ /// `Foo2<'x>` that we would conceptually use in its definition:
+ /// ```ignore (illustrative)
+ /// type Foo1<'x> = impl Bar<'x> = AAA; // <-- this type AAA
+ /// type Foo2<'x> = impl Bar<'x> = BBB; // <-- or this type BBB
+ /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
+ /// ```
+ /// Note that these values are defined in terms of a distinct set of
+ /// generic parameters (`'x` instead of `'a`) from C1 or C2. The main
+ /// purpose of this function is to do that translation.
+ ///
+ /// (*) C1 and C2 were introduced in the comments on
+ /// `register_member_constraints`. Read that comment for more context.
+ ///
+ /// # Parameters
+ ///
+ /// - `def_id`, the `impl Trait` type
+ /// - `substs`, the substs used to instantiate this opaque type
+ /// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
+ /// `opaque_defn.concrete_ty`
+ #[instrument(level = "debug", skip(self))]
+ fn infer_opaque_definition_from_instantiation(
+ &self,
+ opaque_type_key: OpaqueTypeKey<'tcx>,
+ instantiated_ty: OpaqueHiddenType<'tcx>,
+ origin: OpaqueTyOrigin,
+ ) -> Ty<'tcx> {
+ if self.is_tainted_by_errors() {
+ return self.tcx.ty_error();
+ }
+
+ let OpaqueTypeKey { def_id, substs } = opaque_type_key;
+
+ // Use substs to build up a reverse map from regions to their
+ // identity mappings. This is necessary because of `impl
+ // Trait` lifetimes are computed by replacing existing
+ // lifetimes with 'static and remapping only those used in the
+ // `impl Trait` return type, resulting in the parameters
+ // shifting.
+ let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
+ debug!(?id_substs);
+ let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
+ substs.iter().enumerate().map(|(index, subst)| (subst, id_substs[index])).collect();
+ debug!("map = {:#?}", map);
+
+ // Convert the type from the function into a type valid outside
+ // the function, by replacing invalid regions with 'static,
+ // after producing an error for each of them.
+ let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new(
+ self.tcx,
+ def_id,
+ map,
+ instantiated_ty.ty,
+ instantiated_ty.span,
+ ));
+ debug!(?definition_ty);
+
+ if !check_opaque_type_parameter_valid(
+ self.tcx,
+ opaque_type_key,
+ origin,
+ instantiated_ty.span,
+ ) {
+ return self.tcx.ty_error();
+ }
+
+ // Only check this for TAIT. RPIT already supports `src/test/ui/impl-trait/nested-return-type2.rs`
+ // on stable and we'd break that.
+ if let OpaqueTyOrigin::TyAlias = origin {
+ // This logic duplicates most of `check_opaque_meets_bounds`.
+ // FIXME(oli-obk): Also do region checks here and then consider removing `check_opaque_meets_bounds` entirely.
+ let param_env = self.tcx.param_env(def_id);
+ let body_id = self.tcx.local_def_id_to_hir_id(def_id.as_local().unwrap());
+ self.tcx.infer_ctxt().enter(move |infcx| {
+ // Require the hidden type to be well-formed with only the generics of the opaque type.
+ // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
+ // hidden type is well formed even without those bounds.
+ let predicate =
+ ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()))
+ .to_predicate(infcx.tcx);
+ let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
+
+ // Require that the hidden type actually fulfills all the bounds of the opaque type, even without
+ // the bounds that the function supplies.
+ match infcx.register_hidden_type(
+ OpaqueTypeKey { def_id, substs: id_substs },
+ ObligationCause::misc(instantiated_ty.span, body_id),
+ param_env,
+ definition_ty,
+ origin,
+ ) {
+ Ok(infer_ok) => {
+ for obligation in infer_ok.obligations {
+ fulfillment_cx.register_predicate_obligation(&infcx, obligation);
+ }
+ }
+ Err(err) => {
+ infcx
+ .report_mismatched_types(
+ &ObligationCause::misc(instantiated_ty.span, body_id),
+ self.tcx.mk_opaque(def_id, id_substs),
+ definition_ty,
+ err,
+ )
+ .emit();
+ }
+ }
+
+ fulfillment_cx.register_predicate_obligation(
+ &infcx,
+ Obligation::misc(instantiated_ty.span, body_id, param_env, predicate),
+ );
+
+ // Check that all obligations are satisfied by the implementation's
+ // version.
+ let errors = fulfillment_cx.select_all_or_error(&infcx);
+
+ let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
+
+ if errors.is_empty() {
+ definition_ty
+ } else {
+ infcx.report_fulfillment_errors(&errors, None, false);
+ self.tcx.ty_error()
+ }
+ })
+ } else {
+ definition_ty
+ }
+ }
+}
+
+fn check_opaque_type_parameter_valid(
+ tcx: TyCtxt<'_>,
+ opaque_type_key: OpaqueTypeKey<'_>,
+ origin: OpaqueTyOrigin,
+ span: Span,
+) -> bool {
+ match origin {
+ // No need to check return position impl trait (RPIT)
+ // because for type and const parameters they are correct
+ // by construction: we convert
+ //
+ // fn foo<P0..Pn>() -> impl Trait
+ //
+ // into
+ //
+ // type Foo<P0...Pn>
+ // fn foo<P0..Pn>() -> Foo<P0...Pn>.
+ //
+ // For lifetime parameters we convert
+ //
+ // fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
+ //
+ // into
+ //
+ // type foo::<'p0..'pn>::Foo<'q0..'qm>
+ // fn foo<l0..'ln>() -> foo::<'static..'static>::Foo<'l0..'lm>.
+ //
+ // which would error here on all of the `'static` args.
+ OpaqueTyOrigin::FnReturn(..) | OpaqueTyOrigin::AsyncFn(..) => return true,
+ // Check these
+ OpaqueTyOrigin::TyAlias => {}
+ }
+ let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
+ let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
+ for (i, arg) in opaque_type_key.substs.iter().enumerate() {
+ let arg_is_param = match arg.unpack() {
+ GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
+ GenericArgKind::Lifetime(lt) if lt.is_static() => {
+ tcx.sess
+ .struct_span_err(span, "non-defining opaque type use in defining scope")
+ .span_label(
+ tcx.def_span(opaque_generics.param_at(i, tcx).def_id),
+ "cannot use static lifetime; use a bound lifetime \
+ instead or remove the lifetime parameter from the \
+ opaque type",
+ )
+ .emit();
+ return false;
+ }
+ GenericArgKind::Lifetime(lt) => {
+ matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
+ }
+ GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
+ };
+
+ if arg_is_param {
+ seen_params.entry(arg).or_default().push(i);
+ } else {
+ // Prevent `fn foo() -> Foo<u32>` from being defining.
+ let opaque_param = opaque_generics.param_at(i, tcx);
+ tcx.sess
+ .struct_span_err(span, "non-defining opaque type use in defining scope")
+ .span_note(
+ tcx.def_span(opaque_param.def_id),
+ &format!(
+ "used non-generic {} `{}` for generic parameter",
+ opaque_param.kind.descr(),
+ arg,
+ ),
+ )
+ .emit();
+ return false;
+ }
+ }
+
+ for (_, indices) in seen_params {
+ if indices.len() > 1 {
+ let descr = opaque_generics.param_at(indices[0], tcx).kind.descr();
+ let spans: Vec<_> = indices
+ .into_iter()
+ .map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
+ .collect();
+ tcx.sess
+ .struct_span_err(span, "non-defining opaque type use in defining scope")
+ .span_note(spans, &format!("{} used multiple times", descr))
+ .emit();
+ return false;
+ }
+ }
+ true
+}
+
+struct ReverseMapper<'tcx> {
+ tcx: TyCtxt<'tcx>,
+
+ opaque_type_def_id: DefId,
+ map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
+ map_missing_regions_to_empty: bool,
+
+ /// initially `Some`, set to `None` once error has been reported
+ hidden_ty: Option<Ty<'tcx>>,
+
+ /// Span of function being checked.
+ span: Span,
+}
+
+impl<'tcx> ReverseMapper<'tcx> {
+ fn new(
+ tcx: TyCtxt<'tcx>,
+ opaque_type_def_id: DefId,
+ map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
+ hidden_ty: Ty<'tcx>,
+ span: Span,
+ ) -> Self {
+ Self {
+ tcx,
+ opaque_type_def_id,
+ map,
+ map_missing_regions_to_empty: false,
+ hidden_ty: Some(hidden_ty),
+ span,
+ }
+ }
+
+ fn fold_kind_mapping_missing_regions_to_empty(
+ &mut self,
+ kind: GenericArg<'tcx>,
+ ) -> GenericArg<'tcx> {
+ assert!(!self.map_missing_regions_to_empty);
+ self.map_missing_regions_to_empty = true;
+ let kind = kind.fold_with(self);
+ self.map_missing_regions_to_empty = false;
+ kind
+ }
+
+ fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
+ assert!(!self.map_missing_regions_to_empty);
+ kind.fold_with(self)
+ }
+}
+
+impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
+ fn tcx(&self) -> TyCtxt<'tcx> {
+ self.tcx
+ }
+
+ #[instrument(skip(self), level = "debug")]
+ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
+ match *r {
+ // Ignore bound regions and `'static` regions that appear in the
+ // type, we only need to remap regions that reference lifetimes
+ // from the function declaration.
+ // This would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
+ ty::ReLateBound(..) | ty::ReStatic => return r,
+
+ // If regions have been erased (by writeback), don't try to unerase
+ // them.
+ ty::ReErased => return r,
+
+ // The regions that we expect from borrow checking.
+ ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReEmpty(ty::UniverseIndex::ROOT) => {}
+
+ ty::ReEmpty(_) | ty::RePlaceholder(_) | ty::ReVar(_) => {
+ // All of the regions in the type should either have been
+ // erased by writeback, or mapped back to named regions by
+ // borrow checking.
+ bug!("unexpected region kind in opaque type: {:?}", r);
+ }
+ }
+
+ let generics = self.tcx().generics_of(self.opaque_type_def_id);
+ match self.map.get(&r.into()).map(|k| k.unpack()) {
+ Some(GenericArgKind::Lifetime(r1)) => r1,
+ Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
+ None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
+ None if generics.parent.is_some() => {
+ if let Some(hidden_ty) = self.hidden_ty.take() {
+ unexpected_hidden_region_diagnostic(
+ self.tcx,
+ self.tcx.def_span(self.opaque_type_def_id),
+ hidden_ty,
+ r,
+ )
+ .emit();
+ }
+ self.tcx.lifetimes.re_root_empty
+ }
+ None => {
+ self.tcx
+ .sess
+ .struct_span_err(self.span, "non-defining opaque type use in defining scope")
+ .span_label(
+ self.span,
+ format!(
+ "lifetime `{}` is part of concrete type but not used in \
+ parameter list of the `impl Trait` type alias",
+ r
+ ),
+ )
+ .emit();
+
+ self.tcx().lifetimes.re_static
+ }
+ }
+ }
+
+ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
+ match *ty.kind() {
+ ty::Closure(def_id, substs) => {
+ // I am a horrible monster and I pray for death. When
+ // we encounter a closure here, it is always a closure
+ // from within the function that we are currently
+ // type-checking -- one that is now being encapsulated
+ // in an opaque type. Ideally, we would
+ // go through the types/lifetimes that it references
+ // and treat them just like we would any other type,
+ // which means we would error out if we find any
+ // reference to a type/region that is not in the
+ // "reverse map".
+ //
+ // **However,** in the case of closures, there is a
+ // somewhat subtle (read: hacky) consideration. The
+ // problem is that our closure types currently include
+ // all the lifetime parameters declared on the
+ // enclosing function, even if they are unused by the
+ // closure itself. We can't readily filter them out,
+ // so here we replace those values with `'empty`. This
+ // can't really make a difference to the rest of the
+ // compiler; those regions are ignored for the
+ // outlives relation, and hence don't affect trait
+ // selection or auto traits, and they are erased
+ // during codegen.
+
+ let generics = self.tcx.generics_of(def_id);
+ let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
+ if index < generics.parent_count {
+ // Accommodate missing regions in the parent kinds...
+ self.fold_kind_mapping_missing_regions_to_empty(kind)
+ } else {
+ // ...but not elsewhere.
+ self.fold_kind_normally(kind)
+ }
+ }));
+
+ self.tcx.mk_closure(def_id, substs)
+ }
+
+ ty::Generator(def_id, substs, movability) => {
+ let generics = self.tcx.generics_of(def_id);
+ let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
+ if index < generics.parent_count {
+ // Accommodate missing regions in the parent kinds...
+ self.fold_kind_mapping_missing_regions_to_empty(kind)
+ } else {
+ // ...but not elsewhere.
+ self.fold_kind_normally(kind)
+ }
+ }));
+
+ self.tcx.mk_generator(def_id, substs, movability)
+ }
+
+ ty::Param(param) => {
+ // Look it up in the substitution list.
+ match self.map.get(&ty.into()).map(|k| k.unpack()) {
+ // Found it in the substitution list; replace with the parameter from the
+ // opaque type.
+ Some(GenericArgKind::Type(t1)) => t1,
+ Some(u) => panic!("type mapped to unexpected kind: {:?}", u),
+ None => {
+ debug!(?param, ?self.map);
+ self.tcx
+ .sess
+ .struct_span_err(
+ self.span,
+ &format!(
+ "type parameter `{}` is part of concrete type but not \
+ used in parameter list for the `impl Trait` type alias",
+ ty
+ ),
+ )
+ .emit();
+
+ self.tcx().ty_error()
+ }
+ }
+ }
+
+ _ => ty.super_fold_with(self),
+ }
+ }
+
+ fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
+ trace!("checking const {:?}", ct);
+ // Find a const parameter
+ match ct.kind() {
+ ty::ConstKind::Param(..) => {
+ // Look it up in the substitution list.
+ match self.map.get(&ct.into()).map(|k| k.unpack()) {
+ // Found it in the substitution list, replace with the parameter from the
+ // opaque type.
+ Some(GenericArgKind::Const(c1)) => c1,
+ Some(u) => panic!("const mapped to unexpected kind: {:?}", u),
+ None => {
+ self.tcx
+ .sess
+ .struct_span_err(
+ self.span,
+ &format!(
+ "const parameter `{}` is part of concrete type but not \
+ used in parameter list for the `impl Trait` type alias",
+ ct
+ ),
+ )
+ .emit();
+
+ self.tcx().const_error(ct.ty())
+ }
+ }
+ }
+
+ _ => ct,
+ }
+ }
+}
let root_empty = self
.infcx
- .next_nll_region_var(NllRegionVariableOrigin::RootEmptyRegion)
+ .next_nll_region_var(NllRegionVariableOrigin::Existential { from_forall: true })
.to_region_vid();
UniversalRegions {
use crate::deriving::generic::*;
use crate::deriving::path_std;
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, Generics, ItemKind, MetaItem, VariantData};
+use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
+use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
trait_span: Span,
substr: &Substructure<'_>,
is_union: bool,
-) -> P<Expr> {
+) -> BlockOrExpr {
let mut stmts = Vec::new();
+ let mut seen_type_names = FxHashSet::default();
let mut process_variant = |variant: &VariantData| {
for field in variant.fields() {
- // let _: AssertParamIsClone<FieldTy>;
- super::assert_ty_bounds(
- cx,
- &mut stmts,
- field.ty.clone(),
- field.span,
- &[sym::clone, sym::AssertParamIsClone],
- );
+ // This basic redundancy checking only prevents duplication of
+ // assertions like `AssertParamIsClone<Foo>` where the type is a
+ // simple name. That's enough to get a lot of cases, though.
+ if let Some(name) = field.ty.kind.is_simple_path() && !seen_type_names.insert(name) {
+ // Already produced an assertion for this type.
+ } else {
+ // let _: AssertParamIsClone<FieldTy>;
+ super::assert_ty_bounds(
+ cx,
+ &mut stmts,
+ field.ty.clone(),
+ field.span,
+ &[sym::clone, sym::AssertParamIsClone],
+ );
+ }
}
};
if is_union {
+ // Just a single assertion for unions, that the union impls `Copy`.
// let _: AssertParamIsCopy<Self>;
let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper)));
super::assert_ty_bounds(
),
}
}
- stmts.push(cx.stmt_expr(cx.expr_deref(trait_span, cx.expr_self(trait_span))));
- cx.expr_block(cx.block(trait_span, stmts))
+ BlockOrExpr::new_mixed(stmts, cx.expr_deref(trait_span, cx.expr_self(trait_span)))
}
fn cs_clone(
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
-) -> P<Expr> {
+) -> BlockOrExpr {
let ctor_path;
let all_fields;
let fn_path = cx.std_path(&[sym::clone, sym::Clone, sym::clone]);
}
}
- match *vdata {
+ let expr = match *vdata {
VariantData::Struct(..) => {
let fields = all_fields
.iter()
cx.expr_call(trait_span, path, subcalls)
}
VariantData::Unit(..) => cx.expr_path(ctor_path),
- }
+ };
+ BlockOrExpr::new_expr(expr)
}
use crate::deriving::generic::*;
use crate::deriving::path_std;
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
+use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substr: &Substructure<'_>,
-) -> P<Expr> {
+) -> BlockOrExpr {
let mut stmts = Vec::new();
+ let mut seen_type_names = FxHashSet::default();
let mut process_variant = |variant: &ast::VariantData| {
for field in variant.fields() {
- // let _: AssertParamIsEq<FieldTy>;
- super::assert_ty_bounds(
- cx,
- &mut stmts,
- field.ty.clone(),
- field.span,
- &[sym::cmp, sym::AssertParamIsEq],
- );
+ // This basic redundancy checking only prevents duplication of
+ // assertions like `AssertParamIsEq<Foo>` where the type is a
+ // simple name. That's enough to get a lot of cases, though.
+ if let Some(name) = field.ty.kind.is_simple_path() && !seen_type_names.insert(name) {
+ // Already produced an assertion for this type.
+ } else {
+ // let _: AssertParamIsEq<FieldTy>;
+ super::assert_ty_bounds(
+ cx,
+ &mut stmts,
+ field.ty.clone(),
+ field.span,
+ &[sym::cmp, sym::AssertParamIsEq],
+ );
+ }
}
};
}
_ => cx.span_bug(trait_span, "unexpected substructure in `derive(Eq)`"),
}
- cx.expr_block(cx.block(trait_span, stmts))
+ BlockOrExpr::new_stmts(stmts)
}
use crate::deriving::path_std;
use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
cx.expr_call_global(span, fn_cmp_path, vec![lft, rgt])
}
-pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let test_id = Ident::new(sym::cmp, span);
let equals_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
// cmp => cmp
// }
//
- cs_fold(
+ let expr = cs_fold(
// foldr nests the if-elses correctly, leaving the first field
// as the outermost one, and the last as the innermost.
false,
// ::std::cmp::Ordering::Equal => old,
// cmp => cmp
// }
-
let new = {
let [other_f] = other_fs else {
cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
};
-
let args =
vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
-
cx.expr_call_global(span, cmp_path.clone(), args)
};
cx.expr_match(span, new, vec![eq_arm, neq_arm])
},
- cx.expr_path(equals_path.clone()),
+ |cx, args| match args {
+ Some((span, self_f, other_fs)) => {
+ let new = {
+ let [other_f] = other_fs else {
+ cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
+ };
+ let args =
+ vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
+ cx.expr_call_global(span, cmp_path.clone(), args)
+ };
+
+ new
+ }
+ None => cx.expr_path(equals_path.clone()),
+ },
Box::new(|cx, span, tag_tuple| {
if tag_tuple.len() != 2 {
cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`")
cx,
span,
substr,
- )
+ );
+ BlockOrExpr::new_expr(expr)
}
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
) {
- // structures are equal if all fields are equal, and non equal, if
- // any fields are not equal or if the enum variants are different
fn cs_op(
cx: &mut ExtCtxt<'_>,
span: Span,
op: BinOpKind,
combiner: BinOpKind,
base: bool,
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let op = |cx: &mut ExtCtxt<'_>, span: Span, self_f: P<Expr>, other_fs: &[P<Expr>]| {
let [other_f] = other_fs else {
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`");
cx.expr_binary(span, op, self_f, other_f.clone())
};
- cs_fold1(
+ let expr = cs_fold(
true, // use foldl
|cx, span, subexpr, self_f, other_fs| {
let eq = op(cx, span, self_f, other_fs);
cx,
span,
substr,
- )
+ );
+ BlockOrExpr::new_expr(expr)
}
- fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+ fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
cs_op(cx, span, substr, BinOpKind::Eq, BinOpKind::And, true)
}
- fn cs_ne(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+ fn cs_ne(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
cs_op(cx, span, substr, BinOpKind::Ne, BinOpKind::Or, false)
}
trait_def.expand(cx, mitem, item, push)
}
-pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let test_id = Ident::new(sym::cmp, span);
let ordering = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
let ordering_expr = cx.expr_path(ordering.clone());
- let equals_expr = cx.expr_some(span, ordering_expr);
let partial_cmp_path = cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]);
// cmp => cmp
// }
//
- cs_fold(
+ let expr = cs_fold(
// foldr nests the if-elses correctly, leaving the first field
// as the outermost one, and the last as the innermost.
false,
cx.expr_match(span, new, vec![eq_arm, neq_arm])
},
- equals_expr,
+ |cx: &mut ExtCtxt<'_>, args: Option<(Span, P<Expr>, &[P<Expr>])>| match args {
+ Some((span, self_f, other_fs)) => {
+ let new = {
+ let [other_f] = other_fs else {
+ cx.span_bug(span, "not exactly 2 arguments in `derive(Ord)`");
+ };
+ let args =
+ vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())];
+ cx.expr_call_global(span, partial_cmp_path.clone(), args)
+ };
+
+ new
+ }
+ None => cx.expr_some(span, ordering_expr.clone()),
+ },
Box::new(|cx, span, tag_tuple| {
if tag_tuple.len() != 2 {
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
cx,
span,
substr,
- )
+ );
+ BlockOrExpr::new_expr(expr)
}
use crate::deriving::generic::*;
use crate::deriving::path_std;
-use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
trait_def.expand(cx, mitem, item, push)
}
-fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
+fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
let (ident, vdata, fields) = match substr.fields {
Struct(vdata, fields) => (substr.type_ident, *vdata, fields),
EnumMatching(_, _, v, fields) => (v.ident, &v.data, fields),
if fields.is_empty() {
// Special case for no fields.
let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
- cx.expr_call_global(span, fn_path_write_str, vec![fmt, name])
+ let expr = cx.expr_call_global(span, fn_path_write_str, vec![fmt, name]);
+ BlockOrExpr::new_expr(expr)
} else if fields.len() <= CUTOFF {
// Few enough fields that we can use a specific-length method.
let debug = if is_struct {
let field = cx.expr_addr_of(field.span, field);
args.push(field);
}
- cx.expr_call_global(span, fn_path_debug, args)
+ let expr = cx.expr_call_global(span, fn_path_debug, args);
+ BlockOrExpr::new_expr(expr)
} else {
// Enough fields that we must use the any-length method.
let mut name_exprs = Vec::with_capacity(fields.len());
stmts.push(names_let.unwrap());
}
stmts.push(values_let);
- stmts.push(cx.stmt_expr(expr));
-
- cx.expr_block(cx.block(span, stmts))
+ BlockOrExpr::new_mixed(stmts, expr)
}
}
trait_span: Span,
substr: &Substructure<'_>,
krate: Symbol,
-) -> P<Expr> {
+) -> BlockOrExpr {
let decoder = substr.nonself_args[0].clone();
let recurse = vec![
Ident::new(krate, trait_span),
let blkarg = Ident::new(sym::_d, trait_span);
let blkdecoder = cx.expr_ident(trait_span, blkarg);
- match *substr.fields {
+ let expr = match *substr.fields {
StaticStruct(_, ref summary) => {
let nfields = match *summary {
Unnamed(ref fields, _) => fields.len(),
)
}
_ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
- }
+ };
+ BlockOrExpr::new_expr(expr)
}
/// Creates a decoder for a single enum variant/struct:
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
-use rustc_ast::ptr::P;
+use rustc_ast as ast;
use rustc_ast::walk_list;
use rustc_ast::EnumDef;
use rustc_ast::VariantData;
-use rustc_ast::{Expr, MetaItem};
use rustc_errors::Applicability;
use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
use rustc_span::symbol::Ident;
pub fn expand_deriving_default(
cx: &mut ExtCtxt<'_>,
span: Span,
- mitem: &MetaItem,
+ mitem: &ast::MetaItem,
item: &Annotatable,
push: &mut dyn FnMut(Annotatable),
) {
trait_span: Span,
substr: &Substructure<'_>,
summary: &StaticFields,
-) -> P<Expr> {
+) -> BlockOrExpr {
// Note that `kw::Default` is "default" and `sym::Default` is "Default"!
let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
- match summary {
+ let expr = match summary {
Unnamed(ref fields, is_tuple) => {
if !is_tuple {
cx.expr_ident(trait_span, substr.type_ident)
.collect();
cx.expr_struct_ident(trait_span, substr.type_ident, default_fields)
}
- }
+ };
+ BlockOrExpr::new_expr(expr)
}
fn default_enum_substructure(
cx: &mut ExtCtxt<'_>,
trait_span: Span,
enum_def: &EnumDef,
-) -> P<Expr> {
- let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span) else {
- return DummyResult::raw_expr(trait_span, true);
+) -> BlockOrExpr {
+ let expr = if let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span)
+ && let Ok(_) = validate_default_attribute(cx, default_variant)
+ {
+ // We now know there is exactly one unit variant with exactly one `#[default]` attribute.
+ cx.expr_path(cx.path(
+ default_variant.span,
+ vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident],
+ ))
+ } else {
+ DummyResult::raw_expr(trait_span, true)
};
-
- // At this point, we know that there is exactly one variant with a `#[default]` attribute. The
- // attribute hasn't yet been validated.
-
- if let Err(()) = validate_default_attribute(cx, default_variant) {
- return DummyResult::raw_expr(trait_span, true);
- }
-
- // We now know there is exactly one unit variant with exactly one `#[default]` attribute.
-
- cx.expr_path(cx.path(
- default_variant.span,
- vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident],
- ))
+ BlockOrExpr::new_expr(expr)
}
fn extract_default_variant<'a>(
use crate::deriving::generic::*;
use crate::deriving::pathvec_std;
-use rustc_ast::ptr::P;
-use rustc_ast::{Expr, ExprKind, MetaItem, Mutability};
+use rustc_ast::{ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
trait_span: Span,
substr: &Substructure<'_>,
krate: Symbol,
-) -> P<Expr> {
+) -> BlockOrExpr {
let encoder = substr.nonself_args[0].clone();
// throw an underscore in front to suppress unused variable warnings
let blkarg = Ident::new(sym::_e, trait_span);
let fn_emit_struct_path =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_struct]);
- cx.expr_call_global(
+ let expr = cx.expr_call_global(
trait_span,
fn_emit_struct_path,
vec![
cx.expr_usize(trait_span, fields.len()),
blk,
],
- )
+ );
+ BlockOrExpr::new_expr(expr)
}
EnumMatching(idx, _, variant, ref fields) => {
let blk = cx.lambda1(trait_span, call, blkarg);
let fn_emit_enum_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum]);
- let ret = cx.expr_call_global(
+ let expr = cx.expr_call_global(
trait_span,
fn_emit_enum_path,
vec![encoder, cx.expr_str(trait_span, substr.type_ident.name), blk],
);
- cx.expr_block(cx.block(trait_span, vec![me, cx.stmt_expr(ret)]))
+ BlockOrExpr::new_mixed(vec![me], expr)
}
_ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),
/// Combine the values of all the fields together. The last argument is
/// all the fields of all the structures.
pub type CombineSubstructureFunc<'a> =
- Box<dyn FnMut(&mut ExtCtxt<'_>, Span, &Substructure<'_>) -> P<Expr> + 'a>;
+ Box<dyn FnMut(&mut ExtCtxt<'_>, Span, &Substructure<'_>) -> BlockOrExpr + 'a>;
/// Deal with non-matching enum variants. The slice is the identifiers holding
/// the variant index value for each of the `Self` arguments.
ty: P<ast::Ty>,
}
+// The code snippets built up for derived code are sometimes used as blocks
+// (e.g. in a function body) and sometimes used as expressions (e.g. in a match
+// arm). This structure avoids committing to either form until necessary,
+// avoiding the insertion of any unnecessary blocks.
+//
+// The statements come before the expression.
+pub struct BlockOrExpr(Vec<ast::Stmt>, Option<P<Expr>>);
+
+impl BlockOrExpr {
+ pub fn new_stmts(stmts: Vec<ast::Stmt>) -> BlockOrExpr {
+ BlockOrExpr(stmts, None)
+ }
+
+ pub fn new_expr(expr: P<Expr>) -> BlockOrExpr {
+ BlockOrExpr(vec![], Some(expr))
+ }
+
+ pub fn new_mixed(stmts: Vec<ast::Stmt>, expr: P<Expr>) -> BlockOrExpr {
+ BlockOrExpr(stmts, Some(expr))
+ }
+
+ // Converts it into a block.
+ fn into_block(mut self, cx: &ExtCtxt<'_>, span: Span) -> P<ast::Block> {
+ if let Some(expr) = self.1 {
+ self.0.push(cx.stmt_expr(expr));
+ }
+ cx.block(span, self.0)
+ }
+
+ // Converts it into an expression.
+ fn into_expr(self, cx: &ExtCtxt<'_>, span: Span) -> P<Expr> {
+ if self.0.is_empty() {
+ match self.1 {
+ None => cx.expr_block(cx.block(span, vec![])),
+ Some(expr) => expr,
+ }
+ } else {
+ cx.expr_block(self.into_block(cx, span))
+ }
+ }
+}
+
/// This method helps to extract all the type parameters referenced from a
/// type. For a type parameter `<T>`, it looks for either a `TyPath` that
/// is not global and starts with `T`, or a `TyQPath`.
type_ident: Ident,
nonself_args: &[P<Expr>],
fields: &SubstructureFields<'_>,
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let span = trait_.span;
let substructure = Substructure { type_ident, nonself_args, fields };
let mut f = self.combine_substructure.borrow_mut();
generics: &Generics,
explicit_self: Option<ast::ExplicitSelf>,
arg_types: Vec<(Ident, P<ast::Ty>)>,
- body: P<Expr>,
+ body: BlockOrExpr,
) -> P<ast::AssocItem> {
let span = trait_.span;
// Create the generics that aren't for `Self`.
let method_ident = Ident::new(self.name, span);
let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
- let body_block = cx.block_expr(body);
+ let body_block = body.into_block(cx, span);
let trait_lo_sp = span.shrink_to_lo();
nonself_args: &[P<Expr>],
use_temporaries: bool,
is_packed: bool,
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let mut raw_fields = Vec::new(); // Vec<[fields of self], [fields of next Self arg], [etc]>
let span = trait_.span;
let mut patterns = Vec::new();
);
if !is_packed {
- body.span = span;
body
} else {
// Do the let-destructuring.
let mut stmts: Vec<_> = iter::zip(self_args, patterns)
.map(|(arg_expr, pat)| cx.stmt_let_pat(span, pat, arg_expr.clone()))
.collect();
- stmts.push(cx.stmt_expr(body));
-
- cx.expr_block(cx.block(span, stmts))
+ stmts.extend(std::mem::take(&mut body.0));
+ BlockOrExpr(stmts, body.1)
}
}
struct_def: &VariantData,
type_ident: Ident,
nonself_args: &[P<Expr>],
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let summary = trait_.summarise_struct(cx, struct_def);
self.call_substructure_method(
type_ident: Ident,
mut self_args: Vec<P<Expr>>,
nonself_args: &[P<Expr>],
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let span = trait_.span;
let variants = &enum_def.variants;
}
// Here is the pat = `(&VariantK, &VariantK, ...)`
- let single_pat = cx.pat_tuple(span, subpats);
+ let single_pat = if subpats.len() == 1 {
+ subpats.pop().unwrap()
+ } else {
+ cx.pat_tuple(span, subpats)
+ };
// For the BodyK, we need to delegate to our caller,
// passing it an EnumMatching to indicate which case
// Self arg, assuming all are instances of VariantK.
// Build up code associated with such a case.
let substructure = EnumMatching(index, variants.len(), variant, field_tuples);
- let arm_expr = self.call_substructure_method(
- cx,
- trait_,
- type_ident,
- nonself_args,
- &substructure,
- );
+ let arm_expr = self
+ .call_substructure_method(cx, trait_, type_ident, nonself_args, &substructure)
+ .into_expr(cx, span);
cx.arm(span, single_pat, arm_expr)
})
// The index and actual variant aren't meaningful in this case,
// so just use whatever
let substructure = EnumMatching(0, variants.len(), v, Vec::new());
- Some(self.call_substructure_method(
- cx,
- trait_,
- type_ident,
- nonself_args,
- &substructure,
- ))
+ Some(
+ self.call_substructure_method(
+ cx,
+ trait_,
+ type_ident,
+ nonself_args,
+ &substructure,
+ )
+ .into_expr(cx, span),
+ )
}
_ if variants.len() > 1 && self_args.len() > 1 => {
// Since we know that all the arguments will match if we reach
}
}
- let arm_expr = self.call_substructure_method(
- cx,
- trait_,
- type_ident,
- nonself_args,
- &catch_all_substructure,
- );
+ let arm_expr = self
+ .call_substructure_method(
+ cx,
+ trait_,
+ type_ident,
+ nonself_args,
+ &catch_all_substructure,
+ )
+ .into_expr(cx, span);
// Final wrinkle: the self_args are expressions that deref
// down to desired places, but we cannot actually deref
// }
let all_match = cx.expr_match(span, match_arg, match_arms);
let arm_expr = cx.expr_if(span, discriminant_test, all_match, Some(arm_expr));
- index_let_stmts.push(cx.stmt_expr(arm_expr));
- cx.expr_block(cx.block(span, index_let_stmts))
+ BlockOrExpr(index_let_stmts, Some(arm_expr))
} else if variants.is_empty() {
// As an additional wrinkle, For a zero-variant enum A,
// currently the compiler
// derive Debug on such a type could here generate code
// that needs the feature gate enabled.)
- deriving::call_unreachable(cx, span)
+ BlockOrExpr(vec![], Some(deriving::call_unreachable(cx, span)))
} else {
// Final wrinkle: the self_args are expressions that deref
// down to desired places, but we cannot actually deref
// expression; here add a layer of borrowing, turning
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
self_args.map_in_place(|self_arg| cx.expr_addr_of(span, self_arg));
- let match_arg = cx.expr(span, ast::ExprKind::Tup(self_args));
- cx.expr_match(span, match_arg, match_arms)
+ let match_arg = if self_args.len() == 1 {
+ self_args.pop().unwrap()
+ } else {
+ cx.expr(span, ast::ExprKind::Tup(self_args))
+ };
+ BlockOrExpr(vec![], Some(cx.expr_match(span, match_arg, match_arms)))
}
}
enum_def: &EnumDef,
type_ident: Ident,
nonself_args: &[P<Expr>],
- ) -> P<Expr> {
+ ) -> BlockOrExpr {
let summary = enum_def
.variants
.iter()
}
}
-// helpful premade recipes
-
-fn cs_fold_fields<'a, F>(
- use_foldl: bool,
- mut f: F,
- base: P<Expr>,
- cx: &mut ExtCtxt<'_>,
- all_fields: &[FieldInfo<'a>],
-) -> P<Expr>
-where
- F: FnMut(&mut ExtCtxt<'_>, Span, P<Expr>, P<Expr>, &[P<Expr>]) -> P<Expr>,
-{
- if use_foldl {
- all_fields
- .iter()
- .fold(base, |old, field| f(cx, field.span, old, field.self_.clone(), &field.other))
- } else {
- all_fields
- .iter()
- .rev()
- .fold(base, |old, field| f(cx, field.span, old, field.self_.clone(), &field.other))
- }
-}
-
-fn cs_fold_enumnonmatch(
- mut enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
- cx: &mut ExtCtxt<'_>,
- trait_span: Span,
- substructure: &Substructure<'_>,
-) -> P<Expr> {
- match *substructure.fields {
- EnumNonMatchingCollapsed(tuple) => enum_nonmatch_f(cx, trait_span, tuple),
- _ => cx.span_bug(trait_span, "cs_fold_enumnonmatch expected an EnumNonMatchingCollapsed"),
- }
-}
-
-fn cs_fold_static(cx: &mut ExtCtxt<'_>, trait_span: Span) -> P<Expr> {
- cx.span_bug(trait_span, "static function in `derive`")
-}
-
-/// Fold the fields. `use_foldl` controls whether this is done
-/// left-to-right (`true`) or right-to-left (`false`).
-pub fn cs_fold<F>(
- use_foldl: bool,
- f: F,
- base: P<Expr>,
- enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
- cx: &mut ExtCtxt<'_>,
- trait_span: Span,
- substructure: &Substructure<'_>,
-) -> P<Expr>
-where
- F: FnMut(&mut ExtCtxt<'_>, Span, P<Expr>, P<Expr>, &[P<Expr>]) -> P<Expr>,
-{
- match *substructure.fields {
- EnumMatching(.., ref all_fields) | Struct(_, ref all_fields) => {
- cs_fold_fields(use_foldl, f, base, cx, all_fields)
- }
- EnumNonMatchingCollapsed(..) => {
- cs_fold_enumnonmatch(enum_nonmatch_f, cx, trait_span, substructure)
- }
- StaticEnum(..) | StaticStruct(..) => cs_fold_static(cx, trait_span),
- }
-}
-
/// Function to fold over fields, with three cases, to generate more efficient and concise code.
/// When the `substructure` has grouped fields, there are two cases:
/// Zero fields: call the base case function with `None` (like the usual base case of `cs_fold`).
/// fields.
/// When the `substructure` is an `EnumNonMatchingCollapsed`, the result of `enum_nonmatch_f`
/// is returned. Statics may not be folded over.
-pub fn cs_fold1<F, B>(
+pub fn cs_fold<F, B>(
use_foldl: bool,
- f: F,
+ mut f: F,
mut b: B,
- enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
+ mut enum_nonmatch_f: EnumNonMatchCollapsedFunc<'_>,
cx: &mut ExtCtxt<'_>,
trait_span: Span,
substructure: &Substructure<'_>,
(true, _) => (b(cx, None), &all_fields[..]),
};
- cs_fold_fields(use_foldl, f, base, cx, rest)
- }
- EnumNonMatchingCollapsed(..) => {
- cs_fold_enumnonmatch(enum_nonmatch_f, cx, trait_span, substructure)
+ if use_foldl {
+ rest.iter().fold(base, |old, field| {
+ f(cx, field.span, old, field.self_.clone(), &field.other)
+ })
+ } else {
+ rest.iter().rev().fold(base, |old, field| {
+ f(cx, field.span, old, field.self_.clone(), &field.other)
+ })
+ }
}
- StaticEnum(..) | StaticStruct(..) => cs_fold_static(cx, trait_span),
+ EnumNonMatchingCollapsed(tuple) => enum_nonmatch_f(cx, trait_span, tuple),
+ StaticEnum(..) | StaticStruct(..) => cx.span_bug(trait_span, "static function in `derive`"),
}
}
use crate::deriving::generic::*;
use crate::deriving::{self, path_std, pathvec_std};
-use rustc_ast::ptr::P;
-use rustc_ast::{Expr, MetaItem, Mutability};
+use rustc_ast::{MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span;
hash_trait_def.expand(cx, mitem, item, push);
}
-fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructure<'_>) -> P<Expr> {
+fn hash_substructure(
+ cx: &mut ExtCtxt<'_>,
+ trait_span: Span,
+ substr: &Substructure<'_>,
+) -> BlockOrExpr {
let [state_expr] = substr.nonself_args else {
cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`");
};
stmts.extend(
fields.iter().map(|FieldInfo { ref self_, span, .. }| call_hash(*span, self_.clone())),
);
-
- cx.expr_block(cx.block(trait_span, stmts))
+ BlockOrExpr::new_stmts(stmts)
}
use rustc_middle::ty::ScalarInt;
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
-use rustc_span::Symbol;
use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
use crate::consts::const_alloc_to_gcc;
self.context.new_rvalue_from_double(typ, val)
}
- fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
- let s_str = s.as_str();
- let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
- self.global_string(s_str)
- });
- let len = s_str.len();
+ fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
+ let str_global = *self
+ .const_str_cache
+ .borrow_mut()
+ .raw_entry_mut()
+ .from_key(s)
+ .or_insert_with(|| (s.to_owned(), self.global_string(s)))
+ .1;
+ let len = s.len();
let cs = self.const_ptrcast(str_global.get_address(None),
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
);
use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers};
use rustc_session::Session;
-use rustc_span::{Span, Symbol};
+use rustc_span::Span;
use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,
/// Cache of constant strings,
- pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
+ pub const_str_cache: RefCell<FxHashMap<String, LValue<'gcc>>>,
/// Cache of globals.
pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
* TODO(antoyo): remove the patches.
*/
-#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)]
+#![feature(
+ rustc_private,
+ decl_macro,
+ associated_type_bounds,
+ never_type,
+ trusted_len,
+ hash_raw_entry
+)]
#![allow(broken_intra_doc_links)]
#![recursion_limit="256"]
#![warn(rust_2018_idioms)]
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
use rustc_middle::ty::ScalarInt;
-use rustc_span::symbol::Symbol;
use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer, Size};
use libc::{c_char, c_uint};
unsafe { llvm::LLVMConstReal(t, val) }
}
- fn const_str(&self, s: Symbol) -> (&'ll Value, &'ll Value) {
- let s_str = s.as_str();
- let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
- let sc = self.const_bytes(s_str.as_bytes());
- let sym = self.generate_local_symbol_name("str");
- let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
- bug!("symbol `{}` is already defined", sym);
- });
- unsafe {
- llvm::LLVMSetInitializer(g, sc);
- llvm::LLVMSetGlobalConstant(g, True);
- llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
- }
- g
- });
- let len = s_str.len();
+ fn const_str(&self, s: &str) -> (&'ll Value, &'ll Value) {
+ let str_global = *self
+ .const_str_cache
+ .borrow_mut()
+ .raw_entry_mut()
+ .from_key(s)
+ .or_insert_with(|| {
+ let sc = self.const_bytes(s.as_bytes());
+ let sym = self.generate_local_symbol_name("str");
+ let g = self.define_global(&sym, self.val_ty(sc)).unwrap_or_else(|| {
+ bug!("symbol `{}` is already defined", sym);
+ });
+ unsafe {
+ llvm::LLVMSetInitializer(g, sc);
+ llvm::LLVMSetGlobalConstant(g, True);
+ llvm::LLVMRustSetLinkage(g, llvm::Linkage::InternalLinkage);
+ }
+ (s.to_owned(), g)
+ })
+ .1;
+ let len = s.len();
let cs = consts::ptrcast(
str_global,
self.type_ptr_to(self.layout_of(self.tcx.types.str_).llvm_type(self)),
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
use rustc_session::Session;
use rustc_span::source_map::Span;
-use rustc_span::symbol::Symbol;
use rustc_target::abi::{
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
};
pub vtables:
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
/// Cache of constant strings,
- pub const_str_cache: RefCell<FxHashMap<Symbol, &'ll Value>>,
+ pub const_str_cache: RefCell<FxHashMap<String, &'ll Value>>,
/// Reverse-direction for const ptrs cast from globals.
///
/// Right now this takes the form of a hex-encoded opaque hash value.
pub fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String {
let mut hasher = StableHasher::new();
- let mut hcx = tcx.create_stable_hashing_context();
- hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher));
+ tcx.with_stable_hashing_context(|mut hcx| {
+ hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher))
+ });
hasher.finish::<Fingerprint>().to_hex()
}
//! This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
+#![feature(hash_raw_entry)]
#![feature(let_chains)]
#![feature(let_else)]
#![feature(extern_types)]
use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_session::cstore::DllImport;
use rustc_session::Session;
-use rustc_span::symbol::Symbol;
use std::io;
use std::path::{Path, PathBuf};
pub(super) fn find_library(
- name: Symbol,
+ name: &str,
verbatim: bool,
search_paths: &[PathBuf],
sess: &Session,
use std::mem;
use std::process::{self, Output};
-use rustc_span::symbol::Symbol;
use rustc_target::spec::LldFlavor;
#[derive(Clone)]
self
}
- pub fn sym_arg(&mut self, arg: Symbol) -> &mut Command {
- self.arg(arg.as_str());
- self
- }
-
pub fn args<I>(&mut self, args: I) -> &mut Command
where
I: IntoIterator<Item: AsRef<OsStr>>,
}
if let Some(name) = lib.name {
let location =
- find_library(name, lib.verbatim.unwrap_or(false), &lib_search_paths, sess);
+ find_library(name.as_str(), lib.verbatim.unwrap_or(false), &lib_search_paths, sess);
ab.add_archive(&location, |_| false).unwrap_or_else(|e| {
sess.fatal(&format!(
"failed to add native library {}: {}",
let path = find_sanitizer_runtime(&sess, &filename);
let rpath = path.to_str().expect("non-utf8 component in path");
linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
- linker.link_dylib(Symbol::intern(&filename), false, true);
+ linker.link_dylib(&filename, false, true);
} else {
let filename = format!("librustc{}_rt.{}.a", channel, name);
let path = find_sanitizer_runtime(&sess, &filename).join(&filename);
let Some(name) = lib.name else {
continue;
};
+ let name = name.as_str();
// Skip if this library is the same as the last.
last = if (lib.name, lib.kind, lib.verbatim) == last {
let Some(name) = lib.name else {
continue;
};
+ let name = name.as_str();
if !relevant_lib(sess, lib) {
continue;
}
}
let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
cmd.link_rust_dylib(
- Symbol::intern(&unlib(&sess.target, filestem)),
+ &unlib(&sess.target, filestem),
parent.unwrap_or_else(|| Path::new("")),
);
}
let Some(name) = lib.name else {
continue;
};
+ let name = name.as_str();
if !relevant_lib(sess, &lib) {
continue;
}
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
use rustc_session::Session;
-use rustc_span::symbol::Symbol;
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
use cc::windows_registry;
pub trait Linker {
fn cmd(&mut self) -> &mut Command;
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path);
- fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool);
- fn link_rust_dylib(&mut self, lib: Symbol, path: &Path);
- fn link_framework(&mut self, framework: Symbol, as_needed: bool);
- fn link_staticlib(&mut self, lib: Symbol, verbatim: bool);
+ fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool);
+ fn link_rust_dylib(&mut self, lib: &str, path: &Path);
+ fn link_framework(&mut self, framework: &str, as_needed: bool);
+ fn link_staticlib(&mut self, lib: &str, verbatim: bool);
fn link_rlib(&mut self, lib: &Path);
fn link_whole_rlib(&mut self, lib: &Path);
- fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]);
+ fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]);
fn include_path(&mut self, path: &Path);
fn framework_path(&mut self, path: &Path);
fn output_filename(&mut self, path: &Path);
}
}
- fn link_dylib(&mut self, lib: Symbol, verbatim: bool, as_needed: bool) {
- if self.sess.target.os == "illumos" && lib.as_str() == "c" {
+ fn link_dylib(&mut self, lib: &str, verbatim: bool, as_needed: bool) {
+ if self.sess.target.os == "illumos" && lib == "c" {
// libc will be added via late_link_args on illumos so that it will
// appear last in the library search order.
// FIXME: This should be replaced by a more complete and generic
}
}
}
- fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) {
+ fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
self.hint_static();
self.cmd.arg(format!("-l{}{}", if verbatim { ":" } else { "" }, lib));
}
self.linker_arg("-znorelro");
}
- fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
+ fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
self.hint_dynamic();
self.cmd.arg(format!("-l{}", lib));
}
- fn link_framework(&mut self, framework: Symbol, as_needed: bool) {
+ fn link_framework(&mut self, framework: &str, as_needed: bool) {
self.hint_dynamic();
if !as_needed {
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
// flag but we have no way to detect that here.
- // self.cmd.arg("-needed_framework").sym_arg(framework);
+ // self.cmd.arg("-needed_framework").arg(framework);
self.sess.warn("`as-needed` modifier not implemented yet for ld64");
}
- self.cmd.arg("-framework").sym_arg(framework);
+ self.cmd.arg("-framework").arg(framework);
}
// Here we explicitly ask that the entire archive is included into the
// don't otherwise explicitly reference them. This can occur for
// libraries which are just providing bindings, libraries with generic
// functions, etc.
- fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, search_path: &[PathBuf]) {
self.hint_static();
let target = &self.sess.target;
if !target.is_like_osx {
self.cmd.arg("/OPT:NOREF,NOICF");
}
- fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) {
+ fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) {
self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" }));
}
- fn link_rust_dylib(&mut self, lib: Symbol, path: &Path) {
+ fn link_rust_dylib(&mut self, lib: &str, path: &Path) {
// When producing a dll, the MSVC linker may not actually emit a
// `foo.lib` file if the dll doesn't actually export any symbols, so we
// check to see if the file is there and just omit linking to it if it's
}
}
- fn link_staticlib(&mut self, lib: Symbol, verbatim: bool) {
+ fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
self.cmd.arg(format!("{}{}", lib, if verbatim { "" } else { ".lib" }));
}
fn framework_path(&mut self, _path: &Path) {
bug!("frameworks are not supported on windows")
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
bug!("frameworks are not supported on windows")
}
- fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) {
self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" }));
}
fn link_whole_rlib(&mut self, path: &Path) {
self.cmd.arg("-L").arg(path);
}
- fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
- self.cmd.arg("-l").sym_arg(lib);
+ fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
+ self.cmd.arg("-l").arg(lib);
}
fn output_filename(&mut self, path: &Path) {
self.cmd.arg(path);
}
- fn link_dylib(&mut self, lib: Symbol, verbatim: bool, _as_needed: bool) {
+ fn link_dylib(&mut self, lib: &str, verbatim: bool, _as_needed: bool) {
// Emscripten always links statically
self.link_staticlib(lib, verbatim);
}
- fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, lib: &str, verbatim: bool, _search_path: &[PathBuf]) {
// not supported?
self.link_staticlib(lib, verbatim);
}
self.link_rlib(lib);
}
- fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
+ fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
self.link_dylib(lib, false, true);
}
bug!("frameworks are not supported on Emscripten")
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
bug!("frameworks are not supported on Emscripten")
}
}
}
- fn link_dylib(&mut self, lib: Symbol, _verbatim: bool, _as_needed: bool) {
- self.cmd.arg("-l").sym_arg(lib);
+ fn link_dylib(&mut self, lib: &str, _verbatim: bool, _as_needed: bool) {
+ self.cmd.arg("-l").arg(lib);
}
- fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
- self.cmd.arg("-l").sym_arg(lib);
+ fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
+ self.cmd.arg("-l").arg(lib);
}
fn link_rlib(&mut self, lib: &Path) {
fn no_relro(&mut self) {}
- fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
- self.cmd.arg("-l").sym_arg(lib);
+ fn link_rust_dylib(&mut self, lib: &str, _path: &Path) {
+ self.cmd.arg("-l").arg(lib);
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
panic!("frameworks not supported")
}
- fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
- self.cmd.arg("-l").sym_arg(lib);
+ fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
+ self.cmd.arg("-l").arg(lib);
}
fn link_whole_rlib(&mut self, lib: &Path) {
}
impl<'a> Linker for L4Bender<'a> {
- fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+ fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
bug!("dylibs are not supported on L4Re");
}
- fn link_staticlib(&mut self, lib: Symbol, _verbatim: bool) {
+ fn link_staticlib(&mut self, lib: &str, _verbatim: bool) {
self.hint_static();
self.cmd.arg(format!("-PC{}", lib));
}
fn set_output_kind(&mut self, _output_kind: LinkOutputKind, _out_filename: &Path) {}
- fn link_rust_dylib(&mut self, _: Symbol, _: &Path) {
+ fn link_rust_dylib(&mut self, _: &str, _: &Path) {
panic!("Rust dylibs not supported");
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
bug!("frameworks not supported on L4Re");
}
- fn link_whole_staticlib(&mut self, lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
self.hint_static();
self.cmd.arg("--whole-archive").arg(format!("-l{}", lib));
self.cmd.arg("--no-whole-archive");
self.cmd.arg("-o").arg(path);
}
- fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+ fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
panic!("external dylibs not supported")
}
- fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) {
+ fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) {
panic!("external dylibs not supported")
}
- fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) {
+ fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) {
panic!("staticlibs not supported")
}
- fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
panic!("staticlibs not supported")
}
panic!("frameworks not supported")
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
panic!("frameworks not supported")
}
self.cmd.arg("-o").arg(path);
}
- fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
+ fn link_dylib(&mut self, _lib: &str, _verbatim: bool, _as_needed: bool) {
panic!("external dylibs not supported")
}
- fn link_rust_dylib(&mut self, _lib: Symbol, _path: &Path) {
+ fn link_rust_dylib(&mut self, _lib: &str, _path: &Path) {
panic!("external dylibs not supported")
}
- fn link_staticlib(&mut self, _lib: Symbol, _verbatim: bool) {
+ fn link_staticlib(&mut self, _lib: &str, _verbatim: bool) {
panic!("staticlibs not supported")
}
- fn link_whole_staticlib(&mut self, _lib: Symbol, _verbatim: bool, _search_path: &[PathBuf]) {
+ fn link_whole_staticlib(&mut self, _lib: &str, _verbatim: bool, _search_path: &[PathBuf]) {
panic!("staticlibs not supported")
}
panic!("frameworks not supported")
}
- fn link_framework(&mut self, _framework: Symbol, _as_needed: bool) {
+ fn link_framework(&mut self, _framework: &str, _as_needed: bool) {
panic!("frameworks not supported")
}
// If we cannot evaluate the constant to a known type, we fall back
// to emitting a stable hash value of the constant. This isn't very pretty
// but we get a deterministic, virtually unique value for the constant.
- let hcx = &mut tcx.create_stable_hashing_context();
- let mut hasher = StableHasher::new();
- let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
- hcx.while_hashing_spans(false, |hcx| ct.to_valtree().hash_stable(hcx, &mut hasher));
+ //
// Let's only emit 64 bits of the hash value. That should be plenty for
// avoiding collisions and will make the emitted type names shorter.
- // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
- // would lead to endianness problems.
- let hash: u128 = hasher.finish();
- let hash_short = (hash.to_le() as u64).to_le();
+ let hash_short = tcx.with_stable_hashing_context(|mut hcx| {
+ let mut hasher = StableHasher::new();
+ let ct = ct.eval(tcx, ty::ParamEnv::reveal_all());
+ hcx.while_hashing_spans(false, |hcx| {
+ ct.to_valtree().hash_stable(hcx, &mut hasher)
+ });
+ // Note: Don't use `StableHashResult` impl of `u64` here directly, since that
+ // would lead to endianness problems.
+ let hash: u128 = hasher.finish();
+ (hash.to_le() as u64).to_le()
+ });
if cpp_like_debuginfo(tcx) {
write!(output, "CONST${:x}", hash_short)
(LangItem::PanicBoundsCheck, vec![index, len, location])
}
_ => {
- let msg_str = Symbol::intern(msg.description());
- let msg = bx.const_str(msg_str);
+ let msg = bx.const_str(msg.description());
// It's `pub fn panic(expr: &str)`, with the wide reference being passed
// as two arguments, and `#[track_caller]` adds an implicit third argument.
(LangItem::Panic, vec![msg.0, msg.1, location])
}
})
});
- let msg = bx.const_str(Symbol::intern(&msg_str));
+ let msg = bx.const_str(&msg_str);
let location = self.get_caller_location(bx, source_info).immediate();
// Obtain the panic entry point.
use crate::mir::place::PlaceRef;
use rustc_middle::mir::interpret::{ConstAllocation, Scalar};
use rustc_middle::ty::layout::TyAndLayout;
-use rustc_span::Symbol;
use rustc_target::abi::{self, Size};
pub trait ConstMethods<'tcx>: BackendTypes {
fn const_u8(&self, i: u8) -> Self::Value;
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
- fn const_str(&self, s: Symbol) -> (Self::Value, Self::Value);
+ fn const_str(&self, s: &str) -> (Self::Value, Self::Value);
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
--- /dev/null
+use rustc_hir::ConstContext;
+use rustc_macros::SessionDiagnostic;
+use rustc_span::Span;
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::unstable_in_stable)]
+pub(crate) struct UnstableInStable {
+ pub gate: String,
+ #[primary_span]
+ pub span: Span,
+ #[suggestion(
+ const_eval::unstable_sugg,
+ code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
+ applicability = "has-placeholders"
+ )]
+ #[suggestion(
+ const_eval::bypass_sugg,
+ code = "#[rustc_allow_const_fn_unstable({gate})]\n",
+ applicability = "has-placeholders"
+ )]
+ pub attr_span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::thread_local_access, code = "E0625")]
+pub(crate) struct NonConstOpErr {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::static_access, code = "E0013")]
+#[help]
+pub(crate) struct StaticAccessErr {
+ #[primary_span]
+ pub span: Span,
+ pub kind: ConstContext,
+ #[note(const_eval::teach_note)]
+ #[help(const_eval::teach_help)]
+ pub teach: Option<()>,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::raw_ptr_to_int)]
+#[note]
+#[note(const_eval::note2)]
+pub(crate) struct RawPtrToIntErr {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::raw_ptr_comparison)]
+#[note]
+pub(crate) struct RawPtrComparisonErr {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::panic_non_str)]
+pub(crate) struct PanicNonStrErr {
+ #[primary_span]
+ pub span: Span,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::mut_deref, code = "E0658")]
+pub(crate) struct MutDerefErr {
+ #[primary_span]
+ pub span: Span,
+ pub kind: ConstContext,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::transient_mut_borrow, code = "E0658")]
+pub(crate) struct TransientMutBorrowErr {
+ #[primary_span]
+ pub span: Span,
+ pub kind: ConstContext,
+}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::transient_mut_borrow_raw, code = "E0658")]
+pub(crate) struct TransientMutBorrowErrRaw {
+ #[primary_span]
+ pub span: Span,
+ pub kind: ConstContext,
+}
err_ub!(DanglingIntPointer(0, _)) =>
{ "a null {kind}" },
err_ub!(DanglingIntPointer(i, _)) =>
- { "a dangling {kind} (address 0x{i:x} is unallocated)" },
+ { "a dangling {kind} (address {i:#x} is unallocated)" },
err_ub!(PointerOutOfBounds { .. }) =>
{ "a dangling {kind} (going beyond the bounds of its allocation)" },
// This cannot happen during const-eval (because interning already detects
// element that byte belongs to so we can
// provide an index.
let i = usize::try_from(
- access.uninit_offset.bytes() / layout.size.bytes(),
+ access.uninit.start.bytes() / layout.size.bytes(),
)
.unwrap();
self.path.push(PathElem::ArrayElem(i));
extern crate rustc_middle;
pub mod const_eval;
+mod errors;
pub mod interpret;
pub mod transform;
pub mod util;
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
-use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed};
+use rustc_errors::{Diagnostic, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet;
use super::resolver::FlowSensitiveAnalysis;
use super::{ConstCx, Qualif};
use crate::const_eval::is_unstable_const_fn;
+use crate::errors::UnstableInStable;
type QualifResults<'mir, 'tcx, Q> =
rustc_mir_dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'mir, 'mir, 'tcx, Q>>;
fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol) {
let attr_span = ccx.tcx.def_span(ccx.def_id()).shrink_to_lo();
- ccx.tcx
- .sess
- .struct_span_err(
- span,
- &format!("const-stable function cannot use `#[feature({})]`", gate.as_str()),
- )
- .span_suggestion(
- attr_span,
- "if it is not part of the public API, make this function unstably const",
- concat!(r#"#[rustc_const_unstable(feature = "...", issue = "...")]"#, '\n'),
- Applicability::HasPlaceholders,
- )
- .span_suggestion(
- attr_span,
- "otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks",
- format!("#[rustc_allow_const_fn_unstable({})]\n", gate),
- Applicability::MaybeIncorrect,
- )
- .emit();
+ ccx.tcx.sess.emit_err(UnstableInStable { gate: gate.to_string(), span, attr_span });
}
//! Concrete error types for all operations which may be invalid in a certain const context.
use hir::def_id::LocalDefId;
-use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
+use rustc_errors::{
+ error_code, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
+};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_trait_selection::traits::SelectionContext;
use super::ConstCx;
+use crate::errors::{
+ MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrComparisonErr, RawPtrToIntErr,
+ StaticAccessErr, TransientMutBorrowErr, TransientMutBorrowErrRaw,
+};
use crate::util::{call_kind, CallDesugaringKind, CallKind};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- let raw = match self.0 {
- hir::BorrowKind::Raw => "raw ",
- hir::BorrowKind::Ref => "",
- };
-
- feature_err(
- &ccx.tcx.sess.parse_sess,
- sym::const_mut_refs,
- span,
- &format!("{}mutable references are not allowed in {}s", raw, ccx.const_kind()),
- )
+ let kind = ccx.const_kind();
+ match self.0 {
+ hir::BorrowKind::Raw => ccx
+ .tcx
+ .sess
+ .create_feature_err(TransientMutBorrowErrRaw { span, kind }, sym::const_mut_refs),
+ hir::BorrowKind::Ref => ccx
+ .tcx
+ .sess
+ .create_feature_err(TransientMutBorrowErr { span, kind }, sym::const_mut_refs),
+ }
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- feature_err(
- &ccx.tcx.sess.parse_sess,
- sym::const_mut_refs,
- span,
- &format!("mutation through a reference is not allowed in {}s", ccx.const_kind()),
- )
+ ccx.tcx
+ .sess
+ .create_feature_err(MutDerefErr { span, kind: ccx.const_kind() }, sym::const_mut_refs)
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- ccx.tcx.sess.struct_span_err(
- span,
- "argument to `panic!()` in a const context must have type `&str`",
- )
+ ccx.tcx.sess.create_err(PanicNonStrErr { span })
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- let mut err = ccx
- .tcx
- .sess
- .struct_span_err(span, "pointers cannot be reliably compared during const eval");
- err.note(
- "see issue #53020 <https://github.com/rust-lang/rust/issues/53020> \
- for more information",
- );
- err
+ ccx.tcx.sess.create_err(RawPtrComparisonErr { span })
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- let mut err = ccx
- .tcx
- .sess
- .struct_span_err(span, "pointers cannot be cast to integers during const eval");
- err.note("at compile-time, pointers do not have an integer value");
- err.note(
- "avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior",
- );
- err
+ ccx.tcx.sess.create_err(RawPtrToIntErr { span })
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- let mut err = struct_span_err!(
- ccx.tcx.sess,
+ ccx.tcx.sess.create_err(StaticAccessErr {
span,
- E0013,
- "{}s cannot refer to statics",
- ccx.const_kind()
- );
- err.help(
- "consider extracting the value of the `static` to a `const`, and referring to that",
- );
- if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
- err.note(
- "`static` and `const` variables can refer to other `const` variables. \
- A `const` variable, however, cannot refer to a `static` variable.",
- );
- err.help("To fix this, the value can be extracted to a `const` and then used.");
- }
- err
+ kind: ccx.const_kind(),
+ teach: ccx.tcx.sess.teach(&error_code!(E0013)).then_some(()),
+ })
}
}
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- struct_span_err!(
- ccx.tcx.sess,
- span,
- E0625,
- "thread-local statics cannot be \
- accessed at compile-time"
- )
+ ccx.tcx.sess.create_err(NonConstOpErr { span })
}
}
#![feature(array_windows)]
#![feature(associated_type_bounds)]
#![feature(auto_traits)]
+#![feature(cell_leak)]
#![feature(control_flow_enum)]
#![feature(extend_one)]
#![feature(let_else)]
pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
self.write()
}
+
+ #[cfg(not(parallel_compiler))]
+ #[inline(always)]
+ pub fn clone_guard<'a>(rg: &ReadGuard<'a, T>) -> ReadGuard<'a, T> {
+ ReadGuard::clone(rg)
+ }
+
+ #[cfg(parallel_compiler)]
+ #[inline(always)]
+ pub fn clone_guard<'a>(rg: &ReadGuard<'a, T>) -> ReadGuard<'a, T> {
+ ReadGuard::rwlock(&rg).read()
+ }
+
+ #[cfg(not(parallel_compiler))]
+ #[inline(always)]
+ pub fn leak(&self) -> &T {
+ ReadGuard::leak(self.read())
+ }
+
+ #[cfg(parallel_compiler)]
+ #[inline(always)]
+ pub fn leak(&self) -> &T {
+ let guard = self.read();
+ let ret = unsafe { &*(&*guard as *const T) };
+ std::mem::forget(guard);
+ ret
+ }
}
// FIXME: Probably a bad idea
-builtin_macros-requires-cfg-pattern =
+builtin-macros-requires-cfg-pattern =
macro requires a cfg-pattern as an argument
.label = cfg-pattern required
-builtin_macros-expected-one-cfg-pattern = expected 1 cfg-pattern
+builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern
--- /dev/null
+const-eval-unstable-in-stable =
+ const-stable function cannot use `#[feature({$gate})]`
+ .unstable-sugg = if it is not part of the public API, make this function unstably const
+ .bypass-sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
+
+const-eval-thread-local-access =
+ thread-local statics cannot be accessed at compile-time
+
+const-eval-static-access =
+ {$kind}s cannot refer to statics
+ .help = consider extracting the value of the `static` to a `const`, and referring to that
+ .teach-note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
+ .teach-help = To fix this, the value can be extracted to a `const` and then used.
+
+const-eval-raw-ptr-to-int =
+ pointers cannot be cast to integers during const eval
+ .note = at compile-time, pointers do not have an integer value
+ .note2 = avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior
+
+const-eval-raw-ptr-comparison =
+ pointers cannot be reliably compared during const eval
+ .note = see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
+
+const-eval-panic-non-str = argument to `panic!()` in a const context must have type `&str`
+
+const-eval-mut-deref =
+ mutation through a reference is not allowed in {$kind}s
+
+const-eval-transient-mut-borrow = mutable references are not allowed in {$kind}s
+
+const-eval-transient-mut-borrow-raw = raw mutable references are not allowed in {$kind}s
parser => "../locales/en-US/parser.ftl",
privacy => "../locales/en-US/privacy.ftl",
typeck => "../locales/en-US/typeck.ftl",
+ const_eval => "../locales/en-US/const_eval.ftl",
}
pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};
rustc_span = { path = "../rustc_span" }
rustc_macros = { path = "../rustc_macros" }
rustc_data_structures = { path = "../rustc_data_structures" }
+rustc_hir = { path = "../rustc_hir" }
rustc_lint_defs = { path = "../rustc_lint_defs" }
unicode-width = "0.1.4"
atty = "0.2"
};
use rustc_data_structures::stable_map::FxHashMap;
use rustc_error_messages::FluentValue;
+use rustc_hir as hir;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_span::edition::LATEST_STABLE_EDITION;
use rustc_span::symbol::{Ident, Symbol};
}
}
+impl IntoDiagnosticArg for hir::ConstContext {
+ fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
+ DiagnosticArgValue::Str(Cow::Borrowed(match self {
+ hir::ConstContext::ConstFn => "constant function",
+ hir::ConstContext::Static(_) => "static",
+ hir::ConstContext::Const => "constant",
+ }))
+ }
+}
+
/// Trait implemented by error types. This should not be implemented manually. Instead, use
/// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic].
#[rustc_diagnostic_item = "AddSubdiagnostic"]
bundle: Option<Lrc<FluentBundle>>,
fallback_bundle: LazyFallbackBundle,
teach: bool,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> EmitterWriter {
let (short, color_config) = self.unzip();
short,
teach,
color,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
)
}
short_message: bool,
teach: bool,
ui_testing: bool,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
}
fallback_bundle: LazyFallbackBundle,
short_message: bool,
teach: bool,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> EmitterWriter {
let dst = Destination::from_stderr(color_config);
short_message,
teach,
ui_testing: false,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
}
}
short_message: bool,
teach: bool,
colored: bool,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> EmitterWriter {
EmitterWriter {
short_message,
teach,
ui_testing: false,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
}
}
width_offset + annotated_file.multiline_depth + 1
};
- let column_width = if let Some(width) = self.terminal_width {
+ let column_width = if let Some(width) = self.diagnostic_width {
width.saturating_sub(code_offset)
} else if self.ui_testing {
DEFAULT_COLUMN_WIDTH
pretty: bool,
ui_testing: bool,
json_rendered: HumanReadableErrorType,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
}
fallback_bundle: LazyFallbackBundle,
pretty: bool,
json_rendered: HumanReadableErrorType,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> JsonEmitter {
JsonEmitter {
pretty,
ui_testing: false,
json_rendered,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
}
}
json_rendered: HumanReadableErrorType,
fluent_bundle: Option<Lrc<FluentBundle>>,
fallback_bundle: LazyFallbackBundle,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> JsonEmitter {
let file_path_mapping = FilePathMapping::empty();
fallback_bundle,
pretty,
json_rendered,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
)
}
fallback_bundle: LazyFallbackBundle,
pretty: bool,
json_rendered: HumanReadableErrorType,
- terminal_width: Option<usize>,
+ diagnostic_width: Option<usize>,
macro_backtrace: bool,
) -> JsonEmitter {
JsonEmitter {
pretty,
ui_testing: false,
json_rendered,
- terminal_width,
+ diagnostic_width,
macro_backtrace,
}
}
je.fluent_bundle.clone(),
je.fallback_bundle.clone(),
false,
- je.terminal_width,
+ je.diagnostic_width,
je.macro_backtrace,
)
.ui_testing(je.ui_testing)
doctest = false
[dependencies]
+rustc_arena = { path = "../rustc_arena" }
rustc_target = { path = "../rustc_target" }
rustc_macros = { path = "../rustc_macros" }
rustc_data_structures = { path = "../rustc_data_structures" }
// HIR types
[] hir_krate: rustc_hir::Crate<'tcx>,
[] arm: rustc_hir::Arm<'tcx>,
- [] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, Span),
+ [] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, rustc_span::Span),
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
[] attribute: rustc_ast::Attribute,
[] block: rustc_hir::Block<'tcx>,
}
}
+// NOTE: `IntoDiagnosticArg` impl for `ConstContext` lives in `rustc_errors`
+// due to a cyclical dependency between hir that crate.
+
/// A literal.
pub type Lit = Spanned<LitKind>;
//! - Example: Examine each expression to look for its type and do some check or other.
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
//! `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use
-//! `tcx.hir().deep_visit_all_item_likes(&mut visitor)`. Within your
+//! `tcx.hir().visit_all_item_likes_in_crate(&mut visitor)`. Within your
//! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
//! `intravisit::walk_expr()` to keep walking the subparts).
//! - Pro: Visitor methods for any kind of HIR node, not just item-like things.
/// (this is why the module is called `intravisit`, to distinguish it
/// from the AST's `visit` module, which acts differently). If you
/// simply want to visit all items in the crate in some order, you
-/// should call `Crate::visit_all_items`. Otherwise, see the comment
+/// should call `tcx.hir().visit_all_item_likes_in_crate`. Otherwise, see the comment
/// on `visit_nested_item` for details on how to visit nested items.
///
/// If you want to ensure that your code handles every variant
#[macro_use]
extern crate rustc_data_structures;
+extern crate self as rustc_hir;
+
mod arena;
pub mod def;
pub mod def_path_hash_map;
pub use lang_items::{LangItem, LanguageItems};
pub use stable_hash_impls::HashStableContext;
pub use target::{MethodKind, Target};
+
+arena_types!(rustc_arena::declare_arena);
let mut visitor =
IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] };
visitor.process_attrs(hir::CRATE_HIR_ID);
- tcx.hir().deep_visit_all_item_likes(&mut visitor);
+ tcx.hir().visit_all_item_likes_in_crate(&mut visitor);
(visitor.if_this_changed, visitor.then_this_would_need)
};
//! and use that to decide when one free region outlives another, and so forth.
use rustc_data_structures::transitive_relation::TransitiveRelation;
-use rustc_middle::ty::{self, Lift, Region, TyCtxt};
+use rustc_middle::ty::{Lift, Region, TyCtxt};
/// Combines a `FreeRegionMap` and a `TyCtxt`.
///
// (with the exception that `'static: 'x` is not notable)
pub fn relate_regions(&mut self, sub: Region<'tcx>, sup: Region<'tcx>) {
debug!("relate_regions(sub={:?}, sup={:?})", sub, sup);
- if self.is_free_or_static(sub) && self.is_free(sup) {
+ if sub.is_free_or_static() && sup.is_free() {
self.relation.add(sub, sup)
}
}
r_a: Region<'tcx>,
r_b: Region<'tcx>,
) -> bool {
- assert!(self.is_free_or_static(r_a) && self.is_free_or_static(r_b));
+ assert!(r_a.is_free_or_static() && r_b.is_free_or_static());
let re_static = tcx.lifetimes.re_static;
if self.check_relation(re_static, r_b) {
// `'a <= 'static` is always true, and not stored in the
r_a == r_b || self.relation.contains(r_a, r_b)
}
- /// True for free regions other than `'static`.
- pub fn is_free(&self, r: Region<'_>) -> bool {
- matches!(*r, ty::ReEarlyBound(_) | ty::ReFree(_))
- }
-
- /// True if `r` is a free region or static of the sort that this
- /// free region map can be used with.
- pub fn is_free_or_static(&self, r: Region<'_>) -> bool {
- match *r {
- ty::ReStatic => true,
- _ => self.is_free(r),
- }
- }
-
/// Computes the least-upper-bound of two free regions. In some
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
r_b: Region<'tcx>,
) -> Region<'tcx> {
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
- assert!(self.is_free(r_a));
- assert!(self.is_free(r_b));
+ assert!(r_a.is_free());
+ assert!(r_b.is_free());
let result = if r_a == r_b {
r_a
} else {
#[derive(Clone)]
pub struct LexicalRegionResolutions<'tcx> {
pub(crate) values: IndexVec<RegionVid, VarValue<'tcx>>,
- pub(crate) error_region: ty::Region<'tcx>,
}
#[derive(Copy, Clone, Debug)]
/// empty region. The `expansion` phase will grow this larger.
fn construct_var_data(&self, tcx: TyCtxt<'tcx>) -> LexicalRegionResolutions<'tcx> {
LexicalRegionResolutions {
- error_region: tcx.lifetimes.re_static,
values: IndexVec::from_fn_n(
|vid| {
let vid_universe = self.var_infos[vid].universe;
// Check for the case where we know that `'b: 'static` -- in that case,
// `a <= b` for all `a`.
- let b_free_or_static = self.region_rels.free_regions.is_free_or_static(b);
+ let b_free_or_static = b.is_free_or_static();
if b_free_or_static && sub_free_regions(tcx.lifetimes.re_static, b) {
return true;
}
// `lub` relationship defined below, since sometimes the "lub"
// is actually the `postdom_upper_bound` (see
// `TransitiveRelation` for more details).
- let a_free_or_static = self.region_rels.free_regions.is_free_or_static(a);
+ let a_free_or_static = a.is_free_or_static();
if a_free_or_static && b_free_or_static {
return sub_free_regions(a, b);
}
where
T: TypeFoldable<'tcx>,
{
- tcx.fold_regions(value, |r, _db| match *r {
- ty::ReVar(rid) => self.resolve_var(rid),
- _ => r,
- })
+ tcx.fold_regions(value, |r, _db| self.resolve_region(tcx, r))
}
fn value(&self, rid: RegionVid) -> &VarValue<'tcx> {
&mut self.values[rid]
}
- pub fn resolve_var(&self, rid: RegionVid) -> ty::Region<'tcx> {
- let result = match self.values[rid] {
- VarValue::Value(r) => r,
- VarValue::ErrorValue => self.error_region,
+ pub(crate) fn resolve_region(
+ &self,
+ tcx: TyCtxt<'tcx>,
+ r: ty::Region<'tcx>,
+ ) -> ty::Region<'tcx> {
+ let result = match *r {
+ ty::ReVar(rid) => match self.values[rid] {
+ VarValue::Value(r) => r,
+ VarValue::ErrorValue => tcx.lifetimes.re_static,
+ },
+ _ => r,
};
- debug!("resolve_var({:?}) = {:?}", rid, result);
+ debug!("resolve_region({:?}) = {:?}", r, result);
result
}
}
/// from a `for<'a> T` binder). Meant to represent "any region".
Placeholder(ty::PlaceholderRegion),
- /// The variable we create to represent `'empty(U0)`.
- RootEmptyRegion,
-
Existential {
/// If this is true, then this variable was created to represent a lifetime
/// bound in a `for` binder. For example, it might have been created to
.region_constraints_added_in_snapshot(&snapshot.undo_snapshot)
}
+ pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'a, 'tcx>) -> bool {
+ self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot)
+ }
+
pub fn add_given(&self, sub: ty::Region<'tcx>, sup: ty::RegionVid) {
self.inner.borrow_mut().unwrap_region_constraints().add_given(sub, sup);
}
};
let lexical_region_resolutions = LexicalRegionResolutions {
- error_region: self.tcx.lifetimes.re_static,
values: rustc_index::vec::IndexVec::from_elem_n(
crate::infer::lexical_region_resolve::VarValue::Value(self.tcx.lifetimes.re_erased),
var_infos.len(),
}
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
- ty::Opaque(def_id, substs) => {
+ ty::Opaque(def_id, substs) if def_id.is_local() => {
let origin = if self.defining_use_anchor.is_some() {
// Check that this is `impl Trait` type is
// declared by `parent_def_id` -- i.e., one whose
fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
match *r {
- ty::ReVar(rid) => Ok(self
+ ty::ReVar(_) => Ok(self
.infcx
.lexical_region_resolutions
.borrow()
.as_ref()
.expect("region resolution not performed")
- .resolve_var(rid)),
+ .resolve_region(self.infcx.tcx, r)),
_ => Ok(r),
}
}
})
}
+ pub(crate) fn opaque_types_in_snapshot(&self, s: &Snapshot<'tcx>) -> bool {
+ self.logs[s.undo_len..].iter().any(|log| matches!(log, UndoLog::OpaqueTypes(..)))
+ }
+
pub(crate) fn region_constraints(
&self,
) -> impl Iterator<Item = &'_ region_constraints::UndoLog<'tcx>> + Clone {
Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => {
info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
let mut ty = ty.clone();
- if result == EvaluationResult::EvaluatedToOk {
+ if result.must_apply_considering_regions() {
ty.obligations = vec![];
}
map.insert(key, ProjectionCacheEntry::NormalizedTy { ty, complete: Some(result) });
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_hir::definitions::Definitions;
-use rustc_hir::Crate;
use rustc_lint::{EarlyCheckNode, LintStore};
use rustc_metadata::creader::CStore;
use rustc_metadata::{encode_metadata, EncodedMetadata};
Ok(krate)
}
-fn lower_to_hir<'tcx>(
- sess: &Session,
- definitions: &mut Definitions,
- cstore: &CrateStoreDyn,
- resolutions: &ty::ResolverOutputs,
- resolver: ty::ResolverAstLowering,
- krate: Rc<ast::Crate>,
- arena: &'tcx rustc_ast_lowering::Arena<'tcx>,
-) -> &'tcx Crate<'tcx> {
- // Lower AST to HIR.
- let hir_crate = rustc_ast_lowering::lower_crate(
- sess,
- &krate,
- definitions,
- cstore,
- resolutions,
- resolver,
- arena,
- );
-
- // Drop AST to free memory
- sess.time("drop_ast", || std::mem::drop(krate));
-
- // Discard hygiene data, which isn't required after lowering to HIR.
- if !sess.opts.debugging_opts.keep_hygiene_data {
- rustc_span::hygiene::clear_syntax_context_map();
- }
-
- hir_crate
-}
-
// Returns all the paths that correspond to generated files.
fn generated_output_paths(
sess: &Session,
pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
let providers = &mut Providers::default();
providers.analysis = analysis;
+ providers.hir_crate = rustc_ast_lowering::lower_to_hir;
proc_macro_decls::provide(providers);
rustc_const_eval::provide(providers);
rustc_middle::hir::provide(providers);
pub fn create_global_ctxt<'tcx>(
compiler: &'tcx Compiler,
lint_store: Lrc<LintStore>,
- krate: Rc<ast::Crate>,
+ krate: Lrc<ast::Crate>,
dep_graph: DepGraph,
resolver: Rc<RefCell<BoxedResolver>>,
outputs: OutputFilenames,
queries: &'tcx OnceCell<TcxQueries<'tcx>>,
global_ctxt: &'tcx OnceCell<GlobalCtxt<'tcx>>,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
- hir_arena: &'tcx WorkerLocal<rustc_ast_lowering::Arena<'tcx>>,
+ hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>,
) -> QueryContext<'tcx> {
// We're constructing the HIR here; we don't care what we will
// read, since we haven't even constructed the *input* to
// incr. comp. yet.
dep_graph.assert_ignored();
- let (mut definitions, cstore, resolver_outputs, resolver_for_lowering) =
+ let (definitions, cstore, resolver_outputs, resolver_for_lowering) =
BoxedResolver::to_resolver_outputs(resolver);
let sess = &compiler.session();
-
- // Lower AST to HIR.
- let krate = lower_to_hir(
- sess,
- &mut definitions,
- &*cstore,
- &resolver_outputs,
- resolver_for_lowering,
- krate,
- hir_arena,
- );
-
let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);
let codegen_backend = compiler.codegen_backend();
sess,
lint_store,
arena,
+ hir_arena,
definitions,
cstore,
resolver_outputs,
+ resolver_for_lowering,
krate,
dep_graph,
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
queries: OnceCell<TcxQueries<'tcx>>,
arena: WorkerLocal<Arena<'tcx>>,
- hir_arena: WorkerLocal<rustc_ast_lowering::Arena<'tcx>>,
+ hir_arena: WorkerLocal<rustc_hir::Arena<'tcx>>,
dep_graph_future: Query<Option<DepGraphFuture>>,
parse: Query<ast::Crate>,
crate_name: Query<String>,
register_plugins: Query<(ast::Crate, Lrc<LintStore>)>,
- expansion: Query<(Rc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
+ expansion: Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>,
dep_graph: Query<DepGraph>,
prepare_outputs: Query<OutputFilenames>,
global_ctxt: Query<QueryContext<'tcx>>,
gcx: OnceCell::new(),
queries: OnceCell::new(),
arena: WorkerLocal::new(|_| Arena::default()),
- hir_arena: WorkerLocal::new(|_| rustc_ast_lowering::Arena::default()),
+ hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()),
dep_graph_future: Default::default(),
parse: Default::default(),
crate_name: Default::default(),
pub fn expansion(
&self,
- ) -> Result<&Query<(Rc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>> {
+ ) -> Result<&Query<(Lrc<ast::Crate>, Rc<RefCell<BoxedResolver>>, Lrc<LintStore>)>> {
tracing::trace!("expansion");
self.expansion.compute(|| {
let crate_name = self.crate_name()?.peek().clone();
let krate = resolver.access(|resolver| {
passes::configure_and_expand(sess, &lint_store, krate, &crate_name, resolver)
})?;
- Ok((Rc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
+ Ok((Lrc::new(krate), Rc::new(RefCell::new(resolver)), lint_store))
})
}
untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
untracked!(dont_buffer_diagnostics, true);
untracked!(dump_dep_graph, true);
+ untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string()));
untracked!(dump_mir, Some(String::from("abc")));
untracked!(dump_mir_dataflow, true);
untracked!(dump_mir_dir, String::from("abc"));
untracked!(span_debug, true);
untracked!(span_free_formats, true);
untracked!(temps_dir, Some(String::from("abc")));
- untracked!(terminal_width, Some(80));
untracked!(threads, 99);
untracked!(time, true);
untracked!(time_llvm_passes, true);
/// Extract the `LintStore` from the query context.
/// This function exists because we've erased `LintStore` as `dyn Any` in the context.
-pub(crate) fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
+pub fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
let store: &dyn Any = &*tcx.lint_store;
store.downcast_ref().unwrap()
}
pub use context::{CheckLintNameResult, FindLintError, LintStore};
pub use context::{EarlyContext, LateContext, LintContext};
pub use early::{check_ast_node, EarlyCheckNode};
-pub use late::check_crate;
+pub use late::{check_crate, unerased_lint_store};
pub use passes::{EarlyLintPass, LateLintPass};
pub use rustc_session::lint::Level::{self, *};
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry {
let _ = previous_defns.entry(name.to_string()).or_insert(ident_span);
- // `typeck-foo-bar` => `foo_bar`
+ // `typeck-foo-bar` => `foo_bar` (in `typeck.ftl`)
+ // `const-eval-baz` => `baz` (in `const_eval.ftl`)
let snake_name = Ident::new(
- &name.replace(&format!("{}-", res.ident), "").replace("-", "_"),
+ // FIXME: should probably trim prefix, not replace all occurrences
+ &name
+ .replace(&format!("{}-", res.ident).replace("_", "-"), "")
+ .replace("-", "_"),
span,
);
constants.extend(quote! {
return;
}
- self.tcx.hir().deep_visit_all_item_likes(self);
+ self.tcx.hir().visit_all_item_likes_in_crate(self);
}
fn encode_def_path_table(&mut self) {
- let table = self.tcx.definitions_untracked().def_path_table();
+ let table = self.tcx.def_path_table();
if self.is_proc_macro {
for def_index in std::iter::once(CRATE_DEF_INDEX)
.chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index))
}
fn encode_def_path_hash_map(&mut self) -> LazyValue<DefPathHashMapRef<'static>> {
- self.lazy(DefPathHashMapRef::BorrowedFromTcx(
- self.tcx.definitions_untracked().def_path_hash_to_def_index_map(),
- ))
+ self.lazy(DefPathHashMapRef::BorrowedFromTcx(self.tcx.def_path_hash_to_def_index_map()))
}
fn encode_source_map(&mut self) -> LazyArray<rustc_span::SourceFile> {
let interpret_alloc_index_bytes = self.position() - i;
// Encode the proc macro data. This affects 'tables',
- // so we need to do this before we encode the tables
+ // so we need to do this before we encode the tables.
+ // This overwrites def_keys, so it must happen after encode_def_path_table.
i = self.position();
let proc_macro_data = self.encode_proc_macros();
let proc_macro_data_bytes = self.position() - i;
return;
}
let tcx = self.tcx;
- let hir = tcx.hir();
- for local_id in hir.iter_local_def_id() {
+ for local_id in tcx.iter_local_def_id() {
let def_id = local_id.to_def_id();
let def_kind = tcx.opt_def_kind(local_id);
let Some(def_kind) = def_kind else { continue };
debug!("EncodeContext::encode_traits_and_impls()");
empty_proc_macro!(self);
let tcx = self.tcx;
- let mut ctx = tcx.create_stable_hashing_context();
let mut all_impls: Vec<_> = tcx.crate_inherent_impls(()).incoherent_impls.iter().collect();
- all_impls.sort_by_cached_key(|&(&simp, _)| {
- let mut hasher = StableHasher::new();
- simp.hash_stable(&mut ctx, &mut hasher);
- hasher.finish::<Fingerprint>();
+ tcx.with_stable_hashing_context(|mut ctx| {
+ all_impls.sort_by_cached_key(|&(&simp, _)| {
+ let mut hasher = StableHasher::new();
+ simp.hash_stable(&mut ctx, &mut hasher);
+ hasher.finish::<Fingerprint>()
+ })
});
let all_impls: Vec<_> = all_impls
.into_iter()
// We use this for most things when incr. comp. is turned off.
[] Null,
+ // We use this to create a forever-red node.
+ [] Red,
+
[anon] TraitSelect,
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
impl rustc_query_system::dep_graph::DepKind for DepKind {
const NULL: Self = DepKind::Null;
+ const RED: Self = DepKind::Red;
fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}(", node.kind)?;
type DepKind = DepKind;
#[inline]
- fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
- TyCtxt::create_stable_hashing_context(*self)
+ fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
+ TyCtxt::with_stable_hashing_context(*self, f)
}
#[inline]
self.tcx.local_def_id_to_hir_id(def_id)
}
- pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'hir {
- // Create a dependency to the crate to be sure we re-execute this when the amount of
- // definitions change.
- self.tcx.ensure().hir_crate(());
- self.tcx.definitions_untracked().iter_local_def_id()
- }
-
/// Do not call this function directly. The query should be called.
pub(super) fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
let hir_id = self.local_def_id_to_hir_id(local_def_id);
}
}
- /// Walks the contents of a crate. See also `Crate::visit_all_items`.
+ /// Walks the contents of the local crate. See also `visit_all_item_likes_in_crate`.
pub fn walk_toplevel_module(self, visitor: &mut impl Visitor<'hir>) {
let (top_mod, span, hir_id) = self.get_module(CRATE_DEF_ID);
visitor.visit_mod(top_mod, span, hir_id);
}
}
- /// Visits all items in the crate in some deterministic (but
- /// unspecified) order. If you need to process every item,
- /// and care about nesting -- usually because your algorithm
- /// follows lexical scoping rules -- then this method is the best choice.
- /// If you don't care about nesting, you should use the `tcx.hir_crate_items()` query
- /// or `items()` instead.
+ /// Visits all item-likes in the crate in some deterministic (but unspecified) order. If you
+ /// need to process every item-like, and don't care about visiting nested items in a particular
+ /// order then this method is the best choice. If you do care about this nesting, you should
+ /// use the `tcx.hir().walk_toplevel_module`.
+ ///
+ /// Note that this function will access HIR for all the item-likes in the crate. If you only
+ /// need to access some of them, it is usually better to manually loop on the iterators
+ /// provided by `tcx.hir_crate_items(())`.
///
/// Please see the notes in `intravisit.rs` for more information.
- pub fn deep_visit_all_item_likes<V>(self, visitor: &mut V)
+ pub fn visit_all_item_likes_in_crate<V>(self, visitor: &mut V)
where
V: Visitor<'hir>,
{
- let krate = self.krate();
- for owner in krate.owners.iter().filter_map(|i| i.as_owner()) {
- match owner.node() {
- OwnerNode::Item(item) => visitor.visit_item(item),
- OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
- OwnerNode::ImplItem(item) => visitor.visit_impl_item(item),
- OwnerNode::TraitItem(item) => visitor.visit_trait_item(item),
- OwnerNode::Crate(_) => {}
- }
+ let krate = self.tcx.hir_crate_items(());
+
+ for id in krate.items() {
+ visitor.visit_item(self.item(id));
+ }
+
+ for id in krate.trait_items() {
+ visitor.visit_trait_item(self.trait_item(id));
+ }
+
+ for id in krate.impl_items() {
+ visitor.visit_impl_item(self.impl_item(id));
+ }
+
+ for id in krate.foreign_items() {
+ visitor.visit_foreign_item(self.foreign_item(id));
}
}
- /// If you don't care about nesting, you should use the
- /// `tcx.hir_module_items()` query or `module_items()` instead.
- /// Please see notes in `deep_visit_all_item_likes`.
- pub fn deep_visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
+ /// This method is the equivalent of `visit_all_item_likes_in_crate` but restricted to
+ /// item-likes in a single module.
+ pub fn visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
where
V: Visitor<'hir>,
{
let module = self.tcx.hir_module_items(module);
- for id in module.items.iter() {
- visitor.visit_item(self.item(*id));
+ for id in module.items() {
+ visitor.visit_item(self.item(id));
}
- for id in module.trait_items.iter() {
- visitor.visit_trait_item(self.trait_item(*id));
+ for id in module.trait_items() {
+ visitor.visit_trait_item(self.trait_item(id));
}
- for id in module.impl_items.iter() {
- visitor.visit_impl_item(self.impl_item(*id));
+ for id in module.impl_items() {
+ visitor.visit_impl_item(self.impl_item(id));
}
- for id in module.foreign_items.iter() {
- visitor.visit_foreign_item(self.foreign_item(*id));
+ for id in module.foreign_items() {
+ visitor.visit_foreign_item(self.foreign_item(id));
}
}
_ => named_span(item.span, item.ident, None),
},
Node::Ctor(_) => return self.opt_span(self.get_parent_node(hir_id)),
+ Node::Expr(Expr { kind: ExprKind::Closure { fn_decl_span, .. }, .. }) => *fn_decl_span,
_ => self.span_with_body(hir_id),
};
Some(span)
source_file_names.sort_unstable();
- let mut hcx = tcx.create_stable_hashing_context();
- let mut stable_hasher = StableHasher::new();
- hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher);
- upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
- source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
- if tcx.sess.opts.debugging_opts.incremental_relative_spans {
- let definitions = &tcx.definitions_untracked();
- let mut owner_spans: Vec<_> = krate
- .owners
- .iter_enumerated()
- .filter_map(|(def_id, info)| {
- let _ = info.as_owner()?;
- let def_path_hash = definitions.def_path_hash(def_id);
- let span = resolutions.source_span[def_id];
- debug_assert_eq!(span.parent(), None);
- Some((def_path_hash, span))
- })
- .collect();
- owner_spans.sort_unstable_by_key(|bn| bn.0);
- owner_spans.hash_stable(&mut hcx, &mut stable_hasher);
- }
- tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
- tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher);
- // Hash visibility information since it does not appear in HIR.
- resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher);
- resolutions.has_pub_restricted.hash_stable(&mut hcx, &mut stable_hasher);
+ let crate_hash: Fingerprint = tcx.with_stable_hashing_context(|mut hcx| {
+ let mut stable_hasher = StableHasher::new();
+ hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher);
+ upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
+ source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
+ if tcx.sess.opts.debugging_opts.incremental_relative_spans {
+ let definitions = tcx.definitions_untracked();
+ let mut owner_spans: Vec<_> = krate
+ .owners
+ .iter_enumerated()
+ .filter_map(|(def_id, info)| {
+ let _ = info.as_owner()?;
+ let def_path_hash = definitions.def_path_hash(def_id);
+ let span = resolutions.source_span[def_id];
+ debug_assert_eq!(span.parent(), None);
+ Some((def_path_hash, span))
+ })
+ .collect();
+ owner_spans.sort_unstable_by_key(|bn| bn.0);
+ owner_spans.hash_stable(&mut hcx, &mut stable_hasher);
+ }
+ tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
+ tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher);
+ // Hash visibility information since it does not appear in HIR.
+ resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher);
+ resolutions.has_pub_restricted.hash_stable(&mut hcx, &mut stable_hasher);
+ stable_hasher.finish()
+ });
- let crate_hash: Fingerprint = stable_hasher.finish();
Svh::new(crate_hash.to_smaller_hash())
}
let hir = tcx.hir();
hir.get_module_parent_node(hir.local_def_id_to_hir_id(id))
};
- providers.hir_crate = |tcx, ()| tcx.untracked_crate;
providers.hir_crate_items = map::hir_crate_items;
providers.crate_hash = map::crate_hash;
providers.hir_module_items = map::hir_module_items;
/// constant arguments of types, e.g. in `let _: [(); /* HERE */];`.
///
/// **This is the most common choice.** A very common pattern is
-/// to use `deep_visit_all_item_likes()` as an outer loop,
+/// to use `visit_all_item_likes_in_crate()` as an outer loop,
/// and to have the visitor that visits the contents of each item
/// using this setting.
pub struct OnlyBodies(());
}
impl AllocRange {
+ #[inline]
+ pub fn from(r: Range<Size>) -> Self {
+ alloc_range(r.start, r.end - r.start) // `Size` subtraction (overflow-checked)
+ }
+
#[inline(always)]
pub fn end(self) -> Size {
self.start + self.size // This does overflow checking.
/// Returns `Ok(())` if it's initialized. Otherwise returns a range of byte
/// indexes for the first contiguous span of the uninitialized access.
#[inline]
- pub fn is_range_initialized(&self, start: Size, end: Size) -> Result<(), Range<Size>> {
+ pub fn is_range_initialized(&self, start: Size, end: Size) -> Result<(), AllocRange> {
if end > self.len {
- return Err(self.len..end);
+ return Err(AllocRange::from(self.len..end));
}
let uninit_start = self.find_bit(start, end, false);
match uninit_start {
Some(uninit_start) => {
let uninit_end = self.find_bit(uninit_start, end, true).unwrap_or(end);
- Err(uninit_start..uninit_end)
+ Err(AllocRange::from(uninit_start..uninit_end))
}
None => Ok(()),
}
///
/// Returns `Ok(())` if it's initialized. Otherwise returns the range of byte
/// indexes of the first contiguous uninitialized access.
- fn is_init(&self, range: AllocRange) -> Result<(), Range<Size>> {
+ fn is_init(&self, range: AllocRange) -> Result<(), AllocRange> {
self.init_mask.is_range_initialized(range.start, range.end()) // `Size` addition
}
/// Checks that a range of bytes is initialized. If not, returns the `InvalidUninitBytes`
/// error which will report the first range of bytes which is uninitialized.
fn check_init(&self, range: AllocRange) -> AllocResult {
- self.is_init(range).map_err(|idx_range| {
+ self.is_init(range).map_err(|uninit_range| {
AllocError::InvalidUninitBytes(Some(UninitBytesAccess {
- access_offset: range.start,
- access_size: range.size,
- uninit_offset: idx_range.start,
- uninit_size: idx_range.end - idx_range.start, // `Size` subtraction
+ access: range,
+ uninit: uninit_range,
}))
})
}
-use super::{AllocId, ConstAlloc, Pointer, Scalar};
+use super::{AllocId, AllocRange, ConstAlloc, Pointer, Scalar};
use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty, ValTree};
AlreadyReported(ErrorGuaranteed { .. }) => {
write!(f, "encountered constants with type errors, stopping evaluation")
}
- Layout(ref err) => write!(f, "{}", err),
- FnAbiAdjustForForeignAbi(ref err) => write!(f, "{}", err),
- SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{}`", ty),
+ Layout(ref err) => write!(f, "{err}"),
+ FnAbiAdjustForForeignAbi(ref err) => write!(f, "{err}"),
+ SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{ty}`"),
}
}
}
/// Details of an access to uninitialized bytes where it is not allowed.
#[derive(Debug)]
pub struct UninitBytesAccess {
- /// Location of the original memory access.
- pub access_offset: Size,
- /// Size of the original memory access.
- pub access_size: Size,
- /// Location of the first uninitialized byte that was accessed.
- pub uninit_offset: Size,
- /// Number of consecutive uninitialized bytes that were accessed.
- pub uninit_size: Size,
+ /// Range of the original memory access.
+ pub access: AllocRange,
+ /// Range of the uninit memory that was encountered. (Might not be maximal.)
+ pub uninit: AllocRange,
}
/// Information about a size mismatch.
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use UndefinedBehaviorInfo::*;
match self {
- Ub(msg) => write!(f, "{}", msg),
+ Ub(msg) => write!(f, "{msg}"),
Unreachable => write!(f, "entering unreachable code"),
BoundsCheckFailed { ref len, ref index } => {
- write!(f, "indexing out of bounds: the len is {} but the index is {}", len, index)
+ write!(f, "indexing out of bounds: the len is {len} but the index is {index}")
}
DivisionByZero => write!(f, "dividing by zero"),
RemainderByZero => write!(f, "calculating the remainder with a divisor of zero"),
DivisionOverflow => write!(f, "overflow in signed division (dividing MIN by -1)"),
RemainderOverflow => write!(f, "overflow in signed remainder (dividing MIN by -1)"),
PointerArithOverflow => write!(f, "overflowing in-bounds pointer arithmetic"),
- InvalidMeta(msg) => write!(f, "invalid metadata in wide pointer: {}", msg),
+ InvalidMeta(msg) => write!(f, "invalid metadata in wide pointer: {msg}"),
InvalidVtableDropFn(sig) => write!(
f,
- "invalid drop function signature: got {}, expected exactly one argument which must be a pointer type",
- sig
+ "invalid drop function signature: got {sig}, expected exactly one argument which must be a pointer type",
),
InvalidVtableSize => {
write!(f, "invalid vtable: size is bigger than largest supported object")
}
- InvalidVtableAlignment(msg) => write!(f, "invalid vtable: alignment {}", msg),
+ InvalidVtableAlignment(msg) => write!(f, "invalid vtable: alignment {msg}"),
UnterminatedCString(p) => write!(
f,
- "reading a null-terminated string starting at {:?} with no null found before end of allocation",
- p,
+ "reading a null-terminated string starting at {p:?} with no null found before end of allocation",
),
PointerUseAfterFree(a) => {
write!(f, "pointer to {a:?} was dereferenced after this allocation got freed")
}
AlignmentCheckFailed { required, has } => write!(
f,
- "accessing memory with alignment {}, but alignment {} is required",
- has.bytes(),
- required.bytes()
+ "accessing memory with alignment {has}, but alignment {required} is required",
+ has = has.bytes(),
+ required = required.bytes()
),
WriteToReadOnly(a) => write!(f, "writing to {a:?} which is read-only"),
DerefFunctionPointer(a) => write!(f, "accessing {a:?} which contains a function"),
ValidationFailure { path: None, msg } => {
- write!(f, "constructing invalid value: {}", msg)
+ write!(f, "constructing invalid value: {msg}")
}
ValidationFailure { path: Some(path), msg } => {
- write!(f, "constructing invalid value at {}: {}", path, msg)
+ write!(f, "constructing invalid value at {path}: {msg}")
}
InvalidBool(b) => {
- write!(f, "interpreting an invalid 8-bit value as a bool: 0x{:02x}", b)
+ write!(f, "interpreting an invalid 8-bit value as a bool: 0x{b:02x}")
}
InvalidChar(c) => {
- write!(f, "interpreting an invalid 32-bit value as a char: 0x{:08x}", c)
+ write!(f, "interpreting an invalid 32-bit value as a char: 0x{c:08x}")
}
- InvalidTag(val) => write!(f, "enum value has invalid tag: {:x}", val),
+ InvalidTag(val) => write!(f, "enum value has invalid tag: {val:x}"),
InvalidFunctionPointer(p) => {
- write!(f, "using {:?} as function pointer but it does not point to a function", p)
+ write!(f, "using {p:?} as function pointer but it does not point to a function")
}
- InvalidStr(err) => write!(f, "this string is not valid UTF-8: {}", err),
- InvalidUninitBytes(Some((alloc, access))) => write!(
+ InvalidStr(err) => write!(f, "this string is not valid UTF-8: {err}"),
+ InvalidUninitBytes(Some((alloc, info))) => write!(
f,
- "reading {} byte{} of memory starting at {:?}, \
- but {} byte{} {} uninitialized starting at {:?}, \
+ "reading memory at {alloc:?}{access:?}, \
+ but memory is uninitialized at {uninit:?}, \
and this operation requires initialized memory",
- access.access_size.bytes(),
- pluralize!(access.access_size.bytes()),
- Pointer::new(*alloc, access.access_offset),
- access.uninit_size.bytes(),
- pluralize!(access.uninit_size.bytes()),
- pluralize!("is", access.uninit_size.bytes()),
- Pointer::new(*alloc, access.uninit_offset),
+ access = info.access,
+ uninit = info.uninit,
),
InvalidUninitBytes(None) => write!(
f,
DeadLocal => write!(f, "accessing a dead local variable"),
ScalarSizeMismatch(self::ScalarSizeMismatch { target_size, data_size }) => write!(
f,
- "scalar size mismatch: expected {} bytes but got {} bytes instead",
- target_size, data_size
+ "scalar size mismatch: expected {target_size} bytes but got {data_size} bytes instead",
),
UninhabitedEnumVariantWritten => {
write!(f, "writing discriminant of an uninhabited enum")
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use UnsupportedOpInfo::*;
match self {
- Unsupported(ref msg) => write!(f, "{}", msg),
+ Unsupported(ref msg) => write!(f, "{msg}"),
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes"),
PartialPointerOverwrite(ptr) => {
- write!(f, "unable to overwrite parts of a pointer in memory at {:?}", ptr)
+ write!(f, "unable to overwrite parts of a pointer in memory at {ptr:?}")
}
- ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
- ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
+ ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({did:?})"),
+ ReadExternStatic(did) => write!(f, "cannot read from extern static ({did:?})"),
}
}
}
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use InterpError::*;
match *self {
- Unsupported(ref msg) => write!(f, "{}", msg),
- InvalidProgram(ref msg) => write!(f, "{}", msg),
- UndefinedBehavior(ref msg) => write!(f, "{}", msg),
- ResourceExhaustion(ref msg) => write!(f, "{}", msg),
- MachineStop(ref msg) => write!(f, "{}", msg),
+ Unsupported(ref msg) => write!(f, "{msg}"),
+ InvalidProgram(ref msg) => write!(f, "{msg}"),
+ UndefinedBehavior(ref msg) => write!(f, "{msg}"),
+ ResourceExhaustion(ref msg) => write!(f, "{msg}"),
+ MachineStop(ref msg) => write!(f, "{msg}"),
}
}
}
///////////////////////////////////////////////////////////////////////////
// BasicBlockData
+/// Data for a basic block, including a list of its statements.
+///
/// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct BasicBlockData<'tcx> {
/// Accessor for terminator.
///
/// Terminator may not be None after construction of the basic block is complete. This accessor
- /// provides a convenience way to reach the terminator.
+ /// provides a convenient way to reach the terminator.
#[inline]
pub fn terminator(&self) -> &Terminator<'tcx> {
self.terminator.as_ref().expect("invalid terminator state")
///////////////////////////////////////////////////////////////////////////
// Statements
+/// A statement in a basic block, including information about its source code.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
pub struct Statement<'tcx> {
pub source_info: SourceInfo,
desc { "get the resolver outputs" }
}
+ query resolver_for_lowering(_: ()) -> &'tcx Steal<ty::ResolverAstLowering> {
+ eval_always
+ no_hash
+ desc { "get the resolver for lowering" }
+ }
+
/// Return the span for a definition.
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
/// This is because the `hir_crate` query gives you access to all other items.
/// To avoid this fate, do not call `tcx.hir().krate()`; instead,
/// prefer wrappers like `tcx.visit_all_items_in_krate()`.
- query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
+ query hir_crate(key: ()) -> Crate<'tcx> {
+ storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "get the crate HIR" }
}
ErrorReporting,
/// Multiple applicable `impl`s where found. The `DefId`s correspond to
/// all the `impl`s' Items.
- Ambiguous(Vec<DefId>),
+ Ambiguous(Vec<AmbiguousSelection>),
}
+#[derive(Copy, Clone, Debug)]
+pub enum AmbiguousSelection {
+ Impl(DefId),
+ ParamEnv(Span),
+}
+
+TrivialTypeTraversalAndLiftImpls! { AmbiguousSelection, }
+
/// When performing resolution, it is typically the case that there
/// can be one of three outcomes:
///
EvaluatedToOk,
/// Evaluation successful, but there were unevaluated region obligations.
EvaluatedToOkModuloRegions,
+ /// Evaluation successful, but need to rerun because opaque types got
+ /// hidden types assigned without it being known whether the opaque types
+ /// are within their defining scope
+ EvaluatedToOkModuloOpaqueTypes,
/// Evaluation is known to be ambiguous -- it *might* hold for some
/// assignment of inference variables, but it might not.
///
pub fn may_apply(self) -> bool {
match self {
- EvaluatedToOk | EvaluatedToOkModuloRegions | EvaluatedToAmbig | EvaluatedToUnknown => {
- true
- }
+ EvaluatedToOkModuloOpaqueTypes
+ | EvaluatedToOk
+ | EvaluatedToOkModuloRegions
+ | EvaluatedToAmbig
+ | EvaluatedToUnknown => true,
EvaluatedToErr | EvaluatedToRecur => false,
}
match self {
EvaluatedToUnknown | EvaluatedToRecur => true,
- EvaluatedToOk | EvaluatedToOkModuloRegions | EvaluatedToAmbig | EvaluatedToErr => false,
+ EvaluatedToOkModuloOpaqueTypes
+ | EvaluatedToOk
+ | EvaluatedToOkModuloRegions
+ | EvaluatedToAmbig
+ | EvaluatedToErr => false,
}
}
}
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal;
-use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
+use rustc_data_structures::sync::{self, Lock, Lrc, ReadGuard, RwLock, WorkerLocal};
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::{DecorateLint, ErrorGuaranteed, LintDiagnosticBuilder, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
+use rustc_hir::definitions::Definitions;
use rustc_hir::intravisit::Visitor;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{
pub struct GlobalCtxt<'tcx> {
pub arena: &'tcx WorkerLocal<Arena<'tcx>>,
+ pub hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
interners: CtxtInterners<'tcx>,
/// Common consts, pre-interned for your convenience.
pub consts: CommonConsts<'tcx>,
- definitions: rustc_hir::definitions::Definitions,
+ definitions: RwLock<Definitions>,
cstore: Box<CrateStoreDyn>,
/// Output of the resolver.
pub(crate) untracked_resolutions: ty::ResolverOutputs,
-
- pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>,
+ untracked_resolver_for_lowering: Steal<ty::ResolverAstLowering>,
+ /// The entire crate as AST. This field serves as the input for the hir_crate query,
+ /// which lowers it from AST to HIR. It must not be read or used by anything else.
+ pub untracked_crate: Steal<Lrc<ast::Crate>>,
/// This provides access to the incremental compilation on-disk cache for query results.
/// Do not access this directly. It is only meant to be used by
s: &'tcx Session,
lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
- definitions: rustc_hir::definitions::Definitions,
+ hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
+ definitions: Definitions,
cstore: Box<CrateStoreDyn>,
untracked_resolutions: ty::ResolverOutputs,
- krate: &'tcx hir::Crate<'tcx>,
+ untracked_resolver_for_lowering: ty::ResolverAstLowering,
+ krate: Lrc<ast::Crate>,
dep_graph: DepGraph,
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
queries: &'tcx dyn query::QueryEngine<'tcx>,
sess: s,
lint_store,
arena,
+ hir_arena,
interners,
dep_graph,
- definitions,
+ definitions: RwLock::new(definitions),
cstore,
- untracked_resolutions,
prof: s.prof.clone(),
types: common_types,
lifetimes: common_lifetimes,
consts: common_consts,
- untracked_crate: krate,
+ untracked_resolutions,
+ untracked_resolver_for_lowering: Steal::new(untracked_resolver_for_lowering),
+ untracked_crate: Steal::new(krate),
on_disk_cache,
queries,
query_caches: query::QueryCaches::default(),
pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
// Accessing the DefKey is ok, since it is part of DefPathHash.
if let Some(id) = id.as_local() {
- self.definitions.def_key(id)
+ self.definitions_untracked().def_key(id)
} else {
self.cstore.def_key(id)
}
pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath {
// Accessing the DefPath is ok, since it is part of DefPathHash.
if let Some(id) = id.as_local() {
- self.definitions.def_path(id)
+ self.definitions_untracked().def_path(id)
} else {
self.cstore.def_path(id)
}
pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
// Accessing the DefPathHash is ok, it is incr. comp. stable.
if let Some(def_id) = def_id.as_local() {
- self.definitions.def_path_hash(def_id)
+ self.definitions_untracked().def_path_hash(def_id)
} else {
self.cstore.def_path_hash(def_id)
}
// If this is a DefPathHash from the local crate, we can look up the
// DefId in the tcx's `Definitions`.
if stable_crate_id == self.sess.local_stable_crate_id() {
- self.definitions.local_def_path_hash_to_def_id(hash, err).to_def_id()
+ self.definitions.read().local_def_path_hash_to_def_id(hash, err).to_def_id()
} else {
// If this is a DefPathHash from an upstream crate, let the CrateStore map
// it to a DefId.
)
}
+ /// Create a new definition within the incr. comp. engine.
+ pub fn create_def(self, parent: LocalDefId, data: hir::definitions::DefPathData) -> LocalDefId {
+ // This function modifies `self.definitions` using a side-effect.
+ // We need to ensure that these side effects are re-run by the incr. comp. engine.
+ // Depending on the forever-red node will tell the graph that the calling query
+ // needs to be re-evaluated.
+ use rustc_query_system::dep_graph::DepNodeIndex;
+ self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
+
+ // The following call has the side effect of modifying the tables inside `definitions`.
+ // These very tables are relied on by the incr. comp. engine to decode DepNodes and to
+ // decode the on-disk cache.
+ //
+ // Any LocalDefId which is used within queries, either as key or result, either:
+ // - has been created before the construction of the TyCtxt;
+ // - has been created by this call to `create_def`.
+ // As a consequence, this LocalDefId is always re-created before it is needed by the incr.
+ // comp. engine itself.
+ //
+ // This call also writes to the value of `source_span` and `expn_that_defined` queries.
+ // This is fine because:
+ // - those queries are `eval_always` so we won't miss their result changing;
+ // - this write will have happened before these queries are called.
+ self.definitions.write().create_def(parent, data)
+ }
+
+ pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {
+ // Create a dependency to the crate to be sure we re-execute this when the amount of
+ // definitions change.
+ self.ensure().hir_crate(());
+ // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+ // while iterating. If some query needs to add definitions, it should be `ensure`d above.
+ let definitions = self.definitions.leak();
+ definitions.iter_local_def_id()
+ }
+
+ pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable {
+ // Create a dependency to the crate to be sure we reexcute this when the amount of
+ // definitions change.
+ self.ensure().hir_crate(());
+ // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+ // while iterating. If some query needs to add definitions, it should be `ensure`d above.
+ let definitions = self.definitions.leak();
+ definitions.def_path_table()
+ }
+
+ pub fn def_path_hash_to_def_index_map(
+ self,
+ ) -> &'tcx rustc_hir::def_path_hash_map::DefPathHashMap {
+ // Create a dependency to the crate to be sure we reexcute this when the amount of
+ // definitions change.
+ self.ensure().hir_crate(());
+ // Leak a read lock once we start iterating on definitions, to prevent adding new onces
+ // while iterating. If some query needs to add definitions, it should be `ensure`d above.
+ let definitions = self.definitions.leak();
+ definitions.def_path_hash_to_def_index_map()
+ }
+
/// Note that this is *untracked* and should only be used within the query
/// system if the result is otherwise tracked through queries
pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn {
/// Note that this is *untracked* and should only be used within the query
/// system if the result is otherwise tracked through queries
- pub fn definitions_untracked(self) -> &'tcx hir::definitions::Definitions {
- &self.definitions
+ #[inline]
+ pub fn definitions_untracked(self) -> ReadGuard<'tcx, Definitions> {
+ self.definitions.read()
}
/// Note that this is *untracked* and should only be used within the query
}
#[inline(always)]
- pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> {
- StableHashingContext::new(
- self.sess,
- &self.definitions,
- &*self.cstore,
- &self.untracked_resolutions.source_span,
- )
- }
-
- #[inline(always)]
- pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> {
- StableHashingContext::ignore_spans(
+ pub fn with_stable_hashing_context<R>(
+ self,
+ f: impl FnOnce(StableHashingContext<'_>) -> R,
+ ) -> R {
+ let definitions = self.definitions_untracked();
+ let hcx = StableHashingContext::new(
self.sess,
- &self.definitions,
+ &*definitions,
&*self.cstore,
&self.untracked_resolutions.source_span,
- )
+ );
+ f(hcx)
}
pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult {
self.interners.intern_ty(
st,
self.sess,
- &self.definitions,
+ &self.definitions.read(),
&*self.cstore,
// This is only used to create a stable hashing context.
&self.untracked_resolutions.source_span,
pub fn provide(providers: &mut ty::query::Providers) {
providers.resolutions = |tcx, ()| &tcx.untracked_resolutions;
+ providers.resolver_for_lowering = |tcx, ()| &tcx.untracked_resolver_for_lowering;
providers.module_reexports =
|tcx, id| tcx.resolutions(()).reexport_map.get(&id).map(|v| &v[..]);
providers.crate_name = |tcx, id| {
#[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable, Lift)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct OpaqueTypeKey<'tcx> {
+ // FIXME(oli-obk): make this a LocalDefId
pub def_id: DefId,
pub substs: SubstsRef<'tcx>,
}
_ => bug!("free_region_binding_scope invoked on inappropriate region: {:?}", self),
}
}
+
+ /// True for free regions other than `'static`.
+ pub fn is_free(self) -> bool {
+ matches!(*self, ty::ReEarlyBound(_) | ty::ReFree(_))
+ }
+
+ /// True if `self` is a free region or static.
+ pub fn is_free_or_static(self) -> bool {
+ match *self {
+ ty::ReStatic => true,
+ _ => self.is_free(),
+ }
+ }
}
/// Type utilities
/// Creates a hash of the type `Ty` which will be the same no matter what crate
/// context it's calculated within. This is used by the `type_id` intrinsic.
pub fn type_id_hash(self, ty: Ty<'tcx>) -> u64 {
- let mut hasher = StableHasher::new();
- let mut hcx = self.create_stable_hashing_context();
-
// We want the type_id be independent of the types free regions, so we
// erase them. The erase_regions() call will also anonymize bound
// regions, which is desirable too.
let ty = self.erase_regions(ty);
- hcx.while_hashing_spans(false, |hcx| ty.hash_stable(hcx, &mut hasher));
- hasher.finish()
+ self.with_stable_hashing_context(|mut hcx| {
+ let mut hasher = StableHasher::new();
+ hcx.while_hashing_spans(false, |hcx| ty.hash_stable(hcx, &mut hasher));
+ hasher.finish()
+ })
}
pub fn res_generics_def_id(self, res: Res) -> Option<DefId> {
_: &mir::Statement<'tcx>,
loc: Location,
) {
- // If we move from a place then only stops needing storage *after*
+ // If we move from a place then it only stops needing storage *after*
// that statement.
self.check_for_move(trans, loc);
}
pub struct ConstProp;
impl<'tcx> MirPass<'tcx> for ConstProp {
- fn is_enabled(&self, _sess: &rustc_session::Session) -> bool {
- // FIXME(#70073): Unlike the other passes in "optimizations", this one emits errors, so it
- // runs even when MIR optimizations are disabled. We should separate the lint out from the
- // transform and move the lint as early in the pipeline as possible.
- true
+ fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
+ sess.mir_opt_level() >= 1
}
#[instrument(skip(self, tcx), level = "debug")]
/// Returns `true` if and only if this `op` should be const-propagated into.
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
- let mir_opt_level = self.tcx.sess.mir_opt_level();
-
- if mir_opt_level == 0 {
- return false;
- }
-
if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) {
return false;
}
use crate::MirPass;
use rustc_data_structures::graph::WithNumNodes;
-use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_index::vec::IndexVec;
use rustc_middle::hir;
fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 {
// FIXME(cjgillot) Stop hashing HIR manually here.
- let mut hcx = tcx.create_no_span_stable_hashing_context();
- let mut stable_hasher = StableHasher::new();
let owner = hir_body.id().hir_id.owner;
- let bodies = &tcx.hir_owner_nodes(owner).unwrap().bodies;
- hcx.with_hir_bodies(false, owner, bodies, |hcx| {
- hir_body.value.hash_stable(hcx, &mut stable_hasher)
- });
- stable_hasher.finish()
+ tcx.hir_owner_nodes(owner).unwrap().hash_including_bodies.to_smaller_hash()
}
);
expn_data.def_site = callee_body.span;
let expn_data =
- LocalExpnId::fresh(expn_data, self.tcx.create_stable_hashing_context());
+ self.tcx.with_stable_hashing_context(|hcx| LocalExpnId::fresh(expn_data, hcx));
let mut integrator = Integrator {
args: &args,
new_locals: Local::new(caller_body.local_decls.len())..,
intravisit::walk_struct_def(self, v)
}
}
- tcx.hir().deep_visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set });
+ tcx.hir().visit_all_item_likes_in_crate(&mut GatherCtors { tcx, set: &mut set });
set
}
// MACRO_RULES ITEM
self.parse_item_macro_rules(vis, has_bang)?
} else if self.isnt_macro_invocation()
- && (self.token.is_ident_named(Symbol::intern("import"))
- || self.token.is_ident_named(Symbol::intern("using")))
+ && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using))
{
return self.recover_import_as_use();
} else if self.isnt_macro_invocation() && vis.kind.is_pub() {
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
let check_attr_visitor = &mut CheckAttrVisitor { tcx };
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, check_attr_visitor);
+ tcx.hir().visit_item_likes_in_module(module_def_id, check_attr_visitor);
if module_def_id.is_top_level_module() {
check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
let mut vis = CheckConstVisitor::new(tcx);
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut vis);
+ tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis);
}
pub(crate) fn provide(providers: &mut Providers) {
errors: &errors,
};
- tcx.hir().deep_visit_item_likes_in_module(module_id, &mut v);
+ tcx.hir().visit_item_likes_in_module(module_id, &mut v);
});
let errors = errors.into_inner();
}
fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
+ tcx.hir().visit_item_likes_in_module(module_def_id, &mut IrMaps::new(tcx));
}
pub fn provide(providers: &mut Providers) {
}
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
- tcx.hir().deep_visit_item_likes_in_module(
+ tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut CheckLoopVisitor { sess: &tcx.sess, hir_map: tcx.hir(), cx: Normal },
);
use rustc_target::spec::abi::Abi;
fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
+ tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckNakedFunctions { tcx });
}
pub(crate) fn provide(providers: &mut Providers) {
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors.
fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
+ tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx });
}
pub(crate) fn provide(providers: &mut Providers) {
let mut missing = MissingStabilityAnnotations { tcx, access_levels };
missing.check_missing_stability(CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID));
tcx.hir().walk_toplevel_module(&mut missing);
- tcx.hir().deep_visit_all_item_likes(&mut missing);
+ tcx.hir().visit_all_item_likes_in_crate(&mut missing);
}
let declared_lang_features = &tcx.features().declared_lang_features;
#[cfg(debug_assertions)]
{
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
- let mut hcx = decoder.tcx.create_stable_hashing_context();
- let mut hasher = StableHasher::new();
- hcx.while_hashing_spans(true, |hcx| {
- expn_id.expn_data().hash_stable(hcx, &mut hasher)
+ let local_hash: u64 = decoder.tcx.with_stable_hashing_context(|mut hcx| {
+ let mut hasher = StableHasher::new();
+ expn_id.expn_data().hash_stable(&mut hcx, &mut hasher);
+ hasher.finish()
});
- let local_hash: u64 = hasher.finish();
debug_assert_eq!(hash.local_hash(), local_hash);
}
.and_then(|def_id| tcx.opt_def_kind(def_id))
};
let hash = || {
- let mut hcx = tcx.create_stable_hashing_context();
- let mut hasher = StableHasher::new();
- std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
- key.hash_stable(&mut hcx, &mut hasher);
- hasher.finish::<u64>()
+ tcx.with_stable_hashing_context(|mut hcx|{
+ let mut hasher = StableHasher::new();
+ std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
+ key.hash_stable(&mut hcx, &mut hasher);
+ hasher.finish::<u64>()
+ })
};
QueryStackFrame::new(name, description, span, def_kind, hash)
}
}
+ // We use this for the forever-red node.
+ pub fn Red() -> DepKindStruct {
+ DepKindStruct {
+ is_anon: false,
+ is_eval_always: false,
+ fingerprint_style: FingerprintStyle::Unit,
+ force_from_dep_node: Some(|_, dep_node| bug!("force_from_dep_node: encountered {:?}", dep_node)),
+ try_load_from_on_disk_cache: None,
+ }
+ }
+
pub fn TraitSelect() -> DepKindStruct {
DepKindStruct {
is_anon: true,
#[inline(always)]
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint {
- let mut hcx = tcx.create_stable_hashing_context();
- let mut hasher = StableHasher::new();
-
- self.hash_stable(&mut hcx, &mut hasher);
-
- hasher.finish()
+ tcx.with_stable_hashing_context(|mut hcx| {
+ let mut hasher = StableHasher::new();
+ self.hash_stable(&mut hcx, &mut hasher);
+ hasher.finish()
+ })
}
#[inline(always)]
impl DepNodeIndex {
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
pub const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0);
+ pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1);
}
impl std::convert::From<DepNodeIndex> for QueryInvocationId {
record_stats,
);
+ let colors = DepNodeColorMap::new(prev_graph_node_count);
+
// Instantiate a dependy-less node only once for anonymous queries.
let _green_node_index = current.intern_new_node(
profiler,
smallvec![],
Fingerprint::ZERO,
);
- debug_assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
+ assert_eq!(_green_node_index, DepNodeIndex::SINGLETON_DEPENDENCYLESS_ANON_NODE);
+
+ // Instantiate a dependy-less red node only once for anonymous queries.
+ let (_red_node_index, _prev_and_index) = current.intern_node(
+ profiler,
+ &prev_graph,
+ DepNode { kind: DepKind::RED, hash: Fingerprint::ZERO.into() },
+ smallvec![],
+ None,
+ false,
+ );
+ assert_eq!(_red_node_index, DepNodeIndex::FOREVER_RED_NODE);
+ assert!(matches!(_prev_and_index, None | Some((_, DepNodeColor::Red))));
DepGraph {
data: Some(Lrc::new(DepGraphData {
current,
processed_side_effects: Default::default(),
previous: prev_graph,
- colors: DepNodeColorMap::new(prev_graph_node_count),
+ colors,
debug_loaded_from_disk: Default::default(),
})),
virtual_dep_node_index: Lrc::new(AtomicU32::new(0)),
let dcx = cx.dep_context();
let hashing_timer = dcx.profiler().incr_result_hashing();
- let current_fingerprint = hash_result.map(|f| {
- let mut hcx = dcx.create_stable_hashing_context();
- f(&mut hcx, &result)
- });
+ let current_fingerprint =
+ hash_result.map(|f| dcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, &result)));
let print_status = cfg!(debug_assertions) && dcx.sess().opts.debugging_opts.dep_tasks;
let nanos = duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64;
let mut stable_hasher = StableHasher::new();
nanos.hash(&mut stable_hasher);
+ let anon_id_seed = stable_hasher.finish();
#[cfg(debug_assertions)]
let forbidden_edge = match env::var("RUST_FORBID_DEP_GRAPH_EDGE") {
)
}),
prev_index_to_index: Lock::new(IndexVec::from_elem_n(None, prev_graph_node_count)),
- anon_id_seed: stable_hasher.finish(),
+ anon_id_seed,
#[cfg(debug_assertions)]
forbidden_edge,
total_read_count: AtomicU64::new(0),
type DepKind: self::DepKind;
/// Create a hashing context for hashing new results.
- fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
+ fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
/// Describe the different families of dependency nodes.
pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder> + 'static {
+ /// DepKind to use when incr. comp. is turned off.
const NULL: Self;
+ /// DepKind to use to create the initial forever-red node.
+ const RED: Self;
+
/// Implementation of `std::fmt::Debug` for `DepNode`.
fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
use crate::ich;
+
use rustc_ast as ast;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
&mut self,
hash_bodies: bool,
owner: LocalDefId,
- bodies: &'a SortedMap<hir::ItemLocalId, &'a hir::Body<'a>>,
- f: impl FnOnce(&mut Self),
+ bodies: &SortedMap<hir::ItemLocalId, &hir::Body<'_>>,
+ f: impl FnOnce(&mut StableHashingContext<'_>),
) {
- let prev = self.body_resolver;
- self.body_resolver = BodyResolver::Traverse { hash_bodies, owner, bodies };
- f(self);
- self.body_resolver = prev;
+ f(&mut StableHashingContext {
+ body_resolver: BodyResolver::Traverse { hash_bodies, owner, bodies },
+ ..self.clone()
+ });
}
#[inline]
debug!("BEGIN verify_ich({:?})", dep_node);
let new_hash = query.hash_result.map_or(Fingerprint::ZERO, |f| {
- let mut hcx = tcx.create_stable_hashing_context();
- f(&mut hcx, result)
+ tcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, result))
});
let old_hash = tcx.dep_graph().prev_fingerprint_of(dep_node);
debug!("END verify_ich({:?})", dep_node);
&& let ModuleKind::Def(DefKind::Enum, def_id, _) = parent_scope.module.kind
&& let Some(span) = self.opt_span(def_id)
{
- err.span_help(
- self.session.source_map().guess_head_span(span),
- "consider adding `#[derive(Default)]` to this enum",
- );
+ let source_map = self.session.source_map();
+ let head_span = source_map.guess_head_span(span);
+ if let Ok(head) = source_map.span_to_snippet(head_span) {
+ err.span_suggestion(head_span, "consider adding a derive", format!("#[derive(Default)]\n{head}"), Applicability::MaybeIncorrect);
+ } else {
+ err.span_help(
+ head_span,
+ "consider adding `#[derive(Default)]` to this enum",
+ );
+ }
}
for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] {
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
prints: Vec::new(),
cg: Default::default(),
error_format: ErrorOutputType::default(),
+ diagnostic_width: None,
externs: Externs(BTreeMap::new()),
crate_name: None,
libs: Vec::new(),
never = never colorize output",
"auto|always|never",
),
+ opt::opt_s(
+ "",
+ "diagnostic-width",
+ "Inform rustc of the width of the output so that diagnostics can be truncated to fit",
+ "WIDTH",
+ ),
opt::multi_s(
"",
"remap-path-prefix",
let error_format = parse_error_format(matches, color, json_rendered);
+ let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_else(|_| {
+ early_error(error_format, "`--diagnostic-width` must be an positive integer");
+ });
+
let unparsed_crate_types = matches.opt_strs("crate-type");
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
.unwrap_or_else(|e| early_error(error_format, &e));
prints,
cg,
error_format,
+ diagnostic_width,
externs,
unstable_features: UnstableFeatures::from_environment(crate_name.as_deref()),
crate_name,
test: bool [TRACKED],
error_format: ErrorOutputType [UNTRACKED],
+ diagnostic_width: Option<usize> [UNTRACKED],
/// If `Some`, enable incremental compilation, using the given
/// directory to store intermediate results.
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) \
(default: no)"),
+ dump_drop_tracking_cfg: Option<String> = (None, parse_opt_string, [UNTRACKED],
+ "dump drop-tracking control-flow graph as a `.dot` file (default: no)"),
dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
"dump MIR state to file.
`val` is used to select which passes and functions to dump. For example:
"panic strategy for out-of-memory handling"),
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
+ diagnostic_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
+ "set the current output width for diagnostic truncation"),
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
"support compiling tests with panic=abort (default: no)"),
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
"show extended diagnostic help (default: no)"),
temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
"the directory the intermediate files are written to"),
- terminal_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
- "set the current terminal width"),
// Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
// alongside query results and changes to translation options can affect diagnostics - so
// translation options should be tracked.
use crate::code_stats::CodeStats;
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
-use crate::parse::ParseSess;
+use crate::parse::{add_feature_diagnostics, ParseSess};
use crate::search_paths::{PathKind, SearchPath};
use crate::{filesearch, lint};
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.parse_sess.create_err(err)
}
+ pub fn create_feature_err<'a>(
+ &'a self,
+ err: impl SessionDiagnostic<'a>,
+ feature: Symbol,
+ ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
+ let mut err = self.parse_sess.create_err(err);
+ add_feature_diagnostics(&mut err, &self.parse_sess, feature);
+ err
+ }
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
self.parse_sess.emit_err(err)
}
fallback_bundle,
short,
sopts.debugging_opts.teach,
- sopts.debugging_opts.terminal_width,
+ sopts.diagnostic_width,
macro_backtrace,
),
Some(dst) => EmitterWriter::new(
short,
false, // no teach messages when writing to a buffer
false, // no colors when writing to a buffer
- None, // no terminal width
+ None, // no diagnostic width
macro_backtrace,
),
};
fallback_bundle,
pretty,
json_rendered,
- sopts.debugging_opts.terminal_width,
+ sopts.diagnostic_width,
macro_backtrace,
)
.ui_testing(sopts.debugging_opts.ui_testing),
fallback_bundle,
pretty,
json_rendered,
- sopts.debugging_opts.terminal_width,
+ sopts.diagnostic_width,
macro_backtrace,
)
.ui_testing(sopts.debugging_opts.ui_testing),
impl_lint_pass,
impl_macros,
impl_trait_in_bindings,
+ import,
import_shadowing,
imported_main,
in_band_lifetimes,
use_nested_groups,
used,
used_with_arg,
+ using,
usize,
v1,
va_arg,
let substs = instance.substs;
debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
- let mut hasher = StableHasher::new();
- let mut hcx = tcx.create_stable_hashing_context();
-
- record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
- // the main symbol name is not necessarily unique; hash in the
- // compiler's internal def-path, guaranteeing each symbol has a
- // truly unique path
- tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
-
- // Include the main item-type. Note that, in this case, the
- // assertions about `needs_subst` may not hold, but this item-type
- // ought to be the same for every reference anyway.
- assert!(!item_type.has_erasable_regions());
- hcx.while_hashing_spans(false, |hcx| {
- item_type.hash_stable(hcx, &mut hasher);
-
- // If this is a function, we hash the signature as well.
- // This is not *strictly* needed, but it may help in some
- // situations, see the `run-make/a-b-a-linker-guard` test.
- if let ty::FnDef(..) = item_type.kind() {
- item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
- }
+ tcx.with_stable_hashing_context(|mut hcx| {
+ let mut hasher = StableHasher::new();
+
+ record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
+ // the main symbol name is not necessarily unique; hash in the
+ // compiler's internal def-path, guaranteeing each symbol has a
+ // truly unique path
+ tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
+
+ // Include the main item-type. Note that, in this case, the
+ // assertions about `needs_subst` may not hold, but this item-type
+ // ought to be the same for every reference anyway.
+ assert!(!item_type.has_erasable_regions());
+ hcx.while_hashing_spans(false, |hcx| {
+ item_type.hash_stable(hcx, &mut hasher);
+
+ // If this is a function, we hash the signature as well.
+ // This is not *strictly* needed, but it may help in some
+ // situations, see the `run-make/a-b-a-linker-guard` test.
+ if let ty::FnDef(..) = item_type.kind() {
+ item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
+ }
- // also include any type parameters (for generic items)
- substs.hash_stable(hcx, &mut hasher);
+ // also include any type parameters (for generic items)
+ substs.hash_stable(hcx, &mut hasher);
- if let Some(instantiating_crate) = instantiating_crate {
- tcx.def_path_hash(instantiating_crate.as_def_id())
- .stable_crate_id()
- .hash_stable(hcx, &mut hasher);
- }
+ if let Some(instantiating_crate) = instantiating_crate {
+ tcx.def_path_hash(instantiating_crate.as_def_id())
+ .stable_crate_id()
+ .hash_stable(hcx, &mut hasher);
+ }
- // We want to avoid accidental collision between different types of instances.
- // Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
- // instances without this.
- discriminant(&instance.def).hash_stable(hcx, &mut hasher);
+ // We want to avoid accidental collision between different types of instances.
+ // Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
+ // instances without this.
+ discriminant(&instance.def).hash_stable(hcx, &mut hasher);
+ });
});
- });
- // 64 bits should be enough to avoid collisions.
- hasher.finish::<u64>()
+ // 64 bits should be enough to avoid collisions.
+ hasher.finish::<u64>()
+ })
}
// Follow C++ namespace-mangling style, see
pub mod autoderef;
pub mod infer;
-pub mod opaque_types;
pub mod traits;
+++ /dev/null
-use crate::traits;
-use crate::traits::error_reporting::InferCtxtExt as _;
-use crate::traits::TraitEngineExt as _;
-use rustc_data_structures::fx::FxHashMap;
-use rustc_hir::def_id::DefId;
-use rustc_hir::OpaqueTyOrigin;
-use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
-use rustc_infer::infer::{InferCtxt, TyCtxtInferExt as _};
-use rustc_infer::traits::{Obligation, ObligationCause, TraitEngine};
-use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
-use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts};
-use rustc_middle::ty::visit::TypeVisitable;
-use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, ToPredicate, Ty, TyCtxt};
-use rustc_span::Span;
-
-pub trait InferCtxtExt<'tcx> {
- fn infer_opaque_definition_from_instantiation(
- &self,
- opaque_type_key: OpaqueTypeKey<'tcx>,
- instantiated_ty: OpaqueHiddenType<'tcx>,
- origin: OpaqueTyOrigin,
- ) -> Ty<'tcx>;
-}
-
-impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
- /// Given the fully resolved, instantiated type for an opaque
- /// type, i.e., the value of an inference variable like C1 or C2
- /// (*), computes the "definition type" for an opaque type
- /// definition -- that is, the inferred value of `Foo1<'x>` or
- /// `Foo2<'x>` that we would conceptually use in its definition:
- /// ```ignore (illustrative)
- /// type Foo1<'x> = impl Bar<'x> = AAA; // <-- this type AAA
- /// type Foo2<'x> = impl Bar<'x> = BBB; // <-- or this type BBB
- /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
- /// ```
- /// Note that these values are defined in terms of a distinct set of
- /// generic parameters (`'x` instead of `'a`) from C1 or C2. The main
- /// purpose of this function is to do that translation.
- ///
- /// (*) C1 and C2 were introduced in the comments on
- /// `register_member_constraints`. Read that comment for more context.
- ///
- /// # Parameters
- ///
- /// - `def_id`, the `impl Trait` type
- /// - `substs`, the substs used to instantiate this opaque type
- /// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
- /// `opaque_defn.concrete_ty`
- #[instrument(level = "debug", skip(self))]
- fn infer_opaque_definition_from_instantiation(
- &self,
- opaque_type_key: OpaqueTypeKey<'tcx>,
- instantiated_ty: OpaqueHiddenType<'tcx>,
- origin: OpaqueTyOrigin,
- ) -> Ty<'tcx> {
- if self.is_tainted_by_errors() {
- return self.tcx.ty_error();
- }
-
- let OpaqueTypeKey { def_id, substs } = opaque_type_key;
-
- // Use substs to build up a reverse map from regions to their
- // identity mappings. This is necessary because of `impl
- // Trait` lifetimes are computed by replacing existing
- // lifetimes with 'static and remapping only those used in the
- // `impl Trait` return type, resulting in the parameters
- // shifting.
- let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
- debug!(?id_substs);
- let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
- substs.iter().enumerate().map(|(index, subst)| (subst, id_substs[index])).collect();
- debug!("map = {:#?}", map);
-
- // Convert the type from the function into a type valid outside
- // the function, by replacing invalid regions with 'static,
- // after producing an error for each of them.
- let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new(
- self.tcx,
- def_id,
- map,
- instantiated_ty.ty,
- instantiated_ty.span,
- ));
- debug!(?definition_ty);
-
- if !check_opaque_type_parameter_valid(
- self.tcx,
- opaque_type_key,
- origin,
- instantiated_ty.span,
- ) {
- return self.tcx.ty_error();
- }
-
- // Only check this for TAIT. RPIT already supports `src/test/ui/impl-trait/nested-return-type2.rs`
- // on stable and we'd break that.
- if let OpaqueTyOrigin::TyAlias = origin {
- // This logic duplicates most of `check_opaque_meets_bounds`.
- // FIXME(oli-obk): Also do region checks here and then consider removing `check_opaque_meets_bounds` entirely.
- let param_env = self.tcx.param_env(def_id);
- let body_id = self.tcx.local_def_id_to_hir_id(def_id.as_local().unwrap());
- self.tcx.infer_ctxt().enter(move |infcx| {
- // Require the hidden type to be well-formed with only the generics of the opaque type.
- // Defining use functions may have more bounds than the opaque type, which is ok, as long as the
- // hidden type is well formed even without those bounds.
- let predicate =
- ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()))
- .to_predicate(infcx.tcx);
- let mut fulfillment_cx = <dyn TraitEngine<'tcx>>::new(infcx.tcx);
-
- // Require that the hidden type actually fulfills all the bounds of the opaque type, even without
- // the bounds that the function supplies.
- match infcx.register_hidden_type(
- OpaqueTypeKey { def_id, substs: id_substs },
- ObligationCause::misc(instantiated_ty.span, body_id),
- param_env,
- definition_ty,
- origin,
- ) {
- Ok(infer_ok) => {
- for obligation in infer_ok.obligations {
- fulfillment_cx.register_predicate_obligation(&infcx, obligation);
- }
- }
- Err(err) => {
- infcx
- .report_mismatched_types(
- &ObligationCause::misc(instantiated_ty.span, body_id),
- self.tcx.mk_opaque(def_id, id_substs),
- definition_ty,
- err,
- )
- .emit();
- }
- }
-
- fulfillment_cx.register_predicate_obligation(
- &infcx,
- Obligation::misc(instantiated_ty.span, body_id, param_env, predicate),
- );
-
- // Check that all obligations are satisfied by the implementation's
- // version.
- let errors = fulfillment_cx.select_all_or_error(&infcx);
-
- let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
-
- if errors.is_empty() {
- definition_ty
- } else {
- infcx.report_fulfillment_errors(&errors, None, false);
- self.tcx.ty_error()
- }
- })
- } else {
- definition_ty
- }
- }
-}
-
-fn check_opaque_type_parameter_valid(
- tcx: TyCtxt<'_>,
- opaque_type_key: OpaqueTypeKey<'_>,
- origin: OpaqueTyOrigin,
- span: Span,
-) -> bool {
- match origin {
- // No need to check return position impl trait (RPIT)
- // because for type and const parameters they are correct
- // by construction: we convert
- //
- // fn foo<P0..Pn>() -> impl Trait
- //
- // into
- //
- // type Foo<P0...Pn>
- // fn foo<P0..Pn>() -> Foo<P0...Pn>.
- //
- // For lifetime parameters we convert
- //
- // fn foo<'l0..'ln>() -> impl Trait<'l0..'lm>
- //
- // into
- //
- // type foo::<'p0..'pn>::Foo<'q0..'qm>
- // fn foo<l0..'ln>() -> foo::<'static..'static>::Foo<'l0..'lm>.
- //
- // which would error here on all of the `'static` args.
- OpaqueTyOrigin::FnReturn(..) | OpaqueTyOrigin::AsyncFn(..) => return true,
- // Check these
- OpaqueTyOrigin::TyAlias => {}
- }
- let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
- let mut seen_params: FxHashMap<_, Vec<_>> = FxHashMap::default();
- for (i, arg) in opaque_type_key.substs.iter().enumerate() {
- let arg_is_param = match arg.unpack() {
- GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
- GenericArgKind::Lifetime(lt) if lt.is_static() => {
- tcx.sess
- .struct_span_err(span, "non-defining opaque type use in defining scope")
- .span_label(
- tcx.def_span(opaque_generics.param_at(i, tcx).def_id),
- "cannot use static lifetime; use a bound lifetime \
- instead or remove the lifetime parameter from the \
- opaque type",
- )
- .emit();
- return false;
- }
- GenericArgKind::Lifetime(lt) => {
- matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
- }
- GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
- };
-
- if arg_is_param {
- seen_params.entry(arg).or_default().push(i);
- } else {
- // Prevent `fn foo() -> Foo<u32>` from being defining.
- let opaque_param = opaque_generics.param_at(i, tcx);
- tcx.sess
- .struct_span_err(span, "non-defining opaque type use in defining scope")
- .span_note(
- tcx.def_span(opaque_param.def_id),
- &format!(
- "used non-generic {} `{}` for generic parameter",
- opaque_param.kind.descr(),
- arg,
- ),
- )
- .emit();
- return false;
- }
- }
-
- for (_, indices) in seen_params {
- if indices.len() > 1 {
- let descr = opaque_generics.param_at(indices[0], tcx).kind.descr();
- let spans: Vec<_> = indices
- .into_iter()
- .map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
- .collect();
- tcx.sess
- .struct_span_err(span, "non-defining opaque type use in defining scope")
- .span_note(spans, &format!("{} used multiple times", descr))
- .emit();
- return false;
- }
- }
- true
-}
-
-struct ReverseMapper<'tcx> {
- tcx: TyCtxt<'tcx>,
-
- opaque_type_def_id: DefId,
- map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
- map_missing_regions_to_empty: bool,
-
- /// initially `Some`, set to `None` once error has been reported
- hidden_ty: Option<Ty<'tcx>>,
-
- /// Span of function being checked.
- span: Span,
-}
-
-impl<'tcx> ReverseMapper<'tcx> {
- fn new(
- tcx: TyCtxt<'tcx>,
- opaque_type_def_id: DefId,
- map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
- hidden_ty: Ty<'tcx>,
- span: Span,
- ) -> Self {
- Self {
- tcx,
- opaque_type_def_id,
- map,
- map_missing_regions_to_empty: false,
- hidden_ty: Some(hidden_ty),
- span,
- }
- }
-
- fn fold_kind_mapping_missing_regions_to_empty(
- &mut self,
- kind: GenericArg<'tcx>,
- ) -> GenericArg<'tcx> {
- assert!(!self.map_missing_regions_to_empty);
- self.map_missing_regions_to_empty = true;
- let kind = kind.fold_with(self);
- self.map_missing_regions_to_empty = false;
- kind
- }
-
- fn fold_kind_normally(&mut self, kind: GenericArg<'tcx>) -> GenericArg<'tcx> {
- assert!(!self.map_missing_regions_to_empty);
- kind.fold_with(self)
- }
-}
-
-impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
- fn tcx(&self) -> TyCtxt<'tcx> {
- self.tcx
- }
-
- #[instrument(skip(self), level = "debug")]
- fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
- match *r {
- // Ignore bound regions and `'static` regions that appear in the
- // type, we only need to remap regions that reference lifetimes
- // from the function declaration.
- // This would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
- ty::ReLateBound(..) | ty::ReStatic => return r,
-
- // If regions have been erased (by writeback), don't try to unerase
- // them.
- ty::ReErased => return r,
-
- // The regions that we expect from borrow checking.
- ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReEmpty(ty::UniverseIndex::ROOT) => {}
-
- ty::ReEmpty(_) | ty::RePlaceholder(_) | ty::ReVar(_) => {
- // All of the regions in the type should either have been
- // erased by writeback, or mapped back to named regions by
- // borrow checking.
- bug!("unexpected region kind in opaque type: {:?}", r);
- }
- }
-
- let generics = self.tcx().generics_of(self.opaque_type_def_id);
- match self.map.get(&r.into()).map(|k| k.unpack()) {
- Some(GenericArgKind::Lifetime(r1)) => r1,
- Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
- None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
- None if generics.parent.is_some() => {
- if let Some(hidden_ty) = self.hidden_ty.take() {
- unexpected_hidden_region_diagnostic(
- self.tcx,
- self.tcx.def_span(self.opaque_type_def_id),
- hidden_ty,
- r,
- )
- .emit();
- }
- self.tcx.lifetimes.re_root_empty
- }
- None => {
- self.tcx
- .sess
- .struct_span_err(self.span, "non-defining opaque type use in defining scope")
- .span_label(
- self.span,
- format!(
- "lifetime `{}` is part of concrete type but not used in \
- parameter list of the `impl Trait` type alias",
- r
- ),
- )
- .emit();
-
- self.tcx().lifetimes.re_static
- }
- }
- }
-
- fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
- match *ty.kind() {
- ty::Closure(def_id, substs) => {
- // I am a horrible monster and I pray for death. When
- // we encounter a closure here, it is always a closure
- // from within the function that we are currently
- // type-checking -- one that is now being encapsulated
- // in an opaque type. Ideally, we would
- // go through the types/lifetimes that it references
- // and treat them just like we would any other type,
- // which means we would error out if we find any
- // reference to a type/region that is not in the
- // "reverse map".
- //
- // **However,** in the case of closures, there is a
- // somewhat subtle (read: hacky) consideration. The
- // problem is that our closure types currently include
- // all the lifetime parameters declared on the
- // enclosing function, even if they are unused by the
- // closure itself. We can't readily filter them out,
- // so here we replace those values with `'empty`. This
- // can't really make a difference to the rest of the
- // compiler; those regions are ignored for the
- // outlives relation, and hence don't affect trait
- // selection or auto traits, and they are erased
- // during codegen.
-
- let generics = self.tcx.generics_of(def_id);
- let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
- if index < generics.parent_count {
- // Accommodate missing regions in the parent kinds...
- self.fold_kind_mapping_missing_regions_to_empty(kind)
- } else {
- // ...but not elsewhere.
- self.fold_kind_normally(kind)
- }
- }));
-
- self.tcx.mk_closure(def_id, substs)
- }
-
- ty::Generator(def_id, substs, movability) => {
- let generics = self.tcx.generics_of(def_id);
- let substs = self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
- if index < generics.parent_count {
- // Accommodate missing regions in the parent kinds...
- self.fold_kind_mapping_missing_regions_to_empty(kind)
- } else {
- // ...but not elsewhere.
- self.fold_kind_normally(kind)
- }
- }));
-
- self.tcx.mk_generator(def_id, substs, movability)
- }
-
- ty::Param(param) => {
- // Look it up in the substitution list.
- match self.map.get(&ty.into()).map(|k| k.unpack()) {
- // Found it in the substitution list; replace with the parameter from the
- // opaque type.
- Some(GenericArgKind::Type(t1)) => t1,
- Some(u) => panic!("type mapped to unexpected kind: {:?}", u),
- None => {
- debug!(?param, ?self.map);
- self.tcx
- .sess
- .struct_span_err(
- self.span,
- &format!(
- "type parameter `{}` is part of concrete type but not \
- used in parameter list for the `impl Trait` type alias",
- ty
- ),
- )
- .emit();
-
- self.tcx().ty_error()
- }
- }
- }
-
- _ => ty.super_fold_with(self),
- }
- }
-
- fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
- trace!("checking const {:?}", ct);
- // Find a const parameter
- match ct.kind() {
- ty::ConstKind::Param(..) => {
- // Look it up in the substitution list.
- match self.map.get(&ct.into()).map(|k| k.unpack()) {
- // Found it in the substitution list, replace with the parameter from the
- // opaque type.
- Some(GenericArgKind::Const(c1)) => c1,
- Some(u) => panic!("const mapped to unexpected kind: {:?}", u),
- None => {
- self.tcx
- .sess
- .struct_span_err(
- self.span,
- &format!(
- "const parameter `{}` is part of concrete type but not \
- used in parameter list for the `impl Trait` type alias",
- ct
- ),
- )
- .emit();
-
- self.tcx().const_error(ct.ty())
- }
- }
- }
-
- _ => ct,
- }
- }
-}
-
-/// Given a set of predicates that apply to an object type, returns
-/// the region bounds that the (erased) `Self` type must
-/// outlive. Precisely *because* the `Self` type is erased, the
-/// parameter `erased_self_ty` must be supplied to indicate what type
-/// has been used to represent `Self` in the predicates
-/// themselves. This should really be a unique type; `FreshTy(0)` is a
-/// popular choice.
-///
-/// N.B., in some cases, particularly around higher-ranked bounds,
-/// this function returns a kind of conservative approximation.
-/// That is, all regions returned by this function are definitely
-/// required, but there may be other region bounds that are not
-/// returned, as well as requirements like `for<'a> T: 'a`.
-///
-/// Requires that trait definitions have been processed so that we can
-/// elaborate predicates and walk supertraits.
-#[instrument(skip(tcx, predicates), level = "debug")]
-pub(crate) fn required_region_bounds<'tcx>(
- tcx: TyCtxt<'tcx>,
- erased_self_ty: Ty<'tcx>,
- predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
-) -> Vec<ty::Region<'tcx>> {
- assert!(!erased_self_ty.has_escaping_bound_vars());
-
- traits::elaborate_predicates(tcx, predicates)
- .filter_map(|obligation| {
- debug!(?obligation);
- match obligation.predicate.kind().skip_binder() {
- ty::PredicateKind::Projection(..)
- | ty::PredicateKind::Trait(..)
- | ty::PredicateKind::Subtype(..)
- | ty::PredicateKind::Coerce(..)
- | ty::PredicateKind::WellFormed(..)
- | ty::PredicateKind::ObjectSafe(..)
- | ty::PredicateKind::ClosureKind(..)
- | ty::PredicateKind::RegionOutlives(..)
- | ty::PredicateKind::ConstEvaluatable(..)
- | ty::PredicateKind::ConstEquate(..)
- | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
- ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
- // Search for a bound of the form `erased_self_ty
- // : 'a`, but be wary of something like `for<'a>
- // erased_self_ty : 'a` (we interpret a
- // higher-ranked bound like that as 'static,
- // though at present the code in `fulfill.rs`
- // considers such bounds to be unsatisfiable, so
- // it's kind of a moot point since you could never
- // construct such an object, but this seems
- // correct even if that code changes).
- if t == &erased_self_ty && !r.has_escaping_bound_vars() {
- Some(*r)
- } else {
- None
- }
- }
- }
- })
- .collect()
-}
use rustc_hir::Item;
use rustc_hir::Node;
use rustc_infer::infer::error_reporting::same_type_modulo_infer;
-use rustc_infer::traits::TraitEngine;
+use rustc_infer::traits::{AmbiguousSelection, TraitEngine};
use rustc_middle::thir::abstract_const::NotConstEvaluatable;
use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::error::ExpectedFound;
fn annotate_source_of_ambiguity(
&self,
err: &mut Diagnostic,
- impls: &[DefId],
+ impls: &[AmbiguousSelection],
predicate: ty::Predicate<'tcx>,
);
);
match selcx.select_from_obligation(&obligation) {
Err(SelectionError::Ambiguous(impls)) if impls.len() > 1 => {
+ if self.is_tainted_by_errors() && subst.is_none() {
+ // If `subst.is_none()`, then this is probably two param-env
+ // candidates or impl candidates that are equal modulo lifetimes.
+ // Therefore, if we've already emitted an error, just skip this
+ // one, since it's not particularly actionable.
+ err.cancel();
+ return;
+ }
self.annotate_source_of_ambiguity(&mut err, &impls, predicate);
}
_ => {
fn annotate_source_of_ambiguity(
&self,
err: &mut Diagnostic,
- impls: &[DefId],
+ impls: &[AmbiguousSelection],
predicate: ty::Predicate<'tcx>,
) {
let mut spans = vec![];
let mut crates = vec![];
let mut post = vec![];
- for def_id in impls {
- match self.tcx.span_of_impl(*def_id) {
- Ok(span) => spans.push(span),
- Err(name) => {
- crates.push(name);
- if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
- post.push(header);
+ let mut or_where_clause = false;
+ for ambig in impls {
+ match ambig {
+ AmbiguousSelection::Impl(def_id) => match self.tcx.span_of_impl(*def_id) {
+ Ok(span) => spans.push(span),
+ Err(name) => {
+ crates.push(name);
+ if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
+ post.push(header);
+ }
}
+ },
+ AmbiguousSelection::ParamEnv(span) => {
+ or_where_clause = true;
+ spans.push(*span);
}
}
}
- let msg = format!("multiple `impl`s satisfying `{}` found", predicate);
+ let msg = format!(
+ "multiple `impl`s{} satisfying `{}` found",
+ if or_where_clause { " or `where` clauses" } else { "" },
+ predicate
+ );
let mut crate_names: Vec<_> = crates.iter().map(|n| format!("`{}`", n)).collect();
crate_names.sort();
crate_names.dedup();
Ok(
EvaluationResult::EvaluatedToOk
| EvaluationResult::EvaluatedToOkModuloRegions
+ | EvaluationResult::EvaluatedToOkModuloOpaqueTypes
| EvaluationResult::EvaluatedToAmbig,
) => {}
_ => return false,
//!
//! [rustc dev guide]:https://rustc-dev-guide.rust-lang.org/traits/resolution.html#candidate-assembly
use hir::LangItem;
+use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
-use rustc_infer::traits::TraitEngine;
+use rustc_infer::traits::util::elaborate_predicates_with_span;
+use rustc_infer::traits::{AmbiguousSelection, TraitEngine};
use rustc_infer::traits::{Obligation, SelectionError, TraitObligation};
use rustc_lint_defs::builtin::DEREF_INTO_DYN_SUPERTRAIT;
use rustc_middle::ty::print::with_no_trimmed_paths;
// and report ambiguity.
if i > 1 {
debug!("multiple matches, ambig");
+
+ // Collect a list of (probable) spans that point to a param-env candidate
+ let tcx = self.infcx.tcx;
+ let owner = stack.obligation.cause.body_id.owner.to_def_id();
+ let predicates = tcx.predicates_of(owner).instantiate_identity(tcx);
+ let param_env_spans: FxHashMap<_, _> = elaborate_predicates_with_span(
+ tcx,
+ std::iter::zip(predicates.predicates, predicates.spans),
+ )
+ .filter_map(|obligation| {
+ let kind = obligation.predicate.kind();
+ if let ty::PredicateKind::Trait(trait_pred) = kind.skip_binder() {
+ if trait_pred.trait_ref
+ == ty::TraitRef::identity(tcx, trait_pred.def_id())
+ .skip_binder()
+ {
+ // HACK: Remap the `Self: Trait` predicate that every trait has to a more useful span
+ Some((
+ kind.rebind(trait_pred),
+ tcx.def_span(trait_pred.def_id()),
+ ))
+ } else {
+ Some((kind.rebind(trait_pred), obligation.cause.span))
+ }
+ } else {
+ None
+ }
+ })
+ .collect();
+
return Err(Ambiguous(
candidates
.into_iter()
.filter_map(|c| match c.candidate {
- SelectionCandidate::ImplCandidate(def_id) => Some(def_id),
+ SelectionCandidate::ImplCandidate(def_id) => {
+ Some(AmbiguousSelection::Impl(def_id))
+ }
+ SelectionCandidate::ParamCandidate(predicate) => {
+ Some(AmbiguousSelection::ParamEnv(
+ *param_env_spans.get(&predicate)?,
+ ))
+ }
_ => None,
})
.collect(),
Err(_) => return Ok(EvaluatedToErr),
}
+ if self.infcx.opaque_types_added_in_snapshot(snapshot) {
+ return Ok(result.max(EvaluatedToOkModuloOpaqueTypes));
+ }
+
match self.infcx.region_constraints_added_in_snapshot(snapshot) {
None => Ok(result),
Some(_) => Ok(result.max(EvaluatedToOkModuloRegions)),
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
) -> Option<NonStructuralMatchTy<'tcx>> {
- // FIXME: we should instead pass in an `infcx` from the outside.
- tcx.infer_ctxt().enter(|infcx| {
- ty.visit_with(&mut Search { infcx, span, seen: FxHashSet::default() }).break_value()
- })
+ ty.visit_with(&mut Search { tcx, span, seen: FxHashSet::default() }).break_value()
}
/// This method returns true if and only if `adt_ty` itself has been marked as
/// This implements the traversal over the structure of a given type to try to
/// find instances of ADTs (specifically structs or enums) that do not implement
/// the structural-match traits (`StructuralPartialEq` and `StructuralEq`).
-struct Search<'a, 'tcx> {
+struct Search<'tcx> {
span: Span,
- infcx: InferCtxt<'a, 'tcx>,
+ tcx: TyCtxt<'tcx>,
/// Tracks ADTs previously encountered during search, so that
/// we will not recur on them again.
seen: FxHashSet<hir::def_id::DefId>,
}
-impl<'a, 'tcx> Search<'a, 'tcx> {
- fn tcx(&self) -> TyCtxt<'tcx> {
- self.infcx.tcx
- }
-
+impl<'tcx> Search<'tcx> {
fn type_marked_structural(&self, adt_ty: Ty<'tcx>) -> bool {
- adt_ty.is_structural_eq_shallow(self.tcx())
+ adt_ty.is_structural_eq_shallow(self.tcx)
}
}
-impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
+impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
type BreakTy = NonStructuralMatchTy<'tcx>;
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
return ControlFlow::CONTINUE;
}
ty::Array(_, n)
- if { n.try_eval_usize(self.tcx(), ty::ParamEnv::reveal_all()) == Some(0) } =>
+ if { n.try_eval_usize(self.tcx, ty::ParamEnv::reveal_all()) == Some(0) } =>
{
// rust-lang/rust#62336: ignore type of contents
// for empty array.
bug!("unexpected type during structural-match checking: {:?}", ty);
}
ty::Error(_) => {
- self.tcx().sess.delay_span_bug(self.span, "ty::Error in structural-match check");
+ self.tcx.sess.delay_span_bug(self.span, "ty::Error in structural-match check");
// We still want to check other types after encountering an error,
// as this may still emit relevant errors.
return ControlFlow::CONTINUE;
// even though we skip super_visit_with, we must recur on
// fields of ADT.
- let tcx = self.tcx();
+ let tcx = self.tcx;
adt_def.all_fields().map(|field| field.ty(tcx, substs)).try_for_each(|field_ty| {
- let ty = self.tcx().normalize_erasing_regions(ty::ParamEnv::empty(), field_ty);
+ let ty = self.tcx.normalize_erasing_regions(ty::ParamEnv::empty(), field_ty);
debug!("structural-match ADT: field_ty={:?}, ty={:?}", field_ty, ty);
ty.visit_with(self)
})
use crate::infer::InferCtxt;
-use crate::opaque_types::required_region_bounds;
use crate::traits;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
}
fn normalize(mut self) -> Vec<traits::PredicateObligation<'tcx>> {
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
let infcx = &mut self.infcx;
let param_env = self.param_env;
let mut obligations = Vec::with_capacity(self.out.len());
self.out.extend(obligations);
let tcx = self.tcx();
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
let param_env = self.param_env;
let depth = self.recursion_depth;
let predicate =
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
.to_predicate(self.tcx());
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
cause,
self.recursion_depth,
let resolved = self.infcx.shallow_resolve(infer);
// the `InferConst` changed, meaning that we made progress.
if resolved != infer {
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
kind: ty::ConstKind::Infer(resolved),
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
if !defer_to_coercion {
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
let component_traits = data.auto_traits().chain(data.principal_def_id());
let tcx = self.tcx();
self.out.extend(component_traits.map(|did| {
let ty = self.infcx.shallow_resolve(ty);
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
// Not yet resolved, but we've made progress.
- let cause = self.cause(traits::MiscObligation);
+ let cause = self.cause(traits::WellFormed(None));
self.out.push(traits::Obligation::with_depth(
cause,
self.recursion_depth,
required_region_bounds(tcx, open_ty, predicates)
}
+
+/// Given a set of predicates that apply to an object type, returns
+/// the region bounds that the (erased) `Self` type must
+/// outlive. Precisely *because* the `Self` type is erased, the
+/// parameter `erased_self_ty` must be supplied to indicate what type
+/// has been used to represent `Self` in the predicates
+/// themselves. This should really be a unique type; `FreshTy(0)` is a
+/// popular choice.
+///
+/// N.B., in some cases, particularly around higher-ranked bounds,
+/// this function returns a kind of conservative approximation.
+/// That is, all regions returned by this function are definitely
+/// required, but there may be other region bounds that are not
+/// returned, as well as requirements like `for<'a> T: 'a`.
+///
+/// Requires that trait definitions have been processed so that we can
+/// elaborate predicates and walk supertraits.
+#[instrument(skip(tcx, predicates), level = "debug")]
+pub(crate) fn required_region_bounds<'tcx>(
+ tcx: TyCtxt<'tcx>,
+ erased_self_ty: Ty<'tcx>,
+ predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
+) -> Vec<ty::Region<'tcx>> {
+ assert!(!erased_self_ty.has_escaping_bound_vars());
+
+ traits::elaborate_predicates(tcx, predicates)
+ .filter_map(|obligation| {
+ debug!(?obligation);
+ match obligation.predicate.kind().skip_binder() {
+ ty::PredicateKind::Projection(..)
+ | ty::PredicateKind::Trait(..)
+ | ty::PredicateKind::Subtype(..)
+ | ty::PredicateKind::Coerce(..)
+ | ty::PredicateKind::WellFormed(..)
+ | ty::PredicateKind::ObjectSafe(..)
+ | ty::PredicateKind::ClosureKind(..)
+ | ty::PredicateKind::RegionOutlives(..)
+ | ty::PredicateKind::ConstEvaluatable(..)
+ | ty::PredicateKind::ConstEquate(..)
+ | ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
+ ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ref t, ref r)) => {
+ // Search for a bound of the form `erased_self_ty
+ // : 'a`, but be wary of something like `for<'a>
+ // erased_self_ty : 'a` (we interpret a
+ // higher-ranked bound like that as 'static,
+ // though at present the code in `fulfill.rs`
+ // considers such bounds to be unsatisfiable, so
+ // it's kind of a moot point since you could never
+ // construct such an object, but this seems
+ // correct even if that code changes).
+ if t == &erased_self_ty && !r.has_escaping_bound_vars() {
+ Some(*r)
+ } else {
+ None
+ }
+ }
+ }
+ })
+ .collect()
+}
| TypeFlags::HAS_CT_INFER.bits
| TypeFlags::HAS_TY_PLACEHOLDER.bits
| TypeFlags::HAS_CT_PLACEHOLDER.bits
- // The `evaluate_obligation` query does not return further
- // obligations. If it evaluates an obligation with an opaque
- // type, that opaque type may get compared to another type,
- // constraining it. We would lose this information.
- // FIXME: differentiate between crate-local opaque types
- // and opaque types from other crates, as only opaque types
- // from the local crate can possibly be a local name
- | TypeFlags::HAS_TY_OPAQUE.bits
// We consider 'freshened' types and constants
// to depend on a particular fn.
// The freshening process throws away information,
};
// we must check that return type of called functions is WF:
- self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation);
+ self.register_wf_obligation(output.into(), call_expr.span, traits::WellFormed(None));
output
}
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
- self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
+ self.register_wf_obligation(t.into(), ast_t.span, traits::WellFormed(None));
t
}
self.register_wf_obligation(
c.into(),
self.tcx.hir().span(ast_c.hir_id),
- ObligationCauseCode::MiscObligation,
+ ObligationCauseCode::WellFormed(None),
);
c
}
self.register_wf_obligation(
c.into(),
self.tcx.hir().span(ast_c.hir_id),
- ObligationCauseCode::MiscObligation,
+ ObligationCauseCode::WellFormed(None),
);
c
}
for arg in substs.iter().filter(|arg| {
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
}) {
- self.register_wf_obligation(arg, expr.span, traits::MiscObligation);
+ self.register_wf_obligation(arg, expr.span, traits::WellFormed(None));
}
}
}
/// Identifies a value whose drop state we need to track.
-#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)]
+#[derive(PartialEq, Eq, Hash, Clone, Copy)]
enum TrackedValue {
/// Represents a named variable, such as a let binding, parameter, or upvar.
///
Temporary(HirId),
}
+impl Debug for TrackedValue {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ ty::tls::with_opt(|opt_tcx| {
+ if let Some(tcx) = opt_tcx {
+ write!(f, "{}", tcx.hir().node_to_string(self.hir_id()))
+ } else {
+ match self {
+ Self::Variable(hir_id) => write!(f, "Variable({:?})", hir_id),
+ Self::Temporary(hir_id) => write!(f, "Temporary({:?})", hir_id),
+ }
+ }
+ })
+ }
+}
+
impl TrackedValue {
fn hir_id(&self) -> HirId {
match self {
/// Place projects are not currently supported.
///
/// The reasoning around these is kind of subtle, so we choose to be more
- /// conservative around these for now. There is not reason in theory we
+ /// conservative around these for now. There is no reason in theory we
/// cannot support these, we just have not implemented it yet.
PlaceProjectionsNotSupported,
}
intravisit::walk_body(&mut drop_range_visitor, body);
drop_range_visitor.drop_ranges.process_deferred_edges();
+ if let Some(filename) = &tcx.sess.opts.debugging_opts.dump_drop_tracking_cfg {
+ super::cfg_visualize::write_graph_to_file(&drop_range_visitor.drop_ranges, filename, tcx);
+ }
(drop_range_visitor.drop_ranges, drop_range_visitor.places.borrowed_temporaries)
}
/// ExprUseVisitor's consume callback doesn't go deep enough for our purposes in all
/// expressions. This method consumes a little deeper into the expression when needed.
fn consume_expr(&mut self, expr: &hir::Expr<'_>) {
- debug!("consuming expr {:?}, count={:?}", expr.hir_id, self.expr_index);
+ debug!("consuming expr {:?}, count={:?}", expr.kind, self.expr_index);
let places = self
.places
.consumed
.get(&expr.hir_id)
.map_or(vec![], |places| places.iter().cloned().collect());
for place in places {
+ trace!(?place, "consuming place");
for_each_consumable(self.hir, place, |value| self.record_drop(value));
}
}
//! flow graph when needed for debugging.
use rustc_graphviz as dot;
+use rustc_middle::ty::TyCtxt;
use super::{DropRangesBuilder, PostOrderId};
///
/// It is not normally called, but is kept around to easily add debugging
/// code when needed.
-#[allow(dead_code)]
-pub(super) fn write_graph_to_file(drop_ranges: &DropRangesBuilder, filename: &str) {
- dot::render(drop_ranges, &mut std::fs::File::create(filename).unwrap()).unwrap();
+pub(super) fn write_graph_to_file(
+ drop_ranges: &DropRangesBuilder,
+ filename: &str,
+ tcx: TyCtxt<'_>,
+) {
+ dot::render(
+ &DropRangesGraph { drop_ranges, tcx },
+ &mut std::fs::File::create(filename).unwrap(),
+ )
+ .unwrap();
}
-impl<'a> dot::GraphWalk<'a> for DropRangesBuilder {
+struct DropRangesGraph<'a, 'tcx> {
+ drop_ranges: &'a DropRangesBuilder,
+ tcx: TyCtxt<'tcx>,
+}
+
+impl<'a> dot::GraphWalk<'a> for DropRangesGraph<'_, '_> {
type Node = PostOrderId;
type Edge = (PostOrderId, PostOrderId);
fn nodes(&'a self) -> dot::Nodes<'a, Self::Node> {
- self.nodes.iter_enumerated().map(|(i, _)| i).collect()
+ self.drop_ranges.nodes.iter_enumerated().map(|(i, _)| i).collect()
}
fn edges(&'a self) -> dot::Edges<'a, Self::Edge> {
- self.nodes
+ self.drop_ranges
+ .nodes
.iter_enumerated()
.flat_map(|(i, node)| {
if node.successors.len() == 0 {
}
}
-impl<'a> dot::Labeller<'a> for DropRangesBuilder {
+impl<'a> dot::Labeller<'a> for DropRangesGraph<'_, '_> {
type Node = PostOrderId;
type Edge = (PostOrderId, PostOrderId);
fn node_label(&'a self, n: &Self::Node) -> dot::LabelText<'a> {
dot::LabelText::LabelStr(
format!(
- "{:?}, local_id: {}",
- n,
- self.post_order_map
+ "{n:?}: {}",
+ self.drop_ranges
+ .post_order_map
.iter()
.find(|(_hir_id, &post_order_id)| post_order_id == *n)
- .map_or("<unknown>".into(), |(hir_id, _)| format!(
- "{}",
- hir_id.local_id.index()
- ))
+ .map_or("<unknown>".into(), |(hir_id, _)| self
+ .tcx
+ .hir()
+ .node_to_string(*hir_id))
)
.into(),
)
if !self.places.consumed.contains_key(&consumer) {
self.places.consumed.insert(consumer, <_>::default());
}
+ debug!(?consumer, ?target, "mark_consumed");
self.places.consumed.get_mut(&consumer).map(|places| places.insert(target));
}
place_with_id: &expr_use_visitor::PlaceWithHirId<'tcx>,
diag_expr_id: HirId,
) {
- let parent = match self.tcx.hir().find_parent_node(place_with_id.hir_id) {
+ let hir = self.tcx.hir();
+ let parent = match hir.find_parent_node(place_with_id.hir_id) {
Some(parent) => parent,
None => place_with_id.hir_id,
};
debug!(
- "consume {:?}; diag_expr_id={:?}, using parent {:?}",
- place_with_id, diag_expr_id, parent
+ "consume {:?}; diag_expr_id={}, using parent {}",
+ place_with_id,
+ hir.node_to_string(diag_expr_id),
+ hir.node_to_string(parent)
);
place_with_id
.try_into()
// the function type must also be well-formed (this is not
// implied by the substs being well-formed because of inherent
// impls and late-bound regions - see issue #28609).
- self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation);
+ self.register_wf_obligation(fty.into(), self.span, traits::WellFormed(None));
}
///////////////////////////////////////////////////////////////////////////
let type_param = generics.type_param(param_type, self.tcx);
Some(self.tcx.def_span(type_param.def_id))
}
- ty::Adt(def, _) if def.did().is_local() => {
- tcx.def_ident_span(def.did()).map(|span| span)
- }
+ ty::Adt(def, _) if def.did().is_local() => Some(tcx.def_span(def.did())),
_ => None,
};
// Find all the requirements that come from a local `impl` block.
let mut skip_list: FxHashSet<_> = Default::default();
let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
- for (data, p, parent_p, impl_def_id, cause_span) in unsatisfied_predicates
+ for (data, p, parent_p, impl_def_id, cause) in unsatisfied_predicates
.iter()
.filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
.filter_map(|(p, parent, c)| match c.code() {
ObligationCauseCode::ImplDerivedObligation(ref data) => {
- Some((&data.derived, p, parent, data.impl_def_id, data.span))
+ Some((&data.derived, p, parent, data.impl_def_id, data))
}
_ => None,
})
let _ = format_pred(*pred);
}
skip_list.insert(p);
- let mut spans = if cause_span != *item_span {
- let mut spans: MultiSpan = cause_span.into();
- spans.push_span_label(cause_span, unsatisfied_msg);
+ let mut spans = if cause.span != *item_span {
+ let mut spans: MultiSpan = cause.span.into();
+ spans.push_span_label(cause.span, unsatisfied_msg);
spans
} else {
ident.span.into()
// Unmet obligation coming from an `impl`.
Some(Node::Item(hir::Item {
- kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }),
+ kind:
+ hir::ItemKind::Impl(hir::Impl {
+ of_trait, self_ty, generics, ..
+ }),
span: item_span,
..
})) if !matches!(
Some(ExpnKind::Macro(MacroKind::Derive, _))
) =>
{
+ let sized_pred =
+ unsatisfied_predicates.iter().any(|(pred, _, _)| {
+ match pred.kind().skip_binder() {
+ ty::PredicateKind::Trait(pred) => {
+ Some(pred.def_id())
+ == self.tcx.lang_items().sized_trait()
+ && pred.polarity == ty::ImplPolarity::Positive
+ }
+ _ => false,
+ }
+ });
+ for param in generics.params {
+ if param.span == cause.span && sized_pred {
+ let (sp, sugg) = match param.colon_span {
+ Some(sp) => (sp.shrink_to_hi(), " ?Sized +"),
+ None => (param.span.shrink_to_hi(), ": ?Sized"),
+ };
+ err.span_suggestion_verbose(
+ sp,
+ "consider relaxing the type parameter's implicit \
+ `Sized` bound",
+ sugg,
+ Applicability::MachineApplicable,
+ );
+ }
+ }
if let Some(pred) = parent_p {
// Done to add the "doesn't satisfy" `span_label`.
let _ = format_pred(*pred);
}
skip_list.insert(p);
- let mut spans = if cause_span != *item_span {
- let mut spans: MultiSpan = cause_span.into();
- spans.push_span_label(cause_span, unsatisfied_msg);
+ let mut spans = if cause.span != *item_span {
+ let mut spans: MultiSpan = cause.span.into();
+ spans.push_span_label(cause.span, unsatisfied_msg);
spans
} else {
let mut spans = Vec::with_capacity(2);
let (migration_string, migrated_variables_concat) =
migration_suggestion_for_2229(self.tcx, &need_migrations);
- let local_def_id = closure_def_id.expect_local();
- let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
- let closure_span = self.tcx.hir().span(closure_hir_id);
- let closure_head_span = self.tcx.sess.source_map().guess_head_span(closure_span);
+ let closure_hir_id =
+ self.tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local());
+ let closure_head_span = self.tcx.def_span(closure_def_id);
self.tcx.struct_span_lint_hir(
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
closure_hir_id,
- closure_head_span,
+ closure_head_span,
|lint| {
let mut diagnostics_builder = lint.build(
&reasons.migration_message(),
migrated_variables_concat
);
+ let closure_span = self.tcx.hir().span_with_body(closure_hir_id);
let mut closure_body_span = {
// If the body was entirely expanded from a macro
// invocation, i.e. the body is not contained inside the
// closure span, then we walk up the expansion until we
// find the span before the expansion.
- let s = self.tcx.hir().span(body_id.hir_id);
+ let s = self.tcx.hir().span_with_body(body_id.hir_id);
s.find_ancestor_inside(closure_span).unwrap_or(s)
};
fcx.register_bound(
item_ty,
tcx.require_lang_item(LangItem::Sized, None),
- traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
+ traits::ObligationCause::new(ty_span, fcx.body_id, traits::WellFormed(None)),
);
}
// Main entry point
fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
- tcx.hir().deep_visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
+ tcx.hir().visit_item_likes_in_module(module_def_id, &mut CollectItemTypesVisitor { tcx });
}
pub fn provide(providers: &mut Providers) {
let cause = traits::ObligationCause::new(
ty.span,
self.hir_id,
- traits::ObligationCauseCode::MiscObligation,
+ traits::ObligationCauseCode::WellFormed(None),
);
fulfill.register_predicate_obligation(
&infcx,
/// on all futures.
///
/// ```no_run
-/// #![feature(into_future)]
-///
/// use std::future::IntoFuture;
///
/// # async fn foo() {
/// multiple times before being `.await`ed.
///
/// ```rust
-/// #![feature(into_future)]
-///
/// use std::future::{ready, Ready, IntoFuture};
///
/// /// Eventually multiply two numbers
/// `IntoFuture::into_future` to obtain an instance of `Future`:
///
/// ```rust
-/// #![feature(into_future)]
-///
/// use std::future::IntoFuture;
///
/// /// Convert the output of a future to a string.
/// format!("{:?}", fut.await)
/// }
/// ```
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
pub trait IntoFuture {
/// The output that the future will produce on completion.
- #[unstable(feature = "into_future", issue = "67644")]
+ #[stable(feature = "into_future", since = "1.64.0")]
type Output;
/// Which kind of future are we turning this into?
- #[unstable(feature = "into_future", issue = "67644")]
+ #[stable(feature = "into_future", since = "1.64.0")]
type IntoFuture: Future<Output = Self::Output>;
/// Creates a future from a value.
/// Basic usage:
///
/// ```no_run
- /// #![feature(into_future)]
- ///
/// use std::future::IntoFuture;
///
/// # async fn foo() {
/// assert_eq!("meow", fut.await);
/// # }
/// ```
- #[unstable(feature = "into_future", issue = "67644")]
+ #[stable(feature = "into_future", since = "1.64.0")]
#[lang = "into_future"]
fn into_future(self) -> Self::IntoFuture;
}
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
impl<F: Future> IntoFuture for F {
type Output = F::Output;
type IntoFuture = F;
#[unstable(feature = "future_join", issue = "91642")]
pub use self::join::join;
-#[unstable(feature = "into_future", issue = "67644")]
+#[stable(feature = "into_future", since = "1.64.0")]
pub use into_future::IntoFuture;
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
self.handle.main_thread_handle()
}
}
+
+/// Windows-specific extensions to [`process::ExitCode`].
+///
+/// This trait is sealed: it cannot be implemented outside the standard library.
+/// This is so that future additional methods are not breaking changes.
+#[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+pub trait ExitCodeExt: Sealed {
+ /// Creates a new `ExitCode` from the raw underlying `u32` return value of
+ /// a process.
+ ///
+ /// The exit code should not be 259, as this conflicts with the `STILL_ACTIVE`
+ /// macro returned from the `GetExitCodeProcess` function to signal that the
+ /// process has yet to run to completion.
+ #[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+ fn from_raw(raw: u32) -> Self;
+}
+
+#[unstable(feature = "windows_process_exit_code_from", issue = "none")]
+impl ExitCodeExt for process::ExitCode {
+ fn from_raw(raw: u32) -> Self {
+ process::ExitCode::from_inner(From::from(raw))
+ }
+}
#[stable(feature = "process_exitcode", since = "1.61.0")]
pub struct ExitCode(imp::ExitCode);
+/// Allows extension traits within `std`.
+#[unstable(feature = "sealed", issue = "none")]
+impl crate::sealed::Sealed for ExitCode {}
+
#[stable(feature = "process_exitcode", since = "1.61.0")]
impl ExitCode {
/// The canonical `ExitCode` for successful termination on this platform.
}
}
+impl AsInner<imp::ExitCode> for ExitCode {
+ fn as_inner(&self) -> &imp::ExitCode {
+ &self.0
+ }
+}
+
+impl FromInner<imp::ExitCode> for ExitCode {
+ fn from_inner(s: imp::ExitCode) -> ExitCode {
+ ExitCode(s)
+ }
+}
+
impl Child {
/// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
/// error is returned.
}
}
+impl From<u32> for ExitCode {
+ fn from(code: u32) -> Self {
+ ExitCode(c::DWORD::from(code))
+ }
+}
+
fn zeroed_startupinfo() -> c::STARTUPINFO {
c::STARTUPINFO {
cb: 0,
eprintln!(
"note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`"
);
- #[cfg(not(test))]
- std::process::exit(1);
- #[cfg(test)]
- // so we can use #[should_panic]
- panic!()
+ crate::detail_exit(1);
}
}
}
}
pub(crate) fn download_component(&self, url: &str, dest_path: &Path, help_on_error: &str) {
+ self.verbose(&format!("download {url}"));
// Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/.
let tempfile = self.tempdir().join(dest_path.file_name().unwrap());
// While bootstrap itself only supports http and https downloads, downstream forks might
if !help_on_error.is_empty() {
eprintln!("{}", help_on_error);
}
- std::process::exit(1);
+ crate::detail_exit(1);
}
}
"error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component"
);
eprintln!("help: try `rustup component add clippy`");
- std::process::exit(1);
+ crate::detail_exit(1);
});
if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") {
rustflags.arg("--cfg=bootstrap");
use std::io::prelude::*;
use std::io::BufReader;
use std::path::{Path, PathBuf};
-use std::process::{exit, Command, Stdio};
+use std::process::{Command, Stdio};
use std::str;
use serde::Deserialize;
});
if !ok {
- exit(1);
+ crate::detail_exit(1);
}
// Ok now we need to actually find all the files listed in `toplevel`. We've
use std::fmt;
use std::fs;
use std::path::{Path, PathBuf};
-use std::process::{exit, Command};
+use std::process::Command;
use std::str::FromStr;
use crate::builder::{Builder, TaskPath};
let get_toml = |_| TomlConfig::default();
#[cfg(not(test))]
let get_toml = |file: &Path| {
- use std::process;
-
let contents =
t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
// Deserialize to Value and then TomlConfig to prevent the Deserialize impl of
Ok(table) => table,
Err(err) => {
eprintln!("failed to parse TOML configuration '{}': {}", file.display(), err);
- process::exit(2);
+ crate::detail_exit(2);
}
}
};
println!("help: maybe your repository history is too shallow?");
println!("help: consider disabling `download-rustc`");
println!("help: or fetch enough history to include one upstream commit");
- exit(1);
+ crate::detail_exit(1);
}
// Warn if there were changes to the compiler or standard library since the ancestor commit.
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustdoc"));
let lib_dir = bin_root.join("lib");
- for lib in t!(fs::read_dir(lib_dir)) {
+ for lib in t!(fs::read_dir(&lib_dir), lib_dir.display().to_string()) {
let lib = t!(lib);
if lib.path().extension() == Some(OsStr::new("so")) {
builder.fix_bin_or_dylib(&lib.path());
}
Some(sha256)
} else if tarball.exists() {
+ builder.unpack(&tarball, &bin_root, prefix);
return;
} else {
None
//! has various flags to configure how it's run.
use std::path::PathBuf;
-use std::process;
use getopts::Options;
// subcommand.
println!("{}\n", subcommand_help);
let exit_code = if args.is_empty() { 0 } else { 1 };
- process::exit(exit_code);
+ crate::detail_exit(exit_code);
}
};
} else if verbose {
panic!("No paths available for subcommand `{}`", subcommand.as_str());
}
- process::exit(exit_code);
+ crate::detail_exit(exit_code);
};
// Done specifying what options are possible, so do the getopts parsing
"Sorry, I couldn't figure out which subcommand you were trying to specify.\n\
You may need to move some options to after the subcommand.\n"
);
- process::exit(1);
+ crate::detail_exit(1);
}
// Extra help text for some commands
match subcommand {
eprintln!("error: {}", err);
eprintln!("help: the available profiles are:");
eprint!("{}", Profile::all_for_help("- "));
- std::process::exit(1);
+ crate::detail_exit(1);
})
} else {
t!(crate::setup::interactive_path())
|| matches.opt_str("keep-stage-std").is_some()
{
eprintln!("--keep-stage not yet supported for x.py check");
- process::exit(1);
+ crate::detail_exit(1);
}
}
Some("warn") => Some(false),
Some(value) => {
eprintln!(r#"invalid value for --warnings: {:?}, expected "warn" or "deny""#, value,);
- process::exit(1);
+ crate::detail_exit(1);
}
None => None,
}
code, run `./x.py fmt` instead.",
cmd_debug,
);
- std::process::exit(1);
+ crate::detail_exit(1);
}
}
}
let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
eprintln!("./x.py fmt is not supported on this channel");
- std::process::exit(1);
+ crate::detail_exit(1);
});
assert!(rustfmt_path.exists(), "{}", rustfmt_path.display());
let src = build.src.clone();
use std::fs::{self, File};
use std::io;
use std::path::{Path, PathBuf};
-use std::process::{self, Command};
+use std::process::Command;
use std::str;
use filetime::FileTime;
for failure in failures.iter() {
eprintln!(" - {}\n", failure);
}
- process::exit(1);
+ detail_exit(1);
}
#[cfg(feature = "build-metrics")]
to download LLVM rather than building it.
"
);
- std::process::exit(1);
+ detail_exit(1);
}
}
#[cfg(windows)]
fn chmod(_path: &Path, _perms: u32) {}
+/// If code is not 0 (successful exit status), exit status is 101 (rust's default error code.)
+/// If the test is running and code is an error code, it will cause a panic.
+fn detail_exit(code: i32) -> ! {
+ // Successful exit
+ if code == 0 {
+ std::process::exit(0);
+ }
+ if cfg!(test) {
+ panic!("status code: {}", code);
+ } else {
+ std::panic::resume_unwind(Box::new(code));
+ }
+}
+
impl Compiler {
pub fn with_stage(mut self, stage: u32) -> Compiler {
self.stage = stage;
than building it.
"
);
- std::process::exit(1);
+ crate::detail_exit(1);
}
}
"note: this will use the configuration in {}",
profile.include_path(&config.src).display()
);
- std::process::exit(1);
+ crate::detail_exit(1);
}
let settings = format!(
io::stdin().read_line(&mut input)?;
if input.is_empty() {
eprintln!("EOF on stdin, when expecting answer to question. Giving up.");
- std::process::exit(1);
+ crate::detail_exit(1);
}
break match parse_with_abbrev(&input) {
Ok(profile) => profile,
}
if !builder.config.cmd.bless() {
- std::process::exit(1);
+ crate::detail_exit(1);
}
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
PATH = inferred_rustfmt_dir.display(),
CHAN = builder.config.channel,
);
- std::process::exit(1);
+ crate::detail_exit(1);
}
crate::format::format(&builder, !builder.config.cmd.bless(), &[]);
}
help: to test the standard library, use `--stage 0 library/std` instead
note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
);
- std::process::exit(1);
+ crate::detail_exit(1);
}
let compiler = self.compiler;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
-use std::process::{exit, Command};
+use std::process::Command;
use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
use crate::channel::GitInfo;
if !is_expected {
if !is_optional_tool {
- exit(1);
+ crate::detail_exit(1);
} else {
None
}
eprintln!("If you do NOT intend to update '{}', please ensure you did not accidentally", tool);
eprintln!("change the submodule at '{}'. You may ask your reviewer for the", submodule);
eprintln!("proper steps.");
- std::process::exit(3);
+ crate::detail_exit(3);
}
fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
Ok(o) => o,
Err(e) => {
eprintln!("Failed to get changed files: {:?}", e);
- std::process::exit(1);
+ crate::detail_exit(1);
}
};
}
if did_error {
- std::process::exit(1);
+ crate::detail_exit(1);
}
check_changed_files(&toolstates);
}
if did_error {
- std::process::exit(1);
+ crate::detail_exit(1);
}
if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) {
if !try_run(cmd, print_cmd_on_fail) {
- std::process::exit(1);
+ crate::detail_exit(1);
}
}
pub fn run_suppressed(cmd: &mut Command) {
if !try_run_suppressed(cmd) {
- std::process::exit(1);
+ crate::detail_exit(1);
}
}
fn fail(s: &str) -> ! {
eprintln!("\n\n{}\n\n", s);
- std::process::exit(1);
+ crate::detail_exit(1);
}
/// Copied from `std::path::absolute` until it stabilizes.
pub(crate) proc_macro_crate: bool,
/// How to format errors and warnings.
pub(crate) error_format: ErrorOutputType,
+ /// Width of output buffer to truncate errors appropriately.
+ pub(crate) diagnostic_width: Option<usize>,
/// Library search paths to hand to the compiler.
pub(crate) libs: Vec<SearchPath>,
/// Library search paths strings to hand to the compiler.
let config::JsonConfig { json_rendered, json_unused_externs, .. } =
config::parse_json(matches);
let error_format = config::parse_error_format(matches, color, json_rendered);
+ let diagnostic_width = matches.opt_get("diagnostic-width").unwrap_or_default();
let codegen_options = CodegenOptions::build(matches, error_format);
let debugging_opts = DebuggingOptions::build(matches, error_format);
- let diag = new_handler(error_format, None, &debugging_opts);
+ let diag = new_handler(error_format, None, diagnostic_width, &debugging_opts);
// check for deprecated options
check_deprecated_options(matches, &diag);
input,
proc_macro_crate,
error_format,
+ diagnostic_width,
libs,
lib_strs,
externs,
pub(crate) fn new_handler(
error_format: ErrorOutputType,
source_map: Option<Lrc<source_map::SourceMap>>,
+ diagnostic_width: Option<usize>,
debugging_opts: &DebuggingOptions,
) -> rustc_errors::Handler {
let fallback_bundle =
fallback_bundle,
short,
debugging_opts.teach,
- debugging_opts.terminal_width,
+ diagnostic_width,
false,
)
.ui_testing(debugging_opts.ui_testing),
fallback_bundle,
pretty,
json_rendered,
- debugging_opts.terminal_width,
+ diagnostic_width,
false,
)
.ui_testing(debugging_opts.ui_testing),
crate_name,
proc_macro_crate,
error_format,
+ diagnostic_width,
libs,
externs,
mut cfgs,
actually_rustdoc: true,
debugging_opts,
error_format,
+ diagnostic_width,
edition,
describe_lints,
crate_name,
}
}
+#[derive(Clone, Copy, PartialEq, Eq)]
+pub(crate) enum Ending {
+ Newline,
+ NoNewline,
+}
+
/// * The Generics from which to emit a where-clause.
/// * The number of spaces to indent each line with.
/// * Whether the where-clause needs to add a comma and newline after the last bound.
gens: &'a clean::Generics,
cx: &'a Context<'tcx>,
indent: usize,
- end_newline: bool,
+ ending: Ending,
) -> impl fmt::Display + 'a + Captures<'tcx> {
use fmt::Write;
let where_preds = comma_sep(where_predicates, false);
let clause = if f.alternate() {
- if end_newline {
+ if ending == Ending::Newline {
// add a space so stripping <br> tags and breaking spaces still renders properly
format!(" where{where_preds}, ")
} else {
}
let where_preds = where_preds.to_string().replace("<br>", &br_with_padding);
- if end_newline {
+ if ending == Ending::Newline {
let mut clause = " ".repeat(indent.saturating_sub(1));
// add a space so stripping <br> tags and breaking spaces still renders properly
write!(
fmt_type(&self.for_, f, use_absolute, cx)?;
}
- fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, true), f)?;
+ fmt::Display::fmt(&print_where_clause(&self.generics, cx, 0, Ending::Newline), f)?;
Ok(())
})
}
use crate::html::escape::Escape;
use crate::html::format::{
href, join_with_double_colon, print_abi_with_space, print_constness_with_space,
- print_default_space, print_generic_bounds, print_where_clause, Buffer, HrefError,
+ print_default_space, print_generic_bounds, print_where_clause, Buffer, Ending, HrefError,
PrintWithSpace,
};
use crate::html::highlight;
if !bounds.is_empty() {
write!(w, ": {}", print_generic_bounds(bounds, cx))
}
- write!(w, "{}", print_where_clause(generics, cx, indent, false));
+ write!(w, "{}", print_where_clause(generics, cx, indent, Ending::NoNewline));
if let Some(default) = default {
write!(w, " = {}", default.print(cx))
}
header_len += 4;
let indent_str = " ";
render_attributes_in_pre(w, meth, indent_str);
- (4, indent_str, false)
+ (4, indent_str, Ending::NoNewline)
} else {
render_attributes_in_code(w, meth);
- (0, "", true)
+ (0, "", Ending::Newline)
};
w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
write!(
use crate::html::escape::Escape;
use crate::html::format::{
join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause,
- Buffer, PrintWithSpace,
+ Buffer, Ending, PrintWithSpace,
};
use crate::html::highlight;
use crate::html::layout::Page;
cx: &'a Context<'tcx>,
) -> bool {
let len_before = buffer.len();
- write!(buffer, "{}", print_where_clause(gens, cx, 0, true));
+ write!(buffer, "{}", print_where_clause(gens, cx, 0, Ending::Newline));
len_before != buffer.len()
}
abi = abi,
name = name,
generics = f.generics.print(cx),
- where_clause = print_where_clause(&f.generics, cx, 0, true),
+ where_clause = print_where_clause(&f.generics, cx, 0, Ending::Newline),
decl = f.decl.full_print(header_len, 0, header.asyncness, cx),
notable_traits = notable_traits_decl(&f.decl, cx),
);
);
if !t.generics.where_predicates.is_empty() {
- write!(w, "{}", print_where_clause(&t.generics, cx, 0, true));
+ write!(w, "{}", print_where_clause(&t.generics, cx, 0, Ending::Newline));
} else {
w.write_str(" ");
}
"trait {}{}{} = {};",
it.name.unwrap(),
t.generics.print(cx),
- print_where_clause(&t.generics, cx, 0, true),
+ print_where_clause(&t.generics, cx, 0, Ending::Newline),
bounds(&t.bounds, true, cx)
);
});
"type {}{}{where_clause} = impl {bounds};",
it.name.unwrap(),
t.generics.print(cx),
- where_clause = print_where_clause(&t.generics, cx, 0, true),
+ where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
bounds = bounds(&t.bounds, false, cx),
);
});
"type {}{}{where_clause} = {type_};",
it.name.unwrap(),
t.generics.print(cx),
- where_clause = print_where_clause(&t.generics, cx, 0, true),
+ where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline),
type_ = t.type_.print(cx),
);
});
}
w.write_str(")");
if let Some(g) = g {
- write!(w, "{}", print_where_clause(g, cx, 0, false));
+ write!(w, "{}", print_where_clause(g, cx, 0, Ending::NoNewline));
}
// We only want a ";" when we are displaying a tuple struct, not a variant tuple struct.
if structhead {
CtorKind::Const => {
// Needed for PhantomData.
if let Some(g) = g {
- write!(w, "{}", print_where_clause(g, cx, 0, false));
+ write!(w, "{}", print_where_clause(g, cx, 0, Ending::NoNewline));
}
w.write_str(";");
}
"human|json|short",
)
}),
+ unstable("diagnostic-width", |o| {
+ o.optopt(
+ "",
+ "diagnostic-width",
+ "Provide width of the output for truncated error messages",
+ "WIDTH",
+ )
+ }),
stable("json", |o| {
o.optopt("", "json", "Configure the structure of JSON diagnostics", "CONFIG")
}),
}
fn main_options(options: config::Options) -> MainResult {
- let diag = core::new_handler(options.error_format, None, &options.debugging_opts);
+ let diag = core::new_handler(
+ options.error_format,
+ None,
+ options.diagnostic_width,
+ &options.debugging_opts,
+ );
match (options.should_test, options.markdown_input()) {
(true, true) => return wrap_return(&diag, markdown::test(options)),
None,
None,
);
- let expn_id = LocalExpnId::fresh(expn_data, self.cx.tcx.create_stable_hashing_context());
+ let expn_id =
+ self.cx.tcx.with_stable_hashing_context(|hcx| LocalExpnId::fresh(expn_data, hcx));
let span = DUMMY_SP.fresh_expansion(expn_id);
let is_empty = rustc_driver::catch_fatal_errors(|| {
// Run call-finder on all items
let mut calls = FxHashMap::default();
let mut finder = FindCalls { calls: &mut calls, tcx, map: tcx.hir(), cx, target_crates };
- tcx.hir().deep_visit_all_item_likes(&mut finder);
+ tcx.hir().visit_all_item_likes_in_crate(&mut finder);
// Sort call locations within a given file in document order
for fn_calls in calls.values_mut() {
// CHECK: @STATIC = {{.*}}, align 4
// This checks the constants from inline_enum_const
-// CHECK: @alloc14 = {{.*}}, align 2
+// CHECK: @alloc12 = {{.*}}, align 2
// This checks the constants from {low,high}_align_const, they share the same
// constant, but the alignment differs, so the higher one should be used
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant1", scope: [[GEN]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant2", scope: [[GEN]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "variant3", scope: [[GEN]],
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "1", scope: [[VARIANT]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "2", scope: [[VARIANT]],
-// CHECK-SAME: file: [[FILE]], line: 18,
+// CHECK-SAME: file: [[FILE]], line: 14,
// CHECK-NOT: flags: DIFlagArtificial
// CHECK-SAME: )
// CHECK: {{!.*}} = !DIDerivedType(tag: DW_TAG_member, name: "3", scope: [[VARIANT]],
},
} */
-fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 13:6]) -> () {
- let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
- let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+ let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
let _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:18: 10:18
- let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
- let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+ let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
scope 1 {
debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
}
bb0: {
- _8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
- switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ _8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+ switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb1: {
}
bb3: {
- return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb4 (cleanup): {
- resume; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ resume; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb5 (cleanup): {
}
bb6: {
- return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb7: {
- goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb8: {
}
bb9: {
- goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb10: {
- StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
- StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
- goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+ StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
+ goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
bb11: {
- return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
+ return; // scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 10:17
}
}
// MIR for `main::{closure#0}` before StateTransform
-fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6], _2: ()) -> ()
+fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 22:18], _2: ()) -> ()
yields ()
{
let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19
}
bb4: {
- return; // scope 0 at $DIR/generator-storage-dead-unwind.rs:28:6: 28:6
+ return; // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:18: 22:18
}
bb5: {
}
bb7: {
- generator_drop; // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+ generator_drop; // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 22:18
}
bb8 (cleanup): {
}
bb11 (cleanup): {
- resume; // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6
+ resume; // scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 22:18
}
bb12 (cleanup): {
},
} */
-fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]>, _2: u8) -> GeneratorState<(), ()> {
+fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> {
debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
- let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
let mut _4: !; // in scope 0 at $DIR/generator-tiny.rs:21:9: 24:10
- let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
let _6: u8; // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18
let mut _7: (); // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:18
let _8: (); // in scope 0 at $DIR/generator-tiny.rs:23:13: 23:21
let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:19:25: 19:25
let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
- let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
scope 1 {
- debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
+ debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
}
bb0: {
- _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
- switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+ switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
}
bb1: {
- _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
nop; // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
- Deinit((((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6])) as variant#3).0: HasDrop)); // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
+ Deinit((((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop)); // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
}
Deinit(_0); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
discriminant(_0) = 0; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
- discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
+ discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
}
}
bb5: {
- StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
- StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
- StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
- _6 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
- goto -> bb3; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+ StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+ StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+ _6 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
+ goto -> bb3; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
}
bb6: {
- unreachable; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
+ unreachable; // scope 0 at $DIR/generator-tiny.rs:19:16: 19:24
}
}
debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18
let mut _10: i32; // in scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
let mut _11: T; // in scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23
- let mut _12: &i32; // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:24
- let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:24
+ let mut _12: &i32; // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:17
+ let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:11:13: 11:17
}
}
Deinit(_3); // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
(_3.0: &i32) = move _4; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
(_3.1: &T) = move _5; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
- StorageDead(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
- StorageDead(_4); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
+ StorageDead(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:16: 11:17
+ StorageDead(_4); // scope 0 at $DIR/inline-closure-captures.rs:11:16: 11:17
StorageLive(_6); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
_6 = &_3; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
StorageLive(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-generator.rs:8:11: 8:11
let _1: std::ops::GeneratorState<i32, bool>; // in scope 0 at $DIR/inline-generator.rs:9:9: 9:11
- let mut _2: std::pin::Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32
- let mut _3: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31
- let mut _4: [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31
+ let mut _2: std::pin::Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32
+ let mut _3: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31
+ let mut _4: [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31
+ let mut _7: bool; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:46
scope 1 {
debug _r => _1; // in scope 1 at $DIR/inline-generator.rs:9:9: 9:11
}
+ scope 2 (inlined g) { // at $DIR/inline-generator.rs:9:28: 9:31
+ }
-+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
++ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
+ debug pointer => _3; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
-+ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
++ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL
+ scope 4 {
-+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL
+ debug pointer => _5; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
+ }
+ }
+ }
+ let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:15:20: 15:21
+ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9
+ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7
-+ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:8
+ }
bb0: {
+ Deinit(_4); // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
+ discriminant(_4) = 0; // scope 2 at $DIR/inline-generator.rs:15:5: 15:41
_3 = &mut _4; // scope 0 at $DIR/inline-generator.rs:9:23: 9:31
-- _2 = Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
+- _2 = Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
- // mir::Constant
- // + span: $DIR/inline-generator.rs:9:14: 9:22
- // + user_ty: UserType(0)
-- // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new}, val: Value(Scalar(<ZST>)) }
+- // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new}, val: Value(Scalar(<ZST>)) }
- }
-
- bb2: {
+ StorageLive(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
+ _6 = move _5; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
+ Deinit(_2); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
-+ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
++ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
+ StorageDead(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL
+ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL
StorageDead(_3); // scope 0 at $DIR/inline-generator.rs:9:31: 9:32
-- _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+- _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
- // mir::Constant
- // + span: $DIR/inline-generator.rs:9:33: 9:39
-- // + literal: Const { ty: for<'r> fn(Pin<&'r mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:41] as Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) }
+- // + literal: Const { ty: for<'r> fn(Pin<&'r mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) }
+ StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ _7 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
-+ StorageLive(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ StorageDead(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ StorageLive(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ StorageDead(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
}
- bb3: {
+ }
+
+ bb3: {
-+ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:17: 15:39
+ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
+ _9 = _11; // scope 6 at $DIR/inline-generator.rs:15:20: 15:21
+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ StorageLive(_14); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
-+ _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
++ _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ discriminant((*_14)) = 3; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ StorageDead(_14); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39
+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
+ }
+
+ bb7: {
-+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
-+ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
++ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
+ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:15:38: 15:39
-+ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ StorageLive(_15); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ StorageDead(_15); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41
-+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
++ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ StorageLive(_15); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ StorageDead(_15); // scope 6 at $DIR/inline-generator.rs:15:8: 15:8
++ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:8: 15:8
+ }
+
+ bb8: {
-+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
+ }
+
+ bb9: {
-+ unreachable; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41
++ unreachable; // scope 6 at $DIR/inline-generator.rs:15:5: 15:8
}
}
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:4:11: 4:11
- let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:33]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
- let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:33]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:6
+ let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:5:9: 5:10
+ let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:6
let mut _3: ((),); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
let mut _4: (); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:7: 6:9
let mut _5: (); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10
}
bb0: {
- Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:40:31: 43:6
- Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:40:31: 43:6
+ Retag([fn entry] _1); // scope 0 at $DIR/retag.rs:40:31: 40:48
+ Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:40:31: 40:48
StorageLive(_3); // scope 0 at $DIR/retag.rs:41:13: 41:15
_3 = _2; // scope 0 at $DIR/retag.rs:41:18: 41:19
Retag(_3); // scope 0 at $DIR/retag.rs:41:18: 41:19
_0 = _2; // scope 1 at $DIR/retag.rs:42:9: 42:10
Retag(_0); // scope 1 at $DIR/retag.rs:42:9: 42:10
StorageDead(_3); // scope 0 at $DIR/retag.rs:43:5: 43:6
- return; // scope 0 at $DIR/retag.rs:43:6: 43:6
+ return; // scope 0 at $DIR/retag.rs:40:48: 40:48
}
}
// ]
Retag(_14); // scope 1 at $DIR/retag.rs:40:31: 43:6
_13 = move _14 as for<'r> fn(&'r i32) -> &'r i32 (Pointer(ClosureFnPointer(Normal))); // scope 1 at $DIR/retag.rs:40:31: 43:6
- StorageDead(_14); // scope 1 at $DIR/retag.rs:43:5: 43:6
+ StorageDead(_14); // scope 1 at $DIR/retag.rs:40:47: 40:48
StorageLive(_15); // scope 6 at $DIR/retag.rs:44:9: 44:11
StorageLive(_16); // scope 6 at $DIR/retag.rs:44:14: 44:15
_16 = _13; // scope 6 at $DIR/retag.rs:44:14: 44:15
37| 0| countdown = 10;
38| 0| }
39| 0| "alt string 2".to_owned()
- 40| 0| };
+ 40| | };
41| 1| println!(
42| 1| "The string or alt: {}"
43| 1| ,
79| 0| countdown = 10;
80| 1| }
81| 1| "alt string 4".to_owned()
- 82| 1| };
+ 82| | };
83| 1| println!(
84| 1| "The string or alt: {}"
85| 1| ,
101| 0| countdown = 10;
102| 5| }
103| 5| format!("'{}'", val)
- 104| 5| };
+ 104| | };
105| 1| println!(
106| 1| "Repeated, quoted string: {:?}"
107| 1| ,
125| 0| countdown = 10;
126| 0| }
127| 0| "closure should be unused".to_owned()
- 128| 0| };
+ 128| | };
129| |
130| 1| let mut countdown = 10;
131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
173| 0| println!(
174| 0| "not called: {}",
175| 0| if is_true { "check" } else { "me" }
- 176| 0| )
+ 176| | )
177| | ;
178| |
179| 1| let short_used_not_covered_closure_line_break_block_embedded_branch =
183| 0| "not called: {}",
184| 0| if is_true { "check" } else { "me" }
185| | )
- 186| 0| }
+ 186| | }
187| | ;
188| |
189| 1| let short_used_covered_closure_line_break_no_block_embedded_branch =
192| 1| "not called: {}",
193| 1| if is_true { "check" } else { "me" }
^0
- 194| 1| )
+ 194| | )
195| | ;
196| |
197| 1| let short_used_covered_closure_line_break_block_embedded_branch =
202| 1| if is_true { "check" } else { "me" }
^0
203| | )
- 204| 1| }
+ 204| | }
205| | ;
206| |
207| 1| if is_false {
17| 1| let mut generator = || {
18| 1| yield get_u32(is_true);
19| 1| return "foo";
- 20| 1| };
+ 20| | };
21| |
22| 1| match Pin::new(&mut generator).resume(()) {
23| 1| GeneratorState::Yielded(Ok(1)) => {}
8| 1| let mut generator = || {
9| 1| yield 1;
10| 1| return "foo"
- 11| 1| };
+ 11| | };
12| |
13| 1| match Pin::new(&mut generator).resume(()) {
14| 1| GeneratorState::Yielded(1) => {}
24| 1| yield 2;
25| 0| yield 3;
26| 0| return "foo"
- 27| 0| };
+ 27| | };
28| |
29| 1| match Pin::new(&mut generator).resume(()) {
30| 1| GeneratorState::Yielded(1) => {}
never = never colorize output
--error-format human|json|short
How errors and other messages are produced
+ --diagnostic-width WIDTH
+ Provide width of the output for truncated error
+ messages
--json CONFIG Configure the structure of JSON diagnostics
--disable-minification
Disable minification applied on JS files
--- /dev/null
+// compile-flags: -Zunstable-options --diagnostic-width=10
+#![deny(rustdoc::bare_urls)]
+
+/// This is a long line that contains a http://link.com
+pub struct Foo; //~^ ERROR
--- /dev/null
+error: this URL is not a hyperlink
+ --> $DIR/diagnostic-width.rs:4:41
+ |
+LL | ... a http://link.com
+ | ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://link.com>`
+ |
+note: the lint level is defined here
+ --> $DIR/diagnostic-width.rs:2:9
+ |
+LL | ...ny(rustdoc::bare_url...
+ | ^^^^^^^^^^^^^^^^^^
+ = note: bare URLs are not automatically turned into clickable links
+
+error: aborting due to previous error
+
let x: u64;
asm!("{}", in(reg) x);
- //~^ ERROR use of possibly-uninitialized variable: `x`
+ //~^ ERROR used binding `x` isn't initialized
let mut y: u64;
asm!("{}", inout(reg) y);
- //~^ ERROR use of possibly-uninitialized variable: `y`
+ //~^ ERROR used binding `y` isn't initialized
let _ = y;
// Outputs require mutable places
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/type-check-2-2.rs:19:28
|
+LL | let x: u64;
+ | - binding declared here but left uninitialized
LL | asm!("{}", in(reg) x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
--> $DIR/type-check-2-2.rs:22:9
|
+LL | let mut y: u64;
+ | ----- binding declared here but left uninitialized
LL | asm!("{}", inout(reg) y);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ `y` used here but it isn't initialized
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-2-2.rs:30:29
|
= note: `SimdNonCopy` does not implement the Copy trait
-error: cannot use value of type `[closure@$DIR/type-check-2.rs:41:28: 41:38]` for inline assembly
+error: cannot use value of type `[closure@$DIR/type-check-2.rs:41:28: 41:36]` for inline assembly
--> $DIR/type-check-2.rs:41:28
|
LL | asm!("{}", in(reg) |x: i32| x);
|
= note: `SimdNonCopy` does not implement the Copy trait
-error: cannot use value of type `[closure@$DIR/type-check-2.rs:52:28: 52:38]` for inline assembly
+error: cannot use value of type `[closure@$DIR/type-check-2.rs:52:28: 52:36]` for inline assembly
--> $DIR/type-check-2.rs:52:28
|
LL | asm!("{}", in(reg) |x: i32| x);
let x: u64;
asm!("{}", in(reg) x);
- //~^ ERROR use of possibly-uninitialized variable: `x`
+ //~^ ERROR E0381
let mut y: u64;
asm!("{}", inout(reg) y);
- //~^ ERROR use of possibly-uninitialized variable: `y`
+ //~^ ERROR E0381
let _ = y;
// Outputs require mutable places
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/type-check-5.rs:15:28
|
+LL | let x: u64;
+ | - binding declared here but left uninitialized
LL | asm!("{}", in(reg) x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
--> $DIR/type-check-5.rs:18:9
|
+LL | let mut y: u64;
+ | ----- binding declared here but left uninitialized
LL | asm!("{}", inout(reg) y);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `y`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ `y` used here but it isn't initialized
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
--> $DIR/type-check-5.rs:26:29
--> $DIR/associated-item-enum.rs:17:11
|
LL | enum Enum { Variant }
- | ---- variant or associated item `mispellable` not found for this enum
+ | --------- variant or associated item `mispellable` not found for this enum
...
LL | Enum::mispellable();
| ^^^^^^^^^^^
--> $DIR/associated-item-enum.rs:18:11
|
LL | enum Enum { Variant }
- | ---- variant or associated item `mispellable_trait` not found for this enum
+ | --------- variant or associated item `mispellable_trait` not found for this enum
...
LL | Enum::mispellable_trait();
| ^^^^^^^^^^^^^^^^^
--> $DIR/associated-item-enum.rs:19:11
|
LL | enum Enum { Variant }
- | ---- variant or associated item `MISPELLABLE` not found for this enum
+ | --------- variant or associated item `MISPELLABLE` not found for this enum
...
LL | Enum::MISPELLABLE;
| ^^^^^^^^^^^
// run-pass
// aux-build: issue-72470-lib.rs
// edition:2021
-#![feature(into_future)]
-
extern crate issue_72470_lib;
use std::{future::{Future, IntoFuture}, pin::Pin};
note: required because it's used within this closure
--> $DIR/issue-70935-complex-spans.rs:25:13
|
-LL | baz(|| async{
- | _____________^
-LL | | foo(tx.clone());
-LL | | }).await;
- | |_________^
+LL | baz(|| async{
+ | ^^
note: required because it's used within this `async fn` body
--> $DIR/issue-70935-complex-spans.rs:9:67
|
LL | | }).await;
| | - ^^^^^^ await occurs here, with the value maybe used later
| |_________|
- | has type `[closure@$DIR/issue-70935-complex-spans.rs:25:13: 27:10]` which is not `Send`
+ | has type `[closure@$DIR/issue-70935-complex-spans.rs:25:13: 25:15]` which is not `Send`
note: the value is later dropped here
--> $DIR/issue-70935-complex-spans.rs:27:17
|
LL | (|_| 2333).await;
| ^^^^^^ only allowed inside `async` functions and blocks
-error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
+error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future
--> $DIR/issue-62009-1.rs:12:15
|
LL | (|_| 2333).await;
- | ^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
+ | ^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future
|
- = help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
- = note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
- = note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
+ = help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]`
+ = note: [closure@$DIR/issue-62009-1.rs:12:6: 12:9] must be a future or must implement `IntoFuture` to be awaited
+ = note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]`
help: remove the `.await`
|
LL - (|_| 2333).await;
if x > 5 {
y = echo(10).await;
}
- y
- //~^ use of possibly-uninitialized variable: `y`
+ y //~ ERROR E0381
}
async fn echo(x: usize) -> usize { x + 1 }
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` is possibly-uninitialized
--> $DIR/no-non-guaranteed-initialization.rs:9:5
|
+LL | let y;
+ | - binding declared here but left uninitialized
+LL | if x > 5 {
+ | ----- if this `if` condition is `false`, `y` is not initialized
+LL | y = echo(10).await;
+LL | }
+ | - an `else` arm might be missing here, initializing `y`
LL | y
- | ^ use of possibly-uninitialized `y`
+ | ^ `y` used here but it is possibly-uninitialized
error: aborting due to previous error
async fn test_tuple() {
let mut t: (i32, i32);
- t.0 = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 42; //~ ERROR E0381
noop().await;
t.1 = 88;
let _ = t;
async fn test_tuple_struct() {
let mut t: T;
- t.0 = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 42; //~ ERROR E0381
noop().await;
t.1 = 88;
let _ = t;
async fn test_struct() {
let mut t: S;
- t.x = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.x = 42; //~ ERROR E0381
noop().await;
t.y = 88;
let _ = t;
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/partial-initialization-across-await.rs:13:5
|
+LL | let mut t: (i32, i32);
+ | ----- binding declared here but left uninitialized
LL | t.0 = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/partial-initialization-across-await.rs:22:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/partial-initialization-across-await.rs:21:5
|
+LL | let mut t: T;
+ | ----- binding declared here but left uninitialized
LL | t.0 = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/partial-initialization-across-await.rs:31:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/partial-initialization-across-await.rs:29:5
|
+LL | let mut t: S;
+ | ----- binding declared here but left uninitialized
LL | t.x = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 3 previous errors
--> $DIR/pin-needed-to-poll.rs:42:20
|
LL | struct Sleep;
- | ----- method `poll` not found for this struct
+ | ------------ method `poll` not found for this struct
...
LL | self.sleep.poll(cx)
| ^^^^ method not found in `Sleep`
| ^^^^^^^^^ expected `()`, found closure
|
= note: expected unit type `()`
- found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14]`
+ found closure `[closure@$DIR/issue-20862.rs:2:5: 2:8]`
error[E0618]: expected function, found `()`
--> $DIR/issue-20862.rs:7:13
--> $DIR/bogus-tag.rs:7:16
|
LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }
- | ----- variant or associated item `Hsl` not found for this enum
+ | ---------- variant or associated item `Hsl` not found for this enum
...
LL | Color::Hsl(h, s, l) => { println!("hsl"); }
| ^^^ variant or associated item not found in `Color`
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/assign_mutable_fields.rs:9:5
|
+LL | let mut x: (u32, u32);
+ | ----- binding declared here but left uninitialized
LL | x.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/assign_mutable_fields.rs:17:5
|
+LL | let mut x: (u32, u32);
+ | ----- binding declared here but left uninitialized
LL | x.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 2 previous errors
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation-impl-trait.rs:11:9
|
-LL | fn bar() -> impl Fn() -> usize {
- | --- ------------------ change this to return `FnMut` instead of `Fn`
-LL | let mut x = 0;
-LL | / move || {
-LL | | x += 1;
- | | ^^^^^^ cannot assign
-LL | | x
-LL | | }
- | |_____- in this closure
+LL | fn bar() -> impl Fn() -> usize {
+ | --- ------------------ change this to return `FnMut` instead of `Fn`
+LL | let mut x = 0;
+LL | move || {
+ | ------- in this closure
+LL | x += 1;
+ | ^^^^^^ cannot assign
error: aborting due to previous error
| - change this to accept `FnMut` instead of `Fn`
...
LL | let _f = to_fn(|| x = 42);
- | ----- ^^^^^^ cannot assign
- | |
+ | ----- -- ^^^^^^ cannot assign
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
| - change this to accept `FnMut` instead of `Fn`
...
LL | let _g = to_fn(|| set(&mut y));
- | ----- ^^^^^^ cannot borrow as mutable
- | |
+ | ----- -- ^^^^^^ cannot borrow as mutable
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
| - change this to accept `FnMut` instead of `Fn`
...
LL | to_fn(|| z = 42);
- | ----- ^^^^^^ cannot assign
- | |
+ | ----- -- ^^^^^^ cannot assign
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
| - change this to accept `FnMut` instead of `Fn`
...
LL | let _f = to_fn(move || x = 42);
- | ----- ^^^^^^ cannot assign
- | |
+ | ----- ------- ^^^^^^ cannot assign
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
| - change this to accept `FnMut` instead of `Fn`
...
LL | let _g = to_fn(move || set(&mut y));
- | ----- ^^^^^^ cannot borrow as mutable
- | |
+ | ----- ------- ^^^^^^ cannot borrow as mutable
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
| - change this to accept `FnMut` instead of `Fn`
...
LL | to_fn(move || z = 42);
- | ----- ^^^^^^ cannot assign
- | |
+ | ----- ------- ^^^^^^ cannot assign
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:53:9
|
-LL | fn foo() -> Box<dyn Fn() -> usize> {
- | --- ---------------------- change this to return `FnMut` instead of `Fn`
-LL | let mut x = 0;
-LL | Box::new(move || {
- | ______________-
-LL | | x += 1;
- | | ^^^^^^ cannot assign
-LL | | x
-LL | | })
- | |_____- in this closure
+LL | fn foo() -> Box<dyn Fn() -> usize> {
+ | --- ---------------------- change this to return `FnMut` instead of `Fn`
+LL | let mut x = 0;
+LL | Box::new(move || {
+ | ------- in this closure
+LL | x += 1;
+ | ^^^^^^ cannot assign
error: aborting due to 7 previous errors
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-raw-address-of-mutability.rs:29:17
|
-LL | fn make_fn<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn make_fn<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | let f = make_fn(|| {
- | _____________-------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | let y = &raw mut x;
- | | ^^^^^^^^^^ cannot borrow as mutable
-LL | | });
- | |_____- in this closure
+LL | let f = make_fn(|| {
+ | ------- -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | let y = &raw mut x;
+ | ^^^^^^^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-raw-address-of-mutability.rs:37:17
|
-LL | fn make_fn<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn make_fn<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | let f = make_fn(move || {
- | _____________-------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | let y = &raw mut x;
- | | ^^^^^^^^^^ cannot borrow as mutable
-LL | | });
- | |_____- in this closure
+LL | let f = make_fn(move || {
+ | ------- ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | let y = &raw mut x;
+ | ^^^^^^^^^^ cannot borrow as mutable
error: aborting due to 5 previous errors
let i: isize;
println!("{}", false && { i = 5; true });
- println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
+ println!("{}", i); //~ ERROR E0381
}
-error[E0381]: borrow of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` is possibly-uninitialized
--> $DIR/borrowck-and-init.rs:5:20
|
+LL | let i: isize;
+ | - binding declared here but left uninitialized
+LL |
+LL | println!("{}", false && { i = 5; true });
+ | ----- binding initialized here in some conditions
LL | println!("{}", i);
- | ^ use of possibly-uninitialized `i`
+ | ^ `i` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
fn force<F>(f: F) where F: FnOnce() { f(); }
fn main() {
let x: isize;
- force(|| { //~ ERROR borrow of possibly-uninitialized variable: `x`
+ force(|| { //~ ERROR E0381
println!("{}", x);
});
}
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-block-unint.rs:4:11
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | force(|| {
- | ^^ use of possibly-uninitialized `x`
+ | ^^ `x` used here but it isn't initialized
LL | println!("{}", x);
| - borrow occurs due to use in closure
x = 0;
}
- println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+ println!("{}", x); //~ ERROR E0381
return 17;
}
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-break-uninit-2.rs:9:20
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
+...
LL | println!("{}", x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
x = 0;
}
- println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+ println!("{}", x); //~ ERROR E0381
return 17;
}
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-break-uninit.rs:9:20
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
+...
LL | println!("{}", x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
fn copy_after_field_assign_after_uninit() {
let mut x: A;
- x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
+ x.a = 1; //~ ERROR E0381
drop(x.a);
}
fn borrow_after_field_assign_after_uninit() {
let mut x: A;
- x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
+ x.a = 1; //~ ERROR E0381
let p = &x.a;
drop(*p);
}
fn move_after_field_assign_after_uninit() {
let mut x: A;
- x.b = Box::new(1); //~ ERROR assign to part of possibly-uninitialized variable: `x`
+ x.b = Box::new(1); //~ ERROR E0381
drop(x.b);
}
|
= note: move occurs because `x.b` has type `Box<isize>`, which does not implement the `Copy` trait
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/borrowck-field-sensitivity.rs:81:5
|
+LL | let mut x: A;
+ | ----- binding declared here but left uninitialized
LL | x.a = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/borrowck-field-sensitivity.rs:87:5
|
+LL | let mut x: A;
+ | ----- binding declared here but left uninitialized
LL | x.a = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/borrowck-field-sensitivity.rs:94:5
|
+LL | let mut x: A;
+ | ----- binding declared here but left uninitialized
LL | x.b = Box::new(1);
- | ^^^ use of possibly-uninitialized `x`
+ | ^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 14 previous errors
--- /dev/null
+fn f() -> isize {
+ let mut x: isize;
+ for _ in 0..0 { x = 10; }
+ return x; //~ ERROR E0381
+}
+
+fn main() { f(); }
--- /dev/null
+error[E0381]: used binding `x` is possibly-uninitialized
+ --> $DIR/borrowck-for-loop-uninitialized-binding.rs:4:12
+ |
+LL | let mut x: isize;
+ | ----- binding declared here but left uninitialized
+LL | for _ in 0..0 { x = 10; }
+ | ---- if the `for` loop runs 0 times, `x` is not initialized
+LL | return x;
+ | ^ `x` used here but it is possibly-uninitialized
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0381`.
fn main() {
let x: isize; if 1 > 2 { x = 10; }
- foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+ foo(x); //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
--> $DIR/borrowck-if-no-else.rs:5:9
|
+LL | let x: isize; if 1 > 2 { x = 10; }
+ | - ----- - an `else` arm might be missing here, initializing `x`
+ | | |
+ | | if this `if` condition is `false`, `x` is not initialized
+ | binding declared here but left uninitialized
LL | foo(x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it is possibly-uninitialized
error: aborting due to previous error
} else {
x = 10;
}
- foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+ foo(x); //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
--> $DIR/borrowck-if-with-else.rs:10:9
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
+LL | if 1 > 2 {
+ | ----- if this condition is `true`, `x` is not initialized
+...
LL | foo(x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it is possibly-uninitialized
error: aborting due to previous error
LL | let x = Box::new(0);
| - captured outer variable
LL | Box::new(|| x)
- | ---^
- | | |
- | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | -- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `Fn` closure
error: aborting due to previous error
fn main() {
let j = || -> isize {
let i: isize;
- i //~ ERROR use of possibly-uninitialized variable: `i`
+ i //~ ERROR E0381
};
j();
}
-error[E0381]: use of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` isn't initialized
--> $DIR/borrowck-init-in-called-fn-expr.rs:4:9
|
+LL | let i: isize;
+ | - binding declared here but left uninitialized
LL | i
- | ^ use of possibly-uninitialized `i`
+ | ^ `i` used here but it isn't initialized
error: aborting due to previous error
fn main() {
let f = || -> isize {
let i: isize;
- i //~ ERROR use of possibly-uninitialized variable: `i`
+ i //~ ERROR E0381
};
println!("{}", f());
}
-error[E0381]: use of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` isn't initialized
--> $DIR/borrowck-init-in-fn-expr.rs:4:9
|
+LL | let i: isize;
+ | - binding declared here but left uninitialized
LL | i
- | ^ use of possibly-uninitialized `i`
+ | ^ `i` used here but it isn't initialized
error: aborting due to previous error
fn main() {
let mut origin: Point;
origin = Point { x: 10, ..origin };
- //~^ ERROR use of possibly-uninitialized variable: `origin` [E0381]
+ //~^ ERROR E0381
origin.clone();
}
-error[E0381]: use of possibly-uninitialized variable: `origin`
+error[E0381]: used binding `origin` isn't initialized
--> $DIR/borrowck-init-in-fru.rs:9:14
|
+LL | let mut origin: Point;
+ | ---------- binding declared here but left uninitialized
LL | origin = Point { x: 10, ..origin };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `origin.y`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ `origin.y` used here but it isn't initialized
error: aborting due to previous error
fn test() {
let v: isize;
- v += 1; //~ ERROR use of possibly-uninitialized variable: `v`
+ v += 1; //~ ERROR E0381
v.clone();
}
-error[E0381]: use of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` isn't initialized
--> $DIR/borrowck-init-op-equal.rs:3:5
|
+LL | let v: isize;
+ | - binding declared here but left uninitialized
LL | v += 1;
- | ^^^^^^ use of possibly-uninitialized `v`
+ | ^^^^^^ `v` used here but it isn't initialized
error: aborting due to previous error
fn test() {
let mut v: isize;
- v = v + 1; //~ ERROR use of possibly-uninitialized variable: `v`
+ v = v + 1; //~ ERROR E0381
v.clone();
}
-error[E0381]: use of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` isn't initialized
--> $DIR/borrowck-init-plus-equal.rs:3:9
|
+LL | let mut v: isize;
+ | ----- binding declared here but left uninitialized
LL | v = v + 1;
- | ^ use of possibly-uninitialized `v`
+ | ^ `v` used here but it isn't initialized
error: aborting due to previous error
error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure
--> $DIR/borrowck-move-by-capture.rs:9:29
|
-LL | let bar: Box<_> = Box::new(3);
- | --- captured outer variable
-LL | let _g = to_fn_mut(|| {
- | ________________________-
-LL | | let _h = to_fn_once(move || -> isize { *bar });
- | | ^^^^^^^^^^^^^^^^ ----
- | | | |
- | | | variable moved due to use in closure
- | | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
- | | move out of `bar` occurs here
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let bar: Box<_> = Box::new(3);
+ | --- captured outer variable
+LL | let _g = to_fn_mut(|| {
+ | -- captured by this `FnMut` closure
+LL | let _h = to_fn_once(move || -> isize { *bar });
+ | ^^^^^^^^^^^^^^^^ ----
+ | | |
+ | | variable moved due to use in closure
+ | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
+ | move out of `bar` occurs here
error: aborting due to previous error
let i: isize;
println!("{}", false || { i = 5; true });
- println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
+ println!("{}", i); //~ ERROR E0381
}
-error[E0381]: borrow of possibly-uninitialized variable: `i`
+error[E0381]: used binding `i` is possibly-uninitialized
--> $DIR/borrowck-or-init.rs:5:20
|
+LL | let i: isize;
+ | - binding declared here but left uninitialized
+LL |
+LL | println!("{}", false || { i = 5; true });
+ | ----- binding initialized here in some conditions
LL | println!("{}", i);
- | ^ use of possibly-uninitialized `i`
+ | ^ `i` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
fn stuff() {
let mut x : (Test2, Test2);
- (x.0).0 = Some(Test);
- //~^ ERROR assign of possibly-uninitialized variable: `x.0`
+ (x.0).0 = Some(Test); //~ ERROR E0381
}
fn main() {
-error[E0381]: assign of possibly-uninitialized variable: `x.0`
+error[E0381]: assigned binding `x.0` isn't fully initialized
--> $DIR/borrowck-partial-reinit-4.rs:17:5
|
+LL | let mut x : (Test2, Test2);
+ | ----- binding declared here but left uninitialized
LL | (x.0).0 = Some(Test);
- | ^^^^^^^ use of possibly-uninitialized `x.0`
+ | ^^^^^^^ `x.0` assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to previous error
fn f() -> isize {
let x: isize;
- return x; //~ ERROR use of possibly-uninitialized variable: `x`
+ return x; //~ ERROR E0381
}
fn main() { f(); }
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-return.rs:3:12
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | return x;
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to previous error
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-storage-dead.rs:16:17
|
+LL | let x: i32;
+ | - binding declared here but left uninitialized
LL | let _ = x + 1;
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to previous error
fn main() {
let bar;
fn baz(_x: isize) { }
- baz(bar); //~ ERROR use of possibly-uninitialized variable: `bar`
+ baz(bar); //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `bar`
+error[E0381]: used binding `bar` isn't initialized
--> $DIR/borrowck-uninit-after-item.rs:4:9
|
+LL | let bar;
+ | --- binding declared here but left uninitialized
+LL | fn baz(_x: isize) { }
LL | baz(bar);
- | ^^^ use of possibly-uninitialized `bar`
+ | ^^^ `bar` used here but it isn't initialized
error: aborting due to previous error
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
--> $DIR/borrowck-uninit-field-access.rs:21:13
|
+LL | let mut a: Point;
+ | ----- binding declared here but left uninitialized
LL | let _ = a.x + 1;
- | ^^^ use of possibly-uninitialized `a.x`
+ | ^^^ `a.x` used here but it isn't initialized
error[E0382]: use of moved value: `line1.origin`
--> $DIR/borrowck-uninit-field-access.rs:25:13
pub fn main() {
let x: isize;
- x += 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x += 1; //~ ERROR E0381
let x: isize;
- x -= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x -= 1; //~ ERROR E0381
let x: isize;
- x *= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x *= 1; //~ ERROR E0381
let x: isize;
- x /= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x /= 1; //~ ERROR E0381
let x: isize;
- x %= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x %= 1; //~ ERROR E0381
let x: isize;
- x ^= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x ^= 1; //~ ERROR E0381
let x: isize;
- x &= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x &= 1; //~ ERROR E0381
let x: isize;
- x |= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x |= 1; //~ ERROR E0381
let x: isize;
- x <<= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x <<= 1; //~ ERROR E0381
let x: isize;
- x >>= 1; //~ ERROR use of possibly-uninitialized variable: `x`
+ x >>= 1; //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:6:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x += 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:9:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x -= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:12:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x *= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:15:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x /= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:18:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x %= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:21:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x ^= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:24:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x &= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:27:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x |= 1;
- | ^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:30:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x <<= 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-in-assignop.rs:33:5
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | x >>= 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` used here but it isn't initialized
error: aborting due to 10 previous errors
fn main() {
let x: &&Box<i32>;
- let _y = &**x; //~ [E0381]
+ let _y = &**x; //~ ERROR [E0381]
let x: &&S<i32, i32>;
- let _y = &**x; //~ [E0381]
+ let _y = &**x; //~ ERROR [E0381]
let x: &&i32;
- let _y = &**x; //~ [E0381]
+ let _y = &**x; //~ ERROR [E0381]
let mut a: S<i32, i32>;
- a.x = 0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+ a.x = 0; //~ ERROR [E0381]
let _b = &a.x;
let mut a: S<&&i32, &&i32>;
- a.x = &&0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+ a.x = &&0; //~ ERROR [E0381]
let _b = &**a.x;
let mut a: S<i32, i32>;
- a.x = 0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
+ a.x = 0; //~ ERROR [E0381]
let _b = &a.y;
let mut a: S<&&i32, &&i32>;
- a.x = &&0; //~ assign to part of possibly-uninitialized variable: `a` [E0381]
+ a.x = &&0; //~ ERROR [E0381]
let _b = &**a.y;
}
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-ref-chain.rs:8:14
|
+LL | let x: &&Box<i32>;
+ | - binding declared here but left uninitialized
LL | let _y = &**x;
- | ^^^^ use of possibly-uninitialized `**x`
+ | ^^^^ `**x` used here but it isn't initialized
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-ref-chain.rs:11:14
|
+LL | let x: &&S<i32, i32>;
+ | - binding declared here but left uninitialized
LL | let _y = &**x;
- | ^^^^ use of possibly-uninitialized `**x`
+ | ^^^^ `**x` used here but it isn't initialized
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit-ref-chain.rs:14:14
|
+LL | let x: &&i32;
+ | - binding declared here but left uninitialized
LL | let _y = &**x;
- | ^^^^ use of possibly-uninitialized `**x`
+ | ^^^^ `**x` used here but it isn't initialized
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
--> $DIR/borrowck-uninit-ref-chain.rs:18:5
|
+LL | let mut a: S<i32, i32>;
+ | ----- binding declared here but left uninitialized
LL | a.x = 0;
- | ^^^^^^^ use of possibly-uninitialized `a`
+ | ^^^^^^^ `a` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
--> $DIR/borrowck-uninit-ref-chain.rs:22:5
|
+LL | let mut a: S<&&i32, &&i32>;
+ | ----- binding declared here but left uninitialized
LL | a.x = &&0;
- | ^^^^^^^^^ use of possibly-uninitialized `a`
+ | ^^^^^^^^^ `a` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
--> $DIR/borrowck-uninit-ref-chain.rs:27:5
|
+LL | let mut a: S<i32, i32>;
+ | ----- binding declared here but left uninitialized
LL | a.x = 0;
- | ^^^^^^^ use of possibly-uninitialized `a`
+ | ^^^^^^^ `a` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `a`
+error[E0381]: partially assigned binding `a` isn't fully initialized
--> $DIR/borrowck-uninit-ref-chain.rs:31:5
|
+LL | let mut a: S<&&i32, &&i32>;
+ | ----- binding declared here but left uninitialized
LL | a.x = &&0;
- | ^^^^^^^^^ use of possibly-uninitialized `a`
+ | ^^^^^^^^^ `a` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 7 previous errors
fn main() {
let x: isize;
- foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
+ foo(x); //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-uninit.rs:5:9
|
+LL | let x: isize;
+ | - binding declared here but left uninitialized
LL | foo(x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to previous error
unsafe {
let mut s: S;
let mut u: U;
- s.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `s`
- u.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `u`
+ s.a = 0; //~ ERROR E0381
+ u.a = 0; //~ ERROR E0381
let sa = s.a;
let ua = u.a;
}
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
+error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/borrowck-union-uninitialized.rs:13:9
|
+LL | let mut s: S;
+ | ----- binding declared here but left uninitialized
+LL | let mut u: U;
LL | s.a = 0;
- | ^^^^^^^ use of possibly-uninitialized `s`
+ | ^^^^^^^ `s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
--> $DIR/borrowck-union-uninitialized.rs:14:9
|
+LL | let mut u: U;
+ | ----- binding declared here but left uninitialized
+LL | s.a = 0;
LL | u.a = 0;
- | ^^^^^^^ use of possibly-uninitialized `u`
+ | ^^^^^^^ `u` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 2 previous errors
-error[E0381]: use of possibly-uninitialized variable: `w`
+error[E0381]: used binding `w` isn't initialized
--> $DIR/borrowck-use-in-index-lvalue.rs:3:5
|
+LL | let w: &mut [isize];
+ | - binding declared here but left uninitialized
LL | w[5] = 0;
- | ^^^^ use of possibly-uninitialized `*w`
+ | ^^^^ `*w` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `w`
+error[E0381]: used binding `w` isn't initialized
--> $DIR/borrowck-use-in-index-lvalue.rs:6:5
|
+LL | let mut w: &mut [isize];
+ | ----- binding declared here but left uninitialized
LL | w[5] = 0;
- | ^^^^ use of possibly-uninitialized `*w`
+ | ^^^^ `*w` used here but it isn't initialized
error: aborting due to 2 previous errors
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
|
+LL | let x: &i32;
+ | - binding declared here but left uninitialized
LL | let y = x as *const dyn Foo;
- | ^ use of possibly-uninitialized `*x`
+ | ^ `*x` used here but it isn't initialized
error: aborting due to previous error
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
|
+LL | let x: &i32;
+ | - binding declared here but left uninitialized
LL | let y = x as *const i32;
- | ^ use of possibly-uninitialized `*x`
+ | ^ `*x` used here but it isn't initialized
error: aborting due to previous error
v = 3;
break;
}
- println!("{}", v); //~ ERROR borrow of possibly-uninitialized variable: `v`
+ println!("{}", v); //~ ERROR E0381
}
fn main() {
-error[E0381]: borrow of possibly-uninitialized variable: `v`
+error[E0381]: used binding `v` is possibly-uninitialized
--> $DIR/borrowck-while-break.rs:7:20
|
+LL | let v;
+ | - binding declared here but left uninitialized
+LL | while cond {
+ | ---- if this condition isn't met and the `while` loop runs 0 times, `v` is not initialized
+...
LL | println!("{}", v);
- | ^ use of possibly-uninitialized `v`
+ | ^ `v` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
fn main() {
let x: bool;
- while x { } //~ ERROR use of possibly-uninitialized variable: `x`
+ while x { } //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/borrowck-while-cond.rs:3:11
|
+LL | let x: bool;
+ | - binding declared here but left uninitialized
LL | while x { }
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to previous error
fn f() -> isize {
let mut x: isize;
while 1 == 1 { x = 10; }
- return x; //~ ERROR use of possibly-uninitialized variable: `x`
+ return x; //~ ERROR E0381
}
fn main() { f(); }
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` is possibly-uninitialized
--> $DIR/borrowck-while.rs:4:12
|
+LL | let mut x: isize;
+ | ----- binding declared here but left uninitialized
+LL | while 1 == 1 { x = 10; }
+ | ------ if this condition isn't met and the `while` loop runs 0 times, `x` is not initialized
LL | return x;
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it is possibly-uninitialized
error: aborting due to previous error
fn main() {
let mut t: (u64, u64);
t.0 = 1;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
t.1 = 1;
let mut t: (u64, u64);
t.1 = 1;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
t.0 = 1;
let mut t: (u64, u64);
t.0 = 1;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
let mut t: (u64,);
t.0 = 1;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
}
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/disallow-possibly-uninitialized.rs:6:5
|
+LL | let mut t: (u64, u64);
+ | ----- binding declared here but left uninitialized
LL | t.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/disallow-possibly-uninitialized.rs:11:5
|
+LL | let mut t: (u64, u64);
+ | ----- binding declared here but left uninitialized
LL | t.1 = 1;
- | ^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/disallow-possibly-uninitialized.rs:16:5
|
+LL | let mut t: (u64, u64);
+ | ----- binding declared here but left uninitialized
LL | t.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/disallow-possibly-uninitialized.rs:20:5
|
+LL | let mut t: (u64,);
+ | ----- binding declared here but left uninitialized
LL | t.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 4 previous errors
pub fn foo1() {
let x: i32;
loop { x = break; }
- println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+ println!("{}", x); //~ ERROR E0381
}
pub fn foo2() {
let x: i32;
for _ in 0..10 { x = continue; }
- println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
+ println!("{}", x); //~ ERROR E0381
}
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/issue-24267-flow-exit.rs:12:20
|
+LL | let x: i32;
+ | - binding declared here but left uninitialized
+LL | loop { x = break; }
LL | println!("{}", x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/issue-24267-flow-exit.rs:18:20
|
+LL | let x: i32;
+ | - binding declared here but left uninitialized
+LL | for _ in 0..10 { x = continue; }
LL | println!("{}", x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
LL | let _action = move || {
| -------
| | |
- | | return type of closure `[closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15]` contains a lifetime `'2`
+ | | return type of closure `[closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:11]` contains a lifetime `'2`
| lifetime `'1` represents this closure's body
LL | || f() // The `nested` closure
| ^^^^^^ returning this value requires that `'1` must outlive `'2`
{
let mut t: Tuple;
t.0 = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
t.1 = 2;
println!("{:?} {:?}", t.0, t.1);
}
{
let mut u: Tpair;
u.0 = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
+ //~^ ERROR E0381
u.1 = 2;
println!("{:?} {:?}", u.0, u.1);
}
{
let mut v: Spair;
v.x = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
+ //~^ ERROR E0381
v.y = 2;
println!("{:?} {:?}", v.x, v.y);
}
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9
|
+LL | let mut t: Tuple;
+ | ----- binding declared here but left uninitialized
LL | t.0 = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9
|
+LL | let mut u: Tpair;
+ | ----- binding declared here but left uninitialized
LL | u.0 = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `u`
+ | ^^^^^^^^^^ `u` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `v`
+error[E0381]: partially assigned binding `v` isn't fully initialized
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9
|
+LL | let mut v: Spair;
+ | ----- binding declared here but left uninitialized
LL | v.x = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `v`
+ | ^^^^^^^^^^ `v` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 3 previous errors
{
let t: Tuple;
t.0 = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ //~^ ERROR E0381
t.1 = 2;
println!("{:?} {:?}", t.0, t.1);
}
{
let u: Tpair;
u.0 = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
+ //~^ ERROR E0381
u.1 = 2;
println!("{:?} {:?}", u.0, u.1);
}
{
let v: Spair;
v.x = S(1);
- //~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
+ //~^ ERROR E0381
v.y = 2;
println!("{:?} {:?}", v.x, v.y);
}
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9
|
+LL | let t: Tuple;
+ | - binding declared here but left uninitialized
LL | t.0 = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `u`
+error[E0381]: partially assigned binding `u` isn't fully initialized
--> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9
|
+LL | let u: Tpair;
+ | - binding declared here but left uninitialized
LL | u.0 = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `u`
+ | ^^^^^^^^^^ `u` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `v`
+error[E0381]: partially assigned binding `v` isn't fully initialized
--> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9
|
+LL | let v: Spair;
+ | - binding declared here but left uninitialized
LL | v.x = S(1);
- | ^^^^^^^^^^ use of possibly-uninitialized `v`
+ | ^^^^^^^^^^ `v` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 3 previous errors
fn main() {
let e: i32;
match e {
- //~^ ERROR use of possibly-uninitialized variable
+ //~^ ERROR E0381
ref u if true => {}
ref v if true => {
let tx = 0;
-error[E0381]: use of possibly-uninitialized variable: `e`
+error[E0381]: used binding `e` isn't initialized
--> $DIR/issue-62107-match-arm-scopes.rs:3:11
|
+LL | let e: i32;
+ | - binding declared here but left uninitialized
LL | match e {
- | ^ use of possibly-uninitialized `e`
+ | ^ `e` used here but it isn't initialized
error: aborting due to previous error
| ^^^^^^^^
| |
| the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:12:5
- | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+ | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0507]: cannot move out of `val`, a captured variable in an `FnMut` closure
--> $DIR/issue-87456-point-to-closure.rs:10:28
|
-LL | let val = String::new();
- | --- captured outer variable
+LL | let val = String::new();
+ | --- captured outer variable
LL |
-LL | take_mut(|| {
- | ______________-
-LL | |
-LL | | let _foo: String = val;
- | | ^^^
- | | |
- | | move occurs because `val` has type `String`, which does not implement the `Copy` trait
- | | help: consider borrowing here: `&val`
-LL | |
-LL | |
-LL | | })
- | |_____- captured by this `FnMut` closure
+LL | take_mut(|| {
+ | -- captured by this `FnMut` closure
+LL |
+LL | let _foo: String = val;
+ | ^^^
+ | |
+ | move occurs because `val` has type `String`, which does not implement the `Copy` trait
+ | help: consider borrowing here: `&val`
error: aborting due to previous error
| ^^^^^^^^
| |
| the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:11:5
- | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:31]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+ | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28]>` at $SRC_DIR/std/src/panic.rs:LL:COL
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
| ^^^^^^^^
| |
| the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:11:5
- | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL
+ | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/mutability-errors.rs:40:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
- | | ^^^^^^^^ cannot assign
-LL | | x.0 = 1;
-LL | | &mut x;
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | x = (1,);
+ | ^^^^^^^^ cannot assign
error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
--> $DIR/mutability-errors.rs:41:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
- | | ^^^^^^^ cannot assign
-LL | | &mut x;
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | x = (1,);
+LL | x.0 = 1;
+ | ^^^^^^^ cannot assign
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/mutability-errors.rs:42:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
-LL | | &mut x;
- | | ^^^^^^ cannot borrow as mutable
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | &mut x;
+ | ^^^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
--> $DIR/mutability-errors.rs:43:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
-LL | | &mut x;
-LL | | &mut x.0;
- | | ^^^^^^^^ cannot borrow as mutable
-LL | | });
- | |_____- in this closure
+LL | &mut x.0;
+ | ^^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/mutability-errors.rs:46:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
- | | ^^^^^^^^ cannot assign
-LL | | x.0 = 1;
-LL | | &mut x;
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | x = (1,);
+ | ^^^^^^^^ cannot assign
error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
--> $DIR/mutability-errors.rs:47:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
- | | ^^^^^^^ cannot assign
-LL | | &mut x;
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | x = (1,);
+LL | x.0 = 1;
+ | ^^^^^^^ cannot assign
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/mutability-errors.rs:48:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
-LL | | &mut x;
- | | ^^^^^^ cannot borrow as mutable
-LL | | &mut x.0;
-LL | | });
- | |_____- in this closure
+LL | &mut x;
+ | ^^^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
--> $DIR/mutability-errors.rs:49:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | x = (1,);
-LL | | x.0 = 1;
-LL | | &mut x;
-LL | | &mut x.0;
- | | ^^^^^^^^ cannot borrow as mutable
-LL | | });
- | |_____- in this closure
+LL | &mut x.0;
+ | ^^^^^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/mutability-errors.rs:54:5
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/reassignment_immutable_fields.rs:7:5
|
+LL | let x: (u32, u32);
+ | - binding declared here but left uninitialized
LL | x.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/reassignment_immutable_fields.rs:15:5
|
+LL | let x: (u32, u32);
+ | - binding declared here but left uninitialized
LL | x.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 2 previous errors
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/reassignment_immutable_fields_overlapping.rs:12:5
|
+LL | let x: Foo;
+ | - binding declared here but left uninitialized
LL | x.a = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable
--> $DIR/reassignment_immutable_fields_overlapping.rs:13:5
LL | x.0 = 1;
| ^^^^^^^ cannot assign
-error[E0381]: assign to part of possibly-uninitialized variable: `x`
+error[E0381]: partially assigned binding `x` isn't fully initialized
--> $DIR/reassignment_immutable_fields_twice.rs:12:5
|
+LL | let x: (u32, u32);
+ | - binding declared here but left uninitialized
LL | x.0 = 1;
- | ^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^ `x` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 2 previous errors
error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure
--> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9
|
-LL | let y = vec![format!("World")];
- | - captured outer variable
-LL | call(|| {
- | __________-
-LL | | y.into_iter();
- | | ^ ----------- `y` moved due to this method call
- | | |
- | | move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
-LL | |
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let y = vec![format!("World")];
+ | - captured outer variable
+LL | call(|| {
+ | -- captured by this `Fn` closure
+LL | y.into_iter();
+ | ^ ----------- `y` moved due to this method call
+ | |
+ | move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
|
note: this function takes ownership of the receiver `self`, which moves `y`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
fn test1() {
let x: !;
let c1 = || match x { };
- //~^ ERROR: use of possibly-uninitialized variable: `x`
+ //~^ ERROR E0381
}
// Should fake read the discriminant and throw an error
fn test2() {
let x: !;
let c2 = || match x { _ => () };
- //~^ ERROR: borrow of possibly-uninitialized variable: `x`
+ //~^ ERROR E0381
}
// Testing single variant patterns
fn test3() {
let variant: !;
let c = || {
- //~^ ERROR: borrow of possibly-uninitialized variable: `variant`
+ //~^ ERROR E0381
match variant {
SingleVariant::Points(_) => {}
}
// Should fake read the discriminant and throw an error
fn test4() {
let variant: !;
- let c = || {
- //~^ ERROR: borrow of possibly-uninitialized variable: `variant`
+ let c = || { //~ ERROR E0381
match variant {
SingleVariant::Points(a) => {
println!("{:?}", a);
let g: !;
let a = || {
- match g { };
- //~^ ERROR: use of possibly-uninitialized variable: `g`
+ match g { }; //~ ERROR E0381
let c = || {
- match t { };
- //~^ ERROR: use of possibly-uninitialized variable: `t`
+ match t { }; //~ ERROR E0381
};
c();
fn test6() {
let x: u8;
let c1 = || match x { };
- //~^ ERROR: use of possibly-uninitialized variable: `x`
+ //~^ ERROR E0381
//~| ERROR: non-exhaustive patterns: type `u8` is non-empty
}
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
- --> $DIR/pattern-matching-should-fail.rs:70:23
+ --> $DIR/pattern-matching-should-fail.rs:67:23
|
LL | let c1 = || match x { };
| ^
LL ~ };
|
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/pattern-matching-should-fail.rs:8:23
|
+LL | let x: !;
+ | - binding declared here but left uninitialized
LL | let c1 = || match x { };
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/pattern-matching-should-fail.rs:15:14
|
+LL | let x: !;
+ | - binding declared here but left uninitialized
LL | let c2 = || match x { _ => () };
| ^^ - borrow occurs due to use in closure
| |
- | use of possibly-uninitialized `x`
+ | `x` used here but it isn't initialized
-error[E0381]: borrow of possibly-uninitialized variable: `variant`
+error[E0381]: used binding `variant` isn't initialized
--> $DIR/pattern-matching-should-fail.rs:27:13
|
+LL | let variant: !;
+ | ------- binding declared here but left uninitialized
LL | let c = || {
- | ^^ use of possibly-uninitialized `variant`
+ | ^^ `variant` used here but it isn't initialized
LL |
LL | match variant {
| ------- borrow occurs due to use in closure
-error[E0381]: borrow of possibly-uninitialized variable: `variant`
+error[E0381]: used binding `variant` isn't initialized
--> $DIR/pattern-matching-should-fail.rs:39:13
|
+LL | let variant: !;
+ | ------- binding declared here but left uninitialized
LL | let c = || {
- | ^^ use of possibly-uninitialized `variant`
-LL |
+ | ^^ `variant` used here but it isn't initialized
LL | match variant {
| ------- borrow occurs due to use in closure
-error[E0381]: use of possibly-uninitialized variable: `g`
- --> $DIR/pattern-matching-should-fail.rs:55:15
+error[E0381]: used binding `g` isn't initialized
+ --> $DIR/pattern-matching-should-fail.rs:54:15
|
+LL | let g: !;
+ | - binding declared here but left uninitialized
+...
LL | match g { };
- | ^ use of possibly-uninitialized `g`
+ | ^ `g` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `t`
- --> $DIR/pattern-matching-should-fail.rs:58:19
+error[E0381]: used binding `t` isn't initialized
+ --> $DIR/pattern-matching-should-fail.rs:56:19
|
+LL | let t: !;
+ | - binding declared here but left uninitialized
+...
LL | match t { };
- | ^ use of possibly-uninitialized `t`
+ | ^ `t` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `x`
- --> $DIR/pattern-matching-should-fail.rs:70:23
+error[E0381]: used binding `x` isn't initialized
+ --> $DIR/pattern-matching-should-fail.rs:67:23
|
+LL | let x: u8;
+ | - binding declared here but left uninitialized
LL | let c1 = || match x { };
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to 8 previous errors
--> $DIR/auto_traits.rs:22:19
|
LL | thread::spawn(move || unsafe {
- | ^^^^^^^^^^^^^^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0` does not implement `Send`
+ | ^^^^^^^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0` does not implement `Send`
...
LL | *fptr.0 = 20;
| ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0`
--> $DIR/auto_traits.rs:42:19
|
LL | thread::spawn(move || unsafe {
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^
| |
| in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0.0` does not implement `Send`
| in Rust 2018, this closure implements `Sync` as `fptr` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr` is not fully captured and `fptr.0.0` does not implement `Sync`
--> $DIR/closure-body-macro-fragment.rs:16:17
|
LL | let f = || $body;
- | _________________^
-LL | |
-LL | | f();
-LL | | }};
- | | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
-LL | | ($body:block) => {{
-LL | | m!(@ $body);
- | |__________________^
+ | ^^
+...
+LL | }};
+ | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
...
LL | / m!({
LL | |
--> $DIR/macro.rs:19:13
|
LL | let _ = || dbg!(a.0);
- | ^^^^^^^^---^
- | |
- | in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0`
+ | ^^ --- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0`
...
LL | }
| - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
--> $DIR/migrations_rustfix.rs:33:13
|
LL | let c = || t.0;
- | ^^^---
- | |
- | in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
+ | ^^ --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
...
LL | }
| - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
--> $DIR/multi_diagnostics.rs:133:19
|
LL | thread::spawn(move || unsafe {
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^
| |
| in Rust 2018, this closure implements `Send` as `fptr1` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Send`
| in Rust 2018, this closure implements `Sync` as `fptr1` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr1` is not fully captured and `fptr1.0.0` does not implement `Sync`
--> $DIR/significant_drop.rs:201:18
|
LL | let _c = || tup.0;
- | ^^^-----
- | |
- | in Rust 2018, this closure captures all of `tup`, but in Rust 2021, it will only capture `tup.0`
+ | ^^ ----- in Rust 2018, this closure captures all of `tup`, but in Rust 2021, it will only capture `tup.0`
...
LL | }
| - in Rust 2018, `tup` is dropped here, but in Rust 2021, only `tup.0` will be dropped here as part of the closure
note: required because it's used within this closure
--> $DIR/closure-move-sync.rs:6:27
|
-LL | let t = thread::spawn(|| {
- | ___________________________^
-LL | | recv.recv().unwrap();
-LL | |
-LL | | });
- | |_____^
+LL | let t = thread::spawn(|| {
+ | ^^
note: required by a bound in `spawn`
--> $SRC_DIR/std/src/thread/mod.rs:LL:COL
|
--> $DIR/closure-move-sync.rs:18:19
|
LL | thread::spawn(|| tx.send(()).unwrap());
- | ^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^
note: required by a bound in `spawn`
--> $SRC_DIR/std/src/thread/mod.rs:LL:COL
|
| expected due to this
|
= note: expected fn pointer `fn(u8) -> u8`
- found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:50]`
+ found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:36]`
note: closures can only be coerced to `fn` types if they do not capture any variables
--> $DIR/closure-no-fn-1.rs:6:39
|
| expected due to this
|
= note: expected fn pointer `fn() -> u8`
- found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:35]`
+ found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:29]`
note: closures can only be coerced to `fn` types if they do not capture any variables
--> $DIR/closure-no-fn-2.rs:6:32
|
-error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:6:27: 6:37]` as `fn() -> u8`
+error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:6:28: 6:30]` as `fn() -> u8`
--> $DIR/closure-no-fn-3.rs:6:27
|
LL | let baz: fn() -> u8 = (|| { b }) as fn() -> u8;
| |_____- `match` arms have incompatible types
|
= note: expected fn pointer `fn(usize) -> usize`
- found closure `[closure@$DIR/closure-no-fn-4.rs:5:18: 5:27]`
+ found closure `[closure@$DIR/closure-no-fn-4.rs:5:18: 5:21]`
note: closures can only be coerced to `fn` types if they do not capture any variables
--> $DIR/closure-no-fn-4.rs:5:26
|
| expected due to this
|
= note: expected fn pointer `fn() -> u8`
- found closure `[closure@$DIR/closure-no-fn-5.rs:10:27: 10:47]`
+ found closure `[closure@$DIR/closure-no-fn-5.rs:10:27: 10:29]`
note: closures can only be coerced to `fn` types if they do not capture any variables
--> $DIR/closure-no-fn-5.rs:10:32
|
--> $DIR/closure-reform-bad.rs:11:15
|
LL | let f = |s: &str| println!("{}{}", s, string);
- | ------------------------------------- the found closure
+ | --------- the found closure
LL | call_bare(f)
| --------- ^ expected fn pointer, found closure
| |
| arguments to this function are incorrect
|
= note: expected fn pointer `for<'r> fn(&'r str)`
- found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50]`
+ found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:22]`
note: closures can only be coerced to `fn` types if they do not capture any variables
--> $DIR/closure-reform-bad.rs:10:43
|
--> $DIR/closure-wrong-kind.rs:10:19
|
LL | let closure = |_| foo(x);
- | ^^^^^^^^-^
- | | |
- | | closure is `FnOnce` because it moves the variable `x` out of its environment
+ | ^^^ - closure is `FnOnce` because it moves the variable `x` out of its environment
+ | |
| this closure implements `FnOnce`, not `Fn`
LL | bar(closure);
| --- the requirement to implement `Fn` derives from here
| |_____- `match` arms have incompatible types
|
= note: expected fn item `fn(i32, i32) -> i32 {add}`
- found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:43]`
+ found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22]`
error[E0308]: `match` arms have incompatible types
--> $DIR/closure_cap_coerce_many_fail.rs:18:16
| | ---------------------
| | |
| | the expected closure
- | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:37]`
+ | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22]`
LL | | "-" => |a, b| (a - b + cap) as i32,
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure
LL | | _ => unimplemented!(),
LL | | };
| |_____- `match` arms have incompatible types
|
- = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:37]`
- found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:43]`
+ = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22]`
+ found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:22]`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
| | ---------------------------
| | |
| | the expected closure
- | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:43]`
+ | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22]`
LL | | "-" => |a, b| (a - b) as i32,
| | ^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure
LL | | _ => unimplemented!(),
LL | | };
| |_____- `match` arms have incompatible types
|
- = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:43]`
- found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:37]`
+ = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22]`
+ found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:22]`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
| | ---------------------------
| | |
| | the expected closure
- | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:43]`
+ | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22]`
LL | | "-" => |a, b| (a - b + cap) as i32,
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure
LL | | _ => unimplemented!(),
LL | | };
| |_____- `match` arms have incompatible types
|
- = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:43]`
- found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:43]`
+ = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22]`
+ found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:22]`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
--> $DIR/closure-print-generic-1.rs:17:5
|
LL | let c = to_fn_once(move || {
- | - move occurs because `c` has type `[closure@$DIR/closure-print-generic-1.rs:12:24: 14:6]`, which does not implement the `Copy` trait
+ | - move occurs because `c` has type `[closure@$DIR/closure-print-generic-1.rs:12:24: 12:31]`, which does not implement the `Copy` trait
...
LL | c();
| --- `c` moved due to this call
--> $DIR/closure-print-generic-2.rs:6:22
|
LL | let c = || println!("{} {}", t, x);
- | -------------------------- the found closure
+ | -- the found closure
LL | let c1: () = c;
| -- ^ expected `()`, found closure
| |
| expected due to this
|
= note: expected unit type `()`
- found closure `[closure@$DIR/closure-print-generic-2.rs:5:17: 5:43]`
+ found closure `[closure@$DIR/closure-print-generic-2.rs:5:17: 5:19]`
help: use parentheses to call this closure
|
LL | let c1: () = c();
--> $DIR/closure-print-generic-trim-off-verbose-2.rs:9:23
|
LL | let c = || println!("{} {}", t, x);
- | -------------------------- the found closure
+ | -- the found closure
LL | let c1 : () = c;
| -- ^ expected `()`, found closure
| |
--> $DIR/closure-print-generic-verbose-2.rs:9:23
|
LL | let c = || println!("{} {}", t, x);
- | -------------------------- the found closure
+ | -- the found closure
LL | let c1 : () = c;
| -- ^ expected `()`, found closure
| |
| ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
|
= note: expected struct `Box<dyn Fn(i32) -> u8>`
- found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`
+ found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:22]>`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:14:13
| ^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
|
= note: expected reference `&dyn Fn(i32) -> u8`
- found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`
+ found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:19]`
error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:22:13
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found closure
|
= note: expected struct `Box<dyn Fn(i32) -> u8>`
- found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`
+ found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:25]>`
error: aborting due to 14 previous errors
--> $DIR/issue-18343.rs:7:7
|
LL | struct Obj<F> where F: FnMut() -> u32 {
- | --- method `closure` not found for this struct
+ | ------------- method `closure` not found for this struct
...
LL | o.closure();
| ^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:36:15
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `closure` not found for this struct
+ | ------------- method `closure` not found for this struct
...
LL | o_closure.closure();
| ^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:38:15
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `not_closure` not found for this struct
+ | ------------- method `not_closure` not found for this struct
...
LL | o_closure.not_closure();
| ^^^^^^^^^^^-- help: remove the arguments
--> $DIR/issue-2392.rs:42:12
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `closure` not found for this struct
+ | ------------- method `closure` not found for this struct
...
LL | o_func.closure();
| ^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:45:14
|
LL | struct BoxedObj {
- | -------- method `boxed_closure` not found for this struct
+ | --------------- method `boxed_closure` not found for this struct
...
LL | boxed_fn.boxed_closure();
| ^^^^^^^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:48:19
|
LL | struct BoxedObj {
- | -------- method `boxed_closure` not found for this struct
+ | --------------- method `boxed_closure` not found for this struct
...
LL | boxed_closure.boxed_closure();
| ^^^^^^^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:53:12
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `closure` not found for this struct
+ | ------------- method `closure` not found for this struct
...
LL | w.wrap.closure();
| ^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:55:12
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `not_closure` not found for this struct
+ | ------------- method `not_closure` not found for this struct
...
LL | w.wrap.not_closure();
| ^^^^^^^^^^^-- help: remove the arguments
--> $DIR/issue-2392.rs:58:24
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
- | --- method `closure` not found for this struct
+ | ------------- method `closure` not found for this struct
...
LL | check_expression().closure();
| ^^^^^^^ field, not a method
--> $DIR/issue-2392.rs:64:31
|
LL | struct FuncContainer {
- | ------------- method `f1` not found for this struct
+ | -------------------- method `f1` not found for this struct
...
LL | (*self.container).f1(1);
| ^^ field, not a method
--> $DIR/issue-2392.rs:65:31
|
LL | struct FuncContainer {
- | ------------- method `f2` not found for this struct
+ | -------------------- method `f2` not found for this struct
...
LL | (*self.container).f2(1);
| ^^ field, not a method
--> $DIR/issue-2392.rs:66:31
|
LL | struct FuncContainer {
- | ------------- method `f3` not found for this struct
+ | -------------------- method `f3` not found for this struct
...
LL | (*self.container).f3(1);
| ^^ field, not a method
--> $DIR/issue-32128.rs:12:10
|
LL | struct Example {
- | ------- method `example` not found for this struct
+ | -------------- method `example` not found for this struct
...
LL | demo.example(1);
| ^^^^^^^ field, not a method
-error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
+error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
--> $DIR/issue-33784.rs:27:7
|
LL | p.closure();
LL | (p.closure)();
| + +
-error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
+error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
--> $DIR/issue-33784.rs:29:7
|
LL | q.fn_ptr();
--> $DIR/private-field.rs:16:23
|
LL | pub struct Dog {
- | --- method `dog_age` not found for this struct
+ | -------------- method `dog_age` not found for this struct
...
LL | let dog_age = dog.dog_age();
| ^^^^^^^ private field, not a method
struct X<const N: usize = {
- let s: &'static str; s.len()
- //~^ ERROR borrow of possibly-uninitialized variable
+ let s: &'static str; s.len() //~ ERROR E0381
}>;
fn main() {}
-error[E0381]: borrow of possibly-uninitialized variable: `s`
+error[E0381]: used binding `s` isn't initialized
--> $DIR/const-generic-default-wont-borrowck.rs:2:26
|
LL | let s: &'static str; s.len()
- | ^^^^^^^ use of possibly-uninitialized `*s`
+ | - ^^^^^^^ `*s` used here but it isn't initialized
+ | |
+ | binding declared here but left uninitialized
error: aborting due to previous error
--> $DIR/issue-69654.rs:17:10
|
LL | struct Foo<const N: usize> {}
- | --- function or associated item `foo` not found for this struct
+ | -------------------------- function or associated item `foo` not found for this struct
...
LL | Foo::foo();
| ^^^ function or associated item cannot be called on `Foo<{_: usize}>` due to unsatisfied trait bounds
--> $DIR/issue-80742.rs:30:36
|
LL | struct Inline<T>
- | ------ function or associated item `new` not found for this struct
+ | ---------------- function or associated item `new` not found for this struct
...
LL | let dst = Inline::<dyn Debug>::new(0);
| ^^^ function or associated item cannot be called on `Inline<dyn Debug>` due to unsatisfied trait bounds
--> $DIR/invalid-const-arg-for-type-param.rs:9:7
|
LL | struct S;
- | - method `f` not found for this struct
+ | -------- method `f` not found for this struct
...
LL | S.f::<0>();
| ^ method not found in `S`
--- /dev/null
+// build-pass
+
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
+
+pub fn function_with_bytes<const BYTES: &'static [u8; 4]>() -> &'static [u8] {
+ BYTES
+}
+
+pub fn main() {
+ assert_eq!(function_with_bytes::<b"AAAA">(), &[0x41, 0x41, 0x41, 0x41]);
+ assert_eq!(function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>(), b"AAAA");
+}
--- /dev/null
+#![feature(adt_const_params)]
+//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features]
+
+#[derive(PartialEq, Eq)]
+enum Nat {
+ Z,
+ S(Box<Nat>),
+}
+
+fn foo<const N: Nat>() {}
+//~^ ERROR `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+
+fn main() {}
--- /dev/null
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/issue-80471.rs:1:12
+ |
+LL | #![feature(adt_const_params)]
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(incomplete_features)]` on by default
+ = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
+
+error[E0741]: `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
+ --> $DIR/issue-80471.rs:10:17
+ |
+LL | fn foo<const N: Nat>() {}
+ | ^^^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0741`.
--> $DIR/const-needs_drop-monomorphic.rs:11:46
|
LL | struct Bool<const B: bool> {}
- | ---- function or associated item `assert` not found for this struct
+ | -------------------------- function or associated item `assert` not found for this struct
...
LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert();
| ^^^^^^ function or associated item cannot be called on `Bool<{ std::mem::needs_drop::<T>() }>` due to unsatisfied trait bounds
const FOO: *const u32 = {
let x;
- &x //~ ERROR borrow of possibly-uninitialized variable: `x`
+ &x //~ ERROR E0381
};
fn main() {
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/issue-78655.rs:3:5
|
+LL | let x;
+ | - binding declared here but left uninitialized
LL | &x
- | ^^ use of possibly-uninitialized `x`
+ | ^^ `x` used here but it isn't initialized
error: could not evaluate constant pattern
--> $DIR/issue-78655.rs:7:9
--> $DIR/copy-a-resource.rs:18:16
|
LL | struct Foo {
- | --- method `clone` not found for this struct
+ | ---------- method `clone` not found for this struct
...
LL | let _y = x.clone();
| ^^^^^ method not found in `Foo`
LL | #[rustc_then_this_would_need(trait_def)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: OK
- --> $DIR/dep-graph-struct-signature.rs:32:9
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: OK
--> $DIR/dep-graph-struct-signature.rs:36:5
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: OK
- --> $DIR/dep-graph-struct-signature.rs:48:9
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
- --> $DIR/dep-graph-struct-signature.rs:49:9
- |
-LL | #[rustc_then_this_would_need(typeck)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: OK
--> $DIR/dep-graph-struct-signature.rs:53:5
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: OK
- --> $DIR/dep-graph-struct-signature.rs:55:9
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
- --> $DIR/dep-graph-struct-signature.rs:56:9
- |
-LL | #[rustc_then_this_would_need(typeck)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: OK
--> $DIR/dep-graph-struct-signature.rs:61:9
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: no path from `WillChange` to `fn_sig`
- --> $DIR/dep-graph-struct-signature.rs:77:9
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: no path from `WillChange` to `fn_sig`
--> $DIR/dep-graph-struct-signature.rs:81:5
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+error: OK
+ --> $DIR/dep-graph-struct-signature.rs:32:9
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: no path from `WillChange` to `fn_sig`
+ --> $DIR/dep-graph-struct-signature.rs:77:9
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-struct-signature.rs:48:9
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-struct-signature.rs:49:9
+ |
+LL | #[rustc_then_this_would_need(typeck)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-struct-signature.rs:55:9
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-struct-signature.rs:56:9
+ |
+LL | #[rustc_then_this_would_need(typeck)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
error: aborting due to 22 previous errors
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: OK
- --> $DIR/dep-graph-type-alias.rs:36:5
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: no path from `TypeAlias` to `type_of`
--> $DIR/dep-graph-type-alias.rs:42:1
|
LL | #[rustc_then_this_would_need(type_of)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: OK
- --> $DIR/dep-graph-type-alias.rs:44:5
- |
-LL | #[rustc_then_this_would_need(fn_sig)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: OK
- --> $DIR/dep-graph-type-alias.rs:45:5
- |
-LL | #[rustc_then_this_would_need(typeck)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
error: OK
--> $DIR/dep-graph-type-alias.rs:49:1
|
LL | #[rustc_then_this_would_need(typeck)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+error: OK
+ --> $DIR/dep-graph-type-alias.rs:36:5
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-type-alias.rs:44:5
+ |
+LL | #[rustc_then_this_would_need(fn_sig)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: OK
+ --> $DIR/dep-graph-type-alias.rs:45:5
+ |
+LL | #[rustc_then_this_would_need(typeck)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
error: aborting due to 12 previous errors
|
LL | struct Bar<T: Foo> {
| ------------------
- | | |
- | | method `clone` not found for this struct
+ | |
+ | method `clone` not found for this struct
| doesn't satisfy `Bar<NotClone>: Clone`
...
LL | struct NotClone;
| -------------------- doesn't satisfy `NoDerives: Clone`
...
LL | struct Object<T, A>(T, A);
- | ------ method `use_clone` not found for this struct
+ | ------------------- method `use_clone` not found for this struct
...
LL | foo.use_clone();
| ^^^^^^^^^ method cannot be called on `Object<NoDerives, SomeDerives>` due to unsatisfied trait bounds
| -------------------- doesn't satisfy `NoDerives: Eq`
LL |
LL | struct Object<T>(T);
- | ------ method `use_eq` not found for this struct
+ | ---------------- method `use_eq` not found for this struct
...
LL | foo.use_eq();
| ^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
| -------------------- doesn't satisfy `NoDerives: Ord`
LL |
LL | struct Object<T>(T);
- | ------ method `use_ord` not found for this struct
+ | ---------------- method `use_ord` not found for this struct
...
LL | foo.use_ord();
| ^^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
| doesn't satisfy `NoDerives: PartialOrd`
LL |
LL | struct Object<T>(T);
- | ------ method `use_ord_and_partial_ord` not found for this struct
+ | ---------------- method `use_ord_and_partial_ord` not found for this struct
...
LL | foo.use_ord_and_partial_ord();
| ^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `Object<NoDerives>` due to unsatisfied trait bounds
#[repr(packed)]
struct Packed(u32);
+// An empty enum.
+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum0 {}
+
+// A single-variant enum.
+#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
+enum Enum1 {
+ Single { x: u32 }
+}
+
// A C-like, fieldless enum.
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
enum Fieldless {
Y(bool),
Z(Option<i32>),
}
+
+// A union. Most builtin traits are not derivable for unions.
+#[derive(Clone, Copy)]
+pub union Union {
+ pub b: bool,
+ pub u: u32,
+ pub i: i32,
+}
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Empty {
#[inline]
- fn clone(&self) -> Empty { { *self } }
+ fn clone(&self) -> Empty { *self }
}
#[automatically_derived]
#[allow(unused_qualifications)]
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Empty {
- fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { {} }
+ fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
}
impl ::core::marker::StructuralPartialEq for Empty {}
#[automatically_derived]
#[inline]
#[doc(hidden)]
#[no_coverage]
- fn assert_receiver_is_total_eq(&self) -> () { {} }
+ fn assert_receiver_is_total_eq(&self) -> () {}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Point {
#[inline]
fn clone(&self) -> Point {
- {
- let _: ::core::clone::AssertParamIsClone<u32>;
- let _: ::core::clone::AssertParamIsClone<u32>;
- *self
- }
+ let _: ::core::clone::AssertParamIsClone<u32>;
+ *self
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Point {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- {
- ::core::hash::Hash::hash(&self.x, state);
- ::core::hash::Hash::hash(&self.y, state)
- }
+ ::core::hash::Hash::hash(&self.x, state);
+ ::core::hash::Hash::hash(&self.y, state)
}
}
impl ::core::marker::StructuralPartialEq for Point {}
#[doc(hidden)]
#[no_coverage]
fn assert_receiver_is_total_eq(&self) -> () {
- {
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- }
+ let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
-> ::core::option::Option<::core::cmp::Ordering> {
match ::core::cmp::PartialOrd::partial_cmp(&self.x, &other.x) {
::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
- match ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y)
- {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
+ ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y),
cmp => cmp,
}
}
fn cmp(&self, other: &Point) -> ::core::cmp::Ordering {
match ::core::cmp::Ord::cmp(&self.x, &other.x) {
::core::cmp::Ordering::Equal =>
- match ::core::cmp::Ord::cmp(&self.y, &other.y) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
+ ::core::cmp::Ord::cmp(&self.y, &other.y),
cmp => cmp,
}
}
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Big {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- {
- let names: &'static _ =
- &["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"];
- let values: &[&dyn ::core::fmt::Debug] =
- &[&&self.b1, &&self.b2, &&self.b3, &&self.b4, &&self.b5,
- &&self.b6, &&self.b7, &&self.b8];
- ::core::fmt::Formatter::debug_struct_fields_finish(f, "Big",
- names, values)
- }
+ let names: &'static _ =
+ &["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8"];
+ let values: &[&dyn ::core::fmt::Debug] =
+ &[&&self.b1, &&self.b2, &&self.b3, &&self.b4, &&self.b5,
+ &&self.b6, &&self.b7, &&self.b8];
+ ::core::fmt::Formatter::debug_struct_fields_finish(f, "Big", names,
+ values)
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Big {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- {
- ::core::hash::Hash::hash(&self.b1, state);
- ::core::hash::Hash::hash(&self.b2, state);
- ::core::hash::Hash::hash(&self.b3, state);
- ::core::hash::Hash::hash(&self.b4, state);
- ::core::hash::Hash::hash(&self.b5, state);
- ::core::hash::Hash::hash(&self.b6, state);
- ::core::hash::Hash::hash(&self.b7, state);
- ::core::hash::Hash::hash(&self.b8, state)
- }
+ ::core::hash::Hash::hash(&self.b1, state);
+ ::core::hash::Hash::hash(&self.b2, state);
+ ::core::hash::Hash::hash(&self.b3, state);
+ ::core::hash::Hash::hash(&self.b4, state);
+ ::core::hash::Hash::hash(&self.b5, state);
+ ::core::hash::Hash::hash(&self.b6, state);
+ ::core::hash::Hash::hash(&self.b7, state);
+ ::core::hash::Hash::hash(&self.b8, state)
}
}
impl ::core::marker::StructuralPartialEq for Big {}
#[doc(hidden)]
#[no_coverage]
fn assert_receiver_is_total_eq(&self) -> () {
- {
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- }
+ let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
&other.b7) {
::core::option::Option::Some(::core::cmp::Ordering::Equal)
=>
- match ::core::cmp::PartialOrd::partial_cmp(&self.b8,
- &other.b8) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
+ ::core::cmp::PartialOrd::partial_cmp(&self.b8, &other.b8),
cmp => cmp,
},
cmp => cmp,
::core::cmp::Ordering::Equal =>
match ::core::cmp::Ord::cmp(&self.b7, &other.b7) {
::core::cmp::Ordering::Equal =>
- match ::core::cmp::Ord::cmp(&self.b8, &other.b8) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
+ ::core::cmp::Ord::cmp(&self.b8, &other.b8),
cmp => cmp,
},
cmp => cmp,
impl ::core::clone::Clone for Packed {
#[inline]
fn clone(&self) -> Packed {
- { let _: ::core::clone::AssertParamIsClone<u32>; *self }
+ let _: ::core::clone::AssertParamIsClone<u32>;
+ *self
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Packed {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- {
- let Self(__self_0_0) = *self;
- ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Packed",
- &&__self_0_0)
- }
+ let Self(__self_0_0) = *self;
+ ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Packed",
+ &&__self_0_0)
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Packed {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- {
- let Self(__self_0_0) = *self;
- { ::core::hash::Hash::hash(&__self_0_0, state) }
- }
+ let Self(__self_0_0) = *self;
+ ::core::hash::Hash::hash(&__self_0_0, state)
}
}
impl ::core::marker::StructuralPartialEq for Packed {}
impl ::core::cmp::PartialEq for Packed {
#[inline]
fn eq(&self, other: &Packed) -> bool {
- {
- let Self(__self_0_0) = *self;
- let Self(__self_1_0) = *other;
- __self_0_0 == __self_1_0
- }
+ let Self(__self_0_0) = *self;
+ let Self(__self_1_0) = *other;
+ __self_0_0 == __self_1_0
}
#[inline]
fn ne(&self, other: &Packed) -> bool {
- {
- let Self(__self_0_0) = *self;
- let Self(__self_1_0) = *other;
- __self_0_0 != __self_1_0
- }
+ let Self(__self_0_0) = *self;
+ let Self(__self_1_0) = *other;
+ __self_0_0 != __self_1_0
}
}
impl ::core::marker::StructuralEq for Packed {}
#[doc(hidden)]
#[no_coverage]
fn assert_receiver_is_total_eq(&self) -> () {
- { let _: ::core::cmp::AssertParamIsEq<u32>; }
+ let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
#[inline]
fn partial_cmp(&self, other: &Packed)
-> ::core::option::Option<::core::cmp::Ordering> {
- {
- let Self(__self_0_0) = *self;
- let Self(__self_1_0) = *other;
- match ::core::cmp::PartialOrd::partial_cmp(&__self_0_0,
- &__self_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- }
- }
+ let Self(__self_0_0) = *self;
+ let Self(__self_1_0) = *other;
+ ::core::cmp::PartialOrd::partial_cmp(&__self_0_0, &__self_1_0)
}
}
#[automatically_derived]
impl ::core::cmp::Ord for Packed {
#[inline]
fn cmp(&self, other: &Packed) -> ::core::cmp::Ordering {
- {
- let Self(__self_0_0) = *self;
- let Self(__self_1_0) = *other;
- match ::core::cmp::Ord::cmp(&__self_0_0, &__self_1_0) {
- ::core::cmp::Ordering::Equal => ::core::cmp::Ordering::Equal,
- cmp => cmp,
+ let Self(__self_0_0) = *self;
+ let Self(__self_1_0) = *other;
+ ::core::cmp::Ord::cmp(&__self_0_0, &__self_1_0)
+ }
+}
+
+// An empty enum.
+enum Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum0 {
+ #[inline]
+ fn clone(&self) -> Enum0 { *self }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::marker::Copy for Enum0 { }
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum0 {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ unsafe { ::core::intrinsics::unreachable() }
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum0 {
+ fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+ unsafe { ::core::intrinsics::unreachable() }
+ }
+}
+impl ::core::marker::StructuralPartialEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum0 {
+ #[inline]
+ fn eq(&self, other: &Enum0) -> bool {
+ unsafe { ::core::intrinsics::unreachable() }
+ }
+}
+impl ::core::marker::StructuralEq for Enum0 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum0 {
+ #[inline]
+ #[doc(hidden)]
+ #[no_coverage]
+ fn assert_receiver_is_total_eq(&self) -> () {}
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialOrd for Enum0 {
+ #[inline]
+ fn partial_cmp(&self, other: &Enum0)
+ -> ::core::option::Option<::core::cmp::Ordering> {
+ unsafe { ::core::intrinsics::unreachable() }
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Ord for Enum0 {
+ #[inline]
+ fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering {
+ unsafe { ::core::intrinsics::unreachable() }
+ }
+}
+
+// A single-variant enum.
+enum Enum1 {
+ Single {
+ x: u32,
+ },
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Enum1 {
+ #[inline]
+ fn clone(&self) -> Enum1 {
+ match &*self {
+ &Enum1::Single { x: ref __self_0 } =>
+ Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
+ }
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::fmt::Debug for Enum1 {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ match &*self {
+ &Enum1::Single { x: ref __self_0 } =>
+ ::core::fmt::Formatter::debug_struct_field1_finish(f,
+ "Single", "x", &&*__self_0),
+ }
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::hash::Hash for Enum1 {
+ fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
+ match &*self {
+ &Enum1::Single { x: ref __self_0 } => {
+ ::core::hash::Hash::hash(&*__self_0, state)
}
}
}
}
+impl ::core::marker::StructuralPartialEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialEq for Enum1 {
+ #[inline]
+ fn eq(&self, other: &Enum1) -> bool {
+ match (&*self, &*other) {
+ (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+ x: ref __arg_1_0 }) => *__self_0 == *__arg_1_0,
+ }
+ }
+ #[inline]
+ fn ne(&self, other: &Enum1) -> bool {
+ match (&*self, &*other) {
+ (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+ x: ref __arg_1_0 }) => *__self_0 != *__arg_1_0,
+ }
+ }
+}
+impl ::core::marker::StructuralEq for Enum1 {}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Eq for Enum1 {
+ #[inline]
+ #[doc(hidden)]
+ #[no_coverage]
+ fn assert_receiver_is_total_eq(&self) -> () {
+ let _: ::core::cmp::AssertParamIsEq<u32>;
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::PartialOrd for Enum1 {
+ #[inline]
+ fn partial_cmp(&self, other: &Enum1)
+ -> ::core::option::Option<::core::cmp::Ordering> {
+ match (&*self, &*other) {
+ (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+ x: ref __arg_1_0 }) =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_0, &*__arg_1_0),
+ }
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::cmp::Ord for Enum1 {
+ #[inline]
+ fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {
+ match (&*self, &*other) {
+ (&Enum1::Single { x: ref __self_0 }, &Enum1::Single {
+ x: ref __arg_1_0 }) =>
+ ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+ }
+ }
+}
// A C-like, fieldless enum.
enum Fieldless {
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Fieldless {
#[inline]
- fn clone(&self) -> Fieldless { { *self } }
+ fn clone(&self) -> Fieldless { *self }
}
#[automatically_derived]
#[allow(unused_qualifications)]
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Fieldless {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- match (&*self,) {
- (&Fieldless::A,) => ::core::fmt::Formatter::write_str(f, "A"),
- (&Fieldless::B,) => ::core::fmt::Formatter::write_str(f, "B"),
- (&Fieldless::C,) => ::core::fmt::Formatter::write_str(f, "C"),
+ match &*self {
+ &Fieldless::A => ::core::fmt::Formatter::write_str(f, "A"),
+ &Fieldless::B => ::core::fmt::Formatter::write_str(f, "B"),
+ &Fieldless::C => ::core::fmt::Formatter::write_str(f, "C"),
}
}
}
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Fieldless {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- match (&*self,) {
+ match &*self {
_ => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
impl ::core::cmp::PartialEq for Fieldless {
#[inline]
fn eq(&self, other: &Fieldless) -> bool {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) { _ => true, }
- } else { false }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) { _ => true, }
+ } else { false }
}
}
impl ::core::marker::StructuralEq for Fieldless {}
#[inline]
#[doc(hidden)]
#[no_coverage]
- fn assert_receiver_is_total_eq(&self) -> () { {} }
+ fn assert_receiver_is_total_eq(&self) -> () {}
}
#[automatically_derived]
#[allow(unused_qualifications)]
#[inline]
fn partial_cmp(&self, other: &Fieldless)
-> ::core::option::Option<::core::cmp::Ordering> {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- _ =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- }
- } else {
- ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
- &__arg_1_vi)
- }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ _ =>
+ ::core::option::Option::Some(::core::cmp::Ordering::Equal),
+ }
+ } else {
+ ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+ }
}
}
#[automatically_derived]
impl ::core::cmp::Ord for Fieldless {
#[inline]
fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- _ => ::core::cmp::Ordering::Equal,
- }
- } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) { _ => ::core::cmp::Ordering::Equal, }
+ } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
}
}
impl ::core::clone::Clone for Mixed {
#[inline]
fn clone(&self) -> Mixed {
- {
- let _: ::core::clone::AssertParamIsClone<u32>;
- let _: ::core::clone::AssertParamIsClone<u32>;
- let _: ::core::clone::AssertParamIsClone<u32>;
- *self
- }
+ let _: ::core::clone::AssertParamIsClone<u32>;
+ *self
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Mixed {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- match (&*self,) {
- (&Mixed::P,) => ::core::fmt::Formatter::write_str(f, "P"),
- (&Mixed::Q,) => ::core::fmt::Formatter::write_str(f, "Q"),
- (&Mixed::R(ref __self_0),) =>
+ match &*self {
+ &Mixed::P => ::core::fmt::Formatter::write_str(f, "P"),
+ &Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"),
+ &Mixed::R(ref __self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
&&*__self_0),
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) =>
+ &Mixed::S { d1: ref __self_0, d2: ref __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
"d1", &&*__self_0, "d2", &&*__self_1),
}
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Mixed {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- match (&*self,) {
- (&Mixed::R(ref __self_0),) => {
+ match &*self {
+ &Mixed::R(ref __self_0) => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
::core::hash::Hash::hash(&*__self_0, state)
}
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) => {
+ &Mixed::S { d1: ref __self_0, d2: ref __self_1 } => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
::core::hash::Hash::hash(&*__self_0, state);
impl ::core::cmp::PartialEq for Mixed {
#[inline]
fn eq(&self, other: &Mixed) -> bool {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
- *__self_0 == *__arg_1_0,
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
- &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
- *__self_0 == *__arg_1_0 && *__self_1 == *__arg_1_1,
- _ => true,
- }
- } else { false }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+ *__self_0 == *__arg_1_0,
+ (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+ &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+ *__self_0 == *__arg_1_0 && *__self_1 == *__arg_1_1,
+ _ => true,
+ }
+ } else { false }
}
#[inline]
fn ne(&self, other: &Mixed) -> bool {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
- *__self_0 != *__arg_1_0,
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
- &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
- *__self_0 != *__arg_1_0 || *__self_1 != *__arg_1_1,
- _ => false,
- }
- } else { true }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+ *__self_0 != *__arg_1_0,
+ (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+ &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+ *__self_0 != *__arg_1_0 || *__self_1 != *__arg_1_1,
+ _ => false,
+ }
+ } else { true }
}
}
impl ::core::marker::StructuralEq for Mixed {}
#[doc(hidden)]
#[no_coverage]
fn assert_receiver_is_total_eq(&self) -> () {
- {
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<u32>;
- }
+ let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
#[inline]
fn partial_cmp(&self, other: &Mixed)
-> ::core::option::Option<::core::cmp::Ordering> {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
- &*__arg_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
- &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
- &*__arg_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_1,
- &*__arg_1_1) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
- cmp => cmp,
- },
- _ =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- }
- } else {
- ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
- &__arg_1_vi)
- }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+ &*__arg_1_0),
+ (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+ &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+ match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+ &*__arg_1_0) {
+ ::core::option::Option::Some(::core::cmp::Ordering::Equal)
+ =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_1,
+ &*__arg_1_1),
+ cmp => cmp,
+ },
+ _ =>
+ ::core::option::Option::Some(::core::cmp::Ordering::Equal),
+ }
+ } else {
+ ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+ }
}
}
#[automatically_derived]
impl ::core::cmp::Ord for Mixed {
#[inline]
fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
- match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
- (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
- &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
- match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
- ::core::cmp::Ordering::Equal =>
- match ::core::cmp::Ord::cmp(&*__self_1, &*__arg_1_1) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
- cmp => cmp,
- },
- _ => ::core::cmp::Ordering::Equal,
- }
- } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Mixed::R(ref __self_0), &Mixed::R(ref __arg_1_0)) =>
+ ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+ (&Mixed::S { d1: ref __self_0, d2: ref __self_1 },
+ &Mixed::S { d1: ref __arg_1_0, d2: ref __arg_1_1 }) =>
+ match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
+ ::core::cmp::Ordering::Equal =>
+ ::core::cmp::Ord::cmp(&*__self_1, &*__arg_1_1),
+ cmp => cmp,
+ },
+ _ => ::core::cmp::Ordering::Equal,
+ }
+ } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
}
}
impl ::core::clone::Clone for Fielded {
#[inline]
fn clone(&self) -> Fielded {
- match (&*self,) {
- (&Fielded::X(ref __self_0),) =>
+ match &*self {
+ &Fielded::X(ref __self_0) =>
Fielded::X(::core::clone::Clone::clone(&*__self_0)),
- (&Fielded::Y(ref __self_0),) =>
+ &Fielded::Y(ref __self_0) =>
Fielded::Y(::core::clone::Clone::clone(&*__self_0)),
- (&Fielded::Z(ref __self_0),) =>
+ &Fielded::Z(ref __self_0) =>
Fielded::Z(::core::clone::Clone::clone(&*__self_0)),
}
}
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Fielded {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- match (&*self,) {
- (&Fielded::X(ref __self_0),) =>
+ match &*self {
+ &Fielded::X(ref __self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
&&*__self_0),
- (&Fielded::Y(ref __self_0),) =>
+ &Fielded::Y(ref __self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
&&*__self_0),
- (&Fielded::Z(ref __self_0),) =>
+ &Fielded::Z(ref __self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
&&*__self_0),
}
#[allow(unused_qualifications)]
impl ::core::hash::Hash for Fielded {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
- match (&*self,) {
- (&Fielded::X(ref __self_0),) => {
+ match &*self {
+ &Fielded::X(ref __self_0) => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
::core::hash::Hash::hash(&*__self_0, state)
}
- (&Fielded::Y(ref __self_0),) => {
+ &Fielded::Y(ref __self_0) => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
::core::hash::Hash::hash(&*__self_0, state)
}
- (&Fielded::Z(ref __self_0),) => {
+ &Fielded::Z(ref __self_0) => {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state);
::core::hash::Hash::hash(&*__self_0, state)
impl ::core::cmp::PartialEq for Fielded {
#[inline]
fn eq(&self, other: &Fielded) -> bool {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
- *__self_0 == *__arg_1_0,
- (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
- *__self_0 == *__arg_1_0,
- (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
- *__self_0 == *__arg_1_0,
- _ => unsafe { ::core::intrinsics::unreachable() }
- }
- } else { false }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+ *__self_0 == *__arg_1_0,
+ (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+ *__self_0 == *__arg_1_0,
+ (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+ *__self_0 == *__arg_1_0,
+ _ => unsafe { ::core::intrinsics::unreachable() }
+ }
+ } else { false }
}
#[inline]
fn ne(&self, other: &Fielded) -> bool {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
- *__self_0 != *__arg_1_0,
- (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
- *__self_0 != *__arg_1_0,
- (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
- *__self_0 != *__arg_1_0,
- _ => unsafe { ::core::intrinsics::unreachable() }
- }
- } else { true }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+ *__self_0 != *__arg_1_0,
+ (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+ *__self_0 != *__arg_1_0,
+ (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+ *__self_0 != *__arg_1_0,
+ _ => unsafe { ::core::intrinsics::unreachable() }
+ }
+ } else { true }
}
}
impl ::core::marker::StructuralEq for Fielded {}
#[doc(hidden)]
#[no_coverage]
fn assert_receiver_is_total_eq(&self) -> () {
- {
- let _: ::core::cmp::AssertParamIsEq<u32>;
- let _: ::core::cmp::AssertParamIsEq<bool>;
- let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
- }
+ let _: ::core::cmp::AssertParamIsEq<u32>;
+ let _: ::core::cmp::AssertParamIsEq<bool>;
+ let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
}
}
#[automatically_derived]
#[inline]
fn partial_cmp(&self, other: &Fielded)
-> ::core::option::Option<::core::cmp::Ordering> {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
- &*__arg_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
- (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
- &*__arg_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
- (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
- match ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
- &*__arg_1_0) {
- ::core::option::Option::Some(::core::cmp::Ordering::Equal)
- =>
- ::core::option::Option::Some(::core::cmp::Ordering::Equal),
- cmp => cmp,
- },
- _ => unsafe { ::core::intrinsics::unreachable() }
- }
- } else {
- ::core::cmp::PartialOrd::partial_cmp(&__self_vi,
- &__arg_1_vi)
- }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+ &*__arg_1_0),
+ (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+ &*__arg_1_0),
+ (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+ ::core::cmp::PartialOrd::partial_cmp(&*__self_0,
+ &*__arg_1_0),
+ _ => unsafe { ::core::intrinsics::unreachable() }
+ }
+ } else {
+ ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi)
+ }
}
}
#[automatically_derived]
impl ::core::cmp::Ord for Fielded {
#[inline]
fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {
- {
- let __self_vi = ::core::intrinsics::discriminant_value(&*self);
- let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
- if __self_vi == __arg_1_vi {
- match (&*self, &*other) {
- (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
- match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
- (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
- match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
- (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
- match ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0) {
- ::core::cmp::Ordering::Equal =>
- ::core::cmp::Ordering::Equal,
- cmp => cmp,
- },
- _ => unsafe { ::core::intrinsics::unreachable() }
- }
- } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
- }
+ let __self_vi = ::core::intrinsics::discriminant_value(&*self);
+ let __arg_1_vi = ::core::intrinsics::discriminant_value(&*other);
+ if __self_vi == __arg_1_vi {
+ match (&*self, &*other) {
+ (&Fielded::X(ref __self_0), &Fielded::X(ref __arg_1_0)) =>
+ ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+ (&Fielded::Y(ref __self_0), &Fielded::Y(ref __arg_1_0)) =>
+ ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+ (&Fielded::Z(ref __self_0), &Fielded::Z(ref __arg_1_0)) =>
+ ::core::cmp::Ord::cmp(&*__self_0, &*__arg_1_0),
+ _ => unsafe { ::core::intrinsics::unreachable() }
+ }
+ } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) }
}
}
+
+// A union. Most builtin traits are not derivable for unions.
+pub union Union {
+ pub b: bool,
+ pub u: u32,
+ pub i: i32,
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::clone::Clone for Union {
+ #[inline]
+ fn clone(&self) -> Union {
+ let _: ::core::clone::AssertParamIsCopy<Self>;
+ *self
+ }
+}
+#[automatically_derived]
+#[allow(unused_qualifications)]
+impl ::core::marker::Copy for Union { }
--- /dev/null
+// compile-flags: --diagnostic-width=20
+
+// This test checks that `-Z output-width` effects the human error output by restricting it to an
+// arbitrarily low value so that the effect is visible.
+
+fn main() {
+ let _: () = 42;
+ //~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/flag-human.rs:7:17
+ |
+LL | ..._: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// compile-flags: --diagnostic-width=20 --error-format=json
+
+// This test checks that `-Z output-width` effects the JSON error output by restricting it to an
+// arbitrarily low value so that the effect is visible.
+
+fn main() {
+ let _: () = 42;
+ //~^ ERROR arguments to this function are incorrect
+}
--- /dev/null
+{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
+
+Erroneous code examples:
+
+```compile_fail,E0308
+fn plus_one(x: i32) -> i32 {
+ x + 1
+}
+
+plus_one(\"Not a number\");
+// ^^^^^^^^^^^^^^ expected `i32`, found `&str`
+
+if \"Not a bool\" {
+// ^^^^^^^^^^^^ expected `bool`, found `&str`
+}
+
+let x: f32 = \"Not a float\";
+// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
+// |
+// expected due to this
+```
+
+This error occurs when an expression was used in a place where the compiler
+expected an expression of a different type. It can occur in several cases, the
+most common being when calling a function and passing an argument which has a
+different type than the matching type in the function declaration.
+"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":243,"byte_end":245,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":238,"byte_end":240,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
+ --> $DIR/flag-json.rs:7:17
+ |
+LL | ..._: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+"}
+{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
+
+"}
+{"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.
+"}
--- /dev/null
+// ignore-tidy-linelength
+
+fn main() {
+ let unicode_is_fun = "‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
+ let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+ //~^ ERROR cannot add `&str` to `&str`
+}
--- /dev/null
+error[E0369]: cannot add `&str` to `&str`
+ --> $DIR/non-1-width-unicode-multiline-label.rs:5:260
+ |
+LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+ | -------------- ^ -------------- &str
+ | | |
+ | | `+` cannot be used to concatenate two `&str` strings
+ | &str
+ |
+ = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+ |
+LL | let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
+ | +++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0369`.
--- /dev/null
+// ignore-tidy-linelength
+
+fn main() {
+ let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
+//~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming-2.rs:4:311
+ |
+LL | ...13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let ...
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// ignore-tidy-linelength
+
+fn main() {
+ let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
+//~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming-unicode.rs:4:415
+ |
+LL | ...♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄...
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// ignore-tidy-linelength
+
+fn main() {
+ let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
+//~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming.rs:4:241
+ |
+LL | ... () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ...
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// Test for #78438: ensure underline alignment with many tabs on the left, long line on the right
+
+// ignore-tidy-linelength
+// ignore-tidy-tab
+
+ fn main() {
+ let money = 42i32;
+ match money {
+ v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
+ //~^ ERROR variable `v` is not bound in all patterns
+ v => println!("Enough money {}", v),
+ }
+ }
--- /dev/null
+error[E0408]: variable `v` is not bound in all patterns
+ --> $DIR/tabs-trimming.rs:9:16
+ |
+LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
+ | - ^ ^ pattern doesn't bind `v`
+ | | |
+ | | pattern doesn't bind `v`
+ | variable not in all patterns
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0408`.
--- /dev/null
+// ignore-tidy-linelength
+
+fn foo() -> usize {
+ ()
+//~^ ERROR mismatched types
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/whitespace-trimming-2.rs:4:187
+ |
+LL | ...-> usize {
+ | ----- expected `usize` because of return type
+LL | ... ()
+ | ^^ expected `usize`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// ignore-tidy-linelength
+
+fn main() {
+ let _: () = 42;
+//~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/whitespace-trimming.rs:4:193
+ |
+LL | ... let _: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--> $DIR/issue-40006.rs:38:7
|
LL | struct S;
- | - method `hello_method` not found for this struct
+ | -------- method `hello_method` not found for this struct
...
LL | S.hello_method();
| ^^^^^^^^^^^^ method not found in `S`
--> $DIR/dont-suggest-private-trait-method.rs:4:8
|
LL | struct T;
- | - function or associated item `new` not found for this struct
+ | -------- function or associated item `new` not found for this struct
...
LL | T::new();
| ^^^ function or associated item not found in `T`
fn must_be_init() {
let x: u8;
- let _ = [x; 0]; //~ ERROR: use of possibly-uninitialized variable: `x`
+ let _ = [x; 0]; //~ ERROR E0381
}
fn main() {}
| |constants cannot evaluate destructors
| value is dropped here
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/repeat-drop-2.rs:12:14
|
+LL | let x: u8;
+ | - binding declared here but left uninitialized
LL | let _ = [x; 0];
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error: aborting due to 3 previous errors
-pub enum Test { //~ HELP consider adding `#[derive(Default)]` to this enum
+pub enum Test { //~ HELP consider adding a derive
#[default]
//~^ ERROR cannot find attribute `default` in this scope
First,
LL | #[default]
| ^^^^^^^
|
-help: consider adding `#[derive(Default)]` to this enum
- --> $DIR/suggest-default-attribute.rs:1:1
+help: consider adding a derive
+ |
+LL + #[derive(Default)]
+LL ~ pub enum Test {
|
-LL | pub enum Test {
- | ^^^^^^^^^^^^^
error: aborting due to previous error
--> $DIR/E0599.rs:4:20
|
LL | struct Foo;
- | --- associated item `NotEvenReal` not found for this struct
+ | ---------- associated item `NotEvenReal` not found for this struct
...
LL | || if let Foo::NotEvenReal() = Foo {};
| ^^^^^^^^^^^ associated item not found in `Foo`
//~^ ERROR cannot assign to `x`, as it is a captured variable in a `Fn` closure
//~| NOTE cannot assign
//~| NOTE expects `Fn` instead of `FnMut`
+ //~| NOTE in this closure
}
fn main() {}
| - change this to accept `FnMut` instead of `Fn`
...
LL | bar(move || x = 1);
- | --- ^^^^^ cannot assign
- | |
+ | --- ------- ^^^^^ cannot assign
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error: aborting due to previous error
LL | arc.blablabla();
| ^^^^^^^^^ method not found in `Arc<_>`
-error[E0599]: no method named `blablabla` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>` in the current scope
+error[E0599]: no method named `blablabla` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:38]>` in the current scope
--> $DIR/fn-help-with-err.rs:12:10
|
LL | arc2.blablabla();
- | ---- ^^^^^^^^^ method not found in `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>`
+ | ---- ^^^^^^^^^ method not found in `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:38]>`
| |
| this is a function, perhaps you wish to call it
LL | assert_send(|| {
| ^^^^^^^^^^^ generator is not `Send`
|
- = help: within `[generator@$DIR/drop-yield-twice.rs:7:17: 12:6]`, the trait `Send` is not implemented for `Foo`
+ = help: within `[generator@$DIR/drop-yield-twice.rs:7:17: 7:19]`, the trait `Send` is not implemented for `Foo`
note: generator is not `Send` as this value is used across a yield
--> $DIR/drop-yield-twice.rs:9:9
|
-error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6] as Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 19:6]`
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36] as Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36]`
--> $DIR/generator-yielding-or-returning-itself.rs:15:5
|
LL | want_cyclic_generator_return(|| {
LL | where T: Generator<Yield = (), Return = T>
| ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return`
-error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6] as Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 32:6]`
+error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35] as Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35]`
--> $DIR/generator-yielding-or-returning-itself.rs:28:5
|
LL | want_cyclic_generator_yield(|| {
note: required because it's used within this generator
--> $DIR/issue-68112.rs:48:5
|
-LL | / || {
-LL | | yield;
-LL | | t
-LL | | }
- | |_____^
+LL | || {
+ | ^^
note: required because it appears within the type `impl Generator<Return = Arc<RefCell<i32>>>`
--> $DIR/issue-68112.rs:45:30
|
note: required because it's used within this generator
--> $DIR/issue-68112.rs:59:20
|
-LL | let send_gen = || {
- | ____________________^
-LL | | let _non_send_gen = make_non_send_generator2();
-LL | | yield;
-LL | | };
- | |_____^
+LL | let send_gen = || {
+ | ^^
note: required by a bound in `require_send`
--> $DIR/issue-68112.rs:22:25
|
note: required because it's used within this generator
--> $DIR/not-send-sync.rs:16:17
|
-LL | assert_send(|| {
- | _________________^
-LL | |
-LL | | drop(&a);
-LL | | yield;
-LL | | });
- | |_____^
+LL | assert_send(|| {
+ | ^^
note: required by a bound in `assert_send`
--> $DIR/not-send-sync.rs:7:23
|
LL | assert_sync(|| {
| ^^^^^^^^^^^ generator is not `Sync`
|
- = help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6]`, the trait `Sync` is not implemented for `Cell<i32>`
+ = help: within `[generator@$DIR/not-send-sync.rs:9:17: 9:19]`, the trait `Sync` is not implemented for `Cell<i32>`
note: generator is not `Sync` as this value is used across a yield
--> $DIR/not-send-sync.rs:12:9
|
LL | assert_send(|| {
| ^^^^^^^^^^^ generator is not `Send`
|
- = help: within `[generator@$DIR/partial-drop.rs:14:17: 20:6]`, the trait `Send` is not implemented for `Foo`
+ = help: within `[generator@$DIR/partial-drop.rs:14:17: 14:19]`, the trait `Send` is not implemented for `Foo`
note: generator is not `Send` as this value is used across a yield
--> $DIR/partial-drop.rs:19:9
|
LL | assert_send(|| {
| ^^^^^^^^^^^ generator is not `Send`
|
- = help: within `[generator@$DIR/partial-drop.rs:22:17: 30:6]`, the trait `Send` is not implemented for `Foo`
+ = help: within `[generator@$DIR/partial-drop.rs:22:17: 22:19]`, the trait `Send` is not implemented for `Foo`
note: generator is not `Send` as this value is used across a yield
--> $DIR/partial-drop.rs:29:9
|
LL | assert_send(|| {
| ^^^^^^^^^^^ generator is not `Send`
|
- = help: within `[generator@$DIR/partial-drop.rs:32:17: 39:6]`, the trait `Send` is not implemented for `Foo`
+ = help: within `[generator@$DIR/partial-drop.rs:32:17: 32:19]`, the trait `Send` is not implemented for `Foo`
note: generator is not `Send` as this value is used across a yield
--> $DIR/partial-drop.rs:38:9
|
fn test_tuple() {
let _ = || {
let mut t: (i32, i32);
- t.0 = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 42; //~ ERROR E0381
yield;
t.1 = 88;
let _ = t;
fn test_tuple_struct() {
let _ = || {
let mut t: T;
- t.0 = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 42; //~ ERROR E0381
yield;
t.1 = 88;
let _ = t;
fn test_struct() {
let _ = || {
let mut t: S;
- t.x = 42;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.x = 42; //~ ERROR E0381
yield;
t.y = 88;
let _ = t;
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
+error[E0381]: partially assigned binding `t` isn't fully initialized
--> $DIR/partial-initialization-across-yield.rs:12:9
|
+LL | let mut t: (i32, i32);
+ | ----- binding declared here but left uninitialized
LL | t.0 = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/partial-initialization-across-yield.rs:23:9
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/partial-initialization-across-yield.rs:22:9
|
+LL | let mut t: T;
+ | ----- binding declared here but left uninitialized
LL | t.0 = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/partial-initialization-across-yield.rs:34:9
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/partial-initialization-across-yield.rs:32:9
|
+LL | let mut t: S;
+ | ----- binding declared here but left uninitialized
LL | t.x = 42;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error: aborting due to 3 previous errors
note: required because it's used within this generator
--> $DIR/generator-print-verbose-1.rs:42:5
|
-LL | / || {
-LL | | yield;
-LL | | t
-LL | | }
- | |_____^
+LL | || {
+ | ^^
note: required because it appears within the type `Opaque(DefId(0:39 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])`
--> $DIR/generator-print-verbose-1.rs:41:30
|
note: required because it's used within this generator
--> $DIR/generator-print-verbose-1.rs:52:20
|
-LL | let send_gen = || {
- | ____________________^
-LL | | let _non_send_gen = make_non_send_generator2();
-LL | | yield;
-LL | | };
- | |_____^
+LL | let send_gen = || {
+ | ^^
note: required by a bound in `require_send`
--> $DIR/generator-print-verbose-1.rs:26:25
|
note: required because it's used within this generator
--> $DIR/generator-print-verbose-2.rs:19:17
|
-LL | assert_send(|| {
- | _________________^
-LL | |
-LL | | drop(&a);
-LL | | yield;
-LL | | });
- | |_____^
+LL | assert_send(|| {
+ | ^^
note: required by a bound in `assert_send`
--> $DIR/generator-print-verbose-2.rs:10:23
|
-error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]` cannot be unpinned
+error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` cannot be unpinned
--> $DIR/static-not-unpin.rs:14:18
|
LL | assert_unpin(generator);
- | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]`
+ | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]`
| |
| required by a bound introduced by this call
|
LL | return Ok(6);
| ^^^^^
-error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 15:6] as Generator>::Return == i32`
+error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7] as Generator>::Return == i32`
--> $DIR/type-mismatch-signature-deduction.rs:5:13
|
LL | fn foo() -> impl Generator<Return = i32> {
|
LL | struct S;
| --------
- | | |
- | | method `f` not found for this struct
+ | |
+ | method `f` not found for this struct
| doesn't satisfy `<S as X>::Y<i32> = i32`
| doesn't satisfy `S: M`
...
LL | v.t(|| {});
| ^^^^^^^^^^
|
- = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed`
+ = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:11] well-formed`
error: higher-ranked lifetime error
--> $DIR/issue-59311.rs:17:9
--> $DIR/issue-71955.rs:45:24
|
LL | foo(bar, "string", |s| s.len() == 5);
- | ^^^^^^^^^^^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:25:9
|
--> $DIR/issue-71955.rs:45:24
|
LL | foo(bar, "string", |s| s.len() == 5);
- | ^^^^^^^^^^^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:25:44
|
--> $DIR/issue-71955.rs:48:24
|
LL | foo(baz, "string", |s| s.0.len() == 5);
- | ^^^^^^^^^^^^^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:25:9
|
--> $DIR/issue-71955.rs:48:24
|
LL | foo(baz, "string", |s| s.0.len() == 5);
- | ^^^^^^^^^^^^^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-71955.rs:25:44
|
-error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>`, but its trait bounds were not satisfied
+error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>`, but its trait bounds were not satisfied
--> $DIR/issue-30786.rs:118:22
|
LL | pub struct Map<S, F> {
| --------------------
- | | |
- | | method `filterx` not found for this struct
+ | |
+ | method `filterx` not found for this struct
| doesn't satisfy `_: StreamExt`
...
LL | let filter = map.filterx(|x: &_| true);
- | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>` due to unsatisfied trait bounds
+ | ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>` due to unsatisfied trait bounds
|
note: the following trait bounds were not satisfied:
- `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
- `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
- `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:36]>: Stream`
+ `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
+ `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
+ `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
--> $DIR/issue-30786.rs:96:50
|
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
LL | let filter = map.stream.filterx(|x: &_| true);
| +++++++
-error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>`, but its trait bounds were not satisfied
+error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied
--> $DIR/issue-30786.rs:130:24
|
LL | pub struct Filter<S, F> {
| -----------------------
- | | |
- | | method `countx` not found for this struct
+ | |
+ | method `countx` not found for this struct
| doesn't satisfy `_: StreamExt`
...
LL | let count = filter.countx();
- | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>` due to unsatisfied trait bounds
+ | ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds
|
note: the following trait bounds were not satisfied:
- `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
- `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
- `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:42]>: Stream`
+ `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
+ `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
+ `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
--> $DIR/issue-30786.rs:96:50
|
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
-error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
+error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
--> $DIR/issue-62203-hrtb-ice.rs:38:19
|
LL | let v = Unit2.m(
- | ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
+ | ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
|
note: expected this to be `<_ as Ty<'_>>::V`
--> $DIR/issue-62203-hrtb-ice.rs:21:14
LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m`
-error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&'r u8,),)>>::Output == Unit3`
+error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20] as FnOnce<((&'r u8,),)>>::Output == Unit3`
--> $DIR/issue-62203-hrtb-ice.rs:40:9
|
LL | let v = Unit2.m(
LL | | });
| |_________^ expected struct `Unit3`, found struct `Unit4`
|
-note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>`
+note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:20]>`
--> $DIR/issue-62203-hrtb-ice.rs:17:16
|
LL | impl<'a, A, T> T0<'a, A> for L<T>
// return type, which can't depend on the obligation.
fn cycle1() -> impl Clone {
//~^ ERROR cycle detected
- //~| ERROR cycle detected
send(cycle2().clone());
Rc::new(Cell::new(5))
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires computing type of `cycle2::{opaque#0}`...
- --> $DIR/auto-trait-leak.rs:20:16
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^
-note: ...which requires borrow-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
- --> $DIR/auto-trait-leak.rs:1:1
- |
-LL | / use std::cell::Cell;
-LL | | use std::rc::Rc;
-LL | |
-LL | | fn send<T: Send>(_: T) {}
-... |
-LL | | Rc::new(String::from("foo"))
-LL | | }
- | |_^
-
-error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
- --> $DIR/auto-trait-leak.rs:12:16
+ --> $DIR/auto-trait-leak.rs:14:5
|
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^
- |
-note: ...which requires borrow-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires processing MIR for `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
- |
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | send(cycle2().clone());
+ | ^^^^
+ = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
note: ...which requires computing type of `cycle2::{opaque#0}`...
- --> $DIR/auto-trait-leak.rs:20:16
+ --> $DIR/auto-trait-leak.rs:19:16
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^
note: ...which requires borrow-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires unsafety-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires building MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:19:1
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:20:1
+ --> $DIR/auto-trait-leak.rs:20:5
|
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | send(cycle1().clone());
+ | ^^^^
+ = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`...
= note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/auto-trait-leak.rs:1:1
LL | | }
| |_^
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.
--> $DIR/auto-trait-leak2.rs:10:5
|
LL | move |x| p.set(x)
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^
note: required because it appears within the type `impl Fn(i32)`
--> $DIR/auto-trait-leak2.rs:5:16
|
--> $DIR/auto-trait-leak2.rs:38:5
|
LL | move |x| p.set(x)
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^
note: required because it appears within the type `impl Fn(i32)`
--> $DIR/auto-trait-leak2.rs:33:15
|
--> $DIR/issue-21659-show-relevant-trait-impls-3.rs:20:8
|
LL | struct Bar;
- | --- method `foo` not found for this struct
+ | ---------- method `foo` not found for this struct
...
LL | f1.foo(1usize);
| ^^^ method not found in `Bar`
| --------------------- doesn't satisfy `RawImpl<()>: Raw<()>`
...
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
- | -------- function or associated item `foo` not found for this struct
+ | ----------------------------------------- function or associated item `foo` not found for this struct
|
= note: the following trait bounds were not satisfied:
`RawImpl<()>: Raw<()>`
| |_____^ expected closure, found a different closure
|
= note: expected opaque type `Closure`
- found closure `[closure@$DIR/issue-74282.rs:8:15: 10:6]`
+ found closure `[closure@$DIR/issue-74282.rs:8:15: 8:17]`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
note: tuple struct defined here
--> $DIR/method-suggestion-no-duplication.rs:7:15
|
LL | struct Foo;
- | --- method `is_empty` not found for this struct
+ | ---------- method `is_empty` not found for this struct
...
LL | foo(|s| s.is_empty());
| ^^^^^^^^ method not found in `Foo`
--> $DIR/must_outlive_least_region_or_bound.rs:38:5
|
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
- | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:31]` captures the lifetime `'b` as defined here
+ | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:13]` captures the lifetime `'b` as defined here
LL | move |_| println!("{}", y)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `Sendable`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:27:5: 27:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:27:5: 27:7]`
--> $DIR/nested-return-type2-tait.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^^^^^ the trait `Duh` is not implemented for `Sendable`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:28:5: 28:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:28:5: 28:7]`
--> $DIR/nested-return-type2-tait2.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:27:5: 27:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:27:5: 27:7]`
--> $DIR/nested-return-type2-tait3.rs:14:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
|
= help: the trait `Duh` is implemented for `i32`
-note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:23:5: 23:10]`
+note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:23:5: 23:7]`
--> $DIR/nested-return-type2.rs:12:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
--> $DIR/no-method-suggested-traits.rs:40:9
|
LL | struct Foo;
- | --- method `method` not found for this struct
+ | ---------- method `method` not found for this struct
...
LL | Foo.method();
| ^^^^^^ method not found in `Foo`
--> $DIR/no-method-suggested-traits.rs:59:9
|
LL | struct Foo;
- | --- method `method3` not found for this struct
+ | ---------- method `method3` not found for this struct
...
LL | Foo.method3();
| ^^^^^^^ method not found in `Foo`
--> $DIR/no-method-suggested-traits.rs:63:12
|
LL | enum Bar { X }
- | --- method `method3` not found for this enum
+ | -------- method `method3` not found for this enum
...
LL | Bar::X.method3();
| ^^^^^^^ method not found in `Bar`
LL | / move || {
LL | | x;
LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 37:6]`
+ | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 35:12]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:40:29
LL | / move || {
LL | | &x;
LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 45:6]`
+ | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 43:12]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:48:21
| ^^^^^^^^^^ recursive opaque type
LL |
LL | || closure_sig()
- | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:21]`
+ | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:7]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:53:23
| ^^^^^^^^^^ recursive opaque type
LL |
LL | || generator_sig()
- | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:23]`
+ | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:7]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:58:27
LL | | yield;
LL | | x;
LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6]`
+ | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:67:35
LL | | yield;
LL | | x;
LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6]`
+ | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 74:12]`
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:86:26
--> $DIR/static-return-lifetime-infered.rs:7:9
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
- | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here
+ | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $DIR/static-return-lifetime-infered.rs:7:9
|
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
- | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here
+ | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $DIR/static-return-lifetime-infered.rs:12:9
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
- | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here
+ | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $DIR/static-return-lifetime-infered.rs:12:9
|
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
- | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here
+ | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:30]>` captures the lifetime `'a` as defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $DIR/infinite-autoderef.rs:25:9
|
LL | struct Foo;
- | --- method `bar` not found for this struct
+ | ---------- method `bar` not found for this struct
...
LL | Foo.bar();
| ^^^ method not found in `Foo`
--> $DIR/interior-mutability.rs:5:18
|
LL | catch_unwind(|| { x.set(23); });
- | ^^^^^^^^^^^^^^^^^
+ | ^^
note: required by a bound in `catch_unwind`
--> $SRC_DIR/std/src/panic.rs:LL:COL
|
-error[E0277]: the trait bound `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]: ~const FnOnce<()>` is not satisfied
+error[E0277]: the trait bound `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]: ~const FnOnce<()>` is not satisfied
--> $DIR/const-eval-select-bad.rs:6:27
|
LL | const_eval_select((), || {}, || {});
- | ----------------- ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
+ | ----------------- ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`
| |
| required by a bound introduced by this call
|
- = help: the trait `~const FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
-note: the trait `FnOnce<()>` is implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`, but that implementation is not `const`
+ = help: the trait `~const FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`
+note: the trait `FnOnce<()>` is implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]`, but that implementation is not `const`
--> $DIR/const-eval-select-bad.rs:6:27
|
LL | const_eval_select((), || {}, || {});
| ^^^^^
- = note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]` in a closure with no arguments: `|| { /* code */ }`
+ = note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:29]` in a closure with no arguments: `|| { /* code */ }`
note: required by a bound in `const_eval_select`
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
|
--> $DIR/intrinsic-raw_eq-const-padding.rs:6:5
|
LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading 4 bytes of memory starting at alloc3, but 1 byte is uninitialized starting at alloc3+0x1, and this operation requires initialized memory
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory
error: aborting due to previous error
|
LL | f();
| ^
- = note: move occurs because `f` has type `[closure@$DIR/issue-12127.rs:8:24: 8:41]`, which does not implement the `Copy` trait
+ = note: move occurs because `f` has type `[closure@$DIR/issue-12127.rs:8:24: 8:30]`, which does not implement the `Copy` trait
error: aborting due to previous error
--> $DIR/issue-19692.rs:4:40
|
LL | struct Homura;
- | ------ method `kaname` not found for this struct
+ | ------------- method `kaname` not found for this struct
...
LL | let Some(ref madoka) = Some(homura.kaname());
| ^^^^^^ method not found in `Homura`
| - change this to accept `FnMut` instead of `Fn`
...
LL | call_it(|| x.gen_mut());
- | ------- ^^^^^^^^^^^ cannot borrow as mutable
- | |
+ | ------- -- ^^^^^^^^^^^ cannot borrow as mutable
+ | | |
+ | | in this closure
| expects `Fn` instead of `FnMut`
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/issue-21600.rs:14:17
|
-LL | fn call_it<F>(f: F) where F: Fn() { f(); }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn call_it<F>(f: F) where F: Fn() { f(); }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | call_it(|| {
- | _____-------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | call_it(|| x.gen());
-LL | | call_it(|| x.gen_mut());
- | | ^^ - mutable borrow occurs due to use of `x` in closure
- | | |
- | | cannot borrow as mutable
-LL | |
-LL | |
-LL | | });
- | |_____- in this closure
+LL | call_it(|| {
+ | ------- -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | call_it(|| x.gen());
+LL | call_it(|| x.gen_mut());
+ | ^^ - mutable borrow occurs due to use of `x` in closure
+ | |
+ | cannot borrow as mutable
error: aborting due to 2 previous errors
LL | where &'a T : Foo,
| ^^^
|
- = note: cannot satisfy `&'a T: Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a T: Foo` found
+ --> $DIR/issue-21974.rs:11:19
+ |
+LL | where &'a T : Foo,
+ | ^^^
+LL | &'b T : Foo
+ | ^^^
error: aborting due to previous error
--> $DIR/issue-22933-2.rs:4:55
|
LL | enum Delicious {
- | --------- variant or associated item `PIE` not found for this enum
+ | -------------- variant or associated item `PIE` not found for this enum
...
LL | ApplePie = Delicious::Apple as isize | Delicious::PIE as isize,
| ^^^
--> $DIR/issue-23173.rs:9:23
|
LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ }
- | ----- variant or associated item `Homura` not found for this enum
+ | ---------- variant or associated item `Homura` not found for this enum
...
LL | use_token(&Token::Homura);
| ^^^^^^ variant or associated item not found in `Token`
--> $DIR/issue-23173.rs:10:13
|
LL | struct Struct {
- | ------ function or associated item `method` not found for this struct
+ | ------------- function or associated item `method` not found for this struct
...
LL | Struct::method();
| ^^^^^^ function or associated item not found in `Struct`
--> $DIR/issue-23173.rs:11:13
|
LL | struct Struct {
- | ------ function or associated item `method` not found for this struct
+ | ------------- function or associated item `method` not found for this struct
...
LL | Struct::method;
| ^^^^^^ function or associated item not found in `Struct`
--> $DIR/issue-23173.rs:12:13
|
LL | struct Struct {
- | ------ associated item `Assoc` not found for this struct
+ | ------------- associated item `Assoc` not found for this struct
...
LL | Struct::Assoc;
| ^^^^^ associated item not found in `Struct`
--> $DIR/issue-23217.rs:2:19
|
LL | pub enum SomeEnum {
- | -------- variant or associated item `A` not found for this enum
+ | ----------------- variant or associated item `A` not found for this enum
LL | B = SomeEnum::A,
| ^
| |
--> $DIR/issue-24036.rs:3:9
|
LL | let mut x = |c| c + 1;
- | --------- the expected closure
+ | --- the expected closure
LL | x = |c| c + 1;
| ^^^^^^^^^ expected closure, found a different closure
|
- = note: expected closure `[closure@$DIR/issue-24036.rs:2:17: 2:26]`
- found closure `[closure@$DIR/issue-24036.rs:3:9: 3:18]`
+ = note: expected closure `[closure@$DIR/issue-24036.rs:2:17: 2:20]`
+ found closure `[closure@$DIR/issue-24036.rs:3:9: 3:12]`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
| ^^^^^^^^^^^
|
- = note: cannot satisfy `T0: Trait0<'l0>`
+note: multiple `impl`s or `where` clauses satisfying `T0: Trait0<'l0>` found
+ --> $DIR/issue-24424.rs:4:57
+ |
+LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
+ | ^^^^^^^^^^^ ^^^^^^^^^^^
error: aborting due to previous error
--> $DIR/issue-2823.rs:13:16
|
LL | struct C {
- | - method `clone` not found for this struct
+ | -------- method `clone` not found for this struct
...
LL | let _d = c.clone();
| ^^^^^ method not found in `C`
--> $DIR/issue-28971.rs:7:18
|
LL | enum Foo {
- | --- variant or associated item `Baz` not found for this enum
+ | -------- variant or associated item `Baz` not found for this enum
...
LL | Foo::Baz(..) => (),
| ^^^
--> $DIR/issue-3044.rs:3:35
|
LL | needlesArr.iter().fold(|x, y| {
- | ___________________________________^
+ | ____________________________------_^
+ | | |
+ | | the expected closure
LL | | });
| |_____^ expected closure, found `()`
|
- = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 4:6]`
+ = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 3:34]`
found unit type `()`
error[E0061]: this function takes 2 arguments but 1 argument was supplied
-error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item == &_`
+error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item == &_`
--> $DIR/issue-31173.rs:10:10
|
LL | .cloned()
LL | Self: Sized + Iterator<Item = &'a T>,
| ^^^^^^^^^^^^ required by this bound in `cloned`
-error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`, but its trait bounds were not satisfied
+error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>`, but its trait bounds were not satisfied
--> $DIR/issue-31173.rs:12:10
|
LL | .collect();
- | ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` due to unsatisfied trait bounds
+ | ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>` due to unsatisfied trait bounds
|
::: $SRC_DIR/core/src/iter/adapters/cloned.rs:LL:COL
|
| -------------------------- doesn't satisfy `<_ as Iterator>::Item = &_`
|
= note: the following trait bounds were not satisfied:
- `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]> as Iterator>::Item = &_`
- which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
- `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
- which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>: Iterator`
+ `<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]> as Iterator>::Item = &_`
+ which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
+ `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
+ which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 6:43]>>: Iterator`
error: aborting due to 2 previous errors
--> $DIR/issue-41880.rs:27:24
|
LL | pub struct Iterate<T, F> {
- | ------- method `iter` not found for this struct
+ | ------------------------ method `iter` not found for this struct
...
LL | println!("{:?}", a.iter().take(10).collect::<Vec<usize>>());
- | ^^^^ method not found in `Iterate<{integer}, [closure@$DIR/issue-41880.rs:26:24: 26:31]>`
+ | ^^^^ method not found in `Iterate<{integer}, [closure@$DIR/issue-41880.rs:26:24: 26:27]>`
error: aborting due to previous error
LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> {
| - captured outer variable
LL | id(Box::new(|| *v))
- | ---^^
- | | |
- | | move occurs because `*v` has type `T`, which does not implement the `Copy` trait
+ | -- ^^ move occurs because `*v` has type `T`, which does not implement the `Copy` trait
+ | |
| captured by this `FnMut` closure
error: aborting due to previous error
| ^^^^^ expected `isize`, found closure
|
= note: expected type `isize`
- found closure `[closure@$DIR/issue-48838.rs:2:14: 2:19]`
+ found closure `[closure@$DIR/issue-48838.rs:2:14: 2:17]`
error: aborting due to previous error
| ^^^^^^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
- found closure `[closure@$DIR/issue-50600.rs:2:13: 2:23]`
+ found closure `[closure@$DIR/issue-50600.rs:2:13: 2:20]`
error: aborting due to previous error
| ^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
- found closure `[closure@$DIR/issue-50688.rs:2:9: 2:14]`
+ found closure `[closure@$DIR/issue-50688.rs:2:9: 2:11]`
error: aborting due to previous error
| arguments to this function are incorrect
|
= note: expected type parameter `F`
- found closure `[closure@$DIR/issue-51154.rs:2:30: 2:35]`
+ found closure `[closure@$DIR/issue-51154.rs:2:30: 2:32]`
= help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F`
note: associated function defined here
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
--> $DIR/issue-64430.rs:7:9
|
LL | pub struct Foo;
- | --- method `bar` not found for this struct
+ | -------------- method `bar` not found for this struct
...
LL | Foo.bar()
| ^^^ method not found in `Foo`
--> $DIR/issue-7950.rs:6:10
|
LL | struct Foo;
- | --- function or associated item `bar` not found for this struct
+ | ---------- function or associated item `bar` not found for this struct
...
LL | Foo::bar();
| ^^^ function or associated item not found in `Foo`
--> $DIR/kindck-nonsendable-1.rs:9:5
|
LL | bar(move|| foo(x));
- | ^^^ ------------- within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22]`
+ | ^^^ ------ within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`
| |
| `Rc<usize>` cannot be sent between threads safely
|
- = help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22]`, the trait `Send` is not implemented for `Rc<usize>`
+ = help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`, the trait `Send` is not implemented for `Rc<usize>`
note: required because it's used within this closure
--> $DIR/kindck-nonsendable-1.rs:9:9
|
LL | bar(move|| foo(x));
- | ^^^^^^^^^^^^^
+ | ^^^^^^
note: required by a bound in `bar`
--> $DIR/kindck-nonsendable-1.rs:5:21
|
LL | &'a (): Foo,
| ^^^
|
- = note: cannot satisfy `&'a (): Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a (): Foo` found
+ --> $DIR/issue-34979.rs:6:13
+ |
+LL | &'a (): Foo,
+ | ^^^
+LL | &'static (): Foo;
+ | ^^^
error: aborting due to previous error
--> $DIR/issue-79187-2.rs:8:14
|
LL | take_foo(|a| a);
- | ^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-79187-2.rs:5:21
|
--> $DIR/issue-79187.rs:4:13
|
LL | let f = |_| ();
- | ^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/issue-79187.rs:1:18
|
|
= help: cast can be replaced by coercion; this might require a temporary variable
-error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:25]` as `&dyn Fn(i32)`
+error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:22]` as `&dyn Fn(i32)`
--> $DIR/trivial_casts.rs:73:13
|
LL | let _ = &x as &dyn Fn(i32);
'a: loop {
x = loop { break 'a };
}
- println!("{:?}", x); //~ ERROR borrow of possibly-uninitialized variable
+ println!("{:?}", x); //~ ERROR E0381
}
// test2 and test3 should not fail.
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/loop-proper-liveness.rs:9:22
|
+LL | let x: i32;
+ | - binding declared here but left uninitialized
+...
LL | println!("{:?}", x);
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
LL | pub struct Foo;
| --------------
- | | |
- | | method `take` not found for this struct
+ | |
+ | method `take` not found for this struct
| doesn't satisfy `Foo: Iterator`
...
LL | .take()
LL | .get_x();
| ++
-error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
+error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:23]>, [closure@$DIR/method-missing-call.rs:28:23: 28:28]>`
--> $DIR/method-missing-call.rs:29:16
|
LL | .filter_map;
--> $DIR/method-not-found-generic-arg-elision.rs:82:23
|
LL | struct Point<T> {
- | ----- method `distance` not found for this struct
+ | --------------- method `distance` not found for this struct
...
LL | let d = point_i32.distance();
| ^^^^^^^^ method not found in `Point<i32>`
--> $DIR/method-not-found-generic-arg-elision.rs:84:23
|
LL | struct Point<T> {
- | ----- method `other` not found for this struct
+ | --------------- method `other` not found for this struct
...
LL | let d = point_i32.other();
| ^^^^^ method not found in `Point<i32>`
--> $DIR/method-not-found-generic-arg-elision.rs:87:29
|
LL | v.iter().map(|x| x * x).extend(std::iter::once(100));
- | ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:87:18: 87:27]>`
+ | ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:87:18: 87:21]>`
error[E0599]: no method named `method` found for struct `Wrapper<bool>` in the current scope
--> $DIR/method-not-found-generic-arg-elision.rs:90:13
|
LL | struct Wrapper<T>(T);
- | ------- method `method` not found for this struct
+ | ----------------- method `method` not found for this struct
...
LL | wrapper.method();
| ^^^^^^ method not found in `Wrapper<bool>`
--> $DIR/method-not-found-generic-arg-elision.rs:92:13
|
LL | struct Wrapper<T>(T);
- | ------- method `other` not found for this struct
+ | ----------------- method `other` not found for this struct
...
LL | wrapper.other();
| ^^^^^ method not found in `Wrapper<bool>`
--> $DIR/method-not-found-generic-arg-elision.rs:96:13
|
LL | struct Wrapper2<'a, T, const C: usize> {
- | -------- method `method` not found for this struct
+ | -------------------------------------- method `method` not found for this struct
...
LL | wrapper.method();
| ^^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
--> $DIR/method-not-found-generic-arg-elision.rs:98:13
|
LL | struct Wrapper2<'a, T, const C: usize> {
- | -------- method `other` not found for this struct
+ | -------------------------------------- method `other` not found for this struct
...
LL | wrapper.other();
| ^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
--> $DIR/method-not-found-generic-arg-elision.rs:104:7
|
LL | struct Struct<T>{
- | ------ method `method` not found for this struct
+ | ---------------- method `method` not found for this struct
...
LL | s.method();
| ^^^^^^ method cannot be called on `Struct<f64>` due to unsatisfied trait bounds
//~^ ERROR destructors cannot be evaluated at compile-time
a[0] = String::new();
//~^ ERROR destructors cannot be evaluated at compile-time
- //~| ERROR use of possibly-uninitialized variable
+ //~| ERROR binding `a` isn't initialized
};
struct B<T>([T; 1]);
LL | };
| - value is dropped here
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
--> $DIR/drop-elaboration-after-borrowck-error.rs:7:5
|
+LL | let a: [String; 1];
+ | - binding declared here but left uninitialized
+LL |
LL | a[0] = String::new();
- | ^^^^ use of possibly-uninitialized `a`
+ | ^^^^ `a` used here but it isn't initialized
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-elaboration-after-borrowck-error.rs:18:9
--> $DIR/closure-arg-type-mismatch.rs:3:14
|
LL | a.iter().map(|_: (u32, u32)| 45);
- | ^^^ ------------------ found signature of `fn((u32, u32)) -> _`
+ | ^^^ --------------- found signature of `fn((u32, u32)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
|
--> $DIR/closure-arg-type-mismatch.rs:4:14
|
LL | a.iter().map(|_: &(u16, u16)| 45);
- | ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
+ | ^^^ ---------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
|
--> $DIR/closure-arg-type-mismatch.rs:5:14
|
LL | a.iter().map(|_: (u16, u16)| 45);
- | ^^^ ------------------ found signature of `fn((u16, u16)) -> _`
+ | ^^^ --------------- found signature of `fn((u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
|
--> $DIR/closure-mismatch.rs:8:9
|
LL | baz(|_| ());
- | ^^^^^^
+ | ^^^
note: the lifetime requirement is introduced here
--> $DIR/closure-mismatch.rs:5:11
|
--> $DIR/issue-36053-2.rs:7:32
|
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
- | ^^^^^^ -------------- found signature of `for<'r> fn(&'r str) -> _`
+ | ^^^^^^ --------- found signature of `for<'r> fn(&'r str) -> _`
| |
| expected signature of `for<'r> fn(&'r &str) -> _`
|
LL | P: FnMut(&Self::Item) -> bool,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `filter`
-error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>`, but its trait bounds were not satisfied
+error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>`, but its trait bounds were not satisfied
--> $DIR/issue-36053-2.rs:7:55
|
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
- | -------------- ^^^^^ method cannot be called on `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` due to unsatisfied trait bounds
+ | --------- ^^^^^ method cannot be called on `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>` due to unsatisfied trait bounds
| |
| doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool`
| doesn't satisfy `_: FnMut<(&&str,)>`
| ----------------------- doesn't satisfy `_: Iterator`
|
= note: the following trait bounds were not satisfied:
- `<[closure@$DIR/issue-36053-2.rs:7:39: 7:53] as FnOnce<(&&str,)>>::Output = bool`
- which is required by `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
- `[closure@$DIR/issue-36053-2.rs:7:39: 7:53]: FnMut<(&&str,)>`
- which is required by `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
- `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
- which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>: Iterator`
+ `<[closure@$DIR/issue-36053-2.rs:7:39: 7:48] as FnOnce<(&&str,)>>::Output = bool`
+ which is required by `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
+ `[closure@$DIR/issue-36053-2.rs:7:39: 7:48]: FnMut<(&&str,)>`
+ which is required by `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
+ `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
+ which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:48]>: Iterator`
error: aborting due to 2 previous errors
fn uninit_1() {
loop {
- let value: NonCopy;
- let _used = value; //~ ERROR use of possibly-uninitialized variable: `value`
- //~^ NOTE use of possibly-uninitialized `value`
+ let value: NonCopy; //~ NOTE declared here
+ let _used = value; //~ ERROR binding `value` isn't initialized
+ //~^ NOTE `value` used here but it isn't initialized
}
}
fn uninit_2() {
- let mut value: NonCopy;
+ let mut value: NonCopy; //~ NOTE declared here
loop {
- let _used = value; //~ ERROR use of possibly-uninitialized variable: `value`
- //~^ NOTE use of possibly-uninitialized `value`
+ let _used = value; //~ ERROR binding `value` isn't initialized
+ //~^ NOTE `value` used here but it isn't initialized
}
}
LL | let _used2 = value;
| ^^^^^ value moved here, in previous iteration of loop
-error[E0381]: use of possibly-uninitialized variable: `value`
+error[E0381]: used binding `value` isn't initialized
--> $DIR/issue-72649-uninit-in-loop.rs:61:21
|
+LL | let value: NonCopy;
+ | ----- binding declared here but left uninitialized
LL | let _used = value;
- | ^^^^^ use of possibly-uninitialized `value`
+ | ^^^^^ `value` used here but it isn't initialized
-error[E0381]: use of possibly-uninitialized variable: `value`
+error[E0381]: used binding `value` isn't initialized
--> $DIR/issue-72649-uninit-in-loop.rs:69:21
|
+LL | let mut value: NonCopy;
+ | --------- binding declared here but left uninitialized
+LL | loop {
LL | let _used = value;
- | ^^^^^ use of possibly-uninitialized `value`
+ | ^^^^^ `value` used here but it isn't initialized
error: aborting due to 6 previous errors
fn foo(i: usize) {
let mut a: [D; 4];
- a[i] = d(); //~ ERROR use of possibly-uninitialized variable: `a`
+ a[i] = d(); //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `a`
+error[E0381]: used binding `a` isn't initialized
--> $DIR/move-into-dead-array-1.rs:14:5
|
+LL | let mut a: [D; 4];
+ | ----- binding declared here but left uninitialized
LL | a[i] = d();
- | ^^^^ use of possibly-uninitialized `a`
+ | ^^^^ `a` used here but it isn't initialized
error: aborting due to previous error
fn main() {
let mut x: S;
- std::ptr::addr_of_mut!(x); //~ borrow of
+ std::ptr::addr_of_mut!(x); //~ ERROR E0381
let y = x; // Should error here if `addr_of_mut` is ever allowed on uninitialized variables
drop(y);
-error[E0381]: borrow of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/move-of-addr-of-mut.rs:8:5
|
+LL | let mut x: S;
+ | ----- binding declared here but left uninitialized
LL | std::ptr::addr_of_mut!(x);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `x`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ `x` used here but it isn't initialized
|
= note: this error originates in the macro `std::ptr::addr_of_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
LL | let i = Box::new(3);
| - captured outer variable
LL | let _f = to_fn(|| test(i));
- | --------^-
- | | |
- | | move occurs because `i` has type `Box<usize>`, which does not implement the `Copy` trait
+ | -- ^ move occurs because `i` has type `Box<usize>`, which does not implement the `Copy` trait
+ | |
| captured by this `Fn` closure
error: aborting due to previous error
-error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 21:6] as FnOnce<()>>::Output == ()`
+error[E0271]: type mismatch resolving `<[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47] as FnOnce<()>>::Output == ()`
--> $DIR/fallback-closure-wrap.rs:18:31
|
LL | let error = Closure::wrap(Box::new(move || {
|
= note: expected unit type `()`
found type `!`
- = note: required for the cast from `[closure@$DIR/fallback-closure-wrap.rs:18:40: 21:6]` to the object type `dyn FnMut()`
+ = note: required for the cast from `[closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47]` to the object type `dyn FnMut()`
error: aborting due to previous error
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:27:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | x = 1;}
- | |__________-_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;}
+ | - mutable borrow occurs due to use of `x` in closure
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:31:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | x = 1;});
- | |_____-_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;});
+ | - mutable borrow occurs due to use of `x` in closure
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/closure-captures.rs:39:10
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:38:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | x = 1;}
- | |__________-_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;}
+ | - mutable borrow occurs due to use of `x` in closure
error[E0594]: cannot assign to `x`, as it is not declared as mutable
--> $DIR/closure-captures.rs:43:5
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:42:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | x = 1;});
- | |_____-_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;});
+ | - mutable borrow occurs due to use of `x` in closure
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:48:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(|| {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | *x = 1;});
- | |_________--_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | *x = 1;});
+ | -- mutable borrow occurs due to use of `x` in closure
error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/closure-captures.rs:51:9
|
-LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | fn_ref(move || {
- | _____------_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | ||
- | | ^^ cannot borrow as mutable
-LL | | *x = 1;});
- | |_________--_____- in this closure
- | |
- | mutable borrow occurs due to use of `x` in closure
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | *x = 1;});
+ | -- mutable borrow occurs due to use of `x` in closure
error: aborting due to 12 previous errors
--> $DIR/escape-argument-callee.rs:26:38
|
LL | let mut closure = expect_sig(|p, y| *p = y);
- | ^^^^^^^^^^^^^
+ | ^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
--> $DIR/escape-argument.rs:26:38
|
LL | let mut closure = expect_sig(|p, y| *p = y);
- | ^^^^^^^^^^^^^
+ | ^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
--> $DIR/escape-upvar-nested.rs:21:32
|
LL | let mut closure1 = || p = &y;
- | ^^^^^^^^^
+ | ^^
|
= note: defining type: test::{closure#0}::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/escape-upvar-nested.rs:20:27
|
-LL | let mut closure = || {
- | ___________________________^
-LL | | let mut closure1 = || p = &y;
-LL | | closure1();
-LL | | };
- | |_________^
+LL | let mut closure = || {
+ | ^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
--> $DIR/escape-upvar-ref.rs:23:27
|
LL | let mut closure = || p = &y;
- | ^^^^^^^^^
+ | ^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
note: no external requirements
--> $DIR/propagate-approximated-fail-no-postdom.rs:43:9
|
-LL | / |_outlives1, _outlives2, _outlives3, x, y| {
-LL | | // Only works if 'x: 'y:
-LL | | let p = x.get();
-LL | | demand_y(x, y, p)
-LL | | },
- | |_________^
+LL | |_outlives1, _outlives2, _outlives3, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/propagate-approximated-ref.rs:43:47
|
-LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
- | _______________________________________________^
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get())
-LL | |
-LL | | });
- | |_____^
+LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: no external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15
|
-LL | foo(cell, |cell_a, cell_x| {
- | _______________^
-LL | | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
-LL | |
-LL | | })
- | |_____^
+LL | foo(cell, |cell_a, cell_x| {
+ | ^^^^^^^^^^^^^^^^
|
= note: defining type: case1::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15
|
-LL | foo(cell, |cell_a, cell_x| {
- | _______________^
-LL | | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
-LL | | })
- | |_____^
+LL | foo(cell, |cell_a, cell_x| {
+ | ^^^^^^^^^^^^^^^^
|
= note: defining type: case2::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47
|
-LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
- | _______________________________________________^
-LL | |
-LL | |
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get())
-LL | | });
- | |_____^
+LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
+ | ^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47
|
-LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
- | _______________________________________________^
-LL | |
-LL | |
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get())
-LL | | });
- | |_____^
+LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/propagate-approximated-val.rs:36:45
|
-LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
- | _____________________________________________^
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(outlives1, outlives2, x.get())
-LL | |
-LL | | });
- | |_____^
+LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/propagate-despite-same-free-region.rs:42:9
|
-LL | / |_outlives1, _outlives2, x, y| {
-LL | | // Only works if 'x: 'y:
-LL | | let p = x.get();
-LL | | demand_y(x, y, p)
-LL | | },
- | |_________^
+LL | |_outlives1, _outlives2, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: no external requirements
--> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:35:47
|
-LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
- | _______________________________________________^
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get())
-LL | |
-LL | | });
- | |_____^
+LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
+ | ^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: no external requirements
--> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:39:47
|
-LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
- | _______________________________________________^
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get())
-LL | |
-LL | | });
- | |_____^
+LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: defining type: supply::{closure#0} with closure substs [
i16,
note: external requirements
--> $DIR/propagate-from-trait-match.rs:32:36
|
-LL | establish_relationships(value, |value| {
- | ____________________________________^
-LL | |
-LL | |
-LL | | // This function call requires that
-... |
-LL | | require(value);
-LL | | });
- | |_____^
+LL | establish_relationships(value, |value| {
+ | ^^^^^^^
|
= note: defining type: supply::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/return-wrong-bound-region.rs:11:16
|
LL | expect_sig(|a, b| b); // ought to return `a`
- | ^^^^^^^^
+ | ^^^^^^
|
= note: defining type: test::{closure#0} with closure substs [
i16,
fn cannot_partially_init_adt_with_drop() {
let d: D;
- d.x = 10;
- //~^ ERROR assign of possibly-uninitialized variable: `d` [E0381]
+ d.x = 10; //~ ERROR E0381
}
fn cannot_partially_init_mutable_adt_with_drop() {
let mut d: D;
- d.x = 10;
- //~^ ERROR assign of possibly-uninitialized variable: `d` [E0381]
+ d.x = 10; //~ ERROR E0381
}
fn cannot_partially_reinit_adt_with_drop() {
fn cannot_partially_init_inner_adt_via_outer_with_drop() {
let d: D;
- d.s.y = 20;
- //~^ ERROR assign to part of possibly-uninitialized variable: `d` [E0381]
+ d.s.y = 20; //~ ERROR E0381
}
fn cannot_partially_init_inner_adt_via_mutable_outer_with_drop() {
let mut d: D;
- d.s.y = 20;
- //~^ ERROR assign to part of possibly-uninitialized variable: `d` [E0381]
+ d.s.y = 20; //~ ERROR E0381
}
fn cannot_partially_reinit_inner_adt_via_outer_with_drop() {
-error[E0381]: assign of possibly-uninitialized variable: `d`
+error[E0381]: assigned binding `d` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-erroneous-use.rs:28:5
|
+LL | let d: D;
+ | - binding declared here but left uninitialized
LL | d.x = 10;
- | ^^^^^^^^ use of possibly-uninitialized `d`
+ | ^^^^^^^^ `d` assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign of possibly-uninitialized variable: `d`
- --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:34:5
+error[E0381]: assigned binding `d` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:33:5
|
+LL | let mut d: D;
+ | ----- binding declared here but left uninitialized
LL | d.x = 10;
- | ^^^^^^^^ use of possibly-uninitialized `d`
+ | ^^^^^^^^ `d` assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign of moved value: `d`
- --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:41:5
+ --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:39:5
|
LL | let mut d = D { x: 0, s: S{ y: 0, z: 0 } };
| ----- move occurs because `d` has type `D`, which does not implement the `Copy` trait
LL | d.x = 10;
| ^^^^^^^^ value assigned here after move
-error[E0381]: assign to part of possibly-uninitialized variable: `d`
- --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:47:5
+error[E0381]: partially assigned binding `d` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:45:5
|
+LL | let d: D;
+ | - binding declared here but left uninitialized
LL | d.s.y = 20;
- | ^^^^^^^^^^ use of possibly-uninitialized `d.s`
+ | ^^^^^^^^^^ `d.s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `d`
- --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:53:5
+error[E0381]: partially assigned binding `d` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:50:5
|
+LL | let mut d: D;
+ | ----- binding declared here but left uninitialized
LL | d.s.y = 20;
- | ^^^^^^^^^^ use of possibly-uninitialized `d.s`
+ | ^^^^^^^^^^ `d.s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `d`
- --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:60:5
+ --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:56:5
|
LL | let mut d = D { x: 0, s: S{ y: 0, z: 0} };
| ----- move occurs because `d` has type `D`, which does not implement the `Copy` trait
fn test_0000_local_fully_init_and_use_struct() {
let s: S<B>;
- s.x = 10; s.y = Box::new(20);
- //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+ s.x = 10; s.y = Box::new(20); //~ ERROR E0381
use_fully!(struct s);
}
fn test_0001_local_fully_init_and_use_tuple() {
let t: T;
- t.0 = 10; t.1 = Box::new(20);
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 10; t.1 = Box::new(20); //~ ERROR E0381
use_fully!(tuple t);
}
fn test_0100_local_partial_init_and_use_struct() {
let s: S<B>;
- s.x = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+ s.x = 10; //~ ERROR E0381
use_part!(struct s);
}
fn test_0101_local_partial_init_and_use_tuple() {
let t: T;
- t.0 = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 10; //~ ERROR E0381
use_part!(tuple t);
}
fn test_0200_local_void_init_and_use_struct() {
let s: S<Void>;
- s.x = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `s` [E0381]
+ s.x = 10; //~ ERROR E0381
use_part!(struct s);
}
fn test_0201_local_void_init_and_use_tuple() {
let t: Tvoid;
- t.0 = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
+ t.0 = 10; //~ ERROR E0381
use_part!(tuple t);
}
fn test_1000_field_fully_init_and_use_struct() {
let q: Q<S<B>>;
- q.r.f.x = 10; q.r.f.y = Box::new(20);
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.x = 10; q.r.f.y = Box::new(20); //~ ERROR E0381
use_fully!(struct q.r.f);
}
fn test_1001_field_fully_init_and_use_tuple() {
let q: Q<T>;
- q.r.f.0 = 10; q.r.f.1 = Box::new(20);
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.0 = 10; q.r.f.1 = Box::new(20); //~ ERROR E0381
use_fully!(tuple q.r.f);
}
fn test_1100_field_partial_init_and_use_struct() {
let q: Q<S<B>>;
- q.r.f.x = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.x = 10; //~ ERROR E0381
use_part!(struct q.r.f);
}
fn test_1101_field_partial_init_and_use_tuple() {
let q: Q<T>;
- q.r.f.0 = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.0 = 10; //~ ERROR E0381
use_part!(tuple q.r.f);
}
fn test_1200_field_void_init_and_use_struct() {
let mut q: Q<S<Void>>;
- q.r.f.x = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.x = 10; //~ ERROR E0381
use_part!(struct q.r.f);
}
fn test_1201_field_void_init_and_use_tuple() {
let mut q: Q<Tvoid>;
- q.r.f.0 = 10;
- //~^ ERROR assign to part of possibly-uninitialized variable: `q` [E0381]
+ q.r.f.0 = 10; //~ ERROR E0381
use_part!(tuple q.r.f);
}
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
+error[E0381]: partially assigned binding `s` isn't fully initialized
--> $DIR/issue-21232-partial-init-and-use.rs:97:5
|
+LL | let s: S<B>;
+ | - binding declared here but left uninitialized
LL | s.x = 10; s.y = Box::new(20);
- | ^^^^^^^^ use of possibly-uninitialized `s`
+ | ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/issue-21232-partial-init-and-use.rs:104:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:103:5
|
+LL | let t: T;
+ | - binding declared here but left uninitialized
LL | t.0 = 10; t.1 = Box::new(20);
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `s`
- --> $DIR/issue-21232-partial-init-and-use.rs:111:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:109:5
|
LL | let mut s: S<B> = S::new(); drop(s);
| ----- - value moved here
| ^^^^^^^^ value partially assigned here after move
error[E0382]: assign to part of moved value: `t`
- --> $DIR/issue-21232-partial-init-and-use.rs:118:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:116:5
|
LL | let mut t: T = (0, Box::new(0)); drop(t);
| ----- - value moved here
LL | t.0 = 10; t.1 = Box::new(20);
| ^^^^^^^^ value partially assigned here after move
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
- --> $DIR/issue-21232-partial-init-and-use.rs:125:5
+error[E0381]: partially assigned binding `s` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:123:5
|
+LL | let s: S<B>;
+ | - binding declared here but left uninitialized
LL | s.x = 10;
- | ^^^^^^^^ use of possibly-uninitialized `s`
+ | ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/issue-21232-partial-init-and-use.rs:132:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:129:5
|
+LL | let t: T;
+ | - binding declared here but left uninitialized
LL | t.0 = 10;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `s`
- --> $DIR/issue-21232-partial-init-and-use.rs:139:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:135:5
|
LL | let mut s: S<B> = S::new(); drop(s);
| ----- - value moved here
| ^^^^^^^^ value partially assigned here after move
error[E0382]: assign to part of moved value: `t`
- --> $DIR/issue-21232-partial-init-and-use.rs:146:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:142:5
|
LL | let mut t: T = (0, Box::new(0)); drop(t);
| ----- - value moved here
LL | t.0 = 10;
| ^^^^^^^^ value partially assigned here after move
-error[E0381]: assign to part of possibly-uninitialized variable: `s`
- --> $DIR/issue-21232-partial-init-and-use.rs:153:5
+error[E0381]: partially assigned binding `s` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:149:5
|
+LL | let s: S<Void>;
+ | - binding declared here but left uninitialized
LL | s.x = 10;
- | ^^^^^^^^ use of possibly-uninitialized `s`
+ | ^^^^^^^^ `s` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `t`
- --> $DIR/issue-21232-partial-init-and-use.rs:160:5
+error[E0381]: partially assigned binding `t` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:155:5
|
+LL | let t: Tvoid;
+ | - binding declared here but left uninitialized
LL | t.0 = 10;
- | ^^^^^^^^ use of possibly-uninitialized `t`
+ | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:176:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:170:5
|
+LL | let q: Q<S<B>>;
+ | - binding declared here but left uninitialized
LL | q.r.f.x = 10; q.r.f.y = Box::new(20);
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:183:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:176:5
|
+LL | let q: Q<T>;
+ | - binding declared here but left uninitialized
LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20);
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `q.r`
- --> $DIR/issue-21232-partial-init-and-use.rs:190:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:182:5
|
LL | let mut q: Q<S<B>> = Q::new(S::new()); drop(q.r);
| --- value moved here
= note: move occurs because `q.r` has type `R<S<Box<u32>>>`, which does not implement the `Copy` trait
error[E0382]: assign to part of moved value: `q.r`
- --> $DIR/issue-21232-partial-init-and-use.rs:197:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:189:5
|
LL | let mut q: Q<T> = Q::new((0, Box::new(0))); drop(q.r);
| --- value moved here
|
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:204:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:196:5
|
+LL | let q: Q<S<B>>;
+ | - binding declared here but left uninitialized
LL | q.r.f.x = 10;
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:211:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:202:5
|
+LL | let q: Q<T>;
+ | - binding declared here but left uninitialized
LL | q.r.f.0 = 10;
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `q.r`
- --> $DIR/issue-21232-partial-init-and-use.rs:218:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:208:5
|
LL | let mut q: Q<S<B>> = Q::new(S::new()); drop(q.r);
| --- value moved here
= note: move occurs because `q.r` has type `R<S<Box<u32>>>`, which does not implement the `Copy` trait
error[E0382]: assign to part of moved value: `q.r`
- --> $DIR/issue-21232-partial-init-and-use.rs:225:5
+ --> $DIR/issue-21232-partial-init-and-use.rs:215:5
|
LL | let mut q: Q<T> = Q::new((0, Box::new(0))); drop(q.r);
| --- value moved here
|
= note: move occurs because `q.r` has type `R<(u32, Box<u32>)>`, which does not implement the `Copy` trait
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:232:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:222:5
|
+LL | let mut q: Q<S<Void>>;
+ | ----- binding declared here but left uninitialized
LL | q.r.f.x = 10;
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
-error[E0381]: assign to part of possibly-uninitialized variable: `q`
- --> $DIR/issue-21232-partial-init-and-use.rs:239:5
+error[E0381]: partially assigned binding `q` isn't fully initialized
+ --> $DIR/issue-21232-partial-init-and-use.rs:228:5
|
+LL | let mut q: Q<Tvoid>;
+ | ----- binding declared here but left uninitialized
LL | q.r.f.0 = 10;
- | ^^^^^^^^^^^^ use of possibly-uninitialized `q.r.f`
+ | ^^^^^^^^^^^^ `q.r.f` partially assigned here but it isn't fully initialized
+ |
+ = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit`
error[E0382]: assign to part of moved value: `c`
- --> $DIR/issue-21232-partial-init-and-use.rs:257:13
+ --> $DIR/issue-21232-partial-init-and-use.rs:245:13
|
LL | let mut c = (1, "".to_owned());
| ----- move occurs because `c` has type `(i32, String)`, which does not implement the `Copy` trait
| ^^^^^^^ value partially assigned here after move
error[E0382]: assign to part of moved value: `c`
- --> $DIR/issue-21232-partial-init-and-use.rs:267:13
+ --> $DIR/issue-21232-partial-init-and-use.rs:255:13
|
LL | let mut c = (1, (1, "".to_owned()));
| ----- move occurs because `c` has type `(i32, (i32, String))`, which does not implement the `Copy` trait
| ^^^^^^^^^^^ value partially assigned here after move
error[E0382]: assign to part of moved value: `c.1`
- --> $DIR/issue-21232-partial-init-and-use.rs:275:13
+ --> $DIR/issue-21232-partial-init-and-use.rs:263:13
|
LL | c2 => {
| -- value moved here
LL | let x = (vec![22], vec![44]);
| - captured outer variable
LL | expect_fn(|| drop(x.0));
- | --------^^^-
- | | |
- | | move occurs because `x.0` has type `Vec<i32>`, which does not implement the `Copy` trait
+ | -- ^^^ move occurs because `x.0` has type `Vec<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `Fn` closure
error: aborting due to previous error
| -
| |
| `stmt` dropped here while still borrowed
- | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Map<Rows<'_>, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>`
+ | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Map<Rows<'_>, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:19]>`
|
= note: the temporary is part of an expression at the end of a block;
consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
match y {
_ if { x = 2; true } => 1,
_ if {
- x; //~ ERROR use of possibly-uninitialized variable: `x`
+ x; //~ ERROR E0381
false
} => 2,
_ => 3,
-error[E0381]: use of possibly-uninitialized variable: `x`
+error[E0381]: used binding `x` isn't initialized
--> $DIR/match-cfg-fake-edges.rs:21:13
|
+LL | let x;
+ | - binding declared here but left uninitialized
+...
+LL | _ if { x = 2; true } => 1,
+ | ----- binding initialized here in some conditions
+LL | _ if {
LL | x;
- | ^ use of possibly-uninitialized `x`
+ | ^ `x` used here but it isn't initialized
error[E0382]: use of moved value: `x`
--> $DIR/match-cfg-fake-edges.rs:35:13
LL | x;
| - borrow later used here
-error[E0381]: use of possibly-uninitialized variable: `n`
+error[E0381]: used binding `n` isn't initialized
--> $DIR/match-on-borrowed.rs:93:11
|
+LL | let n: Never;
+ | - binding declared here but left uninitialized
LL | match n {}
- | ^ use of possibly-uninitialized `n`
+ | ^ `n` used here but it isn't initialized
error: aborting due to 4 previous errors
--> $DIR/projection-no-regions-closure.rs:25:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
|
= note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-no-regions-closure.rs:34:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
|
= note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-no-regions-closure.rs:42:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
|
= note: defining type: wrong_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-no-regions-closure.rs:52:23
|
LL | with_signature(x, |mut y| Box::new(y.next()))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^
|
= note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-closure.rs:45:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-closure.rs:56:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-closure.rs:70:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-closure.rs:80:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-closure.rs:37:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-closure.rs:47:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-closure.rs:60:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-closure.rs:69:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-closure.rs:81:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-static-closure.rs:36:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_early::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: projection_outlives::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: elements_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:38:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_late::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:61:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:70:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:79:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:87:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: two_regions::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:97:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: two_regions_outlive::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
--> $DIR/projection-two-region-trait-bound-closure.rs:109:29
|
LL | with_signature(cell, t, |cell, t| require(cell, t));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^
|
= note: defining type: one_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
--> $DIR/ty-param-closure-approximate-lower-bound.rs:24:24
|
LL | twice(cell, value, |a, b| invoke(a, b));
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^
|
= note: defining type: generic::<T>::{closure#0} with closure substs [
i16,
--> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24
|
LL | twice(cell, value, |a, b| invoke(a, b));
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^
|
= note: defining type: generic_fail::<T>::{closure#0} with closure substs [
i16,
--> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23
|
LL | with_signature(x, |y| y)
- | ^^^^^
+ | ^^^
|
= note: defining type: no_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26
|
-LL | with_signature(a, b, |x, y| {
- | __________________________^
-LL | |
-LL | | //
-LL | | // See `correct_region`, which explains the point of this
-... |
-LL | | require(&x, &y)
-LL | | })
- | |_____^
+LL | with_signature(a, b, |x, y| {
+ | ^^^^^^
|
= note: defining type: no_region::<T>::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26
|
-LL | with_signature(a, b, |x, y| {
- | __________________________^
-LL | | // Key point of this test:
-LL | | //
-LL | | // The *closure* is being type-checked with all of its free
-... |
-LL | | require(&x, &y)
-LL | | })
- | |_____^
+LL | with_signature(a, b, |x, y| {
+ | ^^^^^^
|
= note: defining type: correct_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26
|
-LL | with_signature(a, b, |x, y| {
- | __________________________^
-LL | |
-LL | | // See `correct_region`
-LL | | require(&x, &y)
-LL | | })
- | |_____^
+LL | with_signature(a, b, |x, y| {
+ | ^^^^^^
|
= note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [
i32,
note: external requirements
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26
|
-LL | with_signature(a, b, |x, y| {
- | __________________________^
-LL | | // See `correct_region`
-LL | | require(&x, &y)
-LL | | })
- | |_____^
+LL | with_signature(a, b, |x, y| {
+ | ^^^^^^
|
= note: defining type: outlives_region::<'_#1r, '_#2r, T>::{closure#0} with closure substs [
i32,
|
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
| -- lifetime `'a` defined here
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
...
LL | SomeEnum::SomeVariant(Cell::new(&c)),
| ----------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
-...
-LL | };
- | - `c` dropped here while still borrowed
error: aborting due to 3 previous errors
|
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
| -- lifetime `'a` defined here
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
...
LL | f(&c);
| --^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
-LL | };
- | - `c` dropped here while still borrowed
error[E0597]: `c` does not live long enough
--> $DIR/adt-tuple-struct-calls.rs:53:11
|
LL | let f = SomeStruct::<&'a u32>;
| - lifetime `'1` appears in the type of `f`
-...
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
+LL | let c = 66;
LL | f(&c);
| --^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'1`
-LL | };
- | - `c` dropped here while still borrowed
error: aborting due to 4 previous errors
|
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
| -- lifetime `'a` defined here
-...
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
+LL | let c = 66;
LL | some_fn::<&'a u32>(&c);
| -------------------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
-LL | };
- | - `c` dropped here while still borrowed
error: aborting due to 3 previous errors
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
| -- lifetime `'a` defined here
...
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
+LL | let c = 66;
LL | a.method::<&'a u32>(b, &c);
| ------------------------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
-LL | };
- | - `c` dropped here while still borrowed
error: aborting due to 3 previous errors
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
| -- lifetime `'a` defined here
...
+LL | let _closure = || {
+ | - `c` dropped here while still borrowed
+LL | let c = 66;
LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c);
| -------------------------------------------^^-
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
-LL | };
- | - `c` dropped here while still borrowed
error: aborting due to 3 previous errors
error[E0277]: `Rc<()>` cannot be sent between threads safely
--> $DIR/no-send-res-ports.rs:25:5
|
-LL | thread::spawn(move|| {
- | _____^^^^^^^^^^^^^_-
- | | |
- | | `Rc<()>` cannot be sent between threads safely
-LL | |
-LL | | let y = x;
-LL | | println!("{:?}", y);
-LL | | });
- | |_____- within this `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]`
+LL | thread::spawn(move|| {
+ | ^^^^^^^^^^^^^ ------ within this `[closure@$DIR/no-send-res-ports.rs:25:19: 25:25]`
+ | |
+ | `Rc<()>` cannot be sent between threads safely
|
- = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 29:6]`, the trait `Send` is not implemented for `Rc<()>`
+ = help: within `[closure@$DIR/no-send-res-ports.rs:25:19: 25:25]`, the trait `Send` is not implemented for `Rc<()>`
note: required because it appears within the type `Port<()>`
--> $DIR/no-send-res-ports.rs:5:8
|
note: required because it's used within this closure
--> $DIR/no-send-res-ports.rs:25:19
|
-LL | thread::spawn(move|| {
- | ___________________^
-LL | |
-LL | | let y = x;
-LL | | println!("{:?}", y);
-LL | | });
- | |_____^
+LL | thread::spawn(move|| {
+ | ^^^^^^
note: required by a bound in `spawn`
--> $SRC_DIR/std/src/thread/mod.rs:LL:COL
|
--> $DIR/noncopyable-class.rs:34:16
|
LL | struct Foo {
- | --- method `clone` not found for this struct
+ | ---------- method `clone` not found for this struct
...
LL | let _y = x.clone();
| ^^^^^ method not found in `Foo`
-error[E0277]: the trait bound `S: Clone` is not satisfied in `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]`
+error[E0277]: the trait bound `S: Clone` is not satisfied in `[closure@$DIR/not-clone-closure.rs:7:17: 7:24]`
--> $DIR/not-clone-closure.rs:11:23
|
-LL | let hello = move || {
- | _________________-
-LL | | println!("Hello {}", a.0);
-LL | | };
- | |_____- within this `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]`
-LL |
-LL | let hello = hello.clone();
- | ^^^^^ within `[closure@$DIR/not-clone-closure.rs:7:17: 9:6]`, the trait `Clone` is not implemented for `S`
+LL | let hello = move || {
+ | ------- within this `[closure@$DIR/not-clone-closure.rs:7:17: 7:24]`
+...
+LL | let hello = hello.clone();
+ | ^^^^^ within `[closure@$DIR/not-clone-closure.rs:7:17: 7:24]`, the trait `Clone` is not implemented for `S`
|
note: required because it's used within this closure
--> $DIR/not-clone-closure.rs:7:17
|
-LL | let hello = move || {
- | _________________^
-LL | | println!("Hello {}", a.0);
-LL | | };
- | |_____^
+LL | let hello = move || {
+ | ^^^^^^^
help: consider annotating `S` with `#[derive(Clone)]`
|
LL | #[derive(Clone)]
--> $DIR/emoji-identifiers.rs:9:8
|
LL | struct 👀;
- | -- function or associated item `full_of✨` not found for this struct
+ | --------- function or associated item `full_of✨` not found for this struct
...
LL | 👀::full_of✨()
| ^^^^^^^^^
| ^^^^^^^^^^^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:25]`
+ found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:16]`
help: use parentheses to call this closure
|
LL | { true } (|| { true })()
| |__________^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 14:11]`
+ found closure `[closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13]`
help: use parentheses to call this closure
|
LL ~ while (|| Foo {
-error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:22]` cannot be used in patterns
+error: `[closure@$DIR/non-structural-match-types.rs:9:17: 9:19]` cannot be used in patterns
--> $DIR/non-structural-match-types.rs:9:9
|
LL | const { || {} } => {},
| -------------- generic parameter `T` is unused
LL |
LL | let add_one = |x: usize| x + 1;
- | ^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:17:8
| -------------- generic parameter `T` is unused
LL | let x: usize = T;
LL | let add_one = |x: usize| x + 1;
- | ^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:48:13
| -------------- generic parameter `T` is unused
LL | let x: usize = T;
LL | let y = || x;
- | ^^^^
+ | ^^
error: aborting due to 4 previous errors; 1 warning emitted
error: item has unused generic parameters
--> $DIR/generators.rs:35:5
|
-LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
- | - generic parameter `T` is unused
-LL | / || {
-LL | |
-LL | | yield 1;
-LL | | 2
-LL | | }
- | |_____^
+LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
+ | - generic parameter `T` is unused
+LL | || {
+ | ^^
-note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 39:6], u32, u32>`
+note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:35:5: 35:7], u32, u32>`
--> $DIR/generators.rs:86:5
|
LL | finish(unused_type::<u32>());
error: item has unused generic parameters
--> $DIR/generators.rs:60:5
|
-LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
- | ------------ generic parameter `T` is unused
-LL | / || {
-LL | |
-LL | | yield 1;
-LL | | 2
-LL | | }
- | |_____^
+LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin {
+ | ------------ generic parameter `T` is unused
+LL | || {
+ | ^^
-note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 64:6], u32, u32>`
+note: the above error was encountered while instantiating `fn finish::<[generator@$DIR/generators.rs:60:5: 60:7], u32, u32>`
--> $DIR/generators.rs:89:5
|
LL | finish(unused_const::<1u32>());
| - generic parameter `T` is unused
LL | let _: T = Default::default();
LL | let add_one = |x: u32| x + 1;
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^
error: aborting due to 2 previous errors
| generic parameter `I` is unused
...
LL | self.find(|_| true)
- | ^^^^^^^^
+ | ^^^
error: item has unused generic parameters
--> $DIR/predicates.rs:59:4
| - generic parameter `T` is unused
...
LL | let add_one = |x: u32| x + 1;
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:16:8
| - generic parameter `T` is unused
LL | let _: T = Default::default();
LL | let add_one = |x: u32| x + 1;
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:94:23
| - generic parameter `G` is unused
LL |
LL | let add_one = |x: u32| x + 1;
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:92:12
error: item has unused generic parameters
--> $DIR/closures.rs:128:23
|
-LL | pub fn used_impl<G: Default>() -> u32 {
- | - generic parameter `G` is unused
+LL | pub fn used_impl<G: Default>() -> u32 {
+ | - generic parameter `G` is unused
LL |
-LL | let add_one = |x: u32| {
- | _______________________^
-LL | |
-LL | | let _: F = Default::default();
-LL | | x + 1
-LL | | };
- | |_________^
+LL | let add_one = |x: u32| {
+ | ^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:126:12
error: item has unused generic parameters
--> $DIR/closures.rs:115:23
|
-LL | impl<F: Default> Foo<F> {
- | - generic parameter `F` is unused
+LL | impl<F: Default> Foo<F> {
+ | - generic parameter `F` is unused
...
-LL | let add_one = |x: u32| {
- | _______________________^
-LL | |
-LL | | let _: G = Default::default();
-LL | | x + 1
-LL | | };
- | |_________^
+LL | let add_one = |x: u32| {
+ | ^^^^^^^^
error: item has unused generic parameters
--> $DIR/closures.rs:113:12
| - generic parameter `T` is unused
LL | let _: T = Default::default();
LL | (|| Box::new(|| {}) as Box<dyn Fn()>)();
- | ^^^^^
+ | ^^
error: item has unused generic parameters
- --> $DIR/unsized_cast.rs:11:5
+ --> $DIR/unsized_cast.rs:11:6
|
LL | fn foo<T: Default>() {
| - generic parameter `T` is unused
LL | let _: T = Default::default();
LL | (|| Box::new(|| {}) as Box<dyn Fn()>)();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^
error: item has unused generic parameters
--> $DIR/unsized_cast.rs:22:15
| - generic parameter `T` is unused
...
LL | call(&|| {}, ());
- | ^^^^^
+ | ^^
error: item has unused generic parameters
- --> $DIR/unsized_cast.rs:19:5
+ --> $DIR/unsized_cast.rs:19:6
|
-LL | fn foo2<T: Default>() {
- | - generic parameter `T` is unused
-LL | let _: T = Default::default();
-LL | / (|| {
-LL | |
-LL | | let call: extern "rust-call" fn(_, _) = Fn::call;
-LL | | call(&|| {}, ());
-LL | |
-LL | | })();
- | |______^
+LL | fn foo2<T: Default>() {
+ | - generic parameter `T` is unused
+LL | let _: T = Default::default();
+LL | (|| {
+ | ^^
error: aborting due to 4 previous errors
= note: `#[warn(unconditional_recursion)]` on by default
= help: a `loop` may express intention better if this is on purpose
-error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>: Iterator`
+error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>: Iterator`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`)
- = note: required because of the requirements on the impl of `Iterator` for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>, [closure@$DIR/issue-83150.rs:11:24: 11:33]>`
+ = note: required because of the requirements on the impl of `Iterator` for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>, [closure@$DIR/issue-83150.rs:11:24: 11:27]>`
error: aborting due to previous error; 1 warning emitted
fn and_chain() {
let z;
if true && { z = 3; true} && z == 3 {}
- //~^ ERROR use of possibly-uninitialized
+ //~^ ERROR E0381
}
fn and_chain_2() {
let z;
true && { z = 3; true} && z == 3;
- //~^ ERROR use of possibly-uninitialized
+ //~^ ERROR E0381
}
fn or_chain() {
let z;
if false || { z = 3; false} || z == 3 {}
- //~^ ERROR use of possibly-uninitialized
+ //~^ ERROR E0381
}
fn main() {
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
--> $DIR/chains-without-let.rs:3:34
|
+LL | let z;
+ | - binding declared here but left uninitialized
LL | if true && { z = 3; true} && z == 3 {}
- | ^ use of possibly-uninitialized `z`
+ | ----- ^ `z` used here but it is possibly-uninitialized
+ | |
+ | binding initialized here in some conditions
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
--> $DIR/chains-without-let.rs:9:31
|
+LL | let z;
+ | - binding declared here but left uninitialized
LL | true && { z = 3; true} && z == 3;
- | ^ use of possibly-uninitialized `z`
+ | ----- ^ `z` used here but it is possibly-uninitialized
+ | |
+ | binding initialized here in some conditions
-error[E0381]: use of possibly-uninitialized variable: `z`
+error[E0381]: used binding `z` is possibly-uninitialized
--> $DIR/chains-without-let.rs:15:36
|
+LL | let z;
+ | - binding declared here but left uninitialized
LL | if false || { z = 3; false} || z == 3 {}
- | ^ use of possibly-uninitialized `z`
+ | ----- ^ `z` used here but it is possibly-uninitialized
+ | |
+ | binding initialized here in some conditions
error: aborting due to 3 previous errors
| ^^^^^^^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/disallowed-positions.rs:138:41: 138:48]`
+ found closure `[closure@$DIR/disallowed-positions.rs:138:41: 138:43]`
help: use parentheses to call this closure
|
LL | if let Range { start: F, end } = F..(|| true)() {}
| ^^^^^^^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/disallowed-positions.rs:203:44: 203:51]`
+ found closure `[closure@$DIR/disallowed-positions.rs:203:44: 203:46]`
help: use parentheses to call this closure
|
LL | while let Range { start: F, end } = F..(|| true)() {}
--> $DIR/issue-87932.rs:13:8
|
LL | pub struct A {}
- | - function or associated item `deserialize` not found for this struct
+ | ------------ function or associated item `deserialize` not found for this struct
...
LL | A::deserialize();
| ^^^^^^^^^^^ function or associated item not found in `A`
--> $DIR/point-at-arbitrary-self-type-method.rs:8:7
|
LL | struct A;
- | - method `foo` not found for this struct
+ | -------- method `foo` not found for this struct
...
LL | fn foo(self: Box<Self>) {}
| --- the method is available for `Box<A>` here
| |
| the method is available for `Box<A>` here
LL | struct A;
- | - method `foo` not found for this struct
+ | -------- method `foo` not found for this struct
...
LL | A.foo()
| ^^^ method not found in `A`
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
|
-LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
- | ----- captured outer variable
+LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
+ | ----- captured outer variable
...
-LL | f(Box::new(|a| {
- | ________________-
-LL | |
-LL | | foo(f);
- | | ^ move occurs because `f` has type `[closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 54:6]`, which does not implement the `Copy` trait
-LL | |
-LL | | }), 3);
- | |_____- captured by this `FnMut` closure
+LL | f(Box::new(|a| {
+ | --- captured by this `FnMut` closure
+LL |
+LL | foo(f);
+ | ^ move occurs because `f` has type `[closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58]`, which does not implement the `Copy` trait
error[E0505]: cannot move out of `f` because it is borrowed
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16
--> $DIR/issue-7575.rs:62:30
|
LL | struct Myisize(isize);
- | ------- method `fff` not found for this struct
+ | -------------- method `fff` not found for this struct
...
LL | u.f8(42) + u.f9(342) + m.fff(42)
| --^^^
| expected due to this
|
= note: expected unit type `()`
- found closure `[closure@$DIR/move-closure.rs:5:17: 5:27]`
+ found closure `[closure@$DIR/move-closure.rs:5:17: 5:24]`
help: use parentheses to call this closure
|
LL | let x: () = (move || ())();
|
LL | struct MyStruct;
| ---------------
- | | |
- | | method `foo_one` not found for this struct
+ | |
+ | method `foo_one` not found for this struct
| doesn't satisfy `MyStruct: Foo`
...
LL | println!("{}", MyStruct.foo_one());
LL | pub const fn foo() {}
| ^^^^^^^^^^^^^^^^^^^^^
-error: associated function has missing const stability attribute
- --> $DIR/missing-const-stability.rs:15:5
- |
-LL | pub const fn foo() {}
- | ^^^^^^^^^^^^^^^^^^^^^
-
error: implementation has missing const stability attribute
--> $DIR/missing-const-stability.rs:27:1
|
LL | | }
| |_^
+error: associated function has missing const stability attribute
+ --> $DIR/missing-const-stability.rs:15:5
+ |
+LL | pub const fn foo() {}
+ | ^^^^^^^^^^^^^^^^^^^^^
+
error: aborting due to 3 previous errors
LL | bar(foo());
| ++
-error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+error[E0277]: `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9
|
LL | let async_closure = async || ();
| -------- consider calling this closure
LL | bar(async_closure);
- | --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+ | --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]` is not a future
| |
| required by a bound introduced by this call
|
- = help: the trait `Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
- = note: [closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36] must be a future or must implement `IntoFuture` to be awaited
+ = help: the trait `Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33]`
+ = note: [closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33] must be a future or must implement `IntoFuture` to be awaited
note: required by a bound in `bar`
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16
|
| -------------- doesn't satisfy `CloneEnum: Default`
...
LL | struct Foo<X, Y> (X, Y);
- | --- method `test` not found for this struct
+ | ---------------- method `test` not found for this struct
...
LL | let y = x.test();
| ^^^^ method cannot be called on `Foo<Enum, CloneEnum>` due to unsatisfied trait bounds
| ------------------ doesn't satisfy `CloneStruct: Default`
...
LL | struct Foo<X, Y> (X, Y);
- | --- method `test` not found for this struct
+ | ---------------- method `test` not found for this struct
...
LL | let y = x.test();
| ^^^^ method cannot be called on `Foo<Struct, CloneStruct>` due to unsatisfied trait bounds
--> $DIR/derive-trait-for-method-call.rs:40:15
|
LL | struct Foo<X, Y> (X, Y);
- | --- method `test` not found for this struct
+ | ---------------- method `test` not found for this struct
...
LL | let y = x.test();
| ^^^^ method cannot be called on `Foo<Vec<Enum>, Instant>` due to unsatisfied trait bounds
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:28:21
|
-LL | let x = X(Y);
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
- | | -- ^ help: consider borrowing here: `&x`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
-LL | |
-LL | |
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+LL | let X(_t) = x;
+ | -- ^ help: consider borrowing here: `&x`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:32:34
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-LL | |
-LL | | if let Either::One(_t) = e { }
- | | -- ^ help: consider borrowing here: `&e`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | if let Either::One(_t) = e { }
+ | -- ^ help: consider borrowing here: `&e`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:36:37
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | while let Either::One(_t) = e { }
- | | -- ^ help: consider borrowing here: `&e`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | while let Either::One(_t) = e { }
+ | -- ^ help: consider borrowing here: `&e`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:40:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match e {
- | | ^ help: consider borrowing here: `&e`
-... |
-LL | | Either::One(_t)
- | | --
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match e {
+ | ^ help: consider borrowing here: `&e`
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:47:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match e {
- | | ^ help: consider borrowing here: `&e`
-... |
-LL | | Either::One(_t) => (),
- | | --
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match e {
+ | ^ help: consider borrowing here: `&e`
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:56:25
|
-LL | let x = X(Y);
- | - captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | let X(mut _t) = x;
- | | ------ ^ help: consider borrowing here: `&x`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | let X(mut _t) = x;
+ | ------ ^ help: consider borrowing here: `&x`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:60:38
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | if let Either::One(mut _t) = em { }
- | | ------ ^^ help: consider borrowing here: `&em`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | if let Either::One(mut _t) = em { }
+ | ------ ^^ help: consider borrowing here: `&em`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:64:41
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | while let Either::One(mut _t) = em { }
- | | ------ ^^ help: consider borrowing here: `&em`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | while let Either::One(mut _t) = em { }
+ | ------ ^^ help: consider borrowing here: `&em`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:68:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match em {
- | | ^^ help: consider borrowing here: `&em`
-... |
-LL | | Either::One(mut _t)
- | | ------
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match em {
+ | ^^ help: consider borrowing here: `&em`
+...
+LL | Either::One(mut _t)
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:75:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fn(|| {
- | ________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match em {
- | | ^^ help: consider borrowing here: `&em`
-... |
-LL | | Either::One(mut _t) => (),
- | | ------
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `Fn` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fn(|| {
+ | -- captured by this `Fn` closure
+...
+LL | match em {
+ | ^^ help: consider borrowing here: `&em`
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:95:21
|
-LL | let x = X(Y);
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
- | | -- ^ help: consider borrowing here: `&x`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
-LL | |
-LL | |
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+LL | let X(_t) = x;
+ | -- ^ help: consider borrowing here: `&x`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:99:34
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-LL | |
-LL | | if let Either::One(_t) = e { }
- | | -- ^ help: consider borrowing here: `&e`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | if let Either::One(_t) = e { }
+ | -- ^ help: consider borrowing here: `&e`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:103:37
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | while let Either::One(_t) = e { }
- | | -- ^ help: consider borrowing here: `&e`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | while let Either::One(_t) = e { }
+ | -- ^ help: consider borrowing here: `&e`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:107:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match e {
- | | ^ help: consider borrowing here: `&e`
-... |
-LL | | Either::One(_t)
- | | --
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match e {
+ | ^ help: consider borrowing here: `&e`
+...
+LL | Either::One(_t)
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:114:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match e {
- | | ^ help: consider borrowing here: `&e`
-... |
-LL | | Either::One(_t) => (),
- | | --
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match e {
+ | ^ help: consider borrowing here: `&e`
+...
+LL | Either::One(_t) => (),
+ | --
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:123:25
|
-LL | let x = X(Y);
- | - captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | let X(mut _t) = x;
- | | ------ ^ help: consider borrowing here: `&x`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let x = X(Y);
+ | - captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | let X(mut _t) = x;
+ | ------ ^ help: consider borrowing here: `&x`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:127:38
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | if let Either::One(mut _t) = em { }
- | | ------ ^^ help: consider borrowing here: `&em`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | if let Either::One(mut _t) = em { }
+ | ------ ^^ help: consider borrowing here: `&em`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:131:41
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | while let Either::One(mut _t) = em { }
- | | ------ ^^ help: consider borrowing here: `&em`
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | while let Either::One(mut _t) = em { }
+ | ------ ^^ help: consider borrowing here: `&em`
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:135:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match em {
- | | ^^ help: consider borrowing here: `&em`
-... |
-LL | | Either::One(mut _t)
- | | ------
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^ help: consider borrowing here: `&em`
+...
+LL | Either::One(mut _t)
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:142:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match em {
- | | ^^ help: consider borrowing here: `&em`
-... |
-LL | | Either::One(mut _t) => (),
- | | ------
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^ help: consider borrowing here: `&em`
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:150:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | consume_fnmut(|| {
- | ___________________-
-LL | | let X(_t) = x;
-LL | |
-LL | |
-... |
-LL | | match em {
- | | ^^ help: consider borrowing here: `&em`
-... |
-LL | | Either::One(mut _t) => (),
- | | ------
- | | |
- | | data moved here
- | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
-... |
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
+...
+LL | consume_fnmut(|| {
+ | -- captured by this `FnMut` closure
+...
+LL | match em {
+ | ^^ help: consider borrowing here: `&em`
+...
+LL | Either::One(mut _t) => (),
+ | ------
+ | |
+ | data moved here
+ | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error: aborting due to 21 previous errors
--> $DIR/dont-wrap-ambiguous-receivers.rs:18:25
|
LL | pub struct Chaenomeles;
- | ----------- method `pick` not found for this struct
+ | ---------------------- method `pick` not found for this struct
...
LL | banana::Chaenomeles.pick()
| ^^^^ method not found in `Chaenomeles`
--> $DIR/field-has-method.rs:19:15
|
LL | struct InferOk<T> {
- | ------- method `kind` not found for this struct
+ | ----------------- method `kind` not found for this struct
...
LL | let k = i.kind();
| ^^^^ method not found in `InferOk<Ty>`
LL | bar(foo());
| ++
-error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]: T` is not satisfied
+error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]: T` is not satisfied
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9
|
LL | let closure = || S;
| -- consider calling this closure
LL | bar(closure);
- | --- ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
+ | --- ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:21]`
| |
| required by a bound introduced by this call
|
--> $DIR/fn-or-tuple-struct-without-args.rs:46:20
|
LL | let closure = || 42;
- | ----- the found closure
+ | -- the found closure
LL | let _: usize = closure;
| ----- ^^^^^^^ expected `usize`, found closure
| |
| expected due to this
|
= note: expected type `usize`
- found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
+ found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:21]`
help: use parentheses to call this closure
|
LL | let _: usize = closure();
LL | #[derive(Clone)]
|
-error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:33]` cannot be unpinned
+error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22]` cannot be unpinned
--> $DIR/issue-84973-blacklist.rs:17:5
|
LL | f_unpin(static || { yield; });
- | ^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:33]`
+ | ^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22]`
|
= note: consider using `Box::pin`
note: required by a bound in `f_unpin`
--> $DIR/missing-lifetimes-in-signature.rs:19:5
|
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
- | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 22:6]` captures the anonymous lifetime defined here
+ | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12]` captures the anonymous lifetime defined here
...
LL | / move || {
LL | |
error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
--> $DIR/option-content-move2.rs:9:9
|
-LL | let mut var = None;
- | ------- captured outer variable
-LL | func(|| {
- | __________-
-LL | | // Shouldn't suggest `move ||.as_ref()` here
-LL | | move || {
- | | ^^^^^^^ move out of `var` occurs here
-LL | |
-LL | | var = Some(NotCopyable);
- | | ---
- | | |
- | | variable moved due to use in closure
- | | move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
-LL | | }
-LL | | });
- | |_____- captured by this `FnMut` closure
+LL | let mut var = None;
+ | ------- captured outer variable
+LL | func(|| {
+ | -- captured by this `FnMut` closure
+LL | // Shouldn't suggest `move ||.as_ref()` here
+LL | move || {
+ | ^^^^^^^ move out of `var` occurs here
+LL |
+LL | var = Some(NotCopyable);
+ | ---
+ | |
+ | variable moved due to use in closure
+ | move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
error: aborting due to previous error
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7
|
LL | struct GenericAssocMethod<T>(T);
- | ------------------ method `default_hello` not found for this struct
+ | ---------------------------- method `default_hello` not found for this struct
...
LL | x.default_hello();
| --^^^^^^^^^^^^^
| |_____^ expected struct `Box`, found closure
|
= note: expected struct `Box<dyn Fn() -> Result<(), ()>>`
- found closure `[closure@$DIR/suggest-box.rs:4:47: 7:6]`
+ found closure `[closure@$DIR/suggest-box.rs:4:47: 4:49]`
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
help: store this in the heap by calling `Box::new`
|
--> $DIR/suggest-methods.rs:18:7
|
LL | struct Foo;
- | --- method `bat` not found for this struct
+ | ---------- method `bat` not found for this struct
...
LL | f.bat(1.0);
| ^^^ help: there is an associated function with a similar name: `bar`
--> $DIR/suggest-variants.rs:15:12
|
LL | enum Shape {
- | ----- variant or associated item `Squareee` not found for this enum
+ | ---------- variant or associated item `Squareee` not found for this enum
...
LL | Shape::Squareee;
| ^^^^^^^^
--> $DIR/suggest-variants.rs:16:12
|
LL | enum Shape {
- | ----- variant or associated item `Circl` not found for this enum
+ | ---------- variant or associated item `Circl` not found for this enum
...
LL | Shape::Circl;
| ^^^^^
--> $DIR/suggest-variants.rs:17:12
|
LL | enum Shape {
- | ----- variant or associated item `Rombus` not found for this enum
+ | ---------- variant or associated item `Rombus` not found for this enum
...
LL | Shape::Rombus;
| ^^^^^^ variant or associated item not found in `Shape`
LL | const C: _ = || 42;
| ^ not allowed in type signatures
|
-note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:19]` cannot be named
+note: however, the inferred type `[closure@$DIR/unnamable-types.rs:17:14: 17:16]` cannot be named
--> $DIR/unnamable-types.rs:17:14
|
LL | const C: _ = || 42;
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
| ^
|
-note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:51]>` cannot be named
+note: however, the inferred type `S<[closure@$DIR/unnamable-types.rs:23:31: 23:45]>` cannot be named
--> $DIR/unnamable-types.rs:23:11
|
LL | const D = S { t: { let i = 0; move || -> i32 { i } } };
LL | const G = || -> i32 { yield 0; return 1; };
| ^
|
-note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:43]` cannot be named
+note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:20]` cannot be named
--> $DIR/unnamable-types.rs:37:11
|
LL | const G = || -> i32 { yield 0; return 1; };
| --- the method is available for `S` here
LL | }
LL | pub struct S;
- | - method `abc` not found for this struct
+ | ------------ method `abc` not found for this struct
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+++ /dev/null
-// compile-flags: -Z terminal-width=20
-
-// This test checks that `-Z terminal-width` effects the human error output by restricting it to an
-// arbitrarily low value so that the effect is visible.
-
-fn main() {
- let _: () = 42;
- //~^ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/flag-human.rs:7:17
- |
-LL | ..._: () = 42;
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// compile-flags: -Z terminal-width=20 --error-format=json
-
-// This test checks that `-Z terminal-width` effects the JSON error output by restricting it to an
-// arbitrarily low value so that the effect is visible.
-
-fn main() {
- let _: () = 42;
- //~^ ERROR arguments to this function are incorrect
-}
+++ /dev/null
-{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
-
-Erroneous code examples:
-
-```compile_fail,E0308
-fn plus_one(x: i32) -> i32 {
- x + 1
-}
-
-plus_one(\"Not a number\");
-// ^^^^^^^^^^^^^^ expected `i32`, found `&str`
-
-if \"Not a bool\" {
-// ^^^^^^^^^^^^ expected `bool`, found `&str`
-}
-
-let x: f32 = \"Not a float\";
-// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
-// |
-// expected due to this
-```
-
-This error occurs when an expression was used in a place where the compiler
-expected an expression of a different type. It can occur in several cases, the
-most common being when calling a function and passing an argument which has a
-different type than the matching type in the function declaration.
-"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":244,"byte_end":246,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":239,"byte_end":241,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
- --> $DIR/flag-json.rs:7:17
- |
-LL | ..._: () = 42;
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-"}
-{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
-
-"}
-{"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.
-"}
+++ /dev/null
-// ignore-tidy-linelength
-
-fn main() {
- let unicode_is_fun = "‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
- let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
- //~^ ERROR cannot add `&str` to `&str`
-}
+++ /dev/null
-error[E0369]: cannot add `&str` to `&str`
- --> $DIR/non-1-width-unicode-multiline-label.rs:5:260
- |
-LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
- | -------------- ^ -------------- &str
- | | |
- | | `+` cannot be used to concatenate two `&str` strings
- | &str
- |
- = note: string concatenation requires an owned `String` on the left
-help: create an owned `String` from a string reference
- |
-LL | let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
- | +++++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0369`.
+++ /dev/null
-// ignore-tidy-linelength
-
-fn main() {
- let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
-//~^ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/non-whitespace-trimming-2.rs:4:311
- |
-LL | ...13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let ...
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// ignore-tidy-linelength
-
-fn main() {
- let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
-//~^ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/non-whitespace-trimming-unicode.rs:4:415
- |
-LL | ...♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄...
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// ignore-tidy-linelength
-
-fn main() {
- let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
-//~^ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/non-whitespace-trimming.rs:4:241
- |
-LL | ... () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ...
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// Test for #78438: ensure underline alignment with many tabs on the left, long line on the right
-
-// ignore-tidy-linelength
-// ignore-tidy-tab
-
- fn main() {
- let money = 42i32;
- match money {
- v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
- //~^ ERROR variable `v` is not bound in all patterns
- v => println!("Enough money {}", v),
- }
- }
+++ /dev/null
-error[E0408]: variable `v` is not bound in all patterns
- --> $DIR/tabs-trimming.rs:9:16
- |
-LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
- | - ^ ^ pattern doesn't bind `v`
- | | |
- | | pattern doesn't bind `v`
- | variable not in all patterns
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0408`.
+++ /dev/null
-// ignore-tidy-linelength
-
-fn foo() -> usize {
- ()
-//~^ ERROR mismatched types
-}
-
-fn main() {}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/whitespace-trimming-2.rs:4:187
- |
-LL | ...-> usize {
- | ----- expected `usize` because of return type
-LL | ... ()
- | ^^ expected `usize`, found `()`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// ignore-tidy-linelength
-
-fn main() {
- let _: () = 42;
-//~^ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/whitespace-trimming.rs:4:193
- |
-LL | ... let _: () = 42;
- | -- ^^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+struct Victim<'a, T: Perpetrator + ?Sized> {
+ value: u8,
+ perp: &'a T,
+}
+
+trait VictimTrait {
+ type Ret;
+ fn get(self) -> Self::Ret;
+}
+
+// Actual fix is here
+impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ type Ret = u8;
+ fn get(self) -> Self::Ret {
+ self.value
+ }
+}
+
+trait Perpetrator {
+ fn getter<'a>(&'a self) -> Victim<'a, Self> {
+ Victim {
+ value: 0,
+ perp: self,
+ }
+ }
+
+ fn trigger(&self) {
+ self.getter().get();
+ //~^ ERROR the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0599]: the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+ --> $DIR/impl-derived-implicit-sized-bound-2.rs:28:19
+ |
+LL | struct Victim<'a, T: Perpetrator + ?Sized> {
+ | ------------------------------------------
+ | |
+ | method `get` not found for this struct
+ | doesn't satisfy `Victim<'_, Self>: VictimTrait`
+...
+LL | self.getter().get();
+ | ^^^ method cannot be called on `Victim<'_, Self>` due to unsatisfied trait bounds
+ |
+note: trait bound `Self: Sized` was not satisfied
+ --> $DIR/impl-derived-implicit-sized-bound-2.rs:12:10
+ |
+LL | impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ | ^ ----------- -------------
+ | |
+ | unsatisfied trait bound introduced here
+help: consider relaxing the type parameter's implicit `Sized` bound
+ |
+LL | impl<'a, T: ?Sized + Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ | ++++++++
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | struct Victim<'a, T: Perpetrator + ?Sized> where Self: Sized {
+ | +++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
--- /dev/null
+struct Victim<'a, T: Perpetrator + ?Sized>
+where
+ Self: Sized
+{
+ value: u8,
+ perp: &'a T,
+}
+
+trait VictimTrait {
+ type Ret;
+ fn get(self) -> Self::Ret;
+}
+
+// Actual fix is here
+impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ type Ret = u8;
+ fn get(self) -> Self::Ret {
+ self.value
+ }
+}
+
+trait Perpetrator {
+ fn getter<'a>(&'a self) -> Victim<'a, Self> {
+ Victim {
+ value: 0,
+ perp: self,
+ }
+ }
+
+ fn trigger(&self) {
+ self.getter().get();
+ //~^ ERROR the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0599]: the method `get` exists for struct `Victim<'_, Self>`, but its trait bounds were not satisfied
+ --> $DIR/impl-derived-implicit-sized-bound.rs:31:19
+ |
+LL | struct Victim<'a, T: Perpetrator + ?Sized>
+ | ------------------------------------------
+ | |
+ | method `get` not found for this struct
+ | doesn't satisfy `Victim<'_, Self>: VictimTrait`
+...
+LL | self.getter().get();
+ | ^^^ method cannot be called on `Victim<'_, Self>` due to unsatisfied trait bounds
+ |
+note: trait bound `Self: Sized` was not satisfied
+ --> $DIR/impl-derived-implicit-sized-bound.rs:15:10
+ |
+LL | impl<'a, T: Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ | ^ ----------- -------------
+ | |
+ | unsatisfied trait bound introduced here
+help: consider relaxing the type parameter's implicit `Sized` bound
+ |
+LL | impl<'a, T: ?Sized + Perpetrator /*+ ?Sized*/> VictimTrait for Victim<'a, T> {
+ | ++++++++
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | Self: Sized, Self: Sized
+ | +++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
--> $DIR/issue-3973.rs:22:20
|
LL | struct Point {
- | ----- function or associated item `new` not found for this struct
+ | ------------ function or associated item `new` not found for this struct
...
LL | let p = Point::new(0.0, 0.0);
| ^^^ function or associated item not found in `Point`
LL | T: FnMut(&'a ()),
| ^^^^^^^^^^^^^
|
- = note: cannot satisfy `T: FnMut<(&'a (),)>`
+note: multiple `impl`s or `where` clauses satisfying `T: FnMut<(&'a (),)>` found
+ --> $DIR/issue-85735.rs:7:8
+ |
+LL | T: FnMut(&'a ()),
+ | ^^^^^^^^^^^^^
+LL |
+LL | T: FnMut(&'b ()),
+ | ^^^^^^^^^^^^^
error: aborting due to previous error
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`)
= note: required because of the requirements on the impl of `Iterator` for `std::iter::Empty<()>`
= note: 171 redundant requirements hidden
- = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:52]>>`
+ = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48]>>`
error: aborting due to previous error; 1 warning emitted
--> $DIR/item-privacy.rs:67:7
|
LL | struct S;
- | - method `a` not found for this struct
+ | -------- method `a` not found for this struct
...
LL | S.a();
| ^ method not found in `S`
--> $DIR/item-privacy.rs:68:7
|
LL | struct S;
- | - method `b` not found for this struct
+ | -------- method `b` not found for this struct
...
LL | fn b(&self) { }
| - the method is available for `S` here
--> $DIR/item-privacy.rs:78:8
|
LL | struct S;
- | - function or associated item `a` not found for this struct
+ | -------- function or associated item `a` not found for this struct
...
LL | S::a(&S);
| ^ function or associated item not found in `S`
--> $DIR/item-privacy.rs:80:8
|
LL | struct S;
- | - function or associated item `b` not found for this struct
+ | -------- function or associated item `b` not found for this struct
...
LL | S::b(&S);
| ^ function or associated item not found in `S`
--> $DIR/item-privacy.rs:97:8
|
LL | struct S;
- | - associated item `A` not found for this struct
+ | -------- associated item `A` not found for this struct
...
LL | S::A;
| ^ associated item not found in `S`
--> $DIR/item-privacy.rs:98:8
|
LL | struct S;
- | - associated item `B` not found for this struct
+ | -------- associated item `B` not found for this struct
...
LL | S::B;
| ^ associated item not found in `S`
--> $DIR/explicitly-unimplemented-error-message.rs:34:9
|
LL | struct Qux;
- | --- method `clone` not found for this struct
+ | ---------- method `clone` not found for this struct
...
LL | Qux.clone();
| ^^^^^ method not found in `Qux`
--> $DIR/explicitly-unimplemented-error-message.rs:44:9
|
LL | struct Qux;
- | --- method `foo` not found for this struct
+ | ---------- method `foo` not found for this struct
...
LL | Qux.foo();
| ^^^ method not found in `Qux`
Ok::<(), ()>(())?;
use_val(cfg_res);
};
- assert_eq!(cfg_res, 5); //~ ERROR borrow of possibly-uninitialized variable: `cfg_res`
+ assert_eq!(cfg_res, 5); //~ ERROR E0381
}
-error[E0381]: borrow of possibly-uninitialized variable: `cfg_res`
+error[E0381]: used binding `cfg_res` is possibly-uninitialized
--> $DIR/try-block-opt-init.rs:15:5
|
+LL | let cfg_res;
+ | ------- binding declared here but left uninitialized
+...
+LL | cfg_res = 5;
+ | ----------- binding initialized here in some conditions
+...
LL | assert_eq!(cfg_res, 5);
- | ^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `cfg_res`
+ | ^^^^^^^^^^^^^^^^^^^^^^ `cfg_res` used here but it is possibly-uninitialized
|
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
LL | |
LL | | let b = 1;
LL | | });
- | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 5:6]` unexpected
+ | |_____- argument of type `[closure@$DIR/wrong_argument_ice-4.rs:2:13: 2:15]` unexpected
|
note: closure defined here
--> $DIR/wrong_argument_ice-4.rs:2:6
mod m {
type Foo = impl std::fmt::Debug;
//~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
- //~| ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
pub fn foo() -> Foo {
22_u32
| ^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires type-checking `m::bar`...
- --> $DIR/auto-trait-leakage3.rs:15:5
+ --> $DIR/auto-trait-leakage3.rs:15:9
|
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
+LL | is_send(foo());
+ | ^^^^^^^
+ = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
note: cycle used when checking item types in module `m`
--> $DIR/auto-trait-leakage3.rs:6:1
LL | mod m {
| ^^^^^
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:16
- |
-LL | type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/auto-trait-leakage3.rs:15:5
- |
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
- = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
- --> $DIR/auto-trait-leakage3.rs:6:1
- |
-LL | mod m {
- | ^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.
mod m {
type Foo = impl std::fmt::Debug;
//~^ ERROR cycle detected
- //~| ERROR cycle detected
// Cycle: error today, but it'd be nice if it eventually worked
| ^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires type-checking `m::bar`...
- --> $DIR/inference-cycle.rs:15:5
+ --> $DIR/inference-cycle.rs:15:9
|
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
+LL | is_send(foo()); // Today: error
+ | ^^^^^^^
+ = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
= note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
note: cycle used when checking item types in module `m`
--> $DIR/inference-cycle.rs:4:1
LL | mod m {
| ^^^^^
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:16
- |
-LL | type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
- |
-note: ...which requires type-checking `m::bar`...
- --> $DIR/inference-cycle.rs:15:5
- |
-LL | pub fn bar() {
- | ^^^^^^^^^^^^
- = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
- --> $DIR/inference-cycle.rs:4:1
- |
-LL | mod m {
- | ^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.
LL | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[closure@$DIR/issue-53092-2.rs:6:61: 6:71]` (0 bits)
+ = note: source type: `[closure@$DIR/issue-53092-2.rs:6:61: 6:68]` (0 bits)
= note: target type: `Bug<u8, ()>` (size can vary because of [type error])
error[E0277]: the trait bound `U: From<T>` is not satisfied
--> $DIR/issue-57611-trait-alias.rs:21:9
|
LL | |x| x
- | ^^^^^
+ | ^^^
error: implementation of `FnOnce` is not general enough
--> $DIR/issue-57611-trait-alias.rs:21:9
| ^^^^^ expected `()`, found closure
|
= note: expected unit type `()`
- found closure `[closure@$DIR/issue-63279.rs:9:21: 9:26]`
+ found closure `[closure@$DIR/issue-63279.rs:9:21: 9:23]`
help: use parentheses to call this closure
|
LL | || -> Closure { (|| ())() }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
= note: expected unit type `()`
- found closure `[closure@$DIR/issue-63279.rs:9:5: 9:28]`
+ found closure `[closure@$DIR/issue-63279.rs:9:5: 9:18]`
help: use parentheses to call this closure
|
LL | (|| -> Closure { || () })()
-error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 19:10] as Generator>::Yield == ()`
+error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 17:16] as Generator>::Yield == ()`
--> $DIR/issue-94429.rs:15:26
|
LL | fn run(&mut self) -> Self::Gen {
--- /dev/null
+// edition:2018
+
+type AsyncFnPtr = Box<
+ dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>>,
+>;
+
+async fn test() {}
+
+#[allow(unused_must_use)]
+fn main() {
+ Box::new(test) as AsyncFnPtr;
+ //~^ ERROR type mismatch
+}
--- /dev/null
+error[E0271]: type mismatch resolving `<fn() -> impl Future<Output = ()> {test} as FnOnce<()>>::Output == Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+ --> $DIR/issue-98604.rs:11:5
+ |
+LL | Box::new(test) as AsyncFnPtr;
+ | ^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type
+ |
+note: while checking the return type of the `async fn`
+ --> $DIR/issue-98604.rs:7:17
+ |
+LL | async fn test() {}
+ | ^ checked the `Output` of this `async fn`, found opaque type
+ = note: expected struct `Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+ found opaque type `impl Future<Output = ()>`
+ = note: required for the cast from `fn() -> impl Future<Output = ()> {test}` to the object type `dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
--- /dev/null
+fn hi() -> impl Sized { std::ptr::null::<u8>() }
+
+fn main() {
+ let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
+ //~^ ERROR type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
+ let boxed = b();
+ let null = *boxed;
+ println!("{null:?}");
+}
--- /dev/null
+error[E0271]: type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
+ --> $DIR/issue-98608.rs:4:39
+ |
+LL | fn hi() -> impl Sized { std::ptr::null::<u8>() }
+ | ---------- the found opaque type
+...
+LL | let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
+ | ^^^^^^^^^^^^ expected struct `Box`, found opaque type
+ |
+ = note: expected struct `Box<u8>`
+ found opaque type `impl Sized`
+ = note: required for the cast from `fn() -> impl Sized {hi}` to the object type `dyn Fn() -> Box<u8>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
type Foo = impl Debug;
//~^ ERROR cycle detected
-//~| ERROR cycle detected
fn is_send<T: Send>() { }
| ^^^^^^^^^^
|
note: ...which requires type-checking `not_good`...
- --> $DIR/reveal_local.rs:11:1
+ --> $DIR/reveal_local.rs:13:5
|
-LL | fn not_good() {
- | ^^^^^^^^^^^^^
+LL | is_send::<Foo>();
+ | ^^^^^^^^^^^^^^
+ = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`...
= note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/reveal_local.rs:1:1
LL | | fn main() {}
| |____________^
-error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
- --> $DIR/reveal_local.rs:5:12
- |
-LL | type Foo = impl Debug;
- | ^^^^^^^^^^
- |
-note: ...which requires type-checking `not_gooder`...
- --> $DIR/reveal_local.rs:17:1
- |
-LL | fn not_gooder() {
- | ^^^^^^^^^^^^^^^
- = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
- --> $DIR/reveal_local.rs:1:1
- |
-LL | / #![feature(type_alias_impl_trait)]
-LL | |
-LL | | use std::fmt::Debug;
-LL | |
-... |
-LL | |
-LL | | fn main() {}
- | |____________^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.
LL | where &'a T : Foo,
| ^^^
|
- = note: cannot satisfy `&'a T: Foo`
+note: multiple `impl`s or `where` clauses satisfying `&'a T: Foo` found
+ --> $DIR/issue-40294.rs:6:19
+ |
+LL | where &'a T : Foo,
+ | ^^^
+LL | &'b T : Foo
+ | ^^^
error: aborting due to previous error
| help: a return type might be missing here: `-> _`
|
= note: expected unit type `()`
- found generator `[generator@$DIR/issue-91334.rs:10:8: 10:23]`
+ found generator `[generator@$DIR/issue-91334.rs:10:8: 10:10]`
error: aborting due to 5 previous errors
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Map`
|
= note: expected unit type `()`
- found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:3:26: 3:31]>`
+ found struct `Map<std::slice::Iter<'_, char>, [closure@$DIR/return_type_containing_closure.rs:3:26: 3:29]>`
help: consider using a semicolon here
|
LL | vec!['a'].iter().map(|c| c);
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn(|| drop(x));
- | --------^-
- | | |
- | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | -- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `Fn` closure
error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn_mut(|| drop(x));
- | --------^-
- | | |
- | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | -- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `FnMut` closure
error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn(move || drop(x));
- | -------------^-
- | | |
- | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | ------- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `Fn` closure
error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn_mut(move || drop(x));
- | -------------^-
- | | |
- | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | ------- ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | |
| captured by this `FnMut` closure
error: aborting due to 4 previous errors
--> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:14:13
|
LL | let c = || drop(y.0);
- | ^^^^^^^^---^
- | | |
- | | closure is `FnOnce` because it moves the variable `y` out of its environment
+ | ^^ --- closure is `FnOnce` because it moves the variable `y` out of its environment
+ | |
| this closure implements `FnOnce`, not `Fn`
LL | foo(c);
| --- the requirement to implement `Fn` derives from here
error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure
--> $DIR/unboxed-closures-mutate-upvar.rs:53:9
|
-LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | let mut f = to_fn(move || {
- | _________________-----_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | n += 1;
- | | ^^^^^^ cannot assign
-LL | | });
- | |_____- in this closure
+LL | let mut f = to_fn(move || {
+ | ----- ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | n += 1;
+ | ^^^^^^ cannot assign
error: aborting due to 4 previous errors
error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure
--> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:11:9
|
-LL | fn call<F>(f: F) where F : Fn() {
- | - change this to accept `FnMut` instead of `Fn`
+LL | fn call<F>(f: F) where F : Fn() {
+ | - change this to accept `FnMut` instead of `Fn`
...
-LL | call(|| {
- | _____----_-
- | | |
- | | expects `Fn` instead of `FnMut`
-LL | | counter += 1;
- | | ^^^^^^^^^^^^ cannot assign
-LL | |
-LL | | });
- | |_____- in this closure
+LL | call(|| {
+ | ---- -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | counter += 1;
+ | ^^^^^^^^^^^^ cannot assign
error: aborting due to previous error
-error[E0599]: no method named `call` found for closure `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31]` in the current scope
+error[E0599]: no method named `call` found for closure `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29]` in the current scope
--> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10
|
LL | mut_.call((0, ));
- | ---- ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31]`
+ | ---- ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29]`
| |
| this is a function, perhaps you wish to call it
widget::Widget::new();
// Error. Widget type is not known to be uninhabited here,
// so the following code is considered reachable.
- *y = 2; //~ ERROR use of possibly-uninitialized variable
+ *y = 2; //~ ERROR E0381
}
-error[E0381]: use of possibly-uninitialized variable: `y`
+error[E0381]: used binding `y` isn't initialized
--> $DIR/privately-uninhabited-mir-call.rs:28:5
|
+LL | let y: &mut u32;
+ | - binding declared here but left uninitialized
+...
LL | *y = 2;
- | ^^^^^^ use of possibly-uninitialized `y`
+ | ^^^^^^ `y` used here but it isn't initialized
error: aborting due to previous error
|
LL | union U5<T> {
| -----------
- | | |
- | | method `clone` not found for this union
+ | |
+ | method `clone` not found for this union
| doesn't satisfy `U5<CloneNoCopy>: Clone`
...
LL | struct CloneNoCopy;
|
LL | union U5<T> {
| -----------
- | | |
- | | method `clone` not found for this union
+ | |
+ | method `clone` not found for this union
| doesn't satisfy `U5<CloneNoCopy>: Clone`
...
LL | struct CloneNoCopy;
LL | | }
| |_____- `if` and `else` have incompatible types
|
- = note: expected closure `[closure@$DIR/box-instead-of-dyn-fn.rs:8:9: 8:32]`
- found struct `Box<[closure@$DIR/box-instead-of-dyn-fn.rs:10:18: 10:43]>`
+ = note: expected closure `[closure@$DIR/box-instead-of-dyn-fn.rs:8:9: 8:16]`
+ found struct `Box<[closure@$DIR/box-instead-of-dyn-fn.rs:10:18: 10:25]>`
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/box-instead-of-dyn-fn.rs:5:56
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
-help: use `impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` as the return type, as all return paths are of type `Box<[closure@$DIR/issue-91801.rs:10:21: 12:6]>`, which implements `Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a`
+help: use `impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a` as the return type, as all return paths are of type `Box<[closure@$DIR/issue-91801.rs:10:21: 10:70]>`, which implements `Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a`
|
LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> impl Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
use rustc_span::hygiene::MacroKind;
if expr.span.from_expansion() {
let data = expr.span.ctxt().outer_expn_data();
- matches!(data.kind, ExpnKind::Macro(MacroKind::Attr, _))
+ matches!(data.kind, ExpnKind::Macro(MacroKind::Attr|MacroKind::Derive, _))
} else {
false
}
| ^^^^^^^^^^^ expected `usize`, found closure
|
= note: expected type `usize`
- found closure `[closure@$DIR/ice-6251.rs:4:44: 4:55]`
+ found closure `[closure@$DIR/ice-6251.rs:4:44: 4:53]`
error: aborting due to 4 previous errors
s._underscore_field += 1;
}
+/// Tests that we do not lint if the struct field is used in code created with derive.
+#[derive(Clone, Debug)]
+pub struct UnderscoreInStruct {
+ _foo: u32,
+}
+
/// Tests that we do not lint if the underscore is not a prefix
fn non_prefix_underscore(some_foo: u32) -> u32 {
some_foo + 1
| ^^^^^^^^^^^^^^^^^^^
error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used
- --> $DIR/used_underscore_binding.rs:99:16
+ --> $DIR/used_underscore_binding.rs:105:16
|
LL | uses_i(_i);
| ^^
-Subproject commit f76ebd6feb9f59be993336f84ecfdc441ad33d81
+Subproject commit cde87d18239b8d9afa9c6bf1051bf5573dbf326e
libc = { version = "0.2.79", features = ["align"] }
# Ensure default features of libz-sys, which are disabled in some scenarios.
libz-sys = { version = "1.1.2" }
+# same for regex
+regex = { version = "1.5.5" }
proc-macro2 = { version = "1", features = ["default"] }
quote = { version = "1", features = ["default"] }
rand_core_0_5 = { package = "rand_core", version = "0.5.1", features = ["getrandom", "alloc", "std"] }