From 7e1914f75b94d9454a63e8aa2797ab16b8997f80 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 10 Mar 2019 13:07:16 +0100 Subject: [PATCH 01/59] hir: replace NodeId with HirId in trait_impls --- src/librustc/hir/lowering.rs | 6 ++++-- src/librustc/hir/map/mod.rs | 2 +- src/librustc/hir/mod.rs | 2 +- src/librustc/ty/trait_def.rs | 4 ++-- src/librustc_typeck/coherence/builtin.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 11 +++++------ src/librustdoc/passes/collect_trait_impls.rs | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 949fdd2682b96..d3fa7ce283d12 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -89,7 +89,7 @@ pub struct LoweringContext<'a> { bodies: BTreeMap, exported_macros: Vec, - trait_impls: BTreeMap>, + trait_impls: BTreeMap>, trait_auto_impl: BTreeMap, modules: BTreeMap, @@ -2967,6 +2967,7 @@ impl<'a> LoweringContext<'a> { // method, it will not be considered an in-band // lifetime to be added, but rather a reference to a // parent lifetime. + let lowered_trait_impl_id = self.lower_node_id(id).hir_id; let (generics, (trait_ref, lowered_ty)) = self.add_in_band_defs( ast_generics, def_id, @@ -2978,7 +2979,8 @@ impl<'a> LoweringContext<'a> { if let Some(ref trait_ref) = trait_ref { if let Def::Trait(def_id) = trait_ref.path.def { - this.trait_impls.entry(def_id).or_default().push(id); + this.trait_impls.entry(def_id).or_default().push( + lowered_trait_impl_id); } } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 86b6805cc9b4c..44091eb4395be 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -555,7 +555,7 @@ impl<'hir> Map<'hir> { } } - pub fn trait_impls(&self, trait_did: DefId) -> &'hir [NodeId] { + pub fn trait_impls(&self, trait_did: DefId) -> &'hir [HirId] { self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls)); // N.B., intentionally bypass `self.forest.krate()` so that we diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index e47bc3d1c2533..ef72d0187b6b6 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -723,7 +723,7 @@ pub struct Crate { pub trait_items: BTreeMap, pub impl_items: BTreeMap, pub bodies: BTreeMap, - pub trait_impls: BTreeMap>, + pub trait_impls: BTreeMap>, pub trait_auto_impl: BTreeMap, /// A list of the body ids written out in the order in which they diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 9ce8bf2e60a31..a45b5b5b8470a 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -179,8 +179,8 @@ pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - for &node_id in tcx.hir().trait_impls(trait_id) { - add_impl(tcx.hir().local_def_id(node_id)); + for &hir_id in tcx.hir().trait_impls(trait_id) { + add_impl(tcx.hir().local_def_id_from_hir_id(hir_id)); } } diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 5d86bc5409532..2cb2dd50d7505 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -37,7 +37,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { { if Some(self.trait_def_id) == trait_def_id { for &impl_id in self.tcx.hir().trait_impls(self.trait_def_id) { - let impl_def_id = self.tcx.hir().local_def_id(impl_id); + let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(impl_id); f(self.tcx, impl_def_id); } } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 39a2f5d37bd7a..bf7284d8445ff 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -5,22 +5,21 @@ // done by the orphan and overlap modules. Then we build up various // mappings. That mapping code resides here. +use crate::hir::HirId; use crate::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::traits; use rustc::ty::{self, TyCtxt, TypeFoldable}; use rustc::ty::query::Providers; use rustc::util::common::time; -use syntax::ast; - mod builtin; mod inherent_impls; mod inherent_impls_overlap; mod orphan; mod unsafety; -fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { - let impl_def_id = tcx.hir().local_def_id(node_id); +fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_id: HirId) { + let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id); // If there are no traits, then this implementation must have a // base type. @@ -160,8 +159,8 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { /// Overlap: no two impls for the same trait are implemented for the /// same type. Likewise, no two inherent impls for a given type /// constructor provide a method with the same name. -fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { - let impl_def_id = tcx.hir().local_def_id(node_id); +fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_id: HirId) { + let impl_def_id = tcx.hir().local_def_id_from_hir_id(hir_id); let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let trait_def_id = trait_ref.def_id; diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index de043277c8359..611291c2688f5 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -119,7 +119,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate { // doesn't work with it anyway, so pull them from the HIR map instead for &trait_did in cx.all_traits.iter() { for &impl_node in cx.tcx.hir().trait_impls(trait_did) { - let impl_did = cx.tcx.hir().local_def_id(impl_node); + let impl_did = cx.tcx.hir().local_def_id_from_hir_id(impl_node); inline::build_impl(cx, impl_did, &mut new_items); } } From 401329e829cd4c6ced5a2bd9a0891f59672bf241 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 10 Mar 2019 13:08:02 +0100 Subject: [PATCH 02/59] HirIdification: remove all NodeIds from borrowck --- src/librustc_borrowck/borrowck/gather_loans/lifetime.rs | 4 ++-- src/librustc_borrowck/borrowck/gather_loans/mod.rs | 9 +++------ src/librustc_borrowck/borrowck/mod.rs | 8 +++----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 0e08b62668ac8..9680dd4ce2faf 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -2,13 +2,13 @@ //! does not exceed the lifetime of the value being borrowed. use crate::borrowck::*; +use rustc::hir::HirId; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; use rustc::ty; -use syntax::ast; use syntax_pos::Span; use log::debug; @@ -51,7 +51,7 @@ struct GuaranteeLifetimeContext<'a, 'tcx: 'a> { } impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { - fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option) -> R { + fn check(&self, cmt: &mc::cmt_<'tcx>, discr_scope: Option) -> R { //! Main routine. Walks down `cmt` until we find the //! "guarantor". Reports an error if `self.loan_region` is //! larger than scope of `cmt`. diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index bf730ba41f428..ed631f2cdaa0d 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -14,7 +14,6 @@ use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; use rustc::ty::{self, TyCtxt}; -use syntax::ast; use syntax_pos::Span; use rustc::hir; use log::debug; @@ -141,8 +140,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { assignee_cmt: &mc::cmt_<'tcx>, _: euv::MutateMode) { - let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id); - self.guarantee_assignment_valid(node_id, + self.guarantee_assignment_valid(assignment_id, assignment_span, assignee_cmt); } @@ -238,7 +236,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { /// Guarantees that `cmt` is assignable, or reports an error. fn guarantee_assignment_valid(&mut self, - assignment_id: ast::NodeId, + assignment_id: hir::HirId, assignment_span: Span, cmt: &mc::cmt_<'tcx>) { @@ -272,8 +270,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { self.mark_loan_path_as_mutated(&lp); } gather_moves::gather_assignment(self.bccx, &self.move_data, - self.bccx.tcx.hir().node_to_hir_id(assignment_id) - .local_id, + assignment_id.local_id, assignment_span, lp); } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index da065f9e05d9e..3a6e53a92482c 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -34,7 +34,6 @@ use std::fmt; use std::rc::Rc; use rustc_data_structures::sync::Lrc; use std::hash::{Hash, Hasher}; -use syntax::ast; use syntax_pos::{MultiSpan, Span}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use log::debug; @@ -399,12 +398,12 @@ pub enum LoanPathElem<'tcx> { } fn closure_to_block(closure_id: LocalDefId, - tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId { + tcx: TyCtxt<'_, '_, '_>) -> HirId { let closure_id = tcx.hir().local_def_id_to_node_id(closure_id); match tcx.hir().get(closure_id) { Node::Expr(expr) => match expr.node { hir::ExprKind::Closure(.., body_id, _, _) => { - tcx.hir().hir_to_node_id(body_id.hir_id) + body_id.hir_id } _ => { bug!("encountered non-closure id: {}", closure_id) @@ -422,8 +421,7 @@ impl<'a, 'tcx> LoanPath<'tcx> { } LpUpvar(upvar_id) => { let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx); - let hir_id = bccx.tcx.hir().node_to_hir_id(block_id); - region::Scope { id: hir_id.local_id, data: region::ScopeData::Node } + region::Scope { id: block_id.local_id, data: region::ScopeData::Node } } LpDowncast(ref base, _) | LpExtend(ref base, ..) => base.kill_scope(bccx), From aa5374192704861bd64dc031b363a88ec7edc0ad Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 10 Mar 2019 13:08:18 +0100 Subject: [PATCH 03/59] HirIdification: remove all NodeIds from typeck --- src/librustc_typeck/check/method/mod.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 9 +++++---- src/librustc_typeck/check/mod.rs | 15 +++++++-------- src/librustc_typeck/check/writeback.rs | 11 ++--------- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 8f27b5b7dc81f..5e3ebcb3446c6 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -196,7 +196,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { )?; if let Some(import_id) = pick.import_id { - let import_def_id = self.tcx.hir().local_def_id(import_id); + let import_def_id = self.tcx.hir().local_def_id_from_hir_id(import_id); debug!("used_trait_import: {:?}", import_def_id); Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) .unwrap().insert(import_def_id); @@ -428,7 +428,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self_ty, expr_id, ProbeScope::TraitsInScope)?; debug!("resolve_ufcs: pick={:?}", pick); if let Some(import_id) = pick.import_id { - let import_def_id = tcx.hir().local_def_id(import_id); + let import_def_id = tcx.hir().local_def_id_from_hir_id(import_id); debug!("resolve_ufcs: used_trait_import: {:?}", import_def_id); Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) .unwrap().insert(import_def_id); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index efae870c3c3a9..217be19e72a0c 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -120,7 +120,7 @@ struct Candidate<'tcx> { xform_ret_ty: Option>, item: ty::AssociatedItem, kind: CandidateKind<'tcx>, - import_id: Option, + import_id: Option, } #[derive(Debug)] @@ -145,7 +145,7 @@ enum ProbeResult { pub struct Pick<'tcx> { pub item: ty::AssociatedItem, pub kind: PickKind<'tcx>, - pub import_id: Option, + pub import_id: Option, // Indicates that the source expression should be autoderef'd N times // @@ -836,7 +836,8 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { for trait_candidate in applicable_traits.iter() { let trait_did = trait_candidate.def_id; if duplicates.insert(trait_did) { - let import_id = trait_candidate.import_id; + let import_id = trait_candidate.import_id.map(|node_id| + self.fcx.tcx.hir().node_to_hir_id(node_id)); let result = self.assemble_extension_candidates_for_trait(import_id, trait_did); result?; } @@ -887,7 +888,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { } fn assemble_extension_candidates_for_trait(&mut self, - import_id: Option, + import_id: Option, trait_def_id: DefId) -> Result<(), MethodError<'tcx>> { debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 28c79ce0c74e8..13f17d2f44fb1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4966,10 +4966,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // that highlight errors inline. let mut sp = blk.span; let mut fn_span = None; - let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id); - if let Some((decl, ident)) = self.get_parent_fn_decl(blk_node_id) { + if let Some((decl, ident)) = self.get_parent_fn_decl(blk.hir_id) { let ret_sp = decl.output.span(); - if let Some(block_sp) = self.parent_item_span(blk_node_id) { + if let Some(block_sp) = self.parent_item_span(blk.hir_id) { // HACK: on some cases (`ui/liveness/liveness-issue-2163.rs`) the // output would otherwise be incorrect and even misleading. Make sure // the span we're aiming at correspond to a `fn` body. @@ -5009,8 +5008,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty } - fn parent_item_span(&self, id: ast::NodeId) -> Option { - let node = self.tcx.hir().get(self.tcx.hir().get_parent(id)); + fn parent_item_span(&self, id: hir::HirId) -> Option { + let node = self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_item(id)); match node { Node::Item(&hir::Item { node: hir::ItemKind::Fn(_, _, _, body_id), .. @@ -5028,9 +5027,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None } - /// Given a function block's `NodeId`, returns its `FnDecl` if it exists, or `None` otherwise. - fn get_parent_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, ast::Ident)> { - let parent = self.tcx.hir().get(self.tcx.hir().get_parent(blk_id)); + /// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise. + fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(hir::FnDecl, ast::Ident)> { + let parent = self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_item(blk_id)); self.get_node_fn_decl(parent).map(|(fn_decl, ident, _)| (fn_decl, ident)) } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index d001545d1d915..01a77e85caede 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -15,7 +15,6 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::DefIdSet; use rustc_data_structures::sync::Lrc; use std::mem; -use syntax::ast; use syntax_pos::Span; /////////////////////////////////////////////////////////////////////////// @@ -444,8 +443,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { fn visit_opaque_types(&mut self, span: Span) { for (&def_id, opaque_defn) in self.fcx.opaque_types.borrow().iter() { - let node_id = self.tcx().hir().as_local_node_id(def_id).unwrap(); - let instantiated_ty = self.resolve(&opaque_defn.concrete_ty, &node_id); + let hir_id = self.tcx().hir().as_local_hir_id(def_id).unwrap(); + let instantiated_ty = self.resolve(&opaque_defn.concrete_ty, &hir_id); let generics = self.tcx().generics_of(def_id); @@ -731,12 +730,6 @@ impl Locatable for Span { } } -impl Locatable for ast::NodeId { - fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { - tcx.hir().span(*self) - } -} - impl Locatable for DefIndex { fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { let hir_id = tcx.hir().def_index_to_hir_id(*self); From 9151eabf97512efe3d66fa931fcb1e14b7f02e5f Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 10 Mar 2019 13:22:00 +0100 Subject: [PATCH 04/59] HirIdification: remove all NodeIds from rustc_mir --- src/librustc_mir/borrow_check/nll/universal_regions.rs | 8 ++------ src/librustc_mir/build/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 4d9a3775b3123..ae8dfa8144fd9 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -23,7 +23,6 @@ use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_errors::DiagnosticBuilder; use std::iter; -use syntax::ast; use super::ToRegionVid; @@ -200,12 +199,10 @@ impl<'tcx> UniversalRegions<'tcx> { param_env: ty::ParamEnv<'tcx>, ) -> Self { let tcx = infcx.tcx; - let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).unwrap(); - let mir_hir_id = tcx.hir().node_to_hir_id(mir_node_id); + let mir_hir_id = tcx.hir().as_local_hir_id(mir_def_id).unwrap(); UniversalRegionsBuilder { infcx, mir_def_id, - mir_node_id, mir_hir_id, param_env, }.build() @@ -370,7 +367,6 @@ struct UniversalRegionsBuilder<'cx, 'gcx: 'tcx, 'tcx: 'cx> { infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, mir_def_id: DefId, mir_hir_id: HirId, - mir_node_id: ast::NodeId, param_env: ty::ParamEnv<'tcx>, } @@ -475,7 +471,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { let tcx = self.infcx.tcx; let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); - match tcx.hir().body_owner_kind(self.mir_node_id) { + match tcx.hir().body_owner_kind_by_hir_id(self.mir_hir_id) { BodyOwnerKind::Closure | BodyOwnerKind::Fn => { let defining_ty = if self.mir_def_id == closure_base_def_id { diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index c8e48dea1f34c..3aac79c1d16ad 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -373,7 +373,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { /// finish building it. guard_context: Vec, - /// Maps `NodeId`s of variable bindings to the `Local`s created for them. + /// Maps `HirId`s of variable bindings to the `Local`s created for them. /// (A match binding can have two locals; the 2nd is for the arm's guard.) var_indices: HirIdMap, local_decls: IndexVec>, @@ -451,7 +451,7 @@ impl BlockContext { #[derive(Debug)] enum LocalsForNode { - /// In the usual case, a `NodeId` for an identifier maps to at most + /// In the usual case, a `HirId` for an identifier maps to at most /// one `Local` declaration. One(Local), From 584d61a2bee9af2af572103899fc3e485e0a1fa8 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Sun, 10 Mar 2019 13:56:58 +0100 Subject: [PATCH 05/59] hir: remove trait_auto_impl --- src/librustc/hir/lowering.rs | 3 --- src/librustc/hir/map/collector.rs | 1 - src/librustc/hir/map/mod.rs | 12 ------------ src/librustc/hir/mod.rs | 1 - 4 files changed, 17 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index d3fa7ce283d12..7715e926aa1f5 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -90,7 +90,6 @@ pub struct LoweringContext<'a> { exported_macros: Vec, trait_impls: BTreeMap>, - trait_auto_impl: BTreeMap, modules: BTreeMap, @@ -233,7 +232,6 @@ pub fn lower_crate( impl_items: BTreeMap::new(), bodies: BTreeMap::new(), trait_impls: BTreeMap::new(), - trait_auto_impl: BTreeMap::new(), modules: BTreeMap::new(), exported_macros: Vec::new(), catch_scopes: Vec::new(), @@ -514,7 +512,6 @@ impl<'a> LoweringContext<'a> { bodies: self.bodies, body_ids, trait_impls: self.trait_impls, - trait_auto_impl: self.trait_auto_impl, modules: self.modules, } } diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 9f39d648df1bf..e88f9e60702f7 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -121,7 +121,6 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { impl_items: _, bodies: _, trait_impls: _, - trait_auto_impl: _, body_ids: _, modules: _, } = *krate; diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 44091eb4395be..19b9c78be4c38 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -563,18 +563,6 @@ impl<'hir> Map<'hir> { self.forest.krate.trait_impls.get(&trait_did).map_or(&[], |xs| &xs[..]) } - pub fn trait_auto_impl(&self, trait_did: DefId) -> Option { - self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls)); - - // N.B., intentionally bypass `self.forest.krate()` so that we - // do not trigger a read of the whole krate here - self.forest.krate.trait_auto_impl.get(&trait_did).cloned() - } - - pub fn trait_is_auto(&self, trait_did: DefId) -> bool { - self.trait_auto_impl(trait_did).is_some() - } - /// Gets the attributes on the crate. This is preferable to /// invoking `krate.attrs` because it registers a tighter /// dep-graph access. diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index ef72d0187b6b6..a099811b748b1 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -724,7 +724,6 @@ pub struct Crate { pub impl_items: BTreeMap, pub bodies: BTreeMap, pub trait_impls: BTreeMap>, - pub trait_auto_impl: BTreeMap, /// A list of the body ids written out in the order in which they /// appear in the crate. If you're going to process all the bodies From 18229bb1ad197fcc28ed2ff399c738bb500a3f0d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 9 Mar 2019 17:41:01 +0300 Subject: [PATCH 06/59] syntax: Better recovery for `$ty::AssocItem` and `ty!()::AssocItem` --- src/libsyntax/parse/parser.rs | 136 ++++++++---------- src/test/ui/did_you_mean/bad-assoc-expr.rs | 16 +++ .../ui/did_you_mean/bad-assoc-expr.stderr | 23 ++- src/test/ui/did_you_mean/bad-assoc-pat.rs | 18 +++ src/test/ui/did_you_mean/bad-assoc-pat.stderr | 36 ++++- src/test/ui/did_you_mean/bad-assoc-ty.rs | 12 ++ src/test/ui/did_you_mean/bad-assoc-ty.stderr | 34 ++++- 7 files changed, 198 insertions(+), 77 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fe31311094b89..ba948d41c7ad7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -154,6 +154,21 @@ macro_rules! maybe_whole { }; } +/// If the next tokens are ill-formed `$ty::` recover them as `<$ty>::`. +macro_rules! maybe_recover_from_interpolated_ty_qpath { + ($self: expr, $allow_qpath_recovery: expr) => { + if $allow_qpath_recovery && $self.look_ahead(1, |t| t == &token::ModSep) { + if let token::Interpolated(nt) = &$self.token { + if let token::NtTy(ty) = &**nt { + let ty = ty.clone(); + $self.bump(); + return $self.maybe_recover_from_bad_qpath_stage_2($self.prev_span, ty); + } + } + } + } +} + fn maybe_append(mut lhs: Vec, mut rhs: Option>) -> Vec { if let Some(ref mut rhs) = rhs { lhs.append(rhs); @@ -172,11 +187,10 @@ enum PrevTokenKind { Other, } -trait RecoverQPath: Sized { +trait RecoverQPath: Sized + 'static { const PATH_STYLE: PathStyle = PathStyle::Expr; fn to_ty(&self) -> Option>; - fn to_recovered(&self, qself: Option, path: ast::Path) -> Self; - fn to_string(&self) -> String; + fn recovered(qself: Option, path: ast::Path) -> Self; } impl RecoverQPath for Ty { @@ -184,11 +198,8 @@ impl RecoverQPath for Ty { fn to_ty(&self) -> Option> { Some(P(self.clone())) } - fn to_recovered(&self, qself: Option, path: ast::Path) -> Self { - Self { span: path.span, node: TyKind::Path(qself, path), id: self.id } - } - fn to_string(&self) -> String { - pprust::ty_to_string(self) + fn recovered(qself: Option, path: ast::Path) -> Self { + Self { span: path.span, node: TyKind::Path(qself, path), id: ast::DUMMY_NODE_ID } } } @@ -196,11 +207,8 @@ impl RecoverQPath for Pat { fn to_ty(&self) -> Option> { self.to_ty() } - fn to_recovered(&self, qself: Option, path: ast::Path) -> Self { - Self { span: path.span, node: PatKind::Path(qself, path), id: self.id } - } - fn to_string(&self) -> String { - pprust::pat_to_string(self) + fn recovered(qself: Option, path: ast::Path) -> Self { + Self { span: path.span, node: PatKind::Path(qself, path), id: ast::DUMMY_NODE_ID } } } @@ -208,12 +216,9 @@ impl RecoverQPath for Expr { fn to_ty(&self) -> Option> { self.to_ty() } - fn to_recovered(&self, qself: Option, path: ast::Path) -> Self { + fn recovered(qself: Option, path: ast::Path) -> Self { Self { span: path.span, node: ExprKind::Path(qself, path), - id: self.id, attrs: self.attrs.clone() } - } - fn to_string(&self) -> String { - pprust::expr_to_string(self) + attrs: ThinVec::new(), id: ast::DUMMY_NODE_ID } } } @@ -1651,6 +1656,7 @@ impl<'a> Parser<'a> { fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery: bool, allow_c_variadic: bool) -> PResult<'a, P> { + maybe_recover_from_interpolated_ty_qpath!(self, allow_qpath_recovery); maybe_whole!(self, NtTy, |x| x); let lo = self.span; @@ -1802,14 +1808,12 @@ impl<'a> Parser<'a> { }; let span = lo.to(self.prev_span); - let ty = Ty { node, span, id: ast::DUMMY_NODE_ID }; + let ty = P(Ty { node, span, id: ast::DUMMY_NODE_ID }); // Try to recover from use of `+` with incorrect priority. self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty); self.maybe_recover_from_bad_type_plus(allow_plus, &ty)?; - let ty = self.maybe_recover_from_bad_qpath(ty, allow_qpath_recovery)?; - - Ok(P(ty)) + self.maybe_recover_from_bad_qpath(ty, allow_qpath_recovery) } fn parse_remaining_bounds(&mut self, generic_params: Vec, path: ast::Path, @@ -1881,35 +1885,35 @@ impl<'a> Parser<'a> { } // Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`. - fn maybe_recover_from_bad_qpath(&mut self, base: T, allow_recovery: bool) - -> PResult<'a, T> { + fn maybe_recover_from_bad_qpath(&mut self, base: P, allow_recovery: bool) + -> PResult<'a, P> { // Do not add `::` to expected tokens. - if !allow_recovery || self.token != token::ModSep { - return Ok(base); + if allow_recovery && self.token == token::ModSep { + if let Some(ty) = base.to_ty() { + return self.maybe_recover_from_bad_qpath_stage_2(ty.span, ty); + } } - let ty = match base.to_ty() { - Some(ty) => ty, - None => return Ok(base), - }; + Ok(base) + } - self.bump(); // `::` - let mut segments = Vec::new(); - self.parse_path_segments(&mut segments, T::PATH_STYLE, true)?; + fn maybe_recover_from_bad_qpath_stage_2(&mut self, ty_span: Span, ty: P) + -> PResult<'a, P> { + self.expect(&token::ModSep)?; - let span = ty.span.to(self.prev_span); - let path_span = span.to(span); // use an empty path since `position` == 0 - let recovered = base.to_recovered( - Some(QSelf { ty, path_span, position: 0 }), - ast::Path { segments, span }, - ); + let mut path = ast::Path { segments: Vec::new(), span: syntax_pos::DUMMY_SP }; + self.parse_path_segments(&mut path.segments, T::PATH_STYLE, true)?; + path.span = ty_span.to(self.prev_span); + let ty_str = self.sess.source_map().span_to_snippet(ty_span) + .unwrap_or_else(|_| pprust::ty_to_string(&ty)); self.diagnostic() - .struct_span_err(span, "missing angle brackets in associated item path") + .struct_span_err(path.span, "missing angle brackets in associated item path") .span_suggestion( // this is a best-effort recovery - span, "try", recovered.to_string(), Applicability::MaybeIncorrect + path.span, "try", format!("<{}>::{}", ty_str, path), Applicability::MaybeIncorrect ).emit(); - Ok(recovered) + let path_span = path.span.to(path.span); // use an empty path since `position` == 0 + Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path))) } fn parse_borrowed_pointee(&mut self) -> PResult<'a, TyKind> { @@ -2574,15 +2578,6 @@ impl<'a> Parser<'a> { ExprKind::AssignOp(binop, lhs, rhs) } - pub fn mk_mac_expr(&mut self, span: Span, m: Mac_, attrs: ThinVec) -> P { - P(Expr { - id: ast::DUMMY_NODE_ID, - node: ExprKind::Mac(source_map::Spanned {node: m, span: span}), - span, - attrs, - }) - } - fn expect_delimited_token_tree(&mut self) -> PResult<'a, (MacDelimiter, TokenStream)> { let delim = match self.token { token::OpenDelim(delim) => delim, @@ -2612,6 +2607,7 @@ impl<'a> Parser<'a> { /// N.B., this does not parse outer attributes, and is private because it only works /// correctly if called from `parse_dot_or_call_expr()`. fn parse_bottom_expr(&mut self) -> PResult<'a, P> { + maybe_recover_from_interpolated_ty_qpath!(self, true); maybe_whole_expr!(self); // Outer attributes are already parsed and will be @@ -2826,29 +2822,23 @@ impl<'a> Parser<'a> { db.note("variable declaration using `let` is a statement"); return Err(db); } else if self.token.is_path_start() { - let pth = self.parse_path(PathStyle::Expr)?; + let path = self.parse_path(PathStyle::Expr)?; // `!`, as an operator, is prefix, so we know this isn't that if self.eat(&token::Not) { // MACRO INVOCATION expression let (delim, tts) = self.expect_delimited_token_tree()?; - let hi = self.prev_span; - let node = Mac_ { path: pth, tts, delim }; - return Ok(self.mk_mac_expr(lo.to(hi), node, attrs)) - } - if self.check(&token::OpenDelim(token::Brace)) { + hi = self.prev_span; + ex = ExprKind::Mac(respan(lo.to(hi), Mac_ { path, tts, delim })); + } else if self.check(&token::OpenDelim(token::Brace)) && + !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) { // This is a struct literal, unless we're prohibited // from parsing struct literals here. - let prohibited = self.restrictions.contains( - Restrictions::NO_STRUCT_LITERAL - ); - if !prohibited { - return self.parse_struct_expr(lo, pth, attrs); - } + return self.parse_struct_expr(lo, path, attrs); + } else { + hi = path.span; + ex = ExprKind::Path(None, path); } - - hi = pth.span; - ex = ExprKind::Path(None, pth); } else { if !self.unclosed_delims.is_empty() && self.check(&token::Semi) { // Don't complain about bare semicolons after unclosed braces @@ -2883,10 +2873,8 @@ impl<'a> Parser<'a> { } } - let expr = Expr { node: ex, span: lo.to(hi), id: ast::DUMMY_NODE_ID, attrs }; - let expr = self.maybe_recover_from_bad_qpath(expr, true)?; - - return Ok(P(expr)); + let expr = self.mk_expr(lo.to(hi), ex, attrs); + self.maybe_recover_from_bad_qpath(expr, true) } fn parse_struct_expr(&mut self, lo: Span, pth: ast::Path, mut attrs: ThinVec) @@ -4581,6 +4569,7 @@ impl<'a> Parser<'a> { allow_range_pat: bool, expected: Option<&'static str>, ) -> PResult<'a, P> { + maybe_recover_from_interpolated_ty_qpath!(self, true); maybe_whole!(self, NtPat, |x| x); let lo = self.span; @@ -4756,7 +4745,7 @@ impl<'a> Parser<'a> { } } - let pat = Pat { node: pat, span: lo.to(self.prev_span), id: ast::DUMMY_NODE_ID }; + let pat = P(Pat { node: pat, span: lo.to(self.prev_span), id: ast::DUMMY_NODE_ID }); let pat = self.maybe_recover_from_bad_qpath(pat, true)?; if !allow_range_pat { @@ -4782,7 +4771,7 @@ impl<'a> Parser<'a> { } } - Ok(P(pat)) + Ok(pat) } /// Parses `ident` or `ident @ pat`. @@ -5250,7 +5239,8 @@ impl<'a> Parser<'a> { self.warn_missing_semicolon(); StmtKind::Mac(P((mac, style, attrs.into()))) } else { - let e = self.mk_mac_expr(lo.to(hi), mac.node, ThinVec::new()); + let e = self.mk_expr(mac.span, ExprKind::Mac(mac), ThinVec::new()); + let e = self.maybe_recover_from_bad_qpath(e, true)?; let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?; let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?; StmtKind::Expr(e) diff --git a/src/test/ui/did_you_mean/bad-assoc-expr.rs b/src/test/ui/did_you_mean/bad-assoc-expr.rs index 2e13db17d8271..1d584757f2faf 100644 --- a/src/test/ui/did_you_mean/bad-assoc-expr.rs +++ b/src/test/ui/did_you_mean/bad-assoc-expr.rs @@ -18,3 +18,19 @@ fn main() { 10 + (u8)::clone(&0); //~^ ERROR missing angle brackets in associated item path } + +macro_rules! expr { + ($ty: ty) => ($ty::clone(&0)) + //~^ ERROR missing angle brackets in associated item path +} +macro_rules! ty { + () => (u8) +} + +fn check_macros() { + expr!(u8); + let _ = ty!()::clone(&0); + //~^ ERROR missing angle brackets in associated item path + ty!()::clone(&0); + //~^ ERROR missing angle brackets in associated item path +} diff --git a/src/test/ui/did_you_mean/bad-assoc-expr.stderr b/src/test/ui/did_you_mean/bad-assoc-expr.stderr index e1eceabcc30af..2024564b911f6 100644 --- a/src/test/ui/did_you_mean/bad-assoc-expr.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-expr.stderr @@ -34,5 +34,26 @@ error: missing angle brackets in associated item path LL | 10 + (u8)::clone(&0); | ^^^^^^^^^^^ help: try: `<(u8)>::clone` -error: aborting due to 6 previous errors +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-expr.rs:32:13 + | +LL | let _ = ty!()::clone(&0); + | ^^^^^^^^^^^^ help: try: `::clone` + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-expr.rs:34:5 + | +LL | ty!()::clone(&0); + | ^^^^^^^^^^^^ help: try: `::clone` + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-expr.rs:23:19 + | +LL | ($ty: ty) => ($ty::clone(&0)) + | ^^^^^^^^^^ help: try: `<$ty>::clone` +... +LL | expr!(u8); + | ---------- in this macro invocation + +error: aborting due to 9 previous errors diff --git a/src/test/ui/did_you_mean/bad-assoc-pat.rs b/src/test/ui/did_you_mean/bad-assoc-pat.rs index 5bd2f1a894e82..7e7ba59dca816 100644 --- a/src/test/ui/did_you_mean/bad-assoc-pat.rs +++ b/src/test/ui/did_you_mean/bad-assoc-pat.rs @@ -16,3 +16,21 @@ fn main() { //~| ERROR no associated item named `AssocItem` found for type `(u8,)` in the current scope } } + +macro_rules! pat { + ($ty: ty) => ($ty::AssocItem) + //~^ ERROR missing angle brackets in associated item path + //~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope +} +macro_rules! ty { + () => (u8) +} + +fn check_macros() { + match 0u8 { + pat!(u8) => {} + ty!()::AssocItem => {} + //~^ ERROR missing angle brackets in associated item path + //~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope + } +} diff --git a/src/test/ui/did_you_mean/bad-assoc-pat.stderr b/src/test/ui/did_you_mean/bad-assoc-pat.stderr index 92fd9f26777f1..e620e7b43565f 100644 --- a/src/test/ui/did_you_mean/bad-assoc-pat.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-pat.stderr @@ -22,6 +22,21 @@ error: missing angle brackets in associated item path LL | &(u8,)::AssocItem => {} | ^^^^^^^^^^^^^^^^ help: try: `<(u8,)>::AssocItem` +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-pat.rs:32:9 + | +LL | ty!()::AssocItem => {} + | ^^^^^^^^^^^^^^^^ help: try: `::AssocItem` + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-pat.rs:21:19 + | +LL | ($ty: ty) => ($ty::AssocItem) + | ^^^^^^^^^^^^^^ help: try: `<$ty>::AssocItem` +... +LL | pat!(u8) => {} + | -------- in this macro invocation + error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the current scope --> $DIR/bad-assoc-pat.rs:3:15 | @@ -54,6 +69,25 @@ LL | &(u8,)::AssocItem => {} | | | associated item not found in `(u8,)` -error: aborting due to 8 previous errors +error[E0599]: no associated item named `AssocItem` found for type `u8` in the current scope + --> $DIR/bad-assoc-pat.rs:21:24 + | +LL | ($ty: ty) => ($ty::AssocItem) + | -----^^^^^^^^^ + | | + | associated item not found in `u8` +... +LL | pat!(u8) => {} + | -------- in this macro invocation + +error[E0599]: no associated item named `AssocItem` found for type `u8` in the current scope + --> $DIR/bad-assoc-pat.rs:32:16 + | +LL | ty!()::AssocItem => {} + | -------^^^^^^^^^ + | | + | associated item not found in `u8` + +error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.rs b/src/test/ui/did_you_mean/bad-assoc-ty.rs index 436bda1547be9..85e36f887be08 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.rs +++ b/src/test/ui/did_you_mean/bad-assoc-ty.rs @@ -33,4 +33,16 @@ type G = 'static + (Send)::AssocTy; type H = Fn(u8) -> (u8)::Output; //~^ ERROR ambiguous associated type +macro_rules! ty { + ($ty: ty) => ($ty::AssocTy); + //~^ ERROR missing angle brackets in associated item path + //~| ERROR ambiguous associated type + () => (u8); +} + +type J = ty!(u8); +type I = ty!()::AssocTy; +//~^ ERROR missing angle brackets in associated item path +//~| ERROR ambiguous associated type + fn main() {} diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index a9dcc831ba7d5..7e7f18f2d6e43 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -38,7 +38,22 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:27:10 | LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<'static + Send>::AssocTy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<'static + (Send)>::AssocTy` + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:44:10 + | +LL | type I = ty!()::AssocTy; + | ^^^^^^^^^^^^^^ help: try: `::AssocTy` + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:37:19 + | +LL | ($ty: ty) => ($ty::AssocTy); + | ^^^^^^^^^^^^ help: try: `<$ty>::AssocTy` +... +LL | type J = ty!(u8); + | ------- in this macro invocation error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:1:10 @@ -88,7 +103,22 @@ error[E0223]: ambiguous associated type LL | type H = Fn(u8) -> (u8)::Output; | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` -error: aborting due to 15 previous errors +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:37:19 + | +LL | ($ty: ty) => ($ty::AssocTy); + | ^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` +... +LL | type J = ty!(u8); + | ------- in this macro invocation + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:44:10 + | +LL | type I = ty!()::AssocTy; + | ^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` + +error: aborting due to 19 previous errors Some errors occurred: E0121, E0223. For more information about an error, try `rustc --explain E0121`. From 79c3651988185bb762e9d59d8c74350416cd669f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 10 Mar 2019 11:53:16 +0300 Subject: [PATCH 07/59] syntax: Optimize `maybe_whole`/`maybe_whole_expr` slightly --- src/libsyntax/parse/parser.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ba948d41c7ad7..bc7cb0403ef93 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -118,23 +118,22 @@ enum BlockMode { /// `token::Interpolated` tokens. macro_rules! maybe_whole_expr { ($p:expr) => { - if let token::Interpolated(nt) = $p.token.clone() { - match *nt { - token::NtExpr(ref e) | token::NtLiteral(ref e) => { + if let token::Interpolated(nt) = &$p.token { + match &**nt { + token::NtExpr(e) | token::NtLiteral(e) => { + let e = e.clone(); $p.bump(); - return Ok((*e).clone()); + return Ok(e); } - token::NtPath(ref path) => { + token::NtPath(path) => { + let path = path.clone(); $p.bump(); - let span = $p.span; - let kind = ExprKind::Path(None, (*path).clone()); - return Ok($p.mk_expr(span, kind, ThinVec::new())); + return Ok($p.mk_expr($p.span, ExprKind::Path(None, path), ThinVec::new())); } - token::NtBlock(ref block) => { + token::NtBlock(block) => { + let block = block.clone(); $p.bump(); - let span = $p.span; - let kind = ExprKind::Block((*block).clone(), None); - return Ok($p.mk_expr(span, kind, ThinVec::new())); + return Ok($p.mk_expr($p.span, ExprKind::Block(block, None), ThinVec::new())); } _ => {}, }; @@ -145,8 +144,9 @@ macro_rules! maybe_whole_expr { /// As maybe_whole_expr, but for things other than expressions macro_rules! maybe_whole { ($p:expr, $constructor:ident, |$x:ident| $e:expr) => { - if let token::Interpolated(nt) = $p.token.clone() { - if let token::$constructor($x) = (*nt).clone() { + if let token::Interpolated(nt) = &$p.token { + if let token::$constructor(x) = &**nt { + let $x = x.clone(); $p.bump(); return Ok($e); } From 1ab8ca353237470c2587985279d074c1524e90e1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 12 Mar 2019 10:37:15 +0300 Subject: [PATCH 08/59] Address review comments --- src/libsyntax/parse/parser.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bc7cb0403ef93..cae0be463266c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1884,7 +1884,9 @@ impl<'a> Parser<'a> { Ok(()) } - // Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`. + /// Try to recover from associated item paths like `[T]::AssocItem`/`(T, U)::AssocItem`. + /// Attempt to convert the base expression/pattern/type into a type, parse the `::AssocItem` + /// tail, and combine them into a `::AssocItem` expression/pattern/type. fn maybe_recover_from_bad_qpath(&mut self, base: P, allow_recovery: bool) -> PResult<'a, P> { // Do not add `::` to expected tokens. @@ -1896,6 +1898,8 @@ impl<'a> Parser<'a> { Ok(base) } + /// Given an already parsed `Ty` parse the `::AssocItem` tail and + /// combine them into a `::AssocItem` expression/pattern/type. fn maybe_recover_from_bad_qpath_stage_2(&mut self, ty_span: Span, ty: P) -> PResult<'a, P> { self.expect(&token::ModSep)?; @@ -1912,7 +1916,7 @@ impl<'a> Parser<'a> { path.span, "try", format!("<{}>::{}", ty_str, path), Applicability::MaybeIncorrect ).emit(); - let path_span = path.span.to(path.span); // use an empty path since `position` == 0 + let path_span = ty_span.shrink_to_hi(); // use an empty path since `position` == 0 Ok(P(T::recovered(Some(QSelf { ty, path_span, position: 0 }), path))) } From 856b081eb2ae3264da07434debd55d734fba7eb4 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 11 Mar 2019 11:03:19 +0100 Subject: [PATCH 09/59] middle: replace NodeId with HirId in AccessLevels --- src/librustc/middle/dead.rs | 2 +- src/librustc/middle/privacy.rs | 4 +- src/librustc/middle/reachable.rs | 5 +-- src/librustc/middle/stability.rs | 2 +- src/librustc_lint/builtin.rs | 12 ++--- src/librustc_privacy/lib.rs | 25 ++++------- src/librustc_save_analysis/dump_visitor.rs | 51 ++++++++++++++-------- src/librustdoc/core.rs | 6 +-- 8 files changed, 55 insertions(+), 52 deletions(-) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 94de999c25da8..0de169e652371 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -414,7 +414,7 @@ fn create_and_seed_worklist<'a, 'tcx>( ) -> (Vec, FxHashMap) { let worklist = access_levels.map.iter().filter_map(|(&id, level)| { if level >= &privacy::AccessLevel::Reachable { - Some(tcx.hir().node_to_hir_id(id)) + Some(id) } else { None } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 6ba55f882f8fd..787ff8d48c119 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -2,11 +2,11 @@ //! outside their scopes. This pass will also generate a set of exported items //! which are available for use externally when compiled as a library. +use crate::hir::HirId; use crate::util::nodemap::{DefIdSet, FxHashMap}; use std::hash::Hash; use std::fmt; -use syntax::ast::NodeId; use rustc_macros::HashStable; // Accessibility levels, sorted in ascending order @@ -27,7 +27,7 @@ pub enum AccessLevel { // Accessibility levels for reachable HIR nodes #[derive(Clone)] -pub struct AccessLevels { +pub struct AccessLevels { pub map: FxHashMap } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 72f6d22b696f7..a7294dbf07c00 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -354,8 +354,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, // We need only trait impls here, not inherent impls, and only non-exported ones if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node { - let node_id = self.tcx.hir().hir_to_node_id(item.hir_id); - if !self.access_levels.is_reachable(node_id) { + if !self.access_levels.is_reachable(item.hir_id) { self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id)); let trait_def_id = match trait_ref.path.def { @@ -415,7 +414,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> // use the lang items, so we need to be sure to mark them as // exported. reachable_context.worklist.extend( - access_levels.map.iter().map(|(id, _)| tcx.hir().node_to_hir_id(*id))); + access_levels.map.iter().map(|(id, _)| *id)); for item in tcx.lang_items().items().iter() { if let Some(did) = *item { if let Some(hir_id) = tcx.hir().as_local_hir_id(did) { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 1677384059e09..b0abe215867b5 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -319,7 +319,7 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { let stab = self.tcx.stability().local_stability(hir_id); let is_error = !self.tcx.sess.opts.test && stab.is_none() && - self.access_levels.is_reachable(self.tcx.hir().hir_to_node_id(hir_id)); + self.access_levels.is_reachable(hir_id); if is_error { self.tcx.sess.span_err( span, diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 7a7c49e460428..ad69493bf79c5 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -380,8 +380,7 @@ impl MissingDoc { // It's an option so the crate root can also use this function (it doesn't // have a NodeId). if let Some(id) = id { - let node_id = cx.tcx.hir().hir_to_node_id(id); - if !cx.access_levels.is_exported(node_id) { + if !cx.access_levels.is_exported(id) { return; } } @@ -557,8 +556,7 @@ impl LintPass for MissingCopyImplementations { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { - let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id); - if !cx.access_levels.is_reachable(node_id) { + if !cx.access_levels.is_reachable(item.hir_id) { return; } let (def, ty) = match item.node { @@ -629,8 +627,7 @@ impl LintPass for MissingDebugImplementations { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) { - let node_id = cx.tcx.hir().hir_to_node_id(item.hir_id); - if !cx.access_levels.is_reachable(node_id) { + if !cx.access_levels.is_reachable(item.hir_id) { return; } @@ -1169,9 +1166,8 @@ impl UnreachablePub { fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: hir::HirId, vis: &hir::Visibility, span: Span, exportable: bool) { let mut applicability = Applicability::MachineApplicable; - let node_id = cx.tcx.hir().hir_to_node_id(id); match vis.node { - hir::VisibilityKind::Public if !cx.access_levels.is_reachable(node_id) => { + hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => { if span.ctxt().outer().expn_info().is_some() { applicability = Applicability::MaybeIncorrect; } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 52514a3ca97d6..386a121d5acac 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -379,8 +379,8 @@ impl VisibilityLike for Option { // (which require reaching the `DefId`s in them). const SHALLOW: bool = true; fn new_min<'a, 'tcx>(find: &FindMin<'a, 'tcx, Self>, def_id: DefId) -> Self { - cmp::min(if let Some(node_id) = find.tcx.hir().as_local_node_id(def_id) { - find.access_levels.map.get(&node_id).cloned() + cmp::min(if let Some(hir_id) = find.tcx.hir().as_local_hir_id(def_id) { + find.access_levels.map.get(&hir_id).cloned() } else { Self::MAX }, find.min) @@ -410,8 +410,7 @@ struct ReachEverythingInTheInterfaceVisitor<'b, 'a: 'b, 'tcx: 'a> { impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { fn get(&self, id: hir::HirId) -> Option { - let node_id = self.tcx.hir().hir_to_node_id(id); - self.access_levels.map.get(&node_id).cloned() + self.access_levels.map.get(&id).cloned() } // Updates node level and returns the updated level. @@ -419,8 +418,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { let old_level = self.get(id); // Accessibility levels can only grow. if level > old_level { - let node_id = self.tcx.hir().hir_to_node_id(id); - self.access_levels.map.insert(node_id, level.unwrap()); + self.access_levels.map.insert(id, level.unwrap()); self.changed = true; level } else { @@ -1197,8 +1195,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { fn trait_is_public(&self, trait_id: hir::HirId) -> bool { // FIXME: this would preferably be using `exported_items`, but all // traits are exported currently (see `EmbargoVisitor.exported_trait`). - let node_id = self.tcx.hir().hir_to_node_id(trait_id); - self.access_levels.is_public(node_id) + self.access_levels.is_public(trait_id) } fn check_generic_bound(&mut self, bound: &hir::GenericBound) { @@ -1210,8 +1207,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { } fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility) -> bool { - let node_id = self.tcx.hir().hir_to_node_id(*id); - self.access_levels.is_reachable(node_id) || vis.node.is_pub() + self.access_levels.is_reachable(*id) || vis.node.is_pub() } } @@ -1325,8 +1321,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => { self.access_levels.is_reachable( - self.tcx.hir().hir_to_node_id( - impl_item_ref.id.hir_id)) + impl_item_ref.id.hir_id) } hir::ImplItemKind::Existential(..) | hir::ImplItemKind::Type(_) => false, @@ -1455,8 +1450,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { } fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) { - let node_id = self.tcx.hir().hir_to_node_id(item.hir_id); - if self.access_levels.is_reachable(node_id) { + if self.access_levels.is_reachable(item.hir_id) { intravisit::walk_foreign_item(self, item) } } @@ -1474,8 +1468,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { v: &'tcx hir::Variant, g: &'tcx hir::Generics, item_id: hir::HirId) { - let node_id = self.tcx.hir().hir_to_node_id(v.node.data.hir_id()); - if self.access_levels.is_reachable(node_id) { + if self.access_levels.is_reachable(v.node.data.hir_id()) { self.in_variant = true; intravisit::walk_variant(self, v, g, item_id); self.in_variant = false; diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index b82aee7c96ad2..8eb2702447dbc 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -58,17 +58,19 @@ macro_rules! down_cast_data { } macro_rules! access_from { - ($save_ctxt:expr, $vis:expr, $id:expr) => { + ($save_ctxt:expr, $item:expr, $id:expr) => { Access { - public: $vis.node.is_pub(), + public: $item.vis.node.is_pub(), reachable: $save_ctxt.access_levels.is_reachable($id), } }; +} - ($save_ctxt:expr, $item:expr) => { +macro_rules! access_from_vis { + ($save_ctxt:expr, $vis:expr, $id:expr) => { Access { - public: $item.vis.node.is_pub(), - reachable: $save_ctxt.access_levels.is_reachable($item.id), + public: $vis.node.is_pub(), + reachable: $save_ctxt.access_levels.is_reachable($id), } }; } @@ -303,7 +305,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { method_data.value = sig_str; method_data.sig = sig::method_signature(id, ident, generics, sig, &self.save_ctxt); - self.dumper.dump_def(&access_from!(self.save_ctxt, vis, id), method_data); + let hir_id = self.tcx.hir().node_to_hir_id(id); + self.dumper.dump_def(&access_from_vis!(self.save_ctxt, vis, hir_id), method_data); } // walk arg and return types @@ -324,7 +327,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) { let field_data = self.save_ctxt.get_field_data(field, parent_id); if let Some(field_data) = field_data { - self.dumper.dump_def(&access_from!(self.save_ctxt, field), field_data); + let hir_id = self.tcx.hir().node_to_hir_id(field.id); + self.dumper.dump_def(&access_from!(self.save_ctxt, field, hir_id), field_data); } } @@ -389,7 +393,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { |v| v.process_formals(&decl.inputs, &fn_data.qualname), ); self.process_generic_params(ty_params, &fn_data.qualname, item.id); - self.dumper.dump_def(&access_from!(self.save_ctxt, item), fn_data); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); + self.dumper.dump_def(&access_from!(self.save_ctxt, item, hir_id), fn_data); } for arg in &decl.inputs { @@ -409,10 +414,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { typ: &'l ast::Ty, expr: &'l ast::Expr, ) { + let hir_id = self.tcx.hir().node_to_hir_id(item.id); self.nest_tables(item.id, |v| { if let Some(var_data) = v.save_ctxt.get_item_data(item) { down_cast_data!(var_data, DefData, item.span); - v.dumper.dump_def(&access_from!(v.save_ctxt, item), var_data); + v.dumper.dump_def(&access_from!(v.save_ctxt, item, hir_id), var_data); } v.visit_ty(&typ); v.visit_expr(expr); @@ -434,9 +440,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if !self.span.filter_generated(ident.span) { let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt); let span = self.span_from_span(ident.span); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.dumper.dump_def( - &access_from!(self.save_ctxt, vis, id), + &access_from_vis!(self.save_ctxt, vis, hir_id), Def { kind: DefKind::Const, id: id_from_node_id(id, &self.save_ctxt), @@ -510,8 +517,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); self.dumper.dump_def( - &access_from!(self.save_ctxt, item), + &access_from!(self.save_ctxt, item, hir_id), Def { kind, id: id_from_node_id(item.id, &self.save_ctxt), @@ -550,7 +558,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { }; down_cast_data!(enum_data, DefData, item.span); - let access = access_from!(self.save_ctxt, item); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); + let access = access_from!(self.save_ctxt, item, hir_id); for variant in &enum_definition.variants { let name = variant.node.ident.name.to_string(); @@ -698,8 +707,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { .iter() .map(|i| id_from_node_id(i.id, &self.save_ctxt)) .collect(); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); self.dumper.dump_def( - &access_from!(self.save_ctxt, item), + &access_from!(self.save_ctxt, item, hir_id), Def { kind: DefKind::Trait, id, @@ -757,7 +767,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { fn process_mod(&mut self, item: &ast::Item) { if let Some(mod_data) = self.save_ctxt.get_item_data(item) { down_cast_data!(mod_data, DefData, item.span); - self.dumper.dump_def(&access_from!(self.save_ctxt, item), mod_data); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); + self.dumper.dump_def(&access_from!(self.save_ctxt, item, hir_id), mod_data); } } @@ -1197,7 +1208,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // The access is calculated using the current tree ID, but with the root tree's visibility // (since nested trees don't have their own visibility). - let access = access_from!(self.save_ctxt, root_item.vis, id); + let hir_id = self.tcx.hir().node_to_hir_id(id); + let access = access_from!(self.save_ctxt, root_item, hir_id); // The parent def id of a given use tree is always the enclosing item. let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id) @@ -1394,9 +1406,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); let id = id_from_node_id(item.id, &self.save_ctxt); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); self.dumper.dump_def( - &access_from!(self.save_ctxt, item), + &access_from!(self.save_ctxt, item, hir_id), Def { kind: DefKind::Type, id, @@ -1424,9 +1437,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc if !self.span.filter_generated(item.ident.span) { let span = self.span_from_span(item.ident.span); let id = id_from_node_id(item.id, &self.save_ctxt); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); self.dumper.dump_def( - &access_from!(self.save_ctxt, item), + &access_from!(self.save_ctxt, item, hir_id), Def { kind: DefKind::Type, id, @@ -1624,7 +1638,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc } fn visit_foreign_item(&mut self, item: &'l ast::ForeignItem) { - let access = access_from!(self.save_ctxt, item); + let hir_id = self.tcx.hir().node_to_hir_id(item.id); + let access = access_from!(self.save_ctxt, item, hir_id); match item.node { ast::ForeignItemKind::Fn(ref decl, ref generics) => { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 47dbbc20980ba..fe6133dc0830e 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -461,11 +461,11 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt sess.abort_if_errors(); let access_levels = tcx.privacy_access_levels(LOCAL_CRATE); - // Convert from a NodeId set to a DefId set since we don't always have easy access - // to the map from defid -> nodeid + // Convert from a HirId set to a DefId set since we don't always have easy access + // to the map from defid -> hirid let access_levels = AccessLevels { map: access_levels.map.iter() - .map(|(&k, &v)| (tcx.hir().local_def_id(k), v)) + .map(|(&k, &v)| (tcx.hir().local_def_id_from_hir_id(k), v)) .collect() }; From ff5e31ffb5224f458711a35392e0acddb1d4080a Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:02:56 +0000 Subject: [PATCH 10/59] Fix a broken link to the rustc-guide --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e785f03d7de2b..1fc942c7cd98a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,7 @@ can give you a good example of how a typical contribution would go. [pound-rust-internals]: https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals [internals]: https://internals.rust-lang.org [coc]: https://www.rust-lang.org/conduct.html +[rustc-guide]: https://rust-lang.github.io/rustc-guide/ [walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html ## Feature Requests From 6e449daceacd5959b830d24a8c9fc9971a2fc8ea Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:03:11 +0000 Subject: [PATCH 11/59] Remove trailing newlines --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fc942c7cd98a..02777621d6571 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ can give you a good example of how a typical contribution would go. [feature-requests]: #feature-requests To request a change to the way the Rust language works, please head over -to the [RFCs repository](https://github.com/rust-lang/rfcs) and view the +to the [RFCs repository](https://github.com/rust-lang/rfcs) and view the [README](https://github.com/rust-lang/rfcs/blob/master/README.md) for instructions. @@ -191,7 +191,7 @@ before the PR is merged. [breaking-tools-built-with-the-compiler]: #breaking-tools-built-with-the-compiler Rust's build system builds a number of tools that make use of the -internals of the compiler. This includes +internals of the compiler. This includes [Clippy](https://github.com/rust-lang/rust-clippy), [RLS](https://github.com/rust-lang/rls) and [rustfmt](https://github.com/rust-lang/rustfmt). If these tools From 205ab0c260e983615de3a2ed71c8e82e5c48dd8d Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:04:19 +0000 Subject: [PATCH 12/59] Add a link to the Discord and Zulip servers --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02777621d6571..35a741babd23f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ links to the major sections: * [Helpful Links and Information](#helpful-links-and-information) If you have questions, please make a post on [internals.rust-lang.org][internals] or -hop on [#rust-internals][pound-rust-internals]. +hop on the [Rust Discord server][rust-discord], [Rust Zulip server][rust-zulip] or [#rust-internals][pound-rust-internals]. As a reminder, all contributors are expected to follow our [Code of Conduct][coc]. @@ -27,6 +27,8 @@ can give you a good example of how a typical contribution would go. [pound-rust-internals]: https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals [internals]: https://internals.rust-lang.org +[rust-discord]: http://discord.gg/rust-lang +[rust-zulip]: https://rust-lang.zulipchat.com [coc]: https://www.rust-lang.org/conduct.html [rustc-guide]: https://rust-lang.github.io/rustc-guide/ [walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html From 6f3fda9d1d603084c8e6a323bdbea7b780ba87ca Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:07:00 +0000 Subject: [PATCH 13/59] Add links to @rust-highfive and @bors --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35a741babd23f..dde4ac3bbeb77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,7 +132,7 @@ request); you can add [git hooks](https://git-scm.com/book/en/v2/Customizing-Git before every push to make sure you never forget to make this check. All pull requests are reviewed by another person. We have a bot, -@rust-highfive, that will automatically assign a random person to review your +[@rust-highfive][rust-highfive], that will automatically assign a random person to review your request. If you want to request that a specific person reviews your pull request, @@ -149,11 +149,13 @@ on the pull request with an `r+`. It will look something like this: @bors: r+ 38fe8d2 -This tells @bors, our lovable integration bot, that your pull request has +This tells [@bors][bors], our lovable integration bot, that your pull request has been approved. The PR then enters the [merge queue][merge-queue], where @bors will run all the tests on every platform we support. If it all works out, @bors will merge your code into `master` and close the pull request. +[rust-highfive]: https://github.com/rust-highfive +[bors]: https://github.com/bors [merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust Speaking of tests, Rust has a comprehensive test suite. More information about From eadb8443f3ea4269b7010afa3bd5de21515c23b1 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:09:32 +0000 Subject: [PATCH 14/59] Update r+ syntax --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dde4ac3bbeb77..5276171728f0e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -147,7 +147,7 @@ of a random person. This is entirely optional. After someone has reviewed your pull request, they will leave an annotation on the pull request with an `r+`. It will look something like this: - @bors: r+ 38fe8d2 + @bors r+ This tells [@bors][bors], our lovable integration bot, that your pull request has been approved. The PR then enters the [merge queue][merge-queue], where @bors @@ -302,7 +302,7 @@ from the source code itself. Documentation pull requests function in the same way as other pull requests, though you may see a slightly different form of `r+`: - @bors: r+ 38fe8d2 rollup + @bors r+ rollup That additional `rollup` tells @bors that this change is eligible for a 'rollup'. To save @bors some work, and to get small changes through more quickly, when From 308a002eb16425b5164c1d2931d26d802ae89f6f Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:13:26 +0000 Subject: [PATCH 15/59] Make all references to @bors or users links --- CONTRIBUTING.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5276171728f0e..d6253dcb2338a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -136,12 +136,12 @@ All pull requests are reviewed by another person. We have a bot, request. If you want to request that a specific person reviews your pull request, -you can add an `r?` to the message. For example, Steve usually reviews +you can add an `r?` to the message. For example, [Steve][steveklabnik] usually reviews documentation changes. So if you were to make a documentation change, add r? @steveklabnik -to the end of the message, and @rust-highfive will assign @steveklabnik instead +to the end of the message, and @rust-highfive will assign [@steveklabnik][steveklabnik] instead of a random person. This is entirely optional. After someone has reviewed your pull request, they will leave an annotation @@ -150,11 +150,12 @@ on the pull request with an `r+`. It will look something like this: @bors r+ This tells [@bors][bors], our lovable integration bot, that your pull request has -been approved. The PR then enters the [merge queue][merge-queue], where @bors +been approved. The PR then enters the [merge queue][merge-queue], where [@bors][bors] will run all the tests on every platform we support. If it all works out, -@bors will merge your code into `master` and close the pull request. +[@bors][bors] will merge your code into `master` and close the pull request. [rust-highfive]: https://github.com/rust-highfive +[steveklabnik]: https://github.com/steveklabnik [bors]: https://github.com/bors [merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust @@ -304,9 +305,9 @@ though you may see a slightly different form of `r+`: @bors r+ rollup -That additional `rollup` tells @bors that this change is eligible for a 'rollup'. -To save @bors some work, and to get small changes through more quickly, when -@bors attempts to merge a commit that's rollup-eligible, it will also merge +That additional `rollup` tells [@bors][bors] that this change is eligible for a 'rollup'. +To save [@bors][bors] some work, and to get small changes through more quickly, when +[@bors][bors] attempts to merge a commit that's rollup-eligible, it will also merge the other rollup-eligible patches too, and they'll get tested and merged at the same time. @@ -433,7 +434,7 @@ are: * Although out of date, [Tom Lee's great blog article][tlgba] is very helpful * [rustaceans.org][ro] is helpful, but mostly dedicated to IRC * The [Rust Compiler Testing Docs][rctd] -* For @bors, [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) +* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) * **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly) * Don't be afraid to ask! The Rust community is friendly and helpful. From 3a00649256c64cacfdbf5f0e7b370d660291d06e Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:17:49 +0000 Subject: [PATCH 16/59] Move rollup description earlier --- CONTRIBUTING.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6253dcb2338a..ee56f5bf9954e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -154,6 +154,15 @@ been approved. The PR then enters the [merge queue][merge-queue], where [@bors][ will run all the tests on every platform we support. If it all works out, [@bors][bors] will merge your code into `master` and close the pull request. +Depending on the scale of the change, you may see a slightly different form of `r+`: + + @bors r+ rollup + +The additional `rollup` tells [@bors][bors] that this change is eligible for to be +"rolled up". Changes that are rolled up are tested and merged at the same time, to +speed the process up. Typically only small changes that are expected not to conflict +with one another are rolled up. + [rust-highfive]: https://github.com/rust-highfive [steveklabnik]: https://github.com/steveklabnik [bors]: https://github.com/bors @@ -298,18 +307,8 @@ the submodule to. Running `./x.py build` should work now. Documentation improvements are very welcome. The source of `doc.rust-lang.org` is located in `src/doc` in the tree, and standard API documentation is generated -from the source code itself. - -Documentation pull requests function in the same way as other pull requests, -though you may see a slightly different form of `r+`: - - @bors r+ rollup - -That additional `rollup` tells [@bors][bors] that this change is eligible for a 'rollup'. -To save [@bors][bors] some work, and to get small changes through more quickly, when -[@bors][bors] attempts to merge a commit that's rollup-eligible, it will also merge -the other rollup-eligible patches too, and they'll get tested and merged at -the same time. +from the source code itself. Documentation pull requests function in the same way +as other pull requests. To find documentation-related issues, sort by the [T-doc label][tdoc]. From 037596c4ce1548543479ace50500ee3dc2f6720e Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:20:41 +0000 Subject: [PATCH 17/59] Fix capitalisation problem --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee56f5bf9954e..fa408935cc8cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -433,7 +433,8 @@ are: * Although out of date, [Tom Lee's great blog article][tlgba] is very helpful * [rustaceans.org][ro] is helpful, but mostly dedicated to IRC * The [Rust Compiler Testing Docs][rctd] -* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) +* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful +(though you'll need to replace `@homu` with `@bors` in any commands) * **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly) * Don't be afraid to ask! The Rust community is friendly and helpful. From b392c5e3c17396f3987f671a61fa9fbf9f999dae Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 16 Mar 2019 13:14:01 -0400 Subject: [PATCH 18/59] use the identifier span for missing struct field --- src/librustc_typeck/check/_match.rs | 16 ++++++++-------- src/test/ui/issues/issue-17800.stderr | 4 ++-- src/test/ui/issues/issue-51102.stderr | 4 ++-- src/test/ui/issues/issue-52717.stderr | 2 +- src/test/ui/numeric/numeric-fields.stderr | 2 +- src/test/ui/structs/struct-field-cfg.stderr | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 1a3ade7f8baf6..87e0f7d201c17 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -971,7 +971,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); self.field_ty(span, f, substs) }) .unwrap_or_else(|| { - inexistent_fields.push((span, field.ident)); + inexistent_fields.push(field.ident); no_field_errors = false; tcx.types.err }) @@ -987,15 +987,15 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); .collect::>(); if inexistent_fields.len() > 0 { let (field_names, t, plural) = if inexistent_fields.len() == 1 { - (format!("a field named `{}`", inexistent_fields[0].1), "this", "") + (format!("a field named `{}`", inexistent_fields[0]), "this", "") } else { (format!("fields named {}", inexistent_fields.iter() - .map(|(_, name)| format!("`{}`", name)) + .map(|ident| format!("`{}`", ident)) .collect::>() .join(", ")), "these", "s") }; - let spans = inexistent_fields.iter().map(|(span, _)| *span).collect::>(); + let spans = inexistent_fields.iter().map(|ident| ident.span).collect::>(); let mut err = struct_span_err!(tcx.sess, spans, E0026, @@ -1003,8 +1003,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); kind_name, tcx.item_path_str(variant.did), field_names); - if let Some((span, ident)) = inexistent_fields.last() { - err.span_label(*span, + if let Some(ident) = inexistent_fields.last() { + err.span_label(ident.span, format!("{} `{}` does not have {} field{}", kind_name, tcx.item_path_str(variant.did), @@ -1016,8 +1016,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); find_best_match_for_name(input, &ident.as_str(), None); if let Some(suggested_name) = suggested_name { err.span_suggestion( - *span, - "did you mean", + ident.span, + "a field with a similar name exists", suggested_name.to_string(), Applicability::MaybeIncorrect, ); diff --git a/src/test/ui/issues/issue-17800.stderr b/src/test/ui/issues/issue-17800.stderr index b4234245bfb38..6efc7f0c06e11 100644 --- a/src/test/ui/issues/issue-17800.stderr +++ b/src/test/ui/issues/issue-17800.stderr @@ -2,10 +2,10 @@ error[E0026]: variant `MyOption::MySome` does not have a field named `x` --> $DIR/issue-17800.rs:8:28 | LL | MyOption::MySome { x: 42 } => (), - | ^^^^^ + | ^ | | | variant `MyOption::MySome` does not have this field - | help: did you mean: `0` + | help: a field with a similar name exists: `0` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-51102.stderr b/src/test/ui/issues/issue-51102.stderr index 1b2948db2d6c3..4d4b977374ef9 100644 --- a/src/test/ui/issues/issue-51102.stderr +++ b/src/test/ui/issues/issue-51102.stderr @@ -2,7 +2,7 @@ error[E0026]: struct `SimpleStruct` does not have a field named `state` --> $DIR/issue-51102.rs:13:17 | LL | state: 0, - | ^^^^^^^^ struct `SimpleStruct` does not have this field + | ^^^^^ struct `SimpleStruct` does not have this field error[E0025]: field `no_state_here` bound multiple times in the pattern --> $DIR/issue-51102.rs:24:17 @@ -16,7 +16,7 @@ error[E0026]: variant `SimpleEnum::NoState` does not have a field named `state` --> $DIR/issue-51102.rs:33:17 | LL | state: 0 - | ^^^^^^^^ variant `SimpleEnum::NoState` does not have this field + | ^^^^^ variant `SimpleEnum::NoState` does not have this field error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-52717.stderr b/src/test/ui/issues/issue-52717.stderr index 408819813b075..468cdf2dcf921 100644 --- a/src/test/ui/issues/issue-52717.stderr +++ b/src/test/ui/issues/issue-52717.stderr @@ -5,7 +5,7 @@ LL | A::A { fob } => { println!("{}", fob); } | ^^^ | | | variant `A::A` does not have this field - | help: did you mean: `foo` + | help: a field with a similar name exists: `foo` error: aborting due to previous error diff --git a/src/test/ui/numeric/numeric-fields.stderr b/src/test/ui/numeric/numeric-fields.stderr index 1a2ad4a0c0945..ce51bbaa114fd 100644 --- a/src/test/ui/numeric/numeric-fields.stderr +++ b/src/test/ui/numeric/numeric-fields.stderr @@ -10,7 +10,7 @@ error[E0026]: struct `S` does not have a field named `0x1` --> $DIR/numeric-fields.rs:7:17 | LL | S{0: a, 0x1: b, ..} => {} - | ^^^^^^ struct `S` does not have this field + | ^^^ struct `S` does not have this field error: aborting due to 2 previous errors diff --git a/src/test/ui/structs/struct-field-cfg.stderr b/src/test/ui/structs/struct-field-cfg.stderr index c8c624d548b67..565866a682ada 100644 --- a/src/test/ui/structs/struct-field-cfg.stderr +++ b/src/test/ui/structs/struct-field-cfg.stderr @@ -22,7 +22,7 @@ error[E0026]: struct `Foo` does not have a field named `absent` --> $DIR/struct-field-cfg.rs:16:42 | LL | let Foo { present: (), #[cfg(all())] absent: () } = foo; - | ^^^^^^^^^^ struct `Foo` does not have this field + | ^^^^^^ struct `Foo` does not have this field error: aborting due to 4 previous errors From 498beaddf42092f91df3bc9a0af9a80489b2a38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 16:20:15 -0700 Subject: [PATCH 19/59] Tweak spans for E0599 --- src/librustc_typeck/check/method/suggest.rs | 35 +++++++++++-------- .../associated-const-no-item.stderr | 4 +-- src/test/ui/bogus-tag.stderr | 2 +- src/test/ui/did_you_mean/bad-assoc-pat.stderr | 16 +++------ .../dont-suggest-private-trait-method.stderr | 4 +-- .../ui/empty/empty-struct-braces-expr.stderr | 16 ++++----- src/test/ui/error-codes/E0599.stderr | 2 +- .../ui/invalid/invalid-path-in-const.stderr | 4 +-- src/test/ui/issues/issue-22933-2.stderr | 4 +-- src/test/ui/issues/issue-22933-3.stderr | 4 +-- src/test/ui/issues/issue-23173.stderr | 16 +++------ src/test/ui/issues/issue-23217.stderr | 8 ++--- src/test/ui/issues/issue-28344.stderr | 16 ++++----- src/test/ui/issues/issue-28586.stderr | 4 +-- src/test/ui/issues/issue-28971.stderr | 8 ++--- src/test/ui/issues/issue-30123.stderr | 4 +-- src/test/ui/issues/issue-38919.stderr | 4 +-- src/test/ui/issues/issue-39559.stderr | 4 +-- src/test/ui/issues/issue-3973.stderr | 4 +-- src/test/ui/issues/issue-42880.stderr | 2 +- src/test/ui/issues/issue-57362-2.stderr | 4 +-- src/test/ui/issues/issue-7950.stderr | 4 +-- src/test/ui/lexical-scopes.stderr | 4 +-- .../no-double-error.stderr | 4 +-- .../rust-2018/trait-import-suggestions.stderr | 4 +-- src/test/ui/traits/trait-item-privacy.stderr | 16 +++------ .../ui/ufcs/ufcs-partially-resolved.stderr | 8 ++--- .../ui/unspecified-self-in-trait-ref.stderr | 16 +++------ 28 files changed, 81 insertions(+), 140 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index b4a1a2d76c262..cfee7d0c20c4f 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -60,20 +60,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - pub fn report_method_error<'b>(&self, - span: Span, - rcvr_ty: Ty<'tcx>, - item_name: ast::Ident, - source: SelfSource<'b>, - error: MethodError<'tcx>, - args: Option<&'gcx [hir::Expr]>) { + pub fn report_method_error<'b>( + &self, + span: Span, + rcvr_ty: Ty<'tcx>, + item_name: ast::Ident, + source: SelfSource<'b>, + error: MethodError<'tcx>, + args: Option<&'gcx [hir::Expr]>, + ) { + let mut span = span; // Avoid suggestions when we don't know what's going on. if rcvr_ty.references_error() { return; } - let report_candidates = |err: &mut DiagnosticBuilder<'_>, - mut sources: Vec| { + let report_candidates = | + span: Span, + err: &mut DiagnosticBuilder<'_>, + mut sources: Vec, + | { sources.sort(); sources.dedup(); // Dynamic limit to avoid hiding just one candidate, which is silly. @@ -291,9 +297,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.emit(); return; } else { + span = item_name.span; let mut err = struct_span_err!( tcx.sess, - item_name.span, + span, E0599, "no {} named `{}` found for type `{}` in the current scope", item_kind, @@ -303,7 +310,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(suggestion) = suggestion { // enum variant err.span_suggestion( - item_name.span, + span, "did you mean", suggestion.to_string(), Applicability::MaybeIncorrect, @@ -414,9 +421,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.ty_to_string(actual), item_name)); } - report_candidates(&mut err, static_sources); + report_candidates(span, &mut err, static_sources); } else if static_sources.len() > 1 { - report_candidates(&mut err, static_sources); + report_candidates(span, &mut err, static_sources); } if !unsatisfied_predicates.is_empty() { @@ -461,7 +468,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "multiple applicable items in scope"); err.span_label(span, format!("multiple `{}` found", item_name)); - report_candidates(&mut err, sources); + report_candidates(span, &mut err, sources); err.emit(); } diff --git a/src/test/ui/associated-const/associated-const-no-item.stderr b/src/test/ui/associated-const/associated-const-no-item.stderr index de172049872f5..d96cf67b87578 100644 --- a/src/test/ui/associated-const/associated-const-no-item.stderr +++ b/src/test/ui/associated-const/associated-const-no-item.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `ID` found for type `i32` in the current --> $DIR/associated-const-no-item.rs:5:23 | LL | const X: i32 = ::ID; - | -------^^ - | | - | associated item not found in `i32` + | ^^ associated item not found in `i32` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `ID`, perhaps you need to implement it: diff --git a/src/test/ui/bogus-tag.stderr b/src/test/ui/bogus-tag.stderr index 3750df841720c..0bf0d4b14ee91 100644 --- a/src/test/ui/bogus-tag.stderr +++ b/src/test/ui/bogus-tag.stderr @@ -5,7 +5,7 @@ LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), } | ---------- variant `Hsl` not found here ... LL | Color::Hsl(h, s, l) => { println!("hsl"); } - | -------^^^--------- variant not found in `Color` + | ^^^ variant not found in `Color` error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/bad-assoc-pat.stderr b/src/test/ui/did_you_mean/bad-assoc-pat.stderr index 92fd9f26777f1..5d407a5ee8acf 100644 --- a/src/test/ui/did_you_mean/bad-assoc-pat.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-pat.stderr @@ -26,33 +26,25 @@ error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the --> $DIR/bad-assoc-pat.rs:3:15 | LL | [u8]::AssocItem => {} - | ------^^^^^^^^^ - | | - | associated item not found in `[u8]` + | ^^^^^^^^^ associated item not found in `[u8]` error[E0599]: no associated item named `AssocItem` found for type `(u8, u8)` in the current scope --> $DIR/bad-assoc-pat.rs:6:19 | LL | (u8, u8)::AssocItem => {} - | ----------^^^^^^^^^ - | | - | associated item not found in `(u8, u8)` + | ^^^^^^^^^ associated item not found in `(u8, u8)` error[E0599]: no associated item named `AssocItem` found for type `_` in the current scope --> $DIR/bad-assoc-pat.rs:9:12 | LL | _::AssocItem => {} - | ---^^^^^^^^^ - | | - | associated item not found in `_` + | ^^^^^^^^^ associated item not found in `_` error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope --> $DIR/bad-assoc-pat.rs:14:17 | LL | &(u8,)::AssocItem => {} - | -------^^^^^^^^^ - | | - | associated item not found in `(u8,)` + | ^^^^^^^^^ associated item not found in `(u8,)` error: aborting due to 8 previous errors diff --git a/src/test/ui/dont-suggest-private-trait-method.stderr b/src/test/ui/dont-suggest-private-trait-method.stderr index af4253779a4f5..5189ffa62d1ba 100644 --- a/src/test/ui/dont-suggest-private-trait-method.stderr +++ b/src/test/ui/dont-suggest-private-trait-method.stderr @@ -5,9 +5,7 @@ LL | struct T; | --------- function or associated item `new` not found for this ... LL | T::new(); - | ---^^^ - | | - | function or associated item not found in `T` + | ^^^ function or associated item not found in `T` error: aborting due to previous error diff --git a/src/test/ui/empty/empty-struct-braces-expr.stderr b/src/test/ui/empty/empty-struct-braces-expr.stderr index a20d79982493e..57c8c1c85dd41 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.stderr +++ b/src/test/ui/empty/empty-struct-braces-expr.stderr @@ -50,19 +50,19 @@ error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the --> $DIR/empty-struct-braces-expr.rs:22:19 | LL | let xe3 = XE::Empty3; - | ----^^^^^^ - | | | - | | help: did you mean: `XEmpty3` - | variant not found in `empty_struct::XE` + | ^^^^^^ + | | + | variant not found in `empty_struct::XE` + | help: did you mean: `XEmpty3` error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope --> $DIR/empty-struct-braces-expr.rs:23:19 | LL | let xe3 = XE::Empty3(); - | ----^^^^^^ - | | | - | | help: did you mean: `XEmpty3` - | variant not found in `empty_struct::XE` + | ^^^^^^ + | | + | variant not found in `empty_struct::XE` + | help: did you mean: `XEmpty3` error: aborting due to 8 previous errors diff --git a/src/test/ui/error-codes/E0599.stderr b/src/test/ui/error-codes/E0599.stderr index 6fb53e727630f..89bfccf2fbc56 100644 --- a/src/test/ui/error-codes/E0599.stderr +++ b/src/test/ui/error-codes/E0599.stderr @@ -5,7 +5,7 @@ LL | struct Foo; | ----------- associated item `NotEvenReal` not found for this ... LL | || if let Foo::NotEvenReal() = Foo {}; - | -----^^^^^^^^^^^-- associated item not found in `Foo` + | ^^^^^^^^^^^ associated item not found in `Foo` error: aborting due to previous error diff --git a/src/test/ui/invalid/invalid-path-in-const.stderr b/src/test/ui/invalid/invalid-path-in-const.stderr index 13176b8b8fb15..a14ab7d85e851 100644 --- a/src/test/ui/invalid/invalid-path-in-const.stderr +++ b/src/test/ui/invalid/invalid-path-in-const.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `DOESNOTEXIST` found for type `u32` in th --> $DIR/invalid-path-in-const.rs:2:23 | LL | fn f(a: [u8; u32::DOESNOTEXIST]) {} - | -----^^^^^^^^^^^^ - | | - | associated item not found in `u32` + | ^^^^^^^^^^^^ associated item not found in `u32` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22933-2.stderr b/src/test/ui/issues/issue-22933-2.stderr index 97962adc2d286..23b1474bde704 100644 --- a/src/test/ui/issues/issue-22933-2.stderr +++ b/src/test/ui/issues/issue-22933-2.stderr @@ -5,9 +5,7 @@ LL | enum Delicious { | -------------- variant `PIE` not found here ... LL | ApplePie = Delicious::Apple as isize | Delicious::PIE as isize, - | -----------^^^ - | | - | variant not found in `Delicious` + | ^^^ variant not found in `Delicious` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22933-3.stderr b/src/test/ui/issues/issue-22933-3.stderr index aa0052f97013e..b1afda6d15114 100644 --- a/src/test/ui/issues/issue-22933-3.stderr +++ b/src/test/ui/issues/issue-22933-3.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `MIN` found for type `u8` in the current --> $DIR/issue-22933-3.rs:1:22 | LL | const FOO: [u32; u8::MIN as usize] = []; - | ----^^^ - | | - | associated item not found in `u8` + | ^^^ associated item not found in `u8` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23173.stderr b/src/test/ui/issues/issue-23173.stderr index 98c4f867ad6a0..75dba883608e9 100644 --- a/src/test/ui/issues/issue-23173.stderr +++ b/src/test/ui/issues/issue-23173.stderr @@ -5,9 +5,7 @@ LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } | ---------- variant `Homura` not found here ... LL | use_token(&Token::Homura); - | -------^^^^^^ - | | - | variant not found in `Token` + | ^^^^^^ variant not found in `Token` error[E0599]: no function or associated item named `method` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:11:13 @@ -16,9 +14,7 @@ LL | struct Struct { | ------------- function or associated item `method` not found for this ... LL | Struct::method(); - | --------^^^^^^ - | | - | function or associated item not found in `Struct` + | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no function or associated item named `method` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:13:13 @@ -27,9 +23,7 @@ LL | struct Struct { | ------------- function or associated item `method` not found for this ... LL | Struct::method; - | --------^^^^^^ - | | - | function or associated item not found in `Struct` + | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no associated item named `Assoc` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:15:13 @@ -38,9 +32,7 @@ LL | struct Struct { | ------------- associated item `Assoc` not found for this ... LL | Struct::Assoc; - | --------^^^^^ - | | - | associated item not found in `Struct` + | ^^^^^ associated item not found in `Struct` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-23217.stderr b/src/test/ui/issues/issue-23217.stderr index 9cad002036fff..2a982422cab9c 100644 --- a/src/test/ui/issues/issue-23217.stderr +++ b/src/test/ui/issues/issue-23217.stderr @@ -4,10 +4,10 @@ error[E0599]: no variant named `A` found for type `SomeEnum` in the current scop LL | pub enum SomeEnum { | ----------------- variant `A` not found here LL | B = SomeEnum::A, - | ----------^ - | | | - | | help: did you mean: `B` - | variant not found in `SomeEnum` + | ^ + | | + | variant not found in `SomeEnum` + | help: did you mean: `B` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28344.stderr b/src/test/ui/issues/issue-28344.stderr index b6f520c644b32..fcd98b111cfc5 100644 --- a/src/test/ui/issues/issue-28344.stderr +++ b/src/test/ui/issues/issue-28344.stderr @@ -8,10 +8,10 @@ error[E0599]: no function or associated item named `bitor` found for type `dyn s --> $DIR/issue-28344.rs:4:25 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | --------^^^^^ - | | - | function or associated item not found in `dyn std::ops::BitXor<_>` - | help: did you mean: `bitxor` + | ^^^^^ + | | + | function or associated item not found in `dyn std::ops::BitXor<_>` + | help: did you mean: `bitxor` error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified --> $DIR/issue-28344.rs:8:13 @@ -23,10 +23,10 @@ error[E0599]: no function or associated item named `bitor` found for type `dyn s --> $DIR/issue-28344.rs:8:21 | LL | let g = BitXor::bitor; - | --------^^^^^ - | | - | function or associated item not found in `dyn std::ops::BitXor<_>` - | help: did you mean: `bitxor` + | ^^^^^ + | | + | function or associated item not found in `dyn std::ops::BitXor<_>` + | help: did you mean: `bitxor` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-28586.stderr b/src/test/ui/issues/issue-28586.stderr index eccb474c15eb6..d19c4af2df7c9 100644 --- a/src/test/ui/issues/issue-28586.stderr +++ b/src/test/ui/issues/issue-28586.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `BYTES` found for type `usize` in the cur --> $DIR/issue-28586.rs:4:26 | LL | impl Foo for [u8; usize::BYTES] {} - | -------^^^^^ - | | - | associated item not found in `usize` + | ^^^^^ associated item not found in `usize` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28971.stderr b/src/test/ui/issues/issue-28971.stderr index 77d0b53ad216b..4781f7abe8116 100644 --- a/src/test/ui/issues/issue-28971.stderr +++ b/src/test/ui/issues/issue-28971.stderr @@ -5,10 +5,10 @@ LL | enum Foo { | -------- variant `Baz` not found here ... LL | Foo::Baz(..) => (), - | -----^^^---- - | | | - | | help: did you mean: `Bar` - | variant not found in `Foo` + | ^^^ + | | + | variant not found in `Foo` + | help: did you mean: `Bar` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-30123.stderr b/src/test/ui/issues/issue-30123.stderr index 555bdb1236fe6..32bbd4d03d6d7 100644 --- a/src/test/ui/issues/issue-30123.stderr +++ b/src/test/ui/issues/issue-30123.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `new_undirected` found for ty --> $DIR/issue-30123.rs:7:33 | LL | let ug = Graph::::new_undirected(); - | -------------------^^^^^^^^^^^^^^ - | | - | function or associated item not found in `issue_30123_aux::Graph` + | ^^^^^^^^^^^^^^ function or associated item not found in `issue_30123_aux::Graph` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38919.stderr b/src/test/ui/issues/issue-38919.stderr index d23a4dfd0a496..603d42ca35e0b 100644 --- a/src/test/ui/issues/issue-38919.stderr +++ b/src/test/ui/issues/issue-38919.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `Item` found for type `T` in the current --> $DIR/issue-38919.rs:2:8 | LL | T::Item; - | ---^^^^ - | | - | associated item not found in `T` + | ^^^^ associated item not found in `T` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39559.stderr b/src/test/ui/issues/issue-39559.stderr index e851e79faee06..aded0c2de45e4 100644 --- a/src/test/ui/issues/issue-39559.stderr +++ b/src/test/ui/issues/issue-39559.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `dim` found for type `D` in t --> $DIR/issue-39559.rs:14:21 | LL | entries: [T; D::dim()], - | ---^^^ - | | - | function or associated item not found in `D` + | ^^^ function or associated item not found in `D` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `dim`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-3973.stderr b/src/test/ui/issues/issue-3973.stderr index 2ece4c396067c..576da4bcd31c8 100644 --- a/src/test/ui/issues/issue-3973.stderr +++ b/src/test/ui/issues/issue-3973.stderr @@ -14,9 +14,7 @@ LL | struct Point { | ------------ function or associated item `new` not found for this ... LL | let p = Point::new(0.0, 0.0); - | -------^^^ - | | - | function or associated item not found in `Point` + | ^^^ function or associated item not found in `Point` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-42880.stderr b/src/test/ui/issues/issue-42880.stderr index 8a40a49c0def5..763bb9ae0ea9c 100644 --- a/src/test/ui/issues/issue-42880.stderr +++ b/src/test/ui/issues/issue-42880.stderr @@ -2,7 +2,7 @@ error[E0599]: no associated item named `String` found for type `std::string::Str --> $DIR/issue-42880.rs:4:22 | LL | let f = |&Value::String(_)| (); - | -------^^^^^^--- associated item not found in `std::string::String` + | ^^^^^^ associated item not found in `std::string::String` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-57362-2.stderr b/src/test/ui/issues/issue-57362-2.stderr index 522b201ec78cd..2e713cc0ab508 100644 --- a/src/test/ui/issues/issue-57362-2.stderr +++ b/src/test/ui/issues/issue-57362-2.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for type `for< --> $DIR/issue-57362-2.rs:22:25 | LL | let x = ::make_g(); - | ------------^^^^^^ - | | - | function or associated item not found in `for<'r> fn(&'r ())` + | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `make_g`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-7950.stderr b/src/test/ui/issues/issue-7950.stderr index e30f04753762e..bbeab405e2935 100644 --- a/src/test/ui/issues/issue-7950.stderr +++ b/src/test/ui/issues/issue-7950.stderr @@ -5,9 +5,7 @@ LL | struct Foo; | ----------- function or associated item `bar` not found for this ... LL | Foo::bar(); - | -----^^^ - | | - | function or associated item not found in `Foo` + | ^^^ function or associated item not found in `Foo` error: aborting due to previous error diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index fb823ebde2edb..859eb04749f23 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -12,9 +12,7 @@ error[E0599]: no function or associated item named `f` found for type `Foo` in t --> $DIR/lexical-scopes.rs:10:10 | LL | Foo::f(); - | -----^ - | | - | function or associated item not found in `Foo` + | ^ function or associated item not found in `Foo` error: aborting due to 2 previous errors diff --git a/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr b/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr index 1bf9b09fcc5ef..c672acee040b6 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `XXX` found for type `u32` in the current --> $DIR/no-double-error.rs:8:14 | LL | u32::XXX => { } - | -----^^^ - | | - | associated item not found in `u32` + | ^^^ associated item not found in `u32` error: aborting due to previous error diff --git a/src/test/ui/rust-2018/trait-import-suggestions.stderr b/src/test/ui/rust-2018/trait-import-suggestions.stderr index e2ffeaee4b423..a81181228dfda 100644 --- a/src/test/ui/rust-2018/trait-import-suggestions.stderr +++ b/src/test/ui/rust-2018/trait-import-suggestions.stderr @@ -30,9 +30,7 @@ error[E0599]: no function or associated item named `from_str` found for type `u3 --> $DIR/trait-import-suggestions.rs:30:18 | LL | let y = u32::from_str("33"); - | -----^^^^^^^^ - | | - | function or associated item not found in `u32` + | ^^^^^^^^ function or associated item not found in `u32` | = 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: diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr index 97e7ed0ebb071..3bf5309ee7d0c 100644 --- a/src/test/ui/traits/trait-item-privacy.stderr +++ b/src/test/ui/traits/trait-item-privacy.stderr @@ -39,9 +39,7 @@ LL | struct S; | --------- function or associated item `a` not found for this ... LL | S::a(&S); - | ---^ - | | - | function or associated item not found in `S` + | ^ function or associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `a`, perhaps you need to implement it: @@ -54,9 +52,7 @@ LL | struct S; | --------- function or associated item `b` not found for this ... LL | S::b(&S); - | ---^ - | | - | function or associated item not found in `S` + | ^ function or associated item not found in `S` | = 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: @@ -77,9 +73,7 @@ LL | struct S; | --------- associated item `A` not found for this ... LL | S::A; - | ---^ - | | - | associated item not found in `S` + | ^ associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `A`, perhaps you need to implement it: @@ -92,9 +86,7 @@ LL | struct S; | --------- associated item `B` not found for this ... LL | S::B; - | ---^ - | | - | associated item not found in `S` + | ^ associated item not found in `S` | = 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: diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.stderr b/src/test/ui/ufcs/ufcs-partially-resolved.stderr index 799dbf7a6d20f..900c729721104 100644 --- a/src/test/ui/ufcs/ufcs-partially-resolved.stderr +++ b/src/test/ui/ufcs/ufcs-partially-resolved.stderr @@ -190,17 +190,13 @@ error[E0599]: no associated item named `NN` found for type `::Y` in th --> $DIR/ufcs-partially-resolved.rs:38:20 | LL | ::Y::NN; - | ---------------^^ - | | - | associated item not found in `::Y` + | ^^ associated item not found in `::Y` error[E0599]: no associated item named `N` found for type `::X` in the current scope --> $DIR/ufcs-partially-resolved.rs:55:20 | LL | ::X::N; - | ---------------^ - | | - | associated item not found in `::X` + | ^ associated item not found in `::X` error: aborting due to 32 previous errors diff --git a/src/test/ui/unspecified-self-in-trait-ref.stderr b/src/test/ui/unspecified-self-in-trait-ref.stderr index b295b39d33c1d..f894cd36a4f90 100644 --- a/src/test/ui/unspecified-self-in-trait-ref.stderr +++ b/src/test/ui/unspecified-self-in-trait-ref.stderr @@ -2,33 +2,25 @@ error[E0599]: no function or associated item named `lol` found for type `dyn Foo --> $DIR/unspecified-self-in-trait-ref.rs:10:18 | LL | let a = Foo::lol(); - | -----^^^ - | | - | function or associated item not found in `dyn Foo<_>` + | ^^^ function or associated item not found in `dyn Foo<_>` error[E0599]: no function or associated item named `lol` found for type `dyn Foo<_>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:12:23 | LL | let b = Foo::<_>::lol(); - | ----------^^^ - | | - | function or associated item not found in `dyn Foo<_>` + | ^^^ function or associated item not found in `dyn Foo<_>` error[E0599]: no function or associated item named `lol` found for type `dyn Bar<_, _>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:14:18 | LL | let c = Bar::lol(); - | -----^^^ - | | - | function or associated item not found in `dyn Bar<_, _>` + | ^^^ function or associated item not found in `dyn Bar<_, _>` error[E0599]: no function or associated item named `lol` found for type `dyn Bar` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:16:30 | LL | let d = Bar::::lol(); - | -----------------^^^ - | | - | function or associated item not found in `dyn Bar` + | ^^^ function or associated item not found in `dyn Bar` error[E0393]: the type parameter `A` must be explicitly specified --> $DIR/unspecified-self-in-trait-ref.rs:18:13 From 713f96d53d2671136bef8f1123fbf0b91c2bdaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 17:28:52 -0700 Subject: [PATCH 20/59] Swap const evaluation lint spans to point at problem in primary span --- src/librustc/mir/interpret/error.rs | 11 ++ src/librustc_mir/const_eval.rs | 2 + src/librustc_mir/transform/const_prop.rs | 1 + src/test/ui/array_const_index-0.stderr | 4 +- src/test/ui/array_const_index-1.stderr | 4 +- src/test/ui/consts/const-err-early.stderr | 20 +-- src/test/ui/consts/const-err-multi.stderr | 16 +- src/test/ui/consts/const-err.stderr | 4 +- .../conditional_array_execution.stderr | 4 +- .../consts/const-eval/const-eval-overflow2.rs | 24 ++- .../const-eval/const-eval-overflow2.stderr | 48 +++--- .../const-eval/const-eval-overflow2b.rs | 24 ++- .../const-eval/const-eval-overflow2b.stderr | 48 +++--- .../const-eval/const-eval-overflow2c.rs | 24 ++- .../const-eval/const-eval-overflow2c.stderr | 48 +++--- ...nst-pointer-values-in-various-types.stderr | 80 ++++----- .../ui/consts/const-eval/const_panic.stderr | 12 +- .../const-eval/const_panic_libcore.stderr | 12 +- .../const_panic_libcore_main.stderr | 12 +- .../const-eval/const_raw_ptr_ops.stderr | 16 +- .../ui/consts/const-eval/issue-43197.stderr | 8 +- .../ui/consts/const-eval/issue-49296.stderr | 4 +- .../ui/consts/const-eval/issue-50814-2.stderr | 4 +- .../ui/consts/const-eval/issue-50814.stderr | 4 +- .../consts/const-eval/promoted_errors.stderr | 8 +- .../ui/consts/const-eval/pub_const_err.stderr | 4 +- .../const-eval/pub_const_err_bin.stderr | 4 +- .../const-eval/unused-broken-const.stderr | 4 +- src/test/ui/consts/const-int-unchecked.stderr | 160 +++++++++--------- .../const-len-underflow-separate-spans.stderr | 4 +- src/test/ui/consts/const-slice-oob.stderr | 4 +- .../ui/consts/dangling-alloc-id-ice.stderr | 16 +- src/test/ui/consts/dangling_raw_ptr.stderr | 16 +- src/test/ui/error-codes/E0396-fixed.stderr | 4 +- src/test/ui/issues/issue-43105.stderr | 4 +- 35 files changed, 358 insertions(+), 304 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 819c65e250326..5cd1ced20220a 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -100,6 +100,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { tcx: TyCtxtAt<'a, 'gcx, 'tcx>, message: &str, lint_root: hir::HirId, + span: Option, ) -> ErrorHandled { let lint = self.struct_generic( tcx, @@ -108,6 +109,16 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { ); match lint { Ok(mut lint) => { + if let Some(span) = span { + let primary_spans = lint.span.primary_spans().to_vec(); + // point at the actual error as the primary span + lint.replace_span_with(span); + // point to the `const` statement as a secondary span + // they don't have any label + for sp in primary_spans { + lint.span_label(sp, ""); + } + } lint.emit(); ErrorHandled::Reported }, diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 71d9398c686b7..63ea1ece70c16 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -668,6 +668,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(tcx.def_span(def_id)), "any use of this value will cause an error", hir_id, + Some(err.span), ) }, // promoting runtime code is only allowed to error if it references broken constants @@ -684,6 +685,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(span), "reaching this expression at runtime will panic or abort", tcx.hir().as_local_hir_id(def_id).unwrap(), + Some(err.span), ) } // anything else (array lengths, enum initializers, constant patterns) are reported diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 23d8138efccaf..c546520e554ef 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -237,6 +237,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { self.ecx.tcx, "this expression will panic at runtime", lint_root, + None, ); } } diff --git a/src/test/ui/array_const_index-0.stderr b/src/test/ui/array_const_index-0.stderr index dfc89e0ae86ad..78d456d6c2e0e 100644 --- a/src/test/ui/array_const_index-0.stderr +++ b/src/test/ui/array_const_index-0.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-0.rs:2:1 + --> $DIR/array_const_index-0.rs:2:16 | LL | const B: i32 = (&A)[1]; - | ^^^^^^^^^^^^^^^-------^ + | ---------------^^^^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/array_const_index-1.stderr b/src/test/ui/array_const_index-1.stderr index 3e912fad53a5f..3e7360f935bb9 100644 --- a/src/test/ui/array_const_index-1.stderr +++ b/src/test/ui/array_const_index-1.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-1.rs:2:1 + --> $DIR/array_const_index-1.rs:2:16 | LL | const B: i32 = A[1]; - | ^^^^^^^^^^^^^^^----^ + | ---------------^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index a61f9b303aa15..9b0ef94a5b8c3 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:3:1 + --> $DIR/const-err-early.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,34 +13,34 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:4:1 + --> $DIR/const-err-early.rs:4:19 | LL | pub const B: u8 = 200u8 + 200u8; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to add with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:1 + --> $DIR/const-err-early.rs:5:19 | LL | pub const C: u8 = 200u8 * 4; - | ^^^^^^^^^^^^^^^^^^---------^ + | ------------------^^^^^^^^^- | | | attempt to multiply with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:6:1 + --> $DIR/const-err-early.rs:6:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^^-----------------^ + | ------------------^^^^^^^^^^^^^^^^^- | | | attempt to subtract with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:1 + --> $DIR/const-err-early.rs:7:19 | LL | pub const E: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^^^--------^ + | ------------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index af62665c056b0..c647f13fc7520 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:3:1 + --> $DIR/const-err-multi.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,26 +13,26 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:5:1 + --> $DIR/const-err-multi.rs:5:19 | LL | pub const B: i8 = A; - | ^^^^^^^^^^^^^^^^^^-^ + | ------------------^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:7:1 + --> $DIR/const-err-multi.rs:7:19 | LL | pub const C: u8 = A as u8; - | ^^^^^^^^^^^^^^^^^^-------^ + | ------------------^^^^^^^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:1 + --> $DIR/const-err-multi.rs:9:19 | LL | pub const D: i8 = 50 - A; - | ^^^^^^^^^^^^^^^^^^------^ + | ------------------^^^^^^- | | | referenced constant has errors diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr index 082494b43c25b..0ee9ecdef451d 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/const-err.rs:10:1 + --> $DIR/const-err.rs:10:17 | LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^--------^ + | ----------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 | diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index 7722c7423fc87..7f94d849c006c 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/conditional_array_execution.rs:5:1 + --> $DIR/conditional_array_execution.rs:5:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ------------------^^^^^--------------------------- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index 4700c63adbcb3..a0dbcc88cea8a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index 44ee8b336c89c..419b3d52dbff1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:1 + --> $DIR/const-eval-overflow2.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:19:1 + --> $DIR/const-eval-overflow2.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:24:1 + --> $DIR/const-eval-overflow2.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:29:1 + --> $DIR/const-eval-overflow2.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:34:1 + --> $DIR/const-eval-overflow2.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:39:1 + --> $DIR/const-eval-overflow2.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:43:1 + --> $DIR/const-eval-overflow2.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:47:1 + --> $DIR/const-eval-overflow2.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 6bed90aa8ea65..da883671a60a3 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 69e165bef4a7a..2cfd34c9fc3c7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:1 + --> $DIR/const-eval-overflow2b.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2b.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:19:1 + --> $DIR/const-eval-overflow2b.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:24:1 + --> $DIR/const-eval-overflow2b.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:29:1 + --> $DIR/const-eval-overflow2b.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:34:1 + --> $DIR/const-eval-overflow2b.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:39:1 + --> $DIR/const-eval-overflow2b.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:43:1 + --> $DIR/const-eval-overflow2b.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:47:1 + --> $DIR/const-eval-overflow2b.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index 108251e4bd281..e87344405a103 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index ba606f6d09de5..5e63286c594d9 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:1 + --> $DIR/const-eval-overflow2c.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2c.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:19:1 + --> $DIR/const-eval-overflow2c.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:24:1 + --> $DIR/const-eval-overflow2c.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:29:1 + --> $DIR/const-eval-overflow2c.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:34:1 + --> $DIR/const-eval-overflow2c.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:39:1 + --> $DIR/const-eval-overflow2c.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:43:1 + --> $DIR/const-eval-overflow2c.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:47:1 + --> $DIR/const-eval-overflow2c.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index 786338222e3ba..284b06984a31c 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -7,28 +7,28 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:27:5 + --> $DIR/const-pointer-values-in-various-types.rs:27:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:5 + --> $DIR/const-pointer-values-in-various-types.rs:30:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:33:5 + --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -49,26 +49,26 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:5 + --> $DIR/const-pointer-values-in-various-types.rs:42:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:45:5 + --> $DIR/const-pointer-values-in-various-types.rs:45:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:48:5 + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -89,10 +89,10 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:57:5 + --> $DIR/const-pointer-values-in-various-types.rs:57:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -105,42 +105,42 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:63:5 + --> $DIR/const-pointer-values-in-various-types.rs:63:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:66:5 + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:69:5 + --> $DIR/const-pointer-values-in-various-types.rs:69:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:72:5 + --> $DIR/const-pointer-values-in-various-types.rs:72:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:75:5 + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -153,34 +153,34 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:81:5 + --> $DIR/const-pointer-values-in-various-types.rs:81:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:84:5 + --> $DIR/const-pointer-values-in-various-types.rs:84:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:87:5 + --> $DIR/const-pointer-values-in-various-types.rs:87:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:90:5 + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -193,18 +193,18 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:96:5 + --> $DIR/const-pointer-values-in-various-types.rs:96:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:99:5 + --> $DIR/const-pointer-values-in-various-types.rs:99:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -217,18 +217,18 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:105:5 + --> $DIR/const-pointer-values-in-various-types.rs:105:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:108:5 + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index eecac7c71075b..12c7e3d34ab9e 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic.rs:4:1 + --> $DIR/const_panic.rs:4:19 | LL | pub const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19 | @@ -10,20 +10,20 @@ LL | pub const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:7:1 + --> $DIR/const_panic.rs:7:19 | LL | pub const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^^^^^--------------^ + | ------------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:10:1 + --> $DIR/const_panic.rs:10:19 | LL | pub const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic.rs:10:19 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.stderr b/src/test/ui/consts/const-eval/const_panic_libcore.stderr index 83c89c329dcf5..9dddac49c92b8 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:5:1 + --> $DIR/const_panic_libcore.rs:5:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:8:1 + --> $DIR/const_panic_libcore.rs:8:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:11:1 + --> $DIR/const_panic_libcore.rs:11:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore.rs:11:15 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr index 4cc48618e3212..df04a03681127 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:9:1 + --> $DIR/const_panic_libcore_main.rs:9:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:12:1 + --> $DIR/const_panic_libcore_main.rs:12:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:15:1 + --> $DIR/const_panic_libcore_main.rs:15:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore_main.rs:15:15 | diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 773441182b4be..0d4c0b98879cc 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -1,34 +1,34 @@ error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:6:1 + --> $DIR/const_raw_ptr_ops.rs:6:26 | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:12:1 + --> $DIR/const_raw_ptr_ops.rs:12:28 | LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------^^^ + | ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:16:1 + --> $DIR/const_raw_ptr_ops.rs:16:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:17:1 + --> $DIR/const_raw_ptr_ops.rs:17:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 84c686102609e..478e453fe0834 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:8:5 + --> $DIR/issue-43197.rs:8:20 | LL | const X: u32 = 0-1; - | ^^^^^^^^^^^^^^^---^ + | ---------------^^^- | | | attempt to subtract with overflow | @@ -13,10 +13,10 @@ LL | #![warn(const_err)] | ^^^^^^^^^ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:5 + --> $DIR/issue-43197.rs:10:24 | LL | const Y: u32 = foo(0-1); - | ^^^^^^^^^^^^^^^^^^^---^^ + | -------------------^^^-- | | | attempt to subtract with overflow diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 37462db4c965e..5a59a8b2dffcd 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-49296.rs:18:1 + --> $DIR/issue-49296.rs:18:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^^^^^^^^--------^ + | ---------------^^^^^^^^- | | | dangling pointer was dereferenced | diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index 29ebc31b634ad..da560046c547c 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814-2.rs:12:5 + --> $DIR/issue-50814-2.rs:12:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^^^-----------------^ + | -------------------^^^^^^^^^^^^^^^^^- | | | index out of bounds: the len is 3 but the index is 42 | diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 6fbfb4d11fe5a..bc9443b26f5fd 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814.rs:13:5 + --> $DIR/issue-50814.rs:13:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^^---------------^ + | ----------------^^^^^^^^^^^^^^^- | | | attempt to add with overflow | diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index c9d5ede61ade4..ca870c649f5b2 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -50,11 +50,15 @@ warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); - | ^^^^^^^^^^^^^^^^ attempt to divide by zero + | ^^^^^^^^^^^^^^^^ + | | + | attempt to divide by zero warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); - | ^^^^^^^ attempt to divide by zero + | ^^^^^^^ + | | + | attempt to divide by zero diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr index 9395832108d93..bd262b69da81a 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:1 + --> $DIR/pub_const_err.rs:6:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr index 6716f337f4148..866d1753edb95 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:1 + --> $DIR/pub_const_err_bin.rs:4:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index c0061f8b30cbc..603efe449f143 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -1,10 +1,10 @@ warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type error: any use of this value will cause an error - --> $DIR/unused-broken-const.rs:5:1 + --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^^^^^^^^^^^^^-----^ + | -----------------^^^^^- | | | index out of bounds: the len is 0 but the index is 0 | diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index 4382d9174b757..0fa82008711c9 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -1,322 +1,322 @@ error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:14:1 + --> $DIR/const-int-unchecked.rs:14:29 | LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shl | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:16:1 + --> $DIR/const-int-unchecked.rs:16:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:18:1 + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:20:1 + --> $DIR/const-int-unchecked.rs:20:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:22:1 + --> $DIR/const-int-unchecked.rs:22:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:27:1 + --> $DIR/const-int-unchecked.rs:27:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:29:1 + --> $DIR/const-int-unchecked.rs:29:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:31:1 + --> $DIR/const-int-unchecked.rs:31:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:33:1 + --> $DIR/const-int-unchecked.rs:33:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:35:1 + --> $DIR/const-int-unchecked.rs:35:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:40:1 + --> $DIR/const-int-unchecked.rs:40:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:42:1 + --> $DIR/const-int-unchecked.rs:42:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:44:1 + --> $DIR/const-int-unchecked.rs:44:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:46:1 + --> $DIR/const-int-unchecked.rs:46:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:48:1 + --> $DIR/const-int-unchecked.rs:48:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:54:1 + --> $DIR/const-int-unchecked.rs:54:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:56:1 + --> $DIR/const-int-unchecked.rs:56:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:58:1 + --> $DIR/const-int-unchecked.rs:58:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:60:1 + --> $DIR/const-int-unchecked.rs:60:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:62:1 + --> $DIR/const-int-unchecked.rs:62:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:69:1 + --> $DIR/const-int-unchecked.rs:69:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:71:1 + --> $DIR/const-int-unchecked.rs:71:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:73:1 + --> $DIR/const-int-unchecked.rs:73:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:75:1 + --> $DIR/const-int-unchecked.rs:75:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:77:1 + --> $DIR/const-int-unchecked.rs:77:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:82:1 + --> $DIR/const-int-unchecked.rs:82:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:84:1 + --> $DIR/const-int-unchecked.rs:84:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:86:1 + --> $DIR/const-int-unchecked.rs:86:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:88:1 + --> $DIR/const-int-unchecked.rs:88:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:90:1 + --> $DIR/const-int-unchecked.rs:90:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:95:1 + --> $DIR/const-int-unchecked.rs:95:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:97:1 + --> $DIR/const-int-unchecked.rs:97:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:99:1 + --> $DIR/const-int-unchecked.rs:99:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:101:1 + --> $DIR/const-int-unchecked.rs:101:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:103:1 + --> $DIR/const-int-unchecked.rs:103:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:109:1 + --> $DIR/const-int-unchecked.rs:109:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:111:1 + --> $DIR/const-int-unchecked.rs:111:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:113:1 + --> $DIR/const-int-unchecked.rs:113:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:115:1 + --> $DIR/const-int-unchecked.rs:115:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:117:1 + --> $DIR/const-int-unchecked.rs:117:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shr diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index 6ee92032bd777..ef4fa126dca32 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-len-underflow-separate-spans.rs:7:1 + --> $DIR/const-len-underflow-separate-spans.rs:7:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^^^^^^^^^^^---------^ + | -------------------^^^^^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 1122665cf8e55..c90cdbcb26970 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:4:1 + --> $DIR/const-slice-oob.rs:4:18 | LL | const BAR: u32 = FOO[5]; - | ^^^^^^^^^^^^^^^^^------^ + | -----------------^^^^^^- | | | index out of bounds: the len is 3 but the index is 5 | diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index 87f84480bf66b..ba640b90e7d79 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling-alloc-id-ice.rs:8:1 | -LL | / const FOO: &() = { -LL | | let y = (); -LL | | unsafe { Foo { y: &y }.long_live_the_unit } -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: &() = { + | _^ + | |_| + | || +LL | || let y = (); +LL | || unsafe { Foo { y: &y }.long_live_the_unit } +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index 0168c08f011d4..cedcbf819e2d8 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling_raw_ptr.rs:1:1 | -LL | / const FOO: *const u32 = { -LL | | let x = 42; -LL | | &x -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: *const u32 = { + | _^ + | |_| + | || +LL | || let x = 42; +LL | || &x +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr index 2923d97662868..4b7f1fa82c26c 100644 --- a/src/test/ui/error-codes/E0396-fixed.stderr +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/E0396-fixed.rs:5:1 + --> $DIR/E0396-fixed.rs:5:28 | LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^^ + | ---------------------------^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer | diff --git a/src/test/ui/issues/issue-43105.stderr b/src/test/ui/issues/issue-43105.stderr index 3cc0440d2c77a..378fbe6d5c430 100644 --- a/src/test/ui/issues/issue-43105.stderr +++ b/src/test/ui/issues/issue-43105.stderr @@ -5,10 +5,10 @@ LL | const NUM: u8 = xyz(); | ^^^^^ error: any use of this value will cause an error - --> $DIR/issue-43105.rs:3:1 + --> $DIR/issue-43105.rs:3:17 | LL | const NUM: u8 = xyz(); - | ^^^^^^^^^^^^^^^^-----^ + | ----------------^^^^^- | | | calling non-const function `xyz` | From 690bc57882ba94166446403423ac3dc278506d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 18:03:59 -0700 Subject: [PATCH 21/59] Swap primary/secondary spans for E0458 --- src/librustc_metadata/native_libs.rs | 5 +++-- src/test/ui/bad/bad-extern-link-attrs.stderr | 4 ++-- src/test/ui/error-codes/E0458.stderr | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 80786992cd956..87dca77be50ca 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -74,9 +74,10 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { "dylib" => cstore::NativeUnknown, "framework" => cstore::NativeFramework, k => { - struct_span_err!(self.tcx.sess, m.span, E0458, + struct_span_err!(self.tcx.sess, item.span, E0458, "unknown kind: `{}`", k) - .span_label(item.span(), "unknown kind").emit(); + .span_label(item.span(), "unknown kind") + .span_label(m.span, "").emit(); cstore::NativeUnknown } }; diff --git a/src/test/ui/bad/bad-extern-link-attrs.stderr b/src/test/ui/bad/bad-extern-link-attrs.stderr index 5baba599e741f..a77f5f9f4383f 100644 --- a/src/test/ui/bad/bad-extern-link-attrs.stderr +++ b/src/test/ui/bad/bad-extern-link-attrs.stderr @@ -11,10 +11,10 @@ LL | #[link(name = "")] | ^^^^^^^^^^^^^^^^^^ empty name given error[E0458]: unknown kind: `bar` - --> $DIR/bad-extern-link-attrs.rs:4:1 + --> $DIR/bad-extern-link-attrs.rs:4:22 | LL | #[link(name = "foo", kind = "bar")] - | ^^^^^^^^^^^^^^^^^^^^^------------^^ + | ---------------------^^^^^^^^^^^^-- | | | unknown kind diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr index 9cfe7cccac1a5..154e0b121797d 100644 --- a/src/test/ui/error-codes/E0458.stderr +++ b/src/test/ui/error-codes/E0458.stderr @@ -1,8 +1,8 @@ error[E0458]: unknown kind: `wonderful_unicorn` - --> $DIR/E0458.rs:1:1 + --> $DIR/E0458.rs:1:8 | LL | #[link(kind = "wonderful_unicorn")] extern {} - | ^^^^^^^--------------------------^^ + | -------^^^^^^^^^^^^^^^^^^^^^^^^^^-- | | | unknown kind From 18d727f0d7d89ea5529bf91c0d62aad55db7b8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 19:46:44 -0700 Subject: [PATCH 22/59] Tweak unsupported negative trait bounds message --- src/librustc_errors/diagnostic.rs | 2 +- src/libsyntax/parse/parser.rs | 21 +++++++++----- src/test/ui/issues/issue-58857.stderr | 3 +- src/test/ui/parser/issue-33418.fixed | 11 +++++-- src/test/ui/parser/issue-33418.rs | 15 ++++++---- src/test/ui/parser/issue-33418.stderr | 41 +++++++++++++-------------- 6 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 851b19e8177b5..fc1fd960c4ace 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -366,7 +366,7 @@ impl Diagnostic { }], }], msg: msg.to_owned(), - style: SuggestionStyle::HideCodeInline, + style: SuggestionStyle::HideCodeAlways, applicability, }); self diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..7a41675c814bc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5599,8 +5599,14 @@ impl<'a> Parser<'a> { if !negative_bounds.is_empty() || was_negative { let plural = negative_bounds.len() > 1; - let mut err = self.struct_span_err(negative_bounds, - "negative trait bounds are not supported"); + let last_span = negative_bounds.last().map(|sp| *sp); + let mut err = self.struct_span_err( + negative_bounds, + "negative trait bounds are not supported", + ); + if let Some(sp) = last_span { + err.span_label(sp, "negative trait bounds are not supported"); + } if let Some(bound_list) = colon_span { let bound_list = bound_list.to(self.prev_span); let mut new_bound_list = String::new(); @@ -5613,11 +5619,12 @@ impl<'a> Parser<'a> { } new_bound_list = new_bound_list.replacen(" +", ":", 1); } - err.span_suggestion_short(bound_list, - &format!("remove the trait bound{}", - if plural { "s" } else { "" }), - new_bound_list, - Applicability::MachineApplicable); + err.span_suggestion_hidden( + bound_list, + &format!("remove the trait bound{}", if plural { "s" } else { "" }), + new_bound_list, + Applicability::MachineApplicable, + ); } err.emit(); } diff --git a/src/test/ui/issues/issue-58857.stderr b/src/test/ui/issues/issue-58857.stderr index 040e9eb8a6567..56e87215a800c 100644 --- a/src/test/ui/issues/issue-58857.stderr +++ b/src/test/ui/issues/issue-58857.stderr @@ -2,7 +2,8 @@ error: negative trait bounds are not supported --> $DIR/issue-58857.rs:4:7 | LL | impl Conj{} - | ^^^^^^^^ help: remove the trait bound + | ^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: aborting due to previous error diff --git a/src/test/ui/parser/issue-33418.fixed b/src/test/ui/parser/issue-33418.fixed index df11f2d855ce0..2aaa3b5b1ea50 100644 --- a/src/test/ui/parser/issue-33418.fixed +++ b/src/test/ui/parser/issue-33418.fixed @@ -1,10 +1,15 @@ // run-rustfix -trait Tr {} //~ ERROR negative trait bounds are not supported -trait Tr2: SuperA {} //~ ERROR negative trait bounds are not supported -trait Tr3: SuperB {} //~ ERROR negative trait bounds are not supported +trait Tr {} +//~^ ERROR negative trait bounds are not supported +trait Tr2: SuperA {} +//~^ ERROR negative trait bounds are not supported +trait Tr3: SuperB {} +//~^ ERROR negative trait bounds are not supported trait Tr4: SuperB + SuperD {} +//~^ ERROR negative trait bounds are not supported trait Tr5 {} +//~^ ERROR negative trait bounds are not supported trait SuperA {} trait SuperB {} diff --git a/src/test/ui/parser/issue-33418.rs b/src/test/ui/parser/issue-33418.rs index 5bb5f2afca377..5533152092719 100644 --- a/src/test/ui/parser/issue-33418.rs +++ b/src/test/ui/parser/issue-33418.rs @@ -1,12 +1,17 @@ // run-rustfix -trait Tr: !SuperA {} //~ ERROR negative trait bounds are not supported -trait Tr2: SuperA + !SuperB {} //~ ERROR negative trait bounds are not supported -trait Tr3: !SuperA + SuperB {} //~ ERROR negative trait bounds are not supported -trait Tr4: !SuperA + SuperB //~ ERROR negative trait bounds are not supported +trait Tr: !SuperA {} +//~^ ERROR negative trait bounds are not supported +trait Tr2: SuperA + !SuperB {} +//~^ ERROR negative trait bounds are not supported +trait Tr3: !SuperA + SuperB {} +//~^ ERROR negative trait bounds are not supported +trait Tr4: !SuperA + SuperB + !SuperC + SuperD {} -trait Tr5: !SuperA //~ ERROR negative trait bounds are not supported +//~^ ERROR negative trait bounds are not supported +trait Tr5: !SuperA + !SuperB {} +//~^ ERROR negative trait bounds are not supported trait SuperA {} trait SuperB {} diff --git a/src/test/ui/parser/issue-33418.stderr b/src/test/ui/parser/issue-33418.stderr index acbe597ef31a3..660d9fd30c82e 100644 --- a/src/test/ui/parser/issue-33418.stderr +++ b/src/test/ui/parser/issue-33418.stderr @@ -2,41 +2,40 @@ error: negative trait bounds are not supported --> $DIR/issue-33418.rs:3:9 | LL | trait Tr: !SuperA {} - | ^^^^^^^^^ help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:4:19 + --> $DIR/issue-33418.rs:5:19 | LL | trait Tr2: SuperA + !SuperB {} - | ---------^^^^^^^^^ - | | - | help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:5:10 + --> $DIR/issue-33418.rs:7:10 | LL | trait Tr3: !SuperA + SuperB {} - | ^^^^^^^^^--------- - | | - | help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:6:10 + --> $DIR/issue-33418.rs:9:10 | -LL | trait Tr4: !SuperA + SuperB - | __________-^^^^^^^^ -LL | | + !SuperC + SuperD {} - | |_____^^^^^^^^^________- help: remove the trait bounds +LL | trait Tr4: !SuperA + SuperB + | ^^^^^^^^^ +LL | + !SuperC + SuperD {} + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bounds error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:8:10 + --> $DIR/issue-33418.rs:12:10 | -LL | trait Tr5: !SuperA - | __________-^^^^^^^^ -LL | | + !SuperB {} - | | ^^^^^^^^- - | |_____________| - | help: remove the trait bounds +LL | trait Tr5: !SuperA + | ^^^^^^^^^ +LL | + !SuperB {} + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bounds error: aborting due to 5 previous errors From bb15af16634424fd6fea17bd51b1513a615a6c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 20:05:01 -0700 Subject: [PATCH 23/59] Tweak unnecessary import suggestion --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/double-type-import.stderr | 6 ++---- src/test/ui/imports/duplicate.stderr | 6 ++---- src/test/ui/issues/issue-26886.stderr | 12 ++++-------- src/test/ui/issues/issue-52891.stderr | 12 ++++-------- src/test/ui/proc-macro/shadow.stderr | 14 ++++++-------- .../resolve-conflict-import-vs-import.stderr | 6 ++---- .../unresolved-extern-mod-suggestion.stderr | 6 ++---- src/test/ui/use/use-paths-as-items.stderr | 6 ++---- 9 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ac149be4b2a89..973c58a67a5d4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4932,7 +4932,7 @@ impl<'a> Resolver<'a> { Some((directive, _, true)) if should_remove_import && !directive.is_glob() => { // Simple case - remove the entire import. Due to the above match arm, this can // only be a single use so just remove it entirely. - err.span_suggestion( + err.span_suggestion_hidden( directive.use_span_with_attributes, "remove unnecessary import", String::new(), diff --git a/src/test/ui/double-type-import.stderr b/src/test/ui/double-type-import.stderr index c7288af13c278..d5e153d22ad7c 100644 --- a/src/test/ui/double-type-import.stderr +++ b/src/test/ui/double-type-import.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `X` is defined multiple times LL | pub use self::bar::X; | ------------ previous import of the type `X` here LL | use self::bar::X; - | ----^^^^^^^^^^^^- - | | | - | | `X` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^ `X` reimported here | = note: `X` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index 7c43c642ec36e..f85a265487bfd 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `foo` is defined multiple times LL | use a::foo; | ------ previous import of the value `foo` here LL | use a::foo; - | ----^^^^^^- - | | | - | | `foo` reimported here - | help: remove unnecessary import + | ^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module + = help: remove unnecessary import error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:46:15 diff --git a/src/test/ui/issues/issue-26886.stderr b/src/test/ui/issues/issue-26886.stderr index fa7f922707ab9..6002befe0d817 100644 --- a/src/test/ui/issues/issue-26886.stderr +++ b/src/test/ui/issues/issue-26886.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `Arc` is defined multiple times LL | use std::sync::{self, Arc}; | --- previous import of the type `Arc` here LL | use std::sync::Arc; - | ----^^^^^^^^^^^^^^- - | | | - | | `Arc` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^ `Arc` reimported here | = note: `Arc` must be defined only once in the type namespace of this module + = help: remove unnecessary import error[E0252]: the name `sync` is defined multiple times --> $DIR/issue-26886.rs:4:5 @@ -18,12 +16,10 @@ LL | use std::sync::{self, Arc}; | ---- previous import of the module `sync` here ... LL | use std::sync; - | ----^^^^^^^^^- - | | | - | | `sync` reimported here - | help: remove unnecessary import + | ^^^^^^^^^ `sync` reimported here | = note: `sync` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 1385693e91ae0..6068c97505767 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `a` is defined multiple times LL | use issue_52891::a; | -------------- previous import of the module `a` here LL | use issue_52891::a; - | ----^^^^^^^^^^^^^^- - | | | - | | `a` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module + = help: remove unnecessary import error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:14:19 @@ -129,15 +127,13 @@ error[E0252]: the name `n` is defined multiple times --> $DIR/issue-52891.rs:36:5 | LL | use issue_52891::n; - | ------------------- - | | | - | | previous import of the module `n` here - | help: remove unnecessary import + | -------------- previous import of the module `n` here LL | #[macro_use] LL | use issue_52891::n; | ^^^^^^^^^^^^^^ `n` reimported here | = note: `n` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to 10 previous errors diff --git a/src/test/ui/proc-macro/shadow.stderr b/src/test/ui/proc-macro/shadow.stderr index 91b73903aca29..597c05434f33b 100644 --- a/src/test/ui/proc-macro/shadow.stderr +++ b/src/test/ui/proc-macro/shadow.stderr @@ -1,16 +1,14 @@ error[E0259]: the name `derive_a` is defined multiple times --> $DIR/shadow.rs:6:1 | -LL | extern crate derive_a; - | ---------------------- previous import of the extern crate `derive_a` here -LL | / #[macro_use] -LL | | extern crate derive_a; - | | ^^^^^^^^^^^^^^^^^^^^^- - | |_|____________________| - | | help: remove unnecessary import - | `derive_a` reimported here +LL | extern crate derive_a; + | ---------------------- previous import of the extern crate `derive_a` here +LL | #[macro_use] +LL | extern crate derive_a; + | ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here | = note: `derive_a` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr index 1b4b058b783ad..34f18feb9dcd0 100644 --- a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr +++ b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `transmute` is defined multiple times LL | use std::mem::transmute; | ------------------- previous import of the value `transmute` here LL | use std::mem::transmute; - | ----^^^^^^^^^^^^^^^^^^^- - | | | - | | `transmute` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here | = note: `transmute` must be defined only once in the value namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr index e8679a3726d30..cfae699b6edc3 100644 --- a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr +++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr @@ -4,12 +4,10 @@ error[E0254]: the name `core` is defined multiple times LL | extern crate core; | ------------------ previous import of the extern crate `core` here LL | use core; - | ----^^^^- - | | | - | | `core` reimported here - | help: remove unnecessary import + | ^^^^ `core` reimported here | = note: `core` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/use/use-paths-as-items.stderr b/src/test/ui/use/use-paths-as-items.stderr index 334e145098be0..43ebbf157c3c2 100644 --- a/src/test/ui/use/use-paths-as-items.stderr +++ b/src/test/ui/use/use-paths-as-items.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `mem` is defined multiple times LL | use std::{mem, ptr}; | --- previous import of the module `mem` here LL | use std::mem; - | ----^^^^^^^^- - | | | - | | `mem` reimported here - | help: remove unnecessary import + | ^^^^^^^^ `mem` reimported here | = note: `mem` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error From b616ccae5ff718d71c242d3ac9c50ccae07c855f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 22:25:23 -0700 Subject: [PATCH 24/59] Hide obvious suggestion from cli output --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/error-codes/E0430.stderr | 6 ++---- .../ui/issues/issue-45829/import-twice.stderr | 6 ++---- src/test/ui/issues/issue-52891.stderr | 18 +++++------------- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 973c58a67a5d4..4c5b9e3675b47 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -5112,7 +5112,7 @@ impl<'a> Resolver<'a> { // extra for the comma. span.lo().0 - (prev_comma.as_bytes().len() as u32) - 1 )); - err.span_suggestion( + err.tool_only_span_suggestion( span, message, String::new(), Applicability::MaybeIncorrect, ); return; diff --git a/src/test/ui/error-codes/E0430.stderr b/src/test/ui/error-codes/E0430.stderr index 9f8b053de2cac..d8e4a802959a0 100644 --- a/src/test/ui/error-codes/E0430.stderr +++ b/src/test/ui/error-codes/E0430.stderr @@ -10,10 +10,8 @@ error[E0252]: the name `fmt` is defined multiple times --> $DIR/E0430.rs:1:22 | LL | use std::fmt::{self, self}; - | ------^^^^ - | | | | - | | | `fmt` reimported here - | | help: remove unnecessary import + | ---- ^^^^ `fmt` reimported here + | | | previous import of the module `fmt` here | = note: `fmt` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issues/issue-45829/import-twice.stderr b/src/test/ui/issues/issue-45829/import-twice.stderr index 2a1ac57651138..656b011bc3be8 100644 --- a/src/test/ui/issues/issue-45829/import-twice.stderr +++ b/src/test/ui/issues/issue-45829/import-twice.stderr @@ -2,10 +2,8 @@ error[E0252]: the name `A` is defined multiple times --> $DIR/import-twice.rs:6:14 | LL | use foo::{A, A}; - | ---^ - | || | - | || `A` reimported here - | |help: remove unnecessary import + | - ^ `A` reimported here + | | | previous import of the type `A` here | = note: `A` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 6068c97505767..895e3a77946ef 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -44,10 +44,7 @@ LL | use issue_52891::a; | -------------- previous import of the module `a` here ... LL | use issue_52891::{f, g, a}; - | --^ - | | | - | | `a` reimported here - | help: remove unnecessary import + | ^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module @@ -82,16 +79,11 @@ LL | a, error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:26:5 | -LL | use issue_52891::a; - | -------------- previous import of the module `a` here +LL | use issue_52891::a; + | -------------- previous import of the module `a` here ... -LL | m, - | ______- -LL | | a}; - | | ^ - | | | - | |_____`a` reimported here - | help: remove unnecessary import +LL | a}; + | ^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module From 743d0197bf8ad8d452e836ed87257c214609cd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 11 Mar 2019 09:43:05 -0700 Subject: [PATCH 25/59] Deduplicate const eval error spans for better output --- src/librustc/mir/interpret/error.rs | 4 +++- .../ui/consts/const-eval/promoted_errors.stderr | 8 ++------ src/test/ui/consts/dangling-alloc-id-ice.stderr | 16 +++++----------- src/test/ui/consts/dangling_raw_ptr.stderr | 16 +++++----------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 5cd1ced20220a..fc04c7672db68 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -116,7 +116,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { // point to the `const` statement as a secondary span // they don't have any label for sp in primary_spans { - lint.span_label(sp, ""); + if sp != span { + lint.span_label(sp, ""); + } } } lint.emit(); diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index ca870c649f5b2..c9d5ede61ade4 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -50,15 +50,11 @@ warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); - | ^^^^^^^^^^^^^^^^ - | | - | attempt to divide by zero + | ^^^^^^^^^^^^^^^^ attempt to divide by zero warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); - | ^^^^^^^ - | | - | attempt to divide by zero + | ^^^^^^^ attempt to divide by zero diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index ba640b90e7d79..87f84480bf66b 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,17 +1,11 @@ error: any use of this value will cause an error --> $DIR/dangling-alloc-id-ice.rs:8:1 | -LL | const FOO: &() = { - | _^ - | |_| - | || -LL | || let y = (); -LL | || unsafe { Foo { y: &y }.long_live_the_unit } -LL | || }; - | || ^ - | ||__| - | |___type validation failed: encountered dangling pointer in final constant - | +LL | / const FOO: &() = { +LL | | let y = (); +LL | | unsafe { Foo { y: &y }.long_live_the_unit } +LL | | }; + | |__^ type validation failed: encountered dangling pointer in final constant | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index cedcbf819e2d8..0168c08f011d4 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,17 +1,11 @@ error: any use of this value will cause an error --> $DIR/dangling_raw_ptr.rs:1:1 | -LL | const FOO: *const u32 = { - | _^ - | |_| - | || -LL | || let x = 42; -LL | || &x -LL | || }; - | || ^ - | ||__| - | |___type validation failed: encountered dangling pointer in final constant - | +LL | / const FOO: *const u32 = { +LL | | let x = 42; +LL | | &x +LL | | }; + | |__^ type validation failed: encountered dangling pointer in final constant | = note: #[deny(const_err)] on by default From b53ca900db381c72b1fb7eeb7289167b78076603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 11 Mar 2019 09:50:50 -0700 Subject: [PATCH 26/59] Mark duplicate import removal suggestion tool only --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/double-type-import.stderr | 1 - src/test/ui/imports/duplicate.stderr | 1 - src/test/ui/issues/issue-26886.stderr | 2 -- src/test/ui/issues/issue-52891.stderr | 2 -- src/test/ui/proc-macro/shadow.stderr | 1 - src/test/ui/resolve/resolve-conflict-import-vs-import.stderr | 1 - src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr | 1 - src/test/ui/use/use-paths-as-items.stderr | 1 - 9 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 4c5b9e3675b47..38ca5f0b6640a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4932,7 +4932,7 @@ impl<'a> Resolver<'a> { Some((directive, _, true)) if should_remove_import && !directive.is_glob() => { // Simple case - remove the entire import. Due to the above match arm, this can // only be a single use so just remove it entirely. - err.span_suggestion_hidden( + err.tool_only_span_suggestion( directive.use_span_with_attributes, "remove unnecessary import", String::new(), diff --git a/src/test/ui/double-type-import.stderr b/src/test/ui/double-type-import.stderr index d5e153d22ad7c..a2f30d82ec38b 100644 --- a/src/test/ui/double-type-import.stderr +++ b/src/test/ui/double-type-import.stderr @@ -7,7 +7,6 @@ LL | use self::bar::X; | ^^^^^^^^^^^^ `X` reimported here | = note: `X` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index f85a265487bfd..cc897b2b6b7e9 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -7,7 +7,6 @@ LL | use a::foo; | ^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module - = help: remove unnecessary import error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:46:15 diff --git a/src/test/ui/issues/issue-26886.stderr b/src/test/ui/issues/issue-26886.stderr index 6002befe0d817..e2b925ec5a705 100644 --- a/src/test/ui/issues/issue-26886.stderr +++ b/src/test/ui/issues/issue-26886.stderr @@ -7,7 +7,6 @@ LL | use std::sync::Arc; | ^^^^^^^^^^^^^^ `Arc` reimported here | = note: `Arc` must be defined only once in the type namespace of this module - = help: remove unnecessary import error[E0252]: the name `sync` is defined multiple times --> $DIR/issue-26886.rs:4:5 @@ -19,7 +18,6 @@ LL | use std::sync; | ^^^^^^^^^ `sync` reimported here | = note: `sync` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 895e3a77946ef..9173c02bcd866 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -7,7 +7,6 @@ LL | use issue_52891::a; | ^^^^^^^^^^^^^^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module - = help: remove unnecessary import error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:14:19 @@ -125,7 +124,6 @@ LL | use issue_52891::n; | ^^^^^^^^^^^^^^ `n` reimported here | = note: `n` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to 10 previous errors diff --git a/src/test/ui/proc-macro/shadow.stderr b/src/test/ui/proc-macro/shadow.stderr index 597c05434f33b..08057e163496d 100644 --- a/src/test/ui/proc-macro/shadow.stderr +++ b/src/test/ui/proc-macro/shadow.stderr @@ -8,7 +8,6 @@ LL | extern crate derive_a; | ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here | = note: `derive_a` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr index 34f18feb9dcd0..8df68ad3229ed 100644 --- a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr +++ b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr @@ -7,7 +7,6 @@ LL | use std::mem::transmute; | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here | = note: `transmute` must be defined only once in the value namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr index cfae699b6edc3..28333228a29ba 100644 --- a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr +++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr @@ -7,7 +7,6 @@ LL | use core; | ^^^^ `core` reimported here | = note: `core` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/use/use-paths-as-items.stderr b/src/test/ui/use/use-paths-as-items.stderr index 43ebbf157c3c2..b09001a9bcd45 100644 --- a/src/test/ui/use/use-paths-as-items.stderr +++ b/src/test/ui/use/use-paths-as-items.stderr @@ -7,7 +7,6 @@ LL | use std::mem; | ^^^^^^^^ `mem` reimported here | = note: `mem` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error From d1656f1e0dc7288a87ee44e706552db8db7a9eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 16 Mar 2019 18:36:47 -0700 Subject: [PATCH 27/59] Fix rebase --- src/librustc_metadata/native_libs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 87dca77be50ca..04afe56f1d6aa 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -74,7 +74,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { "dylib" => cstore::NativeUnknown, "framework" => cstore::NativeFramework, k => { - struct_span_err!(self.tcx.sess, item.span, E0458, + struct_span_err!(self.tcx.sess, item.span(), E0458, "unknown kind: `{}`", k) .span_label(item.span(), "unknown kind") .span_label(m.span, "").emit(); From 6007e6f649feac9a0cb39270444033f8dbfa9259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Mar 2019 20:09:53 -0700 Subject: [PATCH 28/59] Do not complain about non-existing fields after parse recovery When failing to parse struct-like enum variants, the ADT gets recorded as having no fields. Record that we have actually recovered during parsing of this variant to avoid complaing about non-existing fields when actually using it. --- src/librustc/hir/lowering.rs | 3 +- src/librustc/hir/mod.rs | 4 +-- src/librustc/ty/mod.rs | 28 +++++++++++-------- src/librustc_metadata/decoder.rs | 3 +- src/librustc_save_analysis/dump_visitor.rs | 6 ++-- src/librustc_save_analysis/sig.rs | 18 +++++++----- src/librustc_typeck/check/_match.rs | 20 +++++++------ src/librustc_typeck/check/mod.rs | 17 +++++++---- src/librustc_typeck/collect.rs | 7 ++++- src/libsyntax/ast.rs | 6 ++-- src/libsyntax/config.rs | 2 +- src/libsyntax/mut_visit.rs | 2 +- src/libsyntax/parse/parser.rs | 28 ++++++++++++------- .../ui/parser/recovered-struct-variant.rs | 13 +++++++++ .../ui/parser/recovered-struct-variant.stderr | 8 ++++++ 15 files changed, 108 insertions(+), 57 deletions(-) create mode 100644 src/test/ui/parser/recovered-struct-variant.rs create mode 100644 src/test/ui/parser/recovered-struct-variant.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 949fdd2682b96..73c3b3026d98b 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2672,7 +2672,7 @@ impl<'a> LoweringContext<'a> { fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData { match *vdata { - VariantData::Struct(ref fields, id) => { + VariantData::Struct(ref fields, id, recovered) => { let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id); hir::VariantData::Struct( @@ -2682,6 +2682,7 @@ impl<'a> LoweringContext<'a> { .map(|f| self.lower_struct_field(f)) .collect(), hir_id, + recovered, ) }, VariantData::Tuple(ref fields, id) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 88ab58d10fc34..785d7745b297b 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2173,7 +2173,7 @@ impl StructField { /// Id of the whole struct lives in `Item`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum VariantData { - Struct(HirVec, HirId), + Struct(HirVec, HirId, bool), Tuple(HirVec, HirId), Unit(HirId), } @@ -2187,7 +2187,7 @@ impl VariantData { } pub fn hir_id(&self) -> HirId { match *self { - VariantData::Struct(_, hir_id) + VariantData::Struct(_, hir_id, _) | VariantData::Tuple(_, hir_id) | VariantData::Unit(hir_id) => hir_id, } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 882e2dc62b1c3..47dbed914ddc3 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1811,6 +1811,7 @@ pub struct VariantDef { pub fields: Vec, pub ctor_kind: CtorKind, flags: VariantFlags, + pub recovered: bool, } impl<'a, 'gcx, 'tcx> VariantDef { @@ -1829,16 +1830,17 @@ impl<'a, 'gcx, 'tcx> VariantDef { /// /// If someone speeds up attribute loading to not be a performance concern, they can /// remove this hack and use the constructor `DefId` everywhere. - pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, - did: DefId, - ident: Ident, - discr: VariantDiscr, - fields: Vec, - adt_kind: AdtKind, - ctor_kind: CtorKind, - attribute_def_id: DefId) - -> Self - { + pub fn new( + tcx: TyCtxt<'a, 'gcx, 'tcx>, + did: DefId, + ident: Ident, + discr: VariantDiscr, + fields: Vec, + adt_kind: AdtKind, + ctor_kind: CtorKind, + attribute_def_id: DefId, + recovered: bool, + ) -> Self { debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, ident, discr, fields, adt_kind, ctor_kind, attribute_def_id); let mut flags = VariantFlags::NO_VARIANT_FLAGS; @@ -1852,7 +1854,8 @@ impl<'a, 'gcx, 'tcx> VariantDef { discr, fields, ctor_kind, - flags + flags, + recovered, } } @@ -1868,7 +1871,8 @@ impl_stable_hash_for!(struct VariantDef { discr, fields, ctor_kind, - flags + flags, + recovered }); #[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)] diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 6fe00a4ad2ff2..c608c03095aa3 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -576,7 +576,8 @@ impl<'a, 'tcx> CrateMetadata { }).collect(), adt_kind, data.ctor_kind, - attribute_def_id + attribute_def_id, + false, ) } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 3fea515ae401e..01bb643c1d587 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -481,8 +481,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { }; let (value, fields) = match item.node { - ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, _), _) | - ast::ItemKind::Union(ast::VariantData::Struct(ref fields, _), _) => { + ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, ..), _) | + ast::ItemKind::Union(ast::VariantData::Struct(ref fields, ..), _) => { let include_priv_fields = !self.save_ctxt.config.pub_only; let fields_str = fields .iter() @@ -560,7 +560,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let name_span = variant.node.ident.span; match variant.node.data { - ast::VariantData::Struct(ref fields, _) => { + ast::VariantData::Struct(ref fields, ..) => { let fields_str = fields .iter() .enumerate() diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 64a2c92d04dbd..6e47ae6b15984 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -703,7 +703,7 @@ impl Sig for ast::Variant_ { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let mut text = self.ident.to_string(); match self.data { - ast::VariantData::Struct(ref fields, id) => { + ast::VariantData::Struct(ref fields, id, r) => { let name_def = SigElement { id: id_from_node_id(id, scx), start: offset, @@ -712,12 +712,16 @@ impl Sig for ast::Variant_ { text.push_str(" { "); let mut defs = vec![name_def]; let mut refs = vec![]; - for f in fields { - let field_sig = f.make(offset + text.len(), Some(id), scx)?; - text.push_str(&field_sig.text); - text.push_str(", "); - defs.extend(field_sig.defs.into_iter()); - refs.extend(field_sig.refs.into_iter()); + if r { + text.push_str("/* parse error */ "); + } else { + for f in fields { + let field_sig = f.make(offset + text.len(), Some(id), scx)?; + text.push_str(&field_sig.text); + text.push_str(", "); + defs.extend(field_sig.defs.into_iter()); + refs.extend(field_sig.refs.into_iter()); + } } text.push('}'); Ok(Signature { text, defs, refs }) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c6b66393dd2f1..c30b9d65fec83 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -918,14 +918,16 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); pat_ty } - fn check_struct_pat_fields(&self, - adt_ty: Ty<'tcx>, - pat_id: hir::HirId, - span: Span, - variant: &'tcx ty::VariantDef, - fields: &'gcx [Spanned], - etc: bool, - def_bm: ty::BindingMode) -> bool { + fn check_struct_pat_fields( + &self, + adt_ty: Ty<'tcx>, + pat_id: hir::HirId, + span: Span, + variant: &'tcx ty::VariantDef, + fields: &'gcx [Spanned], + etc: bool, + def_bm: ty::BindingMode, + ) -> bool { let tcx = self.tcx; let (substs, adt) = match adt_ty.sty { @@ -985,7 +987,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); .map(|field| field.ident.modern()) .filter(|ident| !used_fields.contains_key(&ident)) .collect::>(); - if inexistent_fields.len() > 0 { + if inexistent_fields.len() > 0 && !variant.recovered { let (field_names, t, plural) = if inexistent_fields.len() == 1 { (format!("a field named `{}`", inexistent_fields[0].1), "this", "") } else { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fa4bb02189f20..e38a575c560e3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3689,12 +3689,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { field, expr_t) } - fn report_unknown_field(&self, - ty: Ty<'tcx>, - variant: &'tcx ty::VariantDef, - field: &hir::Field, - skip_fields: &[hir::Field], - kind_name: &str) { + fn report_unknown_field( + &self, + ty: Ty<'tcx>, + variant: &'tcx ty::VariantDef, + field: &hir::Field, + skip_fields: &[hir::Field], + kind_name: &str, + ) { + if variant.recovered { + return; + } let mut err = self.type_error_struct_with_diag( field.ident.span, |actual| match ty.sty { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 10e9613bf21a2..c0739db3df6a2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -598,6 +598,10 @@ fn convert_variant<'a, 'tcx>( } }) .collect(); + let recovered = match def { + hir::VariantData::Struct(_, _, r) => *r, + _ => false, + }; ty::VariantDef::new(tcx, did, ident, @@ -605,7 +609,8 @@ fn convert_variant<'a, 'tcx>( fields, adt_kind, CtorKind::from_hir(def), - attribute_def_id + attribute_def_id, + recovered, ) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1a0da73880cfc..5da00ef8ebee2 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2133,7 +2133,7 @@ pub enum VariantData { /// Struct variant. /// /// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`. - Struct(Vec, NodeId), + Struct(Vec, NodeId, bool), /// Tuple variant. /// /// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`. @@ -2147,13 +2147,13 @@ pub enum VariantData { impl VariantData { pub fn fields(&self) -> &[StructField] { match *self { - VariantData::Struct(ref fields, _) | VariantData::Tuple(ref fields, _) => fields, + VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, _) => fields, _ => &[], } } pub fn id(&self) -> NodeId { match *self { - VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, + VariantData::Struct(_, id, _) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, } } pub fn is_struct(&self) -> bool { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index c300ffc2d61b9..7159c949513ac 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -225,7 +225,7 @@ impl<'a> StripUnconfigured<'a> { fn configure_variant_data(&mut self, vdata: &mut ast::VariantData) { match vdata { - ast::VariantData::Struct(fields, _id) | + ast::VariantData::Struct(fields, _id, _) | ast::VariantData::Tuple(fields, _id) => fields.flat_map_in_place(|field| self.configure(field)), ast::VariantData::Unit(_id) => {} diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 462346df7d76d..5bb1d8a4b9476 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -765,7 +765,7 @@ pub fn noop_visit_where_predicate(pred: &mut WherePredicate, vis: pub fn noop_visit_variant_data(vdata: &mut VariantData, vis: &mut T) { match vdata { - VariantData::Struct(fields, id) | + VariantData::Struct(fields, id, _) | VariantData::Tuple(fields, id) => { visit_vec(fields, |field| vis.visit_struct_field(field)); vis.visit_id(id); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..360a101a64faf 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6829,14 +6829,16 @@ impl<'a> Parser<'a> { VariantData::Unit(ast::DUMMY_NODE_ID) } else { // If we see: `struct Foo where T: Copy { ... }` - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } // No `where` so: `struct Foo;` } else if self.eat(&token::Semi) { VariantData::Unit(ast::DUMMY_NODE_ID) // Record-style struct definition } else if self.token == token::OpenDelim(token::Brace) { - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) // Tuple-style struct definition with optional where-clause. } else if self.token == token::OpenDelim(token::Paren) { let body = VariantData::Tuple(self.parse_tuple_struct_body()?, ast::DUMMY_NODE_ID); @@ -6864,9 +6866,11 @@ impl<'a> Parser<'a> { let vdata = if self.token.is_keyword(keywords::Where) { generics.where_clause = self.parse_where_clause()?; - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } else if self.token == token::OpenDelim(token::Brace) { - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } else { let token_str = self.this_token_descr(); let mut err = self.fatal(&format!( @@ -6898,12 +6902,14 @@ impl<'a> Parser<'a> { } } - fn parse_record_struct_body(&mut self) -> PResult<'a, Vec> { + fn parse_record_struct_body(&mut self) -> PResult<'a, (Vec, bool)> { let mut fields = Vec::new(); + let mut recovered = false; if self.eat(&token::OpenDelim(token::Brace)) { while self.token != token::CloseDelim(token::Brace) { let field = self.parse_struct_decl_field().map_err(|e| { self.recover_stmt(); + recovered = true; e }); match field { @@ -6922,7 +6928,7 @@ impl<'a> Parser<'a> { return Err(err); } - Ok(fields) + Ok((fields, recovered)) } fn parse_tuple_struct_body(&mut self) -> PResult<'a, Vec> { @@ -7684,12 +7690,14 @@ impl<'a> Parser<'a> { if self.check(&token::OpenDelim(token::Brace)) { // Parse a struct variant. all_nullary = false; - struct_def = VariantData::Struct(self.parse_record_struct_body()?, - ast::DUMMY_NODE_ID); + let (fields, recovered) = self.parse_record_struct_body()?; + struct_def = VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered); } else if self.check(&token::OpenDelim(token::Paren)) { all_nullary = false; - struct_def = VariantData::Tuple(self.parse_tuple_struct_body()?, - ast::DUMMY_NODE_ID); + struct_def = VariantData::Tuple( + self.parse_tuple_struct_body()?, + ast::DUMMY_NODE_ID, + ); } else if self.eat(&token::Eq) { disr_expr = Some(AnonConst { id: ast::DUMMY_NODE_ID, diff --git a/src/test/ui/parser/recovered-struct-variant.rs b/src/test/ui/parser/recovered-struct-variant.rs new file mode 100644 index 0000000000000..5b195dcc37878 --- /dev/null +++ b/src/test/ui/parser/recovered-struct-variant.rs @@ -0,0 +1,13 @@ +enum Foo { + A { a, b: usize } + //~^ ERROR expected `:`, found `,` +} + +fn main() { + // no complaints about non-existing fields + let f = Foo::A { a:3, b: 4}; + match f { + // no complaints about non-existing fields + Foo::A {a, b} => {} + } +} diff --git a/src/test/ui/parser/recovered-struct-variant.stderr b/src/test/ui/parser/recovered-struct-variant.stderr new file mode 100644 index 0000000000000..51aaf8bb3cfbe --- /dev/null +++ b/src/test/ui/parser/recovered-struct-variant.stderr @@ -0,0 +1,8 @@ +error: expected `:`, found `,` + --> $DIR/recovered-struct-variant.rs:2:10 + | +LL | A { a, b: usize } + | ^ expected `:` + +error: aborting due to previous error + From bb832c2560c8d2c6d1a47d9a9bb0eed518f0b3ad Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Mon, 18 Mar 2019 09:02:57 +0100 Subject: [PATCH 29/59] some small HIR doc improvements --- src/librustc/hir/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 88ab58d10fc34..8941158e561d1 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -816,6 +816,9 @@ pub struct MacroDef { pub legacy: bool, } +/// A block of statements `{ .. }`, which may have a label (in this case the +/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of +/// the `rules` being anything but `DefaultBlock`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Block { /// Statements in a block. @@ -1178,6 +1181,7 @@ impl fmt::Debug for Stmt { } } +/// The contents of a statement. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum StmtKind { /// A local (`let`) binding. @@ -1208,21 +1212,28 @@ impl StmtKind { #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Local { pub pat: P, + /// Type annotation, if any (otherwise the type will be inferred). pub ty: Option>, /// Initializer expression to set the value, if any. pub init: Option>, pub hir_id: HirId, pub span: Span, pub attrs: ThinVec, + /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop + /// desugaring. Otherwise will be `Normal`. pub source: LocalSource, } -/// Represents a single arm of a `match` expression. +/// Represents a single arm of a `match` expression, e.g. +/// ` (if ) => `. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Arm { pub attrs: HirVec, + /// Multiple patterns can be combined with `|` pub pats: HirVec>, + /// Optional guard clause. pub guard: Option, + /// The action to take if this arm matches. pub body: P, } From ec6f983e243ed7988be4eebd356181be7b1f5525 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:37:02 +0000 Subject: [PATCH 30/59] Rename typarams to param_names Co-Authored-By: Gabriel Smith --- src/librustc/hir/print.rs | 4 ++-- src/librustdoc/clean/auto_trait.rs | 8 ++++---- src/librustdoc/clean/mod.rs | 32 +++++++++++++++--------------- src/librustdoc/html/format.rs | 20 +++++++++---------- src/librustdoc/html/render.rs | 6 +++--- src/libsyntax/print/pprust.rs | 4 ++-- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 54a21f2ed5c2a..bff4190ae7925 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -591,12 +591,12 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemKind::Fn(ref decl, header, ref typarams, body) => { + hir::ItemKind::Fn(ref decl, header, ref param_names, body) => { self.head("")?; self.print_fn(decl, header, Some(item.ident.name), - typarams, + param_names, &item.vis, &[], Some(body))?; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 20fa6009b310b..23b5794fb1eef 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -435,7 +435,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { let new_ty = match &poly_trait.trait_ { &Type::ResolvedPath { ref path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -469,7 +469,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { Type::ResolvedPath { path: new_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, } @@ -669,7 +669,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { match **trait_ { Type::ResolvedPath { path: ref trait_path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -724,7 +724,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { PolyTrait { trait_: Type::ResolvedPath { path: new_trait_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, }, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c51c8027de64e..6739873c6044f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1176,7 +1176,7 @@ impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did: trait_ref.def_id, is_generic: false, }, @@ -2244,7 +2244,7 @@ pub enum Type { /// Structs/enums/traits (most that'd be an `hir::TyKind::Path`). ResolvedPath { path: Path, - typarams: Option>, + param_names: Option>, did: DefId, /// `true` if is a `T::Name` path for associated types. is_generic: bool, @@ -2706,7 +2706,7 @@ impl Clean for hir::Ty { } TyKind::TraitObject(ref bounds, ref lifetime) => { match bounds[0].clean(cx).trait_ { - ResolvedPath { path, typarams: None, did, is_generic } => { + ResolvedPath { path, param_names: None, did, is_generic } => { let mut bounds: Vec = bounds[1..].iter().map(|bound| { self::GenericBound::TraitBound(bound.clean(cx), hir::TraitBoundModifier::None) @@ -2714,7 +2714,7 @@ impl Clean for hir::Ty { if !lifetime.is_elided() { bounds.push(self::GenericBound::Outlives(lifetime.clean(cx))); } - ResolvedPath { path, typarams: Some(bounds), did, is_generic, } + ResolvedPath { path, param_names: Some(bounds), did, is_generic, } } _ => Infer // shouldn't happen } @@ -2781,7 +2781,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], substs); ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, } @@ -2792,7 +2792,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], InternalSubsts::empty()); ResolvedPath { path: path, - typarams: None, + param_names: None, did: did, is_generic: false, } @@ -2813,8 +2813,8 @@ impl<'tcx> Clean for Ty<'tcx> { inline::record_extern_fqn(cx, did, TypeKind::Trait); - let mut typarams = vec![]; - reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); + let mut param_names = vec![]; + reg.clean(cx).map(|b| param_names.push(GenericBound::Outlives(b))); for did in dids { let empty = cx.tcx.intern_substs(&[]); let path = external_path(cx, &cx.tcx.item_name(did).as_str(), @@ -2823,13 +2823,13 @@ impl<'tcx> Clean for Ty<'tcx> { let bound = GenericBound::TraitBound(PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, }, generic_params: Vec::new(), }, hir::TraitBoundModifier::None); - typarams.push(bound); + param_names.push(bound); } let mut bindings = vec![]; @@ -2844,7 +2844,7 @@ impl<'tcx> Clean for Ty<'tcx> { false, bindings, substs); ResolvedPath { path, - typarams: Some(typarams), + param_names: Some(param_names), did, is_generic: false, } @@ -3294,8 +3294,8 @@ impl Clean for hir::PathSegment { fn strip_type(ty: Type) -> Type { match ty { - Type::ResolvedPath { path, typarams, did, is_generic } => { - Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic } + Type::ResolvedPath { path, param_names, did, is_generic } => { + Type::ResolvedPath { path: strip_path(&path), param_names, did, is_generic } } Type::Tuple(inner_tys) => { Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect()) @@ -3955,7 +3955,7 @@ fn resolve_type(cx: &DocContext<'_>, _ => false, }; let did = register_def(&*cx, path.def); - ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic } + ResolvedPath { path: path, param_names: None, did: did, is_generic: is_generic } } pub fn register_def(cx: &DocContext<'_>, def: Def) -> DefId { @@ -4381,9 +4381,9 @@ impl From for SimpleBound { match bound.clone() { GenericBound::Outlives(l) => SimpleBound::Outlives(l), GenericBound::TraitBound(t, mod_) => match t.trait_ { - Type::ResolvedPath { path, typarams, .. } => { + Type::ResolvedPath { path, param_names, .. } => { SimpleBound::TraitBound(path.segments, - typarams + param_names .map_or_else(|| Vec::new(), |v| v.iter() .map(|p| SimpleBound::from(p.clone())) .collect()), diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d204a179ca62c..36257914d192f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -521,8 +521,8 @@ fn primitive_link(f: &mut fmt::Formatter<'_>, /// Helper to render type parameters fn tybounds(w: &mut fmt::Formatter<'_>, - typarams: &Option>) -> fmt::Result { - match *typarams { + param_names: &Option>) -> fmt::Result { + match *param_names { Some(ref params) => { for param in params { write!(w, " + ")?; @@ -559,13 +559,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> clean::Generic(ref name) => { f.write_str(name) } - clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => { - if typarams.is_some() { + clean::ResolvedPath{ did, ref param_names, ref path, is_generic } => { + if param_names.is_some() { f.write_str("dyn ")?; } // Paths like T::Output and Self::Output should be rendered with all segments resolved_path(f, did, path, is_generic, use_absolute)?; - tybounds(f, typarams) + tybounds(f, param_names) } clean::Infer => write!(f, "_"), clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()), @@ -663,7 +663,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> } } } - clean::ResolvedPath { typarams: Some(ref v), .. } if !v.is_empty() => { + clean::ResolvedPath { param_names: Some(ref v), .. } if !v.is_empty() => { write!(f, "{}{}{}(", amp, lt, m)?; fmt_type(&ty, f, use_absolute)?; write!(f, ")") @@ -717,7 +717,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> // the ugliness comes from inlining across crates where // everything comes in as a fully resolved QPath (hard to // look at). - box clean::ResolvedPath { did, ref typarams, .. } => { + box clean::ResolvedPath { did, ref param_names, .. } => { match href(did) { Some((ref url, _, ref path)) if !f.alternate() => { write!(f, @@ -731,8 +731,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> _ => write!(f, "{}", name)?, } - // FIXME: `typarams` are not rendered, and this seems bad? - drop(typarams); + // FIXME: `param_names` are not rendered, and this seems bad? + drop(param_names); Ok(()) } _ => { @@ -771,7 +771,7 @@ fn fmt_impl(i: &clean::Impl, fmt::Display::fmt(ty, f)?; } else { match *ty { - clean::ResolvedPath { typarams: None, ref path, is_generic: false, .. } => { + clean::ResolvedPath { param_names: None, ref path, is_generic: false, .. } => { let last = path.segments.last().unwrap(); fmt::Display::fmt(&last.name, f)?; fmt::Display::fmt(&last.args, f)?; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b3a816d17f56c..b1c4a8fc1afbe 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -271,7 +271,7 @@ pub struct Cache { /// Mapping of typaram ids to the name of the type parameter. This is used /// when pretty-printing a type (so pretty-printing doesn't have to /// painfully maintain a context like this) - pub typarams: FxHashMap, + pub param_names: FxHashMap, /// Maps a type ID to all known implementations for that type. This is only /// recognized for intra-crate `ResolvedPath` types, and is used to print @@ -635,7 +635,7 @@ pub fn run(mut krate: clean::Crate, deref_mut_trait_did, owned_box_did, masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), - typarams: external_typarams, + param_names: external_param_names, aliases: Default::default(), }; @@ -1751,7 +1751,7 @@ impl<'a> Cache { clean::GenericParamDefKind::Lifetime => {} clean::GenericParamDefKind::Type { did, .. } | clean::GenericParamDefKind::Const { did, .. } => { - self.typarams.insert(did, param.name.clone()); + self.param_names.insert(did, param.name.clone()); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e04e127ccf15a..07df14ddc722c 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1263,13 +1263,13 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref typarams, ref body) => { + ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { self.head("")?; self.print_fn( decl, header, Some(item.ident), - typarams, + param_names, &item.vis )?; self.s.word(" ")?; From c915fe0245c7506e3f15660dee2d597fb48e9230 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:37:43 +0000 Subject: [PATCH 31/59] Rename external_typarams to external_param_names Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/html/render.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6739873c6044f..5a22614fc71c6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1045,7 +1045,7 @@ impl GenericBound { GenericBound::TraitBound(PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, }, @@ -1469,7 +1469,7 @@ impl<'tcx> Clean for ty::GenericParamDef { (self.name.to_string(), GenericParamDefKind::Lifetime) } ty::GenericParamDefKind::Type { has_default, .. } => { - cx.renderinfo.borrow_mut().external_typarams + cx.renderinfo.borrow_mut().external_param_names .insert(self.def_id, self.name.clean(cx)); let default = if has_default { Some(cx.tcx.type_of(self.def_id).clean(cx)) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b1c4a8fc1afbe..ed46ac0b62d30 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -368,7 +368,7 @@ pub struct Cache { pub struct RenderInfo { pub inlined: FxHashSet, pub external_paths: crate::core::ExternalPaths, - pub external_typarams: FxHashMap, + pub external_param_names: FxHashMap, pub exact_paths: FxHashMap>, pub access_levels: AccessLevels, pub deref_trait_did: Option, @@ -601,7 +601,7 @@ pub fn run(mut krate: clean::Crate, let RenderInfo { inlined: _, external_paths, - external_typarams, + external_param_names, exact_paths, access_levels, deref_trait_did, From 14913159e0509a2b7d1c86984a044b76dd4e4902 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:38:33 +0000 Subject: [PATCH 32/59] Implement `Clean` for const generics Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 19 +++++++++++++++++++ src/librustdoc/html/format.rs | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5a22614fc71c6..0f976c11938c0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2921,6 +2921,25 @@ impl<'tcx> Clean for Ty<'tcx> { } } +impl<'tcx> Clean for ty::LazyConst<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + if let ty::LazyConst::Evaluated(ct) = self { + ct.clean(cx) + } else { + unimplemented!() // FIXME(const_generics) + } + } +} + +impl<'tcx> Clean for ty::Const<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + Constant { + type_: self.ty.clean(cx), + expr: format!("{:?}", self.val), // FIXME(const_generics) + } + } +} + impl Clean for hir::StructField { fn clean(&self, cx: &DocContext<'_>) -> Item { let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 36257914d192f..2cba3c58889ab 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -259,6 +259,12 @@ impl fmt::Display for clean::Lifetime { } } +impl fmt::Display for clean::Constant { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}: {}", self.expr, self.type_) + } +} + impl fmt::Display for clean::PolyTrait { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if !self.generic_params.is_empty() { From 29ed491743df4dbab25fec6f725e6f3b3ace860b Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:39:03 +0000 Subject: [PATCH 33/59] Add `GenericArg` Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0f976c11938c0..8581c40c843e8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3247,6 +3247,23 @@ impl Clean for hir::Path { } } +#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] +pub enum GenericArg { + Lifetime(Lifetime), + Type(Type), + Const(Constant), +} + +impl fmt::Display for GenericArg { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GenericArg::Lifetime(lt) => lt.fmt(f), + GenericArg::Type(ty) => ty.fmt(f), + GenericArg::Const(ct) => ct.fmt(f), + } + } +} + #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum GenericArgs { AngleBracketed { From cd9a2c0b54ee50135fbeb4d83c00f713114f7f67 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:39:56 +0000 Subject: [PATCH 34/59] Refactor `GenericArgs` to include const generics Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/auto_trait.rs | 8 +- src/librustdoc/clean/mod.rs | 116 ++++++++++++++--------------- src/librustdoc/html/format.rs | 19 ++--- 3 files changed, 70 insertions(+), 73 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 23b5794fb1eef..adbe73b165ef4 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -444,7 +444,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .expect("segments were empty"); let (old_input, old_output) = match last_segment.args { - GenericArgs::AngleBracketed { types, .. } => (types, None), + GenericArgs::AngleBracketed { args, .. } => { + let types = args.iter().filter_map(|arg| match arg { + GenericArg::Type(ty) => Some(ty.clone()), + _ => None, + }).collect(); + (types, None) + } GenericArgs::Parenthesized { inputs, output, .. } => { (inputs, output) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8581c40c843e8..50210bcb85d56 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -21,7 +21,7 @@ use rustc::hir::{self, GenericArg, HirVec}; use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::map::DisambiguatedDefPathData; -use rustc::ty::subst::{Kind, InternalSubsts, SubstsRef}; +use rustc::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use rustc::ty::{self, DefIdTree, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::fold::TypeFolder; use rustc::ty::layout::VariantIdx; @@ -1089,24 +1089,37 @@ impl Clean for hir::GenericBound { } } -fn external_generic_args(cx: &DocContext<'_>, trait_did: Option, has_self: bool, - bindings: Vec, substs: SubstsRef<'_>) -> GenericArgs { - let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect(); - let types = substs.types().skip(has_self as usize).collect::>(); +fn external_generic_args( + cx: &DocContext<'_>, + trait_did: Option, + has_self: bool, + bindings: Vec, + substs: SubstsRef<'_>, +) -> GenericArgs { + let mut skip_self = has_self; + let mut first_ty_sty = None; + let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { + UnpackedKind::Lifetime(lt) => { + lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) + } + UnpackedKind::Type(_) if skip_self => { + skip_self = false; + None + } + UnpackedKind::Type(ty) => { + first_ty_sty = Some(&ty.sty); + Some(GenericArg::Type(ty.clean(cx))) + } + UnpackedKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), + }).collect(); match trait_did { // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { - assert_eq!(types.len(), 1); - let inputs = match types[0].sty { - ty::Tuple(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(), - _ => { - return GenericArgs::AngleBracketed { - lifetimes, - types: types.clean(cx), - bindings, - } - } + assert!(first_ty_sty.is_some()); + let inputs = match first_ty_sty { + Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.clean(cx)).collect(), + _ => return GenericArgs::AngleBracketed { args, bindings }, }; let output = None; // FIXME(#20299) return type comes from a projection now @@ -1114,17 +1127,10 @@ fn external_generic_args(cx: &DocContext<'_>, trait_did: Option, has_self // ty::Tuple(ref v) if v.is_empty() => None, // -> () // _ => Some(types[1].clean(cx)) // }; - GenericArgs::Parenthesized { - inputs, - output, - } + GenericArgs::Parenthesized { inputs, output } }, _ => { - GenericArgs::AngleBracketed { - lifetimes, - types: types.clean(cx), - bindings, - } + GenericArgs::AngleBracketed { args, bindings } } } } @@ -1462,7 +1468,7 @@ impl GenericParamDef { } } -impl<'tcx> Clean for ty::GenericParamDef { +impl Clean for ty::GenericParamDef { fn clean(&self, cx: &DocContext<'_>) -> GenericParamDef { let (name, kind) = match self.kind { ty::GenericParamDefKind::Lifetime => { @@ -1484,7 +1490,10 @@ impl<'tcx> Clean for ty::GenericParamDef { }) } ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) + (self.name.clean(cx), GenericParamDefKind::Const { + did: self.def_id, + ty: cx.tcx.type_of(self.def_id).clean(cx), + }) } }; @@ -1685,9 +1694,7 @@ impl<'a, 'tcx> Clean for (&'a ty::Generics, .flat_map(|param| match param.kind { ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)), ty::GenericParamDefKind::Type { .. } => None, - ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) - } + ty::GenericParamDefKind::Const { .. } => Some(param.clean(cx)), }).chain(simplify::ty_params(stripped_typarams).into_iter()) .collect(), where_predicates: simplify::where_clauses(cx, where_predicates), @@ -2365,12 +2372,15 @@ impl Type { } } - pub fn generics(&self) -> Option<&[Type]> { + pub fn generics(&self) -> Option> { match *self { ResolvedPath { ref path, .. } => { path.segments.last().and_then(|seg| { - if let GenericArgs::AngleBracketed { ref types, .. } = seg.args { - Some(&**types) + if let GenericArgs::AngleBracketed { ref args, .. } = seg.args { + Some(args.iter().filter_map(|arg| match arg { + GenericArg::Type(ty) => Some(ty.clone()), + _ => None, + }).collect()) } else { None } @@ -3267,8 +3277,7 @@ impl fmt::Display for GenericArg { #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum GenericArgs { AngleBracketed { - lifetimes: Vec, - types: Vec, + args: Vec, bindings: Vec, }, Parenthesized { @@ -3286,27 +3295,19 @@ impl Clean for hir::GenericArgs { output: if output != Type::Tuple(Vec::new()) { Some(output) } else { None } } } else { - let (mut lifetimes, mut types) = (vec![], vec![]); - let mut elided_lifetimes = true; - for arg in &self.args { - match arg { - GenericArg::Lifetime(lt) => { - if !lt.is_elided() { - elided_lifetimes = false; - } - lifetimes.push(lt.clean(cx)); - } - GenericArg::Type(ty) => { - types.push(ty.clean(cx)); - } - GenericArg::Const(..) => { - unimplemented!() // FIXME(const_generics) - } - } - } + let elide_lifetimes = self.args.iter().all(|arg| match arg { + hir::GenericArg::Lifetime(lt) => lt.is_elided(), + _ => true, + }); GenericArgs::AngleBracketed { - lifetimes: if elided_lifetimes { vec![] } else { lifetimes }, - types, + args: self.args.iter().filter_map(|arg| match arg { + hir::GenericArg::Lifetime(lt) if !elide_lifetimes => { + Some(GenericArg::Lifetime(lt.clean(cx))) + } + hir::GenericArg::Lifetime(_) => None, + hir::GenericArg::Type(ty) => Some(GenericArg::Type(ty.clean(cx))), + hir::GenericArg::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), + }).collect(), bindings: self.bindings.clean(cx), } } @@ -3358,9 +3359,8 @@ fn strip_path(path: &Path) -> Path { PathSegment { name: s.name.clone(), args: GenericArgs::AngleBracketed { - lifetimes: Vec::new(), - types: Vec::new(), - bindings: Vec::new(), + args: vec![], + bindings: vec![], } } }).collect(); @@ -3511,7 +3511,7 @@ impl Clean for doctree::Static { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)] pub struct Constant { pub type_: Type, pub expr: String, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2cba3c58889ab..116839edc2f80 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -306,32 +306,23 @@ impl fmt::Display for clean::GenericBound { impl fmt::Display for clean::GenericArgs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - clean::GenericArgs::AngleBracketed { - ref lifetimes, ref types, ref bindings - } => { - if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() { + clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { + if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; } else { f.write_str("<")?; } let mut comma = false; - for lifetime in lifetimes { - if comma { - f.write_str(", ")?; - } - comma = true; - write!(f, "{}", *lifetime)?; - } - for ty in types { + for arg in args { if comma { f.write_str(", ")?; } comma = true; if f.alternate() { - write!(f, "{:#}", *ty)?; + write!(f, "{:#}", *arg)?; } else { - write!(f, "{}", *ty)?; + write!(f, "{}", *arg)?; } } for binding in bindings { From 38d98a1b2242b6b8fac041ccb249eb492a09d260 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:40:10 +0000 Subject: [PATCH 35/59] Implement const generics in `generics_to_path_params` Co-Authored-By: Gabriel Smith --- src/librustdoc/core.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index dca6458c701c5..1982a16f3b81d 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -236,8 +236,16 @@ impl<'tcx> DocContext<'tcx> { ty::GenericParamDefKind::Type { .. } => { args.push(hir::GenericArg::Type(self.ty_param_to_ty(param.clone()))); } - ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) + ty::GenericParamDefKind::Const => { + args.push(hir::GenericArg::Const(hir::ConstArg { + value: hir::AnonConst { + hir_id: hir::DUMMY_HIR_ID, + body: hir::BodyId { + hir_id: hir::DUMMY_HIR_ID, + } + }, + span: DUMMY_SP, + })) } } } From 9925d9b3b6dd0abe34e48f7d4b6730bb97c7ebd4 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 09:54:37 +0000 Subject: [PATCH 36/59] Fix indentation issue --- src/librustdoc/html/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 116839edc2f80..f56322d9f0631 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -307,7 +307,7 @@ impl fmt::Display for clean::GenericArgs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { - if !args.is_empty() || !bindings.is_empty() { + if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; } else { From b39e664ee8add0f6a36462c18927648aa3dc207e Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:29:25 +0000 Subject: [PATCH 37/59] Make clean::Constant display respect f.alternate() --- src/librustdoc/html/format.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index f56322d9f0631..3a0a19d58008b 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -261,7 +261,9 @@ impl fmt::Display for clean::Lifetime { impl fmt::Display for clean::Constant { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}: {}", self.expr, self.type_) + fmt::Display::fmt(&self.expr, f)?; + f.write_str(": ")?; + fmt::Display::fmt(&self.type_, f) } } From f93ad414ab1b78bb219df84b6a0a5e367dc81a66 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:37:42 +0000 Subject: [PATCH 38/59] Rename first_ty_sty to ty_sty --- src/librustdoc/clean/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 50210bcb85d56..51f1ad1a3765b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1097,7 +1097,7 @@ fn external_generic_args( substs: SubstsRef<'_>, ) -> GenericArgs { let mut skip_self = has_self; - let mut first_ty_sty = None; + let mut ty_sty = None; let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { UnpackedKind::Lifetime(lt) => { lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) @@ -1107,7 +1107,7 @@ fn external_generic_args( None } UnpackedKind::Type(ty) => { - first_ty_sty = Some(&ty.sty); + ty_sty = Some(&ty.sty); Some(GenericArg::Type(ty.clean(cx))) } UnpackedKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), @@ -1116,8 +1116,8 @@ fn external_generic_args( match trait_did { // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { - assert!(first_ty_sty.is_some()); - let inputs = match first_ty_sty { + assert!(ty_sty.is_some()); + let inputs = match ty_sty { Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.clean(cx)).collect(), _ => return GenericArgs::AngleBracketed { args, bindings }, }; From 9bc58118fc80e01eab53c72cfd8658b58d21c593 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:46:59 +0000 Subject: [PATCH 39/59] Rebase over LazyConst changes --- src/librustdoc/clean/mod.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 51f1ad1a3765b..5adce4a41709e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -17,7 +17,7 @@ use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::middle::stability; use rustc::mir::interpret::{GlobalId, ConstValue}; -use rustc::hir::{self, GenericArg, HirVec}; +use rustc::hir::{self, HirVec}; use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::map::DisambiguatedDefPathData; @@ -2931,16 +2931,6 @@ impl<'tcx> Clean for Ty<'tcx> { } } -impl<'tcx> Clean for ty::LazyConst<'tcx> { - fn clean(&self, cx: &DocContext<'_>) -> Constant { - if let ty::LazyConst::Evaluated(ct) = self { - ct.clean(cx) - } else { - unimplemented!() // FIXME(const_generics) - } - } -} - impl<'tcx> Clean for ty::Const<'tcx> { fn clean(&self, cx: &DocContext<'_>) -> Constant { Constant { From 37789c4a1d6e46af2ef619f5640c05764b875dbb Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 19 Mar 2019 06:10:59 +0100 Subject: [PATCH 40/59] Update src/librustc/hir/mod.rs Co-Authored-By: llogiq --- src/librustc/hir/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 8941158e561d1..24c145b3811e3 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1233,7 +1233,7 @@ pub struct Arm { pub pats: HirVec>, /// Optional guard clause. pub guard: Option, - /// The action to take if this arm matches. + /// The expression the arm evaluates to if this arm matches. pub body: P, } From 8cf720bd19a00f52e3db630947f6424946ee0f6c Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Mar 2019 13:59:38 +0100 Subject: [PATCH 41/59] Make Option no larger than ThreadId, with NonZeroU64 --- src/libstd/thread/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 08f0aa2f0d206..40682da8f8b0f 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -163,6 +163,7 @@ use crate::ffi::{CStr, CString}; use crate::fmt; use crate::io; use crate::mem; +use crate::num::NonZeroU64; use crate::panic; use crate::panicking; use crate::str; @@ -1036,7 +1037,7 @@ pub fn park_timeout(dur: Duration) { /// [`Thread`]: ../../std/thread/struct.Thread.html #[stable(feature = "thread_id", since = "1.19.0")] #[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] -pub struct ThreadId(u64); +pub struct ThreadId(NonZeroU64); impl ThreadId { // Generate a new unique thread ID. @@ -1044,7 +1045,7 @@ impl ThreadId { // We never call `GUARD.init()`, so it is UB to attempt to // acquire this mutex reentrantly! static GUARD: mutex::Mutex = mutex::Mutex::new(); - static mut COUNTER: u64 = 0; + static mut COUNTER: u64 = 1; unsafe { let _guard = GUARD.lock(); @@ -1058,7 +1059,7 @@ impl ThreadId { let id = COUNTER; COUNTER += 1; - ThreadId(id) + ThreadId(NonZeroU64::new(id).unwrap()) } } } From a291d4e94cbcd9082f942147cde92b8ae5a39cdc Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Tue, 19 Mar 2019 15:54:21 -0400 Subject: [PATCH 42/59] convert field/method confusion help to suggestions --- src/librustc_typeck/check/method/suggest.rs | 83 +++++++++++-------- .../issue-18343.stderr | 4 +- .../issue-2392.stderr | 48 +++++++---- .../issue-32128.stderr | 4 +- .../issue-33784.stderr | 12 ++- 5 files changed, 98 insertions(+), 53 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 4bf6471a6293c..83a98c38c90ce 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -332,44 +332,61 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If the method name is the name of a field with a function or closure type, // give a helping note that it has to be called as `(x.f)(...)`. if let SelfSource::MethodCall(expr) = source { - for (ty, _) in self.autoderef(span, rcvr_ty) { - if let ty::Adt(def, substs) = ty.sty { - if !def.is_enum() { + let field_receiver = self + .autoderef(span, rcvr_ty) + .find_map(|(ty, _)| match ty.sty { + ty::Adt(def, substs) if !def.is_enum() => { let variant = &def.non_enum_variant(); - if let Some(index) = self.tcx.find_field_index(item_name, variant) { + self.tcx.find_field_index(item_name, variant).map(|index| { let field = &variant.fields[index]; - let snippet = tcx.sess.source_map().span_to_snippet(expr.span); - let expr_string = match snippet { - Ok(expr_string) => expr_string, - _ => "s".into(), // Default to a generic placeholder for the - // expression when we can't generate a - // string snippet. - }; - let field_ty = field.ty(tcx, substs); - let scope = self.tcx.hir().get_module_parent_by_hir_id( - self.body_id); - if field.vis.is_accessible_from(scope, self.tcx) { - if self.is_fn_ty(&field_ty, span) { - err.help(&format!("use `({0}.{1})(...)` if you \ - meant to call the function \ - stored in the `{1}` field", - expr_string, - item_name)); - } else { - err.help(&format!("did you mean to write `{0}.{1}` \ - instead of `{0}.{1}(...)`?", - expr_string, - item_name)); - } - err.span_label(span, "field, not a method"); - } else { - err.span_label(span, "private field, not a method"); - } - break; - } + (field, field_ty) + }) + } + _ => None, + }); + + if let Some((field, field_ty)) = field_receiver { + let scope = self.tcx.hir().get_module_parent_by_hir_id(self.body_id); + let is_accessible = field.vis.is_accessible_from(scope, self.tcx); + + if is_accessible { + if self.is_fn_ty(&field_ty, span) { + let expr_span = expr.span.to(item_name.span); + err.multipart_suggestion( + &format!( + "to call the function stored in `{}`, \ + surround the field access with parentheses", + item_name, + ), + vec![ + (expr_span.shrink_to_lo(), '('.to_string()), + (expr_span.shrink_to_hi(), ')'.to_string()), + ], + Applicability::MachineApplicable, + ); + } else { + let call_expr = self.tcx.hir().expect_expr_by_hir_id( + self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id), + ); + + let span = call_expr.span.trim_start(item_name.span).unwrap(); + + err.span_suggestion( + span, + "remove the arguments", + String::new(), + Applicability::MaybeIncorrect, + ); } } + + let field_kind = if is_accessible { + "field" + } else { + "private field" + }; + err.span_label(item_name.span, format!("{}, not a method", field_kind)); } } else { err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); diff --git a/src/test/ui/confuse-field-and-method/issue-18343.stderr b/src/test/ui/confuse-field-and-method/issue-18343.stderr index 36112cd0e10c9..03f9d990dbb23 100644 --- a/src/test/ui/confuse-field-and-method/issue-18343.stderr +++ b/src/test/ui/confuse-field-and-method/issue-18343.stderr @@ -6,8 +6,10 @@ LL | struct Obj where F: FnMut() -> u32 { ... LL | o.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o.closure)(); + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/confuse-field-and-method/issue-2392.stderr b/src/test/ui/confuse-field-and-method/issue-2392.stderr index 7cd1941d80e83..a3ad54da025a4 100644 --- a/src/test/ui/confuse-field-and-method/issue-2392.stderr +++ b/src/test/ui/confuse-field-and-method/issue-2392.stderr @@ -6,8 +6,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | o_closure.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o_closure.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o_closure.closure)(); + | ^ ^ error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:39:36: 39:41]>` in the current scope --> $DIR/issue-2392.rs:42:15 @@ -16,9 +18,9 @@ LL | struct Obj where F: FnOnce() -> u32 { | -------------------------------------- method `not_closure` not found for this ... LL | o_closure.not_closure(); - | ^^^^^^^^^^^ field, not a method - | - = help: did you mean to write `o_closure.not_closure` instead of `o_closure.not_closure(...)`? + | ^^^^^^^^^^^-- help: remove the arguments + | | + | field, not a method error[E0599]: no method named `closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:46:12 @@ -28,8 +30,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | o_func.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o_func.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o_func.closure)(); + | ^ ^ error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope --> $DIR/issue-2392.rs:49:14 @@ -39,8 +43,10 @@ LL | struct BoxedObj { ... LL | boxed_fn.boxed_closure(); | ^^^^^^^^^^^^^ field, not a method +help: to call the function stored in `boxed_closure`, surround the field access with parentheses | - = help: use `(boxed_fn.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field +LL | (boxed_fn.boxed_closure)(); + | ^ ^ error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope --> $DIR/issue-2392.rs:52:19 @@ -50,8 +56,10 @@ LL | struct BoxedObj { ... LL | boxed_closure.boxed_closure(); | ^^^^^^^^^^^^^ field, not a method +help: to call the function stored in `boxed_closure`, surround the field access with parentheses | - = help: use `(boxed_closure.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field +LL | (boxed_closure.boxed_closure)(); + | ^ ^ error[E0599]: no method named `closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:57:12 @@ -61,8 +69,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | w.wrap.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(w.wrap.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (w.wrap.closure)(); + | ^ ^ error[E0599]: no method named `not_closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:59:12 @@ -71,9 +81,9 @@ LL | struct Obj where F: FnOnce() -> u32 { | -------------------------------------- method `not_closure` not found for this ... LL | w.wrap.not_closure(); - | ^^^^^^^^^^^ field, not a method - | - = help: did you mean to write `w.wrap.not_closure` instead of `w.wrap.not_closure(...)`? + | ^^^^^^^^^^^-- help: remove the arguments + | | + | field, not a method error[E0599]: no method named `closure` found for type `Obj + 'static)>>` in the current scope --> $DIR/issue-2392.rs:62:24 @@ -83,8 +93,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | check_expression().closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(check_expression().closure)(...)` if you meant to call the function stored in the `closure` field +LL | (check_expression().closure)(); + | ^ ^ error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:68:31 @@ -94,8 +106,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f1(1); | ^^ field, not a method +help: to call the function stored in `f1`, surround the field access with parentheses | - = help: use `((*self.container).f1)(...)` if you meant to call the function stored in the `f1` field +LL | ((*self.container).f1)(1); + | ^ ^ error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:69:31 @@ -105,8 +119,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f2(1); | ^^ field, not a method +help: to call the function stored in `f2`, surround the field access with parentheses | - = help: use `((*self.container).f2)(...)` if you meant to call the function stored in the `f2` field +LL | ((*self.container).f2)(1); + | ^ ^ error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:70:31 @@ -116,8 +132,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f3(1); | ^^ field, not a method +help: to call the function stored in `f3`, surround the field access with parentheses | - = help: use `((*self.container).f3)(...)` if you meant to call the function stored in the `f3` field +LL | ((*self.container).f3)(1); + | ^ ^ error: aborting due to 11 previous errors diff --git a/src/test/ui/confuse-field-and-method/issue-32128.stderr b/src/test/ui/confuse-field-and-method/issue-32128.stderr index 902f60668f2ed..fbabb3a88cc6c 100644 --- a/src/test/ui/confuse-field-and-method/issue-32128.stderr +++ b/src/test/ui/confuse-field-and-method/issue-32128.stderr @@ -6,8 +6,10 @@ LL | struct Example { ... LL | demo.example(1); | ^^^^^^^ field, not a method +help: to call the function stored in `example`, surround the field access with parentheses | - = help: use `(demo.example)(...)` if you meant to call the function stored in the `example` field +LL | (demo.example)(1); + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/confuse-field-and-method/issue-33784.stderr b/src/test/ui/confuse-field-and-method/issue-33784.stderr index cce961f1e4edc..60f1a932f4442 100644 --- a/src/test/ui/confuse-field-and-method/issue-33784.stderr +++ b/src/test/ui/confuse-field-and-method/issue-33784.stderr @@ -3,24 +3,30 @@ error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue | LL | p.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(p.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (p.closure)(); + | ^ ^ error[E0599]: no method named `fn_ptr` found for type `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope --> $DIR/issue-33784.rs:29:7 | LL | q.fn_ptr(); | ^^^^^^ field, not a method +help: to call the function stored in `fn_ptr`, surround the field access with parentheses | - = help: use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field +LL | (q.fn_ptr)(); + | ^ ^ error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope --> $DIR/issue-33784.rs:32:7 | LL | s.c_fn_ptr(); | ^^^^^^^^ field, not a method +help: to call the function stored in `c_fn_ptr`, surround the field access with parentheses | - = help: use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr` field +LL | (s.c_fn_ptr)(); + | ^ ^ error: aborting due to 3 previous errors From 757eb679927e2c85457f567487e887eb080eb7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 19 Mar 2019 13:17:25 -0700 Subject: [PATCH 43/59] review comments --- src/librustc/hir/mod.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/parse/parser.rs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 785d7745b297b..51d91cc562f68 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2173,7 +2173,7 @@ impl StructField { /// Id of the whole struct lives in `Item`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum VariantData { - Struct(HirVec, HirId, bool), + Struct(HirVec, HirId, /* recovered */ bool), Tuple(HirVec, HirId), Unit(HirId), } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5da00ef8ebee2..2cbd2dfeb25d6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -620,7 +620,7 @@ pub enum PatKind { /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). /// The `bool` is `true` in the presence of a `..`. - Struct(Path, Vec>, bool), + Struct(Path, Vec>, /* recovered */ bool), /// A tuple struct/variant pattern (`Variant(x, y, .., z)`). /// If the `..` pattern fragment is present, then `Option` denotes its position. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 360a101a64faf..361ecce5bc438 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6902,7 +6902,9 @@ impl<'a> Parser<'a> { } } - fn parse_record_struct_body(&mut self) -> PResult<'a, (Vec, bool)> { + fn parse_record_struct_body( + &mut self, + ) -> PResult<'a, (Vec, /* recovered */ bool)> { let mut fields = Vec::new(); let mut recovered = false; if self.eat(&token::OpenDelim(token::Brace)) { From 46a8beb4b2536740b632d01abff8d341bbf20b6d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Mar 2019 01:22:19 +0100 Subject: [PATCH 44/59] Move some bench tests back from libtest --- src/libtest/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 3fcba0f579145..cb0ce480e4273 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -44,3 +44,28 @@ pub fn black_box(dummy: T) -> T { pub fn black_box(dummy: T) -> T { dummy } + +#[cfg(test)] +mod tests { + use crate::Bencher; + use libtest::stats::Stats; + + #[bench] + pub fn sum_three_items(b: &mut Bencher) { + b.iter(|| { + [1e20f64, 1.5f64, -1e20f64].sum(); + }) + } + + #[bench] + pub fn sum_many_f64(b: &mut Bencher) { + let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60]; + let v = (0..500).map(|i| nums[i % 5]).collect::>(); + b.iter(|| { + v.sum(); + }) + } + + #[bench] + pub fn no_iter(_: &mut Bencher) {} +} From b6e5d7348a6205bdfec582baf150f2471b865e54 Mon Sep 17 00:00:00 2001 From: O01eg Date: Wed, 20 Mar 2019 12:50:18 +0300 Subject: [PATCH 45/59] Add messages for different verbosity levels. Output copy actions --- src/bootstrap/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 976b30a55c94b..0c3daea7a3cd6 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -726,6 +726,17 @@ impl Build { } } + pub fn is_verbose_than(&self, level: usize) -> bool { + self.verbosity > level + } + + /// Prints a message if this build is configured in more verbose mode than `level`. + fn verbose_than(&self, level: usize, msg: &str) { + if self.is_verbose_than(level) { + println!("{}", msg); + } + } + fn info(&self, msg: &str) { if self.config.dry_run { return; } println!("{}", msg); @@ -1158,6 +1169,7 @@ impl Build { /// Copies a file from `src` to `dst` pub fn copy(&self, src: &Path, dst: &Path) { if self.config.dry_run { return; } + self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst)); let _ = fs::remove_file(&dst); let metadata = t!(src.symlink_metadata()); if metadata.file_type().is_symlink() { From c1d9191fa576c600775b4fbb90a3d09ca5e0fa0b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 20 Mar 2019 19:04:38 +0100 Subject: [PATCH 46/59] Add a test for size_of Option --- src/libstd/thread/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 40682da8f8b0f..d856f9b465e04 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1485,9 +1485,10 @@ fn _assert_sync_and_send() { mod tests { use super::Builder; use crate::any::Any; + use crate::mem; use crate::sync::mpsc::{channel, Sender}; use crate::result; - use crate::thread; + use crate::thread::{self, ThreadId}; use crate::time::Duration; use crate::u32; @@ -1717,6 +1718,11 @@ mod tests { thread::sleep(Duration::from_millis(2)); } + #[test] + fn test_size_of_option_thread_id() { + assert_eq!(mem::size_of::>(), mem::size_of::()); + } + #[test] fn test_thread_id_equal() { assert!(thread::current().id() == thread::current().id()); From a8120d660a47559b7ae8eb798bb8f6e62d575000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Mar 2019 11:45:25 -0700 Subject: [PATCH 47/59] Tweak incorrect escaped char diagnostic --- src/libsyntax/parse/lexer/mod.rs | 38 +++++++++---------- src/libsyntax/parse/parser.rs | 13 +++++-- src/test/ui/parser/byte-literals.stderr | 4 +- .../ui/parser/byte-string-literals.stderr | 4 +- .../parser/issue-23620-invalid-escapes.stderr | 24 +++--------- .../ui/parser/lex-bad-char-literals-1.stderr | 4 +- ...-bare-cr-string-literal-doc-comment.stderr | 8 +--- src/test/ui/parser/pat-tuple-3.stderr | 4 +- .../trailing-carriage-return-in-string.stderr | 8 +--- .../wrong-escape-of-curly-braces.stderr | 16 ++------ 10 files changed, 51 insertions(+), 72 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index bcd53dbfeb2c5..cd4944deadb10 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -968,9 +968,10 @@ impl<'a> StringReader<'a> { } else { let span = self.mk_sp(start, self.pos); let mut suggestion = "\\u{".to_owned(); + let msg = "incorrect unicode escape sequence"; let mut err = self.sess.span_diagnostic.struct_span_err( span, - "incorrect unicode escape sequence", + msg, ); let mut i = 0; while let (Some(ch), true) = (self.ch, i < 6) { @@ -991,8 +992,8 @@ impl<'a> StringReader<'a> { Applicability::MaybeIncorrect, ); } else { - err.span_help( - span, + err.span_label(span, msg); + err.help( "format of unicode escape sequences is `\\u{...}`", ); } @@ -1018,25 +1019,24 @@ impl<'a> StringReader<'a> { } c => { let pos = self.pos; - let mut err = self.struct_err_span_char(escaped_pos, - pos, - if ascii_only { - "unknown byte escape" - } else { - "unknown character \ - escape" - }, - c); + let msg = if ascii_only { + "unknown byte escape" + } else { + "unknown character escape" + }; + let mut err = self.struct_err_span_char(escaped_pos, pos, msg, c); + err.span_label(self.mk_sp(escaped_pos, pos), msg); if e == '\r' { - err.span_help(self.mk_sp(escaped_pos, pos), - "this is an isolated carriage return; consider \ - checking your editor and version control \ - settings"); + err.help( + "this is an isolated carriage return; consider checking \ + your editor and version control settings", + ); } if (e == '{' || e == '}') && !ascii_only { - err.span_help(self.mk_sp(escaped_pos, pos), - "if used in a formatting string, curly braces \ - are escaped with `{{` and `}}`"); + err.help( + "if used in a formatting string, curly braces are escaped \ + with `{{` and `}}`", + ); } err.emit(); false diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..48702cf3c4cba 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4229,19 +4229,24 @@ impl<'a> Parser<'a> { fn parse_pat_list(&mut self) -> PResult<'a, (Vec>, Option, bool)> { let mut fields = Vec::new(); let mut ddpos = None; + let mut prev_dd_sp = None; let mut trailing_comma = false; loop { if self.eat(&token::DotDot) { if ddpos.is_none() { ddpos = Some(fields.len()); + prev_dd_sp = Some(self.prev_span); } else { // Emit a friendly error, ignore `..` and continue parsing - self.struct_span_err( + let mut err = self.struct_span_err( self.prev_span, "`..` can only be used once per tuple or tuple struct pattern", - ) - .span_label(self.prev_span, "can only be used once per pattern") - .emit(); + ); + err.span_label(self.prev_span, "can only be used once per pattern"); + if let Some(sp) = prev_dd_sp { + err.span_label(sp, "previously present here"); + } + err.emit(); } } else if !self.check(&token::CloseDelim(token::Paren)) { fields.push(self.parse_pat(None)?); diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr index 36cb0170a1404..4edeccfe47556 100644 --- a/src/test/ui/parser/byte-literals.stderr +++ b/src/test/ui/parser/byte-literals.stderr @@ -2,13 +2,13 @@ error: unknown byte escape: f --> $DIR/byte-literals.rs:6:21 | LL | static FOO: u8 = b'/f'; - | ^ + | ^ unknown byte escape error: unknown byte escape: f --> $DIR/byte-literals.rs:9:8 | LL | b'/f'; - | ^ + | ^ unknown byte escape error: invalid character in numeric character escape: Z --> $DIR/byte-literals.rs:10:10 diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index 2e9b13b933e2b..45c1a94b519a3 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -2,13 +2,13 @@ error: unknown byte escape: f --> $DIR/byte-string-literals.rs:6:32 | LL | static FOO: &'static [u8] = b"/f"; - | ^ + | ^ unknown byte escape error: unknown byte escape: f --> $DIR/byte-string-literals.rs:9:8 | LL | b"/f"; - | ^ + | ^ unknown byte escape error: invalid character in numeric character escape: Z --> $DIR/byte-string-literals.rs:10:10 diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.stderr b/src/test/ui/parser/issue-23620-invalid-escapes.stderr index f6e476ab0cd1d..669a6d26905d1 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.stderr +++ b/src/test/ui/parser/issue-23620-invalid-escapes.stderr @@ -14,13 +14,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:10:15 | LL | let _ = b'/u'; - | ^^ - | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:10:15 + | ^^ incorrect unicode escape sequence | -LL | let _ = b'/u'; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:10:15 @@ -80,13 +76,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:28:28 | LL | let _ = b"/u{a4a4} /xf /u"; - | ^^ + | ^^ incorrect unicode escape sequence | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:28:28 - | -LL | let _ = b"/u{a4a4} /xf /u"; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:28:28 @@ -110,13 +102,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:34:18 | LL | let _ = "/xf /u"; - | ^^ + | ^^ incorrect unicode escape sequence | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:34:18 - | -LL | let _ = "/xf /u"; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:39:14 diff --git a/src/test/ui/parser/lex-bad-char-literals-1.stderr b/src/test/ui/parser/lex-bad-char-literals-1.stderr index 3c8550e3dbe64..e6b71108086df 100644 --- a/src/test/ui/parser/lex-bad-char-literals-1.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-1.stderr @@ -14,13 +14,13 @@ error: unknown character escape: /u{25cf} --> $DIR/lex-bad-char-literals-1.rs:11:7 | LL | '/●' - | ^ + | ^ unknown character escape error: unknown character escape: /u{25cf} --> $DIR/lex-bad-char-literals-1.rs:15:7 | LL | "/●" - | ^ + | ^ unknown character escape error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr index 19117bfa9c972..b4d538bf61312 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr @@ -38,13 +38,9 @@ error: unknown character escape: /r --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 | LL | let _s = "foo/ bar"; - | ^ + | ^ unknown character escape | -help: this is an isolated carriage return; consider checking your editor and version control settings - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 - | -LL | let _s = "foo/ bar"; - | ^ + = help: this is an isolated carriage return; consider checking your editor and version control settings error: aborting due to 7 previous errors diff --git a/src/test/ui/parser/pat-tuple-3.stderr b/src/test/ui/parser/pat-tuple-3.stderr index 0ad7d27b94e54..c9f14bb90429b 100644 --- a/src/test/ui/parser/pat-tuple-3.stderr +++ b/src/test/ui/parser/pat-tuple-3.stderr @@ -2,7 +2,9 @@ error: `..` can only be used once per tuple or tuple struct pattern --> $DIR/pat-tuple-3.rs:3:19 | LL | (.., pat, ..) => {} - | ^^ can only be used once per pattern + | -- ^^ can only be used once per pattern + | | + | previously present here error: aborting due to previous error diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.stderr b/src/test/ui/parser/trailing-carriage-return-in-string.stderr index 972e4296da358..f70f8ac8d7751 100644 --- a/src/test/ui/parser/trailing-carriage-return-in-string.stderr +++ b/src/test/ui/parser/trailing-carriage-return-in-string.stderr @@ -2,13 +2,9 @@ error: unknown character escape: /r --> $DIR/trailing-carriage-return-in-string.rs:10:25 | LL | let bad = "This is / a test"; - | ^ + | ^ unknown character escape | -help: this is an isolated carriage return; consider checking your editor and version control settings - --> $DIR/trailing-carriage-return-in-string.rs:10:25 - | -LL | let bad = "This is / a test"; - | ^ + = help: this is an isolated carriage return; consider checking your editor and version control settings error: aborting due to previous error diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr index 90debfc337d83..346eba04c6500 100644 --- a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr @@ -2,25 +2,17 @@ error: unknown character escape: { --> $DIR/wrong-escape-of-curly-braces.rs:3:17 | LL | let bad = "/{it is wrong/}"; - | ^ + | ^ unknown character escape | -help: if used in a formatting string, curly braces are escaped with `{{` and `}}` - --> $DIR/wrong-escape-of-curly-braces.rs:3:17 - | -LL | let bad = "/{it is wrong/}"; - | ^ + = help: if used in a formatting string, curly braces are escaped with `{{` and `}}` error: unknown character escape: } --> $DIR/wrong-escape-of-curly-braces.rs:3:30 | LL | let bad = "/{it is wrong/}"; - | ^ + | ^ unknown character escape | -help: if used in a formatting string, curly braces are escaped with `{{` and `}}` - --> $DIR/wrong-escape-of-curly-braces.rs:3:30 - | -LL | let bad = "/{it is wrong/}"; - | ^ + = help: if used in a formatting string, curly braces are escaped with `{{` and `}}` error: aborting due to 2 previous errors From 2f8d9a23eea261152bb90fa620e96cfc2715de4a Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 15:07:16 -0600 Subject: [PATCH 48/59] Add NAN test to docs --- src/libstd/f32.rs | 1 + src/libstd/f64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 2fabe30fa9366..a5e28722054a5 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -970,6 +970,7 @@ impl f32 { /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); + /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index a471117f6d6fd..f69c0b8aae356 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,6 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); + /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From e2b5a0334de402b85af6b9aa681fe11c9a3bb6f0 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 15:16:50 -0600 Subject: [PATCH 49/59] Fix formatting and add unit tests for panic cases --- src/libstd/f32.rs | 20 +++++++++++++++++++- src/libstd/f64.rs | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index a5e28722054a5..688d9c1aabbee 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -970,7 +970,7 @@ impl f32 { /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); - /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] @@ -1582,4 +1582,22 @@ mod tests { assert_eq!(f32::from_bits(masked_nan1).to_bits(), masked_nan1); assert_eq!(f32::from_bits(masked_nan2).to_bits(), masked_nan2); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f32.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f32.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f32.clamp(3.0, NAN); + } } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index f69c0b8aae356..5c3bc05c15f15 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,7 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); - /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] @@ -1523,4 +1523,22 @@ mod tests { assert_eq!(f64::from_bits(masked_nan1).to_bits(), masked_nan1); assert_eq!(f64::from_bits(masked_nan2).to_bits(), masked_nan2); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f64.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f64.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f64.clamp(3.0, NAN); + } } From 295cc77e9472c0f61fd39e9f93d7853473f1f183 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 21 Mar 2019 01:17:45 +0300 Subject: [PATCH 50/59] cleanup: Remove compile-fail-fulldeps directory again --- .../auxiliary/lint_group_plugin_test.rs | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs deleted file mode 100644 index 16630e2b31285..0000000000000 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -// force-host - -#![feature(plugin_registrar)] -#![feature(box_syntax, rustc_private)] - -// Load rustc as a plugin to get macros. -#[macro_use] -extern crate rustc; -extern crate rustc_plugin; - -use rustc::hir; -use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray}; -use rustc_plugin::Registry; - -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'"); - -struct Pass; - -impl LintPass for Pass { - fn name(&self) -> &'static str { - "Pass" - } - - fn get_lints(&self) -> LintArray { - lint_array!(TEST_LINT, PLEASE_LINT) - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - match &*it.ident.as_str() { - "lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"), - "pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"), - _ => {} - } - } -} - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_late_lint_pass(box Pass); - reg.register_lint_group("lint_me", None, vec![TEST_LINT, PLEASE_LINT]); -} From 72f5d9137e33fe4aa251dab44c0fc4de71a1a366 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 16:59:46 -0600 Subject: [PATCH 51/59] Fix f64 test --- src/libstd/f64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 5c3bc05c15f15..b171e1c7ac93f 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,7 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); - /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f64::NAN).clamp(-2.0f64, 1.0f64).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From 830c98d7fa4da9381d3ee9c8b918bc5dff11c378 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sat, 16 Mar 2019 18:07:58 +0100 Subject: [PATCH 52/59] Fix undefined behavior in hint::spin_loop for x86 targets without SSE2 The pause instruction requires SSE2 but was being unconditionally used on targets without it, resulting in undefined behavior. This PR fixes that by only using the pause intrinsic if SSE2 is available. It also removes the inline assembly which was not required since these instructions are available in core::arch, and extends support of the spin_loop hint to arm targets with the v6 feature which also support the yield instruction. Closes #59237 . --- src/libcore/hint.rs | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs index 89de5c1bc8af8..b2f82ef0d175c 100644 --- a/src/libcore/hint.rs +++ b/src/libcore/hint.rs @@ -62,13 +62,32 @@ pub unsafe fn unreachable_unchecked() -> ! { #[inline] #[unstable(feature = "renamed_spin_loop", issue = "55002")] pub fn spin_loop() { - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - unsafe { - asm!("pause" ::: "memory" : "volatile"); + #[cfg( + all( + any(target_arch = "x86", target_arch = "x86_64"), + target_feature = "sse2" + ) + )] { + #[cfg(target_arch = "x86")] { + unsafe { crate::arch::x86::_mm_pause() }; + } + + #[cfg(target_arch = "x86_64")] { + unsafe { crate::arch::x86_64::_mm_pause() }; + } } - #[cfg(target_arch = "aarch64")] - unsafe { - asm!("yield" ::: "memory" : "volatile"); + #[cfg( + any( + target_arch = "aarch64", + all(target_arch = "arm", target_feature = "v6") + ) + )] { + #[cfg(target_arch = "aarch64")] { + unsafe { crate::arch::aarch64::__yield() }; + } + #[cfg(target_arch = "arm")] { + unsafe { crate::arch::arm::__yield() }; + } } } From 16a8abe1bb159c4f1255533a4969590e3b7e0e61 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 20 Mar 2019 14:54:43 -0400 Subject: [PATCH 53/59] use suggestions for "enum instead of variant" error --- src/librustc_resolve/error_reporting.rs | 21 ++++-- .../issue-43871-enum-instead-of-variant.rs | 19 ++++++ ...issue-43871-enum-instead-of-variant.stderr | 55 ++++++++++++---- src/test/ui/glob-resolve1.stderr | 5 +- src/test/ui/resolve/privacy-enum-ctor.stderr | 65 ++++++++++++------- 5 files changed, 118 insertions(+), 47 deletions(-) diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index cd771d93e00f6..828ffc6d320e7 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -293,13 +293,20 @@ impl<'a> Resolver<'a> { (Def::Enum(..), PathSource::TupleStruct) | (Def::Enum(..), PathSource::Expr(..)) => { if let Some(variants) = self.collect_enum_variants(def) { - err.note(&format!("did you mean to use one \ - of the following variants?\n{}", - variants.iter() - .map(|suggestion| path_names_to_string(suggestion)) - .map(|suggestion| format!("- `{}`", suggestion)) - .collect::>() - .join("\n"))); + if !variants.is_empty() { + let msg = if variants.len() == 1 { + "try using the enum's variant" + } else { + "try using one of the enum's variants" + }; + + err.span_suggestions( + span, + msg, + variants.iter().map(path_names_to_string), + Applicability::MaybeIncorrect, + ); + } } else { err.note("did you mean to use one of the enum's variants?"); } diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs index f5dbab1ef3586..7d3aba364897f 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs @@ -1,5 +1,20 @@ enum Example { Ex(String), NotEx } +enum Void {} + +enum ManyVariants { + One, + Two, + Three, + Four, + Five, + Six, + Seven, + Eight, + Nine, + Ten, +} + fn result_test() { let x = Option(1); //~ ERROR expected function, found enum @@ -12,6 +27,10 @@ fn result_test() { if let Example(_) = y { //~ ERROR expected tuple struct/variant, found enum println!("It is OK."); } + + let y = Void(); //~ ERROR expected function, found enum + + let z = ManyVariants(); //~ ERROR expected function, found enum } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr index 8a0d0096acbbd..4210b4e057ac1 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr @@ -1,34 +1,63 @@ error[E0423]: expected function, found enum `Option` - --> $DIR/issue-43871-enum-instead-of-variant.rs:4:13 + --> $DIR/issue-43871-enum-instead-of-variant.rs:19:13 | LL | let x = Option(1); | ^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `std::prelude::v1::Option::None` - - `std::prelude::v1::Option::Some` +LL | let x = std::prelude::v1::Option::None(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = std::prelude::v1::Option::Some(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0532]: expected tuple struct/variant, found enum `Option` - --> $DIR/issue-43871-enum-instead-of-variant.rs:6:12 + --> $DIR/issue-43871-enum-instead-of-variant.rs:21:12 | LL | if let Option(_) = x { | ^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `std::prelude::v1::Option::None` - - `std::prelude::v1::Option::Some` +LL | if let std::prelude::v1::Option::None(_) = x { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let std::prelude::v1::Option::Some(_) = x { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0532]: expected tuple struct/variant, found enum `Example` - --> $DIR/issue-43871-enum-instead-of-variant.rs:12:12 + --> $DIR/issue-43871-enum-instead-of-variant.rs:27:12 | LL | if let Example(_) = y { | ^^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `Example::Ex` - - `Example::NotEx` +LL | if let Example::Ex(_) = y { + | ^^^^^^^^^^^ +LL | if let Example::NotEx(_) = y { + | ^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error[E0423]: expected function, found enum `Void` + --> $DIR/issue-43871-enum-instead-of-variant.rs:31:13 + | +LL | let y = Void(); + | ^^^^ + +error[E0423]: expected function, found enum `ManyVariants` + --> $DIR/issue-43871-enum-instead-of-variant.rs:33:13 + | +LL | let z = ManyVariants(); + | ^^^^^^^^^^^^ +help: try using one of the enum's variants + | +LL | let z = ManyVariants::Eight(); + | ^^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Five(); + | ^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Four(); + | ^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Nine(); + | ^^^^^^^^^^^^^^^^^^ +and 6 other candidates + +error: aborting due to 5 previous errors Some errors occurred: E0423, E0532. For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/glob-resolve1.stderr b/src/test/ui/glob-resolve1.stderr index 01730c4d69566..c252a6e220c64 100644 --- a/src/test/ui/glob-resolve1.stderr +++ b/src/test/ui/glob-resolve1.stderr @@ -22,10 +22,7 @@ error[E0423]: expected value, found enum `B` --> $DIR/glob-resolve1.rs:24:5 | LL | B; - | ^ - | - = note: did you mean to use one of the following variants? - - `B::B1` + | ^ help: try using the enum's variant: `B::B1` error[E0425]: cannot find value `C` in this scope --> $DIR/glob-resolve1.rs:25:5 diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 01f0941282e35..75d9c97513d31 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -3,22 +3,32 @@ error[E0423]: expected value, found enum `n::Z` | LL | n::Z; | ^^^^ - | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +help: try using one of the enum's variants + | +LL | m::Z::Fn; + | ^^^^^^^^ +LL | m::Z::Struct; + | ^^^^^^^^^^^^ +LL | m::Z::Unit; + | ^^^^^^^^^^ error[E0423]: expected value, found enum `Z` --> $DIR/privacy-enum-ctor.rs:25:9 | LL | Z; - | ^ help: a function with a similar name exists: `f` + | ^ +help: a function with a similar name exists | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +LL | f; + | ^ +help: try using one of the enum's variants + | +LL | m::Z::Fn; + | ^^^^^^^^ +LL | m::Z::Struct; + | ^^^^^^^^^^^^ +LL | m::Z::Unit; + | ^^^^^^^^^^ error[E0423]: expected value, found struct variant `Z::Struct` --> $DIR/privacy-enum-ctor.rs:29:20 @@ -31,15 +41,18 @@ error[E0423]: expected value, found enum `m::E` | LL | let _: E = m::E; | ^^^^ - | - = note: did you mean to use one of the following variants? - - `E::Fn` - - `E::Struct` - - `E::Unit` help: a function with a similar name exists | LL | let _: E = m::f; | ^ +help: try using one of the enum's variants + | +LL | let _: E = E::Fn; + | ^^^^^ +LL | let _: E = E::Struct; + | ^^^^^^^^^ +LL | let _: E = E::Unit; + | ^^^^^^^ help: possible better candidates are found in other modules, you can import them into scope | LL | use std::f32::consts::E; @@ -58,11 +71,14 @@ error[E0423]: expected value, found enum `E` | LL | let _: E = E; | ^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `E::Fn` - - `E::Struct` - - `E::Unit` +LL | let _: E = E::Fn; + | ^^^^^ +LL | let _: E = E::Struct; + | ^^^^^^^^^ +LL | let _: E = E::Unit; + | ^^^^^^^ help: possible better candidates are found in other modules, you can import them into scope | LL | use std::f32::consts::E; @@ -95,11 +111,14 @@ error[E0423]: expected value, found enum `m::n::Z` | LL | let _: Z = m::n::Z; | ^^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +LL | let _: Z = m::Z::Fn; + | ^^^^^^^^ +LL | let _: Z = m::Z::Struct; + | ^^^^^^^^^^^^ +LL | let _: Z = m::Z::Unit; + | ^^^^^^^^^^ error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:61:12 From de021e39e61cf7a3ae0f3c3c08aea5c344fc8720 Mon Sep 17 00:00:00 2001 From: MikaelUrankar Date: Mon, 21 Jan 2019 18:52:57 +0100 Subject: [PATCH 54/59] FreeBSD 10.x is EOL, in FreeBSD 11 and later, ss_sp is actually a void* [1] dragonflybsd still uses c_char [2] [1] https://svnweb.freebsd.org/base/releng/11.2/sys/sys/signal.h?revision=334459&view=markup#l438 [2] https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/signal.h#L339 --- src/libstd/sys/unix/stack_overflow.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 8c60bddc23839..561279e82785c 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -140,6 +140,7 @@ mod imp { #[cfg(any(target_os = "linux", target_os = "macos", target_os = "bitrig", + target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", target_os = "solaris"))] @@ -147,8 +148,7 @@ mod imp { libc::stack_t { ss_sp: get_stackp(), ss_flags: 0, ss_size: SIGSTKSZ } } - #[cfg(any(target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(target_os = "dragonfly")] unsafe fn get_stack() -> libc::stack_t { libc::stack_t { ss_sp: get_stackp() as *mut i8, ss_flags: 0, ss_size: SIGSTKSZ } } From 6b766baf4a32b8386b0271d40801a498fee00155 Mon Sep 17 00:00:00 2001 From: MikaelUrankar Date: Thu, 21 Mar 2019 17:02:28 +0100 Subject: [PATCH 55/59] Update cargo --- Cargo.lock | 128 ++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d32d07569e42c..ec1cda96b99a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,7 +83,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -95,7 +95,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -107,7 +107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -162,7 +162,7 @@ dependencies = [ "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -259,7 +259,7 @@ dependencies = [ "jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -458,7 +458,7 @@ name = "commoncrypto-sys" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -479,7 +479,7 @@ dependencies = [ "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -499,7 +499,7 @@ dependencies = [ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -530,7 +530,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,7 +657,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -671,7 +671,7 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -729,7 +729,7 @@ name = "directories" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -738,7 +738,7 @@ name = "dirs" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -749,7 +749,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -858,7 +858,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -873,7 +873,7 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -915,7 +915,7 @@ name = "fs2" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -988,7 +988,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1163,7 +1163,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1200,7 +1200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1208,7 +1208,7 @@ name = "jobserver" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1256,7 +1256,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.46" +version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-std-workspace-core 1.0.0", @@ -1269,7 +1269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1282,7 +1282,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1291,7 +1291,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1313,7 +1313,7 @@ version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1379,7 +1379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1480,7 +1480,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1489,7 +1489,7 @@ name = "memmap" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1512,7 +1512,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1530,7 +1530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1544,7 +1544,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1569,7 +1569,7 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1616,7 +1616,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1662,7 +1662,7 @@ name = "num_cpus" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1689,7 +1689,7 @@ dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1712,7 +1712,7 @@ version = "0.9.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-src 111.1.0+1.1.1a (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1750,7 +1750,7 @@ version = "0.0.0" dependencies = [ "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1760,7 +1760,7 @@ dependencies = [ "alloc 0.0.0", "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "unwind 0.0.0", ] @@ -1778,7 +1778,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2027,7 +2027,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2038,7 +2038,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2050,7 +2050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2066,7 +2066,7 @@ name = "rand_chacha" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2088,7 +2088,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2113,7 +2113,7 @@ name = "rand_xorshift" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2132,7 +2132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2515,7 +2515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2612,7 +2612,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3208,7 +3208,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arc-swap 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3235,7 +3235,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3256,7 +3256,7 @@ dependencies = [ "core 0.0.0", "dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "panic_abort 0.0.0", "panic_unwind 0.0.0", "profiler_builtins 0.0.0", @@ -3407,7 +3407,7 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3418,7 +3418,7 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3466,7 +3466,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3485,7 +3485,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3519,7 +3519,7 @@ name = "time" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3600,7 +3600,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "mio-named-pipes 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3632,7 +3632,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "signal-hook 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3703,7 +3703,7 @@ dependencies = [ "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3819,7 +3819,7 @@ version = "0.0.0" dependencies = [ "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3886,7 +3886,7 @@ name = "wait-timeout" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3959,7 +3959,7 @@ name = "xattr" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4094,7 +4094,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)" = "023a4cd09b2ff695f9734c1934145a315594b7986398496841c7031a5a1bbdbd" +"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" "checksum libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48441cb35dc255da8ae72825689a95368bf510659ae1ad55dc4aa88cb1789bf1" "checksum libnghttp2-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d75d7966bda4730b722d1eab8e668df445368a24394bae9fc1e8dc0ab3dbe4f4" "checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d" From 6389478d7030f1d807a46599dfb7a0a2ba97a240 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 21 Mar 2019 23:36:50 +0300 Subject: [PATCH 56/59] Move one test from run-make-fulldeps to ui --- .../run-make-fulldeps/extern-prelude/Makefile | 11 ------- .../run-make-fulldeps/extern-prelude/basic.rs | 6 ---- .../extern-prelude/relative-only.rs | 9 ------ .../extern-prelude/shadow-mod.rs | 14 --------- .../extern-prelude/shadow-prelude.rs | 7 ----- .../auxiliary/extern-prelude-vec.rs} | 2 +- .../auxiliary/extern-prelude.rs} | 2 -- src/test/ui/extern-prelude-fail.rs | 9 ++++++ src/test/ui/extern-prelude-fail.stderr | 16 ++++++++++ src/test/ui/extern-prelude.rs | 31 +++++++++++++++++++ 10 files changed, 57 insertions(+), 50 deletions(-) delete mode 100644 src/test/run-make-fulldeps/extern-prelude/Makefile delete mode 100644 src/test/run-make-fulldeps/extern-prelude/basic.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/relative-only.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs rename src/test/{run-make-fulldeps/extern-prelude/ep-vec.rs => ui/auxiliary/extern-prelude-vec.rs} (60%) rename src/test/{run-make-fulldeps/extern-prelude/ep-lib.rs => ui/auxiliary/extern-prelude.rs} (69%) create mode 100644 src/test/ui/extern-prelude-fail.rs create mode 100644 src/test/ui/extern-prelude-fail.stderr create mode 100644 src/test/ui/extern-prelude.rs diff --git a/src/test/run-make-fulldeps/extern-prelude/Makefile b/src/test/run-make-fulldeps/extern-prelude/Makefile deleted file mode 100644 index 69af01ccf0369..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) ep-lib.rs - $(RUSTC) ep-vec.rs - - $(RUSTC) basic.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib - $(RUSTC) shadow-mod.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib - $(RUSTC) shadow-prelude.rs --extern Vec=$(TMPDIR)/libep_vec.rlib - $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "unresolved import" - $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "failed to resolve" diff --git a/src/test/run-make-fulldeps/extern-prelude/basic.rs b/src/test/run-make-fulldeps/extern-prelude/basic.rs deleted file mode 100644 index dc7cc1f27b6f6..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/basic.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(extern_prelude)] - -fn main() { - let s = ep_lib::S; // It works - s.external(); -} diff --git a/src/test/run-make-fulldeps/extern-prelude/relative-only.rs b/src/test/run-make-fulldeps/extern-prelude/relative-only.rs deleted file mode 100644 index 0fdf3b49d96b4..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/relative-only.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Extern prelude names are not available by absolute paths - -#![feature(extern_prelude)] - -use ep_lib::S; - -fn main() { - let s = ::ep_lib::S; -} diff --git a/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs b/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs deleted file mode 100644 index 69411aaf57c71..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Local module shadows `ep_lib` from extern prelude - -mod ep_lib { - pub struct S; - - impl S { - pub fn internal(&self) {} - } -} - -fn main() { - let s = ep_lib::S; - s.internal(); // OK -} diff --git a/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs b/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs deleted file mode 100644 index 6c6ce12708d79..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Extern prelude shadows standard library prelude - -#![feature(extern_prelude)] - -fn main() { - let x = Vec::new(0f32, ()); // OK -} diff --git a/src/test/run-make-fulldeps/extern-prelude/ep-vec.rs b/src/test/ui/auxiliary/extern-prelude-vec.rs similarity index 60% rename from src/test/run-make-fulldeps/extern-prelude/ep-vec.rs rename to src/test/ui/auxiliary/extern-prelude-vec.rs index 148a4a987266f..a643c8889109a 100644 --- a/src/test/run-make-fulldeps/extern-prelude/ep-vec.rs +++ b/src/test/ui/auxiliary/extern-prelude-vec.rs @@ -1,3 +1,3 @@ -#![crate_type = "rlib"] +#![crate_name = "Vec"] pub fn new(arg1: f32, arg2: ()) {} diff --git a/src/test/run-make-fulldeps/extern-prelude/ep-lib.rs b/src/test/ui/auxiliary/extern-prelude.rs similarity index 69% rename from src/test/run-make-fulldeps/extern-prelude/ep-lib.rs rename to src/test/ui/auxiliary/extern-prelude.rs index f5e129eca6631..2fdfd85a1da30 100644 --- a/src/test/run-make-fulldeps/extern-prelude/ep-lib.rs +++ b/src/test/ui/auxiliary/extern-prelude.rs @@ -1,5 +1,3 @@ -#![crate_type = "rlib"] - pub struct S; impl S { diff --git a/src/test/ui/extern-prelude-fail.rs b/src/test/ui/extern-prelude-fail.rs new file mode 100644 index 0000000000000..7d387025ad44d --- /dev/null +++ b/src/test/ui/extern-prelude-fail.rs @@ -0,0 +1,9 @@ +// compile-flags:--extern extern_prelude +// aux-build:extern-prelude.rs + +// Extern prelude names are not available by absolute paths + +fn main() { + use extern_prelude::S; //~ ERROR unresolved import `extern_prelude` + let s = ::extern_prelude::S; //~ ERROR failed to resolve +} diff --git a/src/test/ui/extern-prelude-fail.stderr b/src/test/ui/extern-prelude-fail.stderr new file mode 100644 index 0000000000000..ad148c04d08af --- /dev/null +++ b/src/test/ui/extern-prelude-fail.stderr @@ -0,0 +1,16 @@ +error[E0432]: unresolved import `extern_prelude` + --> $DIR/extern-prelude-fail.rs:7:9 + | +LL | use extern_prelude::S; + | ^^^^^^^^^^^^^^ maybe a missing `extern crate extern_prelude;`? + +error[E0433]: failed to resolve: maybe a missing `extern crate extern_prelude;`? + --> $DIR/extern-prelude-fail.rs:8:15 + | +LL | let s = ::extern_prelude::S; + | ^^^^^^^^^^^^^^ maybe a missing `extern crate extern_prelude;`? + +error: aborting due to 2 previous errors + +Some errors occurred: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/extern-prelude.rs b/src/test/ui/extern-prelude.rs new file mode 100644 index 0000000000000..0e52f2c5158d4 --- /dev/null +++ b/src/test/ui/extern-prelude.rs @@ -0,0 +1,31 @@ +// compile-pass +// compile-flags:--extern extern_prelude --extern Vec +// aux-build:extern-prelude.rs +// aux-build:extern-prelude-vec.rs + +fn basic() { + // It works + let s = extern_prelude::S; + s.external(); +} + +fn shadow_mod() { + // Local module shadows `extern_prelude` from extern prelude + mod extern_prelude { + pub struct S; + + impl S { + pub fn internal(&self) {} + } + } + + let s = extern_prelude::S; + s.internal(); // OK +} + +fn shadow_prelude() { + // Extern prelude shadows standard library prelude + let x = Vec::new(0f32, ()); // OK +} + +fn main() {} From c97d3d4dd174e8a80e9d0e55ea6f9a73aca60bf2 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Fri, 22 Mar 2019 11:25:44 +0100 Subject: [PATCH 57/59] Add tracking issue number for `seek_convenience` --- src/libstd/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4c88fc889f31f..7147b641e4743 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1381,7 +1381,7 @@ pub trait Seek { /// Ok(()) /// } /// ``` - #[unstable(feature = "seek_convenience", issue = "0")] + #[unstable(feature = "seek_convenience", issue = "59359")] fn stream_len(&mut self) -> Result { let old_pos = self.stream_position()?; let len = self.seek(SeekFrom::End(0))?; @@ -1420,7 +1420,7 @@ pub trait Seek { /// Ok(()) /// } /// ``` - #[unstable(feature = "seek_convenience", issue = "0")] + #[unstable(feature = "seek_convenience", issue = "59359")] fn stream_position(&mut self) -> Result { self.seek(SeekFrom::Current(0)) } From 48af7189c2f0e69c16611c261c4ded84c0ac305d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 20 Mar 2019 13:08:54 +0100 Subject: [PATCH 58/59] Expand `impl FromIterator for Option` doc to include example of early termination. --- src/libcore/option.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index dfc388409a84b..4fad65f3ae28f 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1315,6 +1315,26 @@ impl> FromIterator> for Option { /// Since the last element is zero, it would underflow. Thus, the resulting /// value is `None`. /// + /// Here is a variation on the previous example, showing that no + /// further elements are taken from `iter` after the first `None`. + /// + /// ``` + /// let items = vec![3_u16, 2, 1, 10]; + /// + /// let mut shared = 0; + /// + /// let res: Option> = items + /// .iter() + /// .map(|x| shared += x; x.checked_sub(2)) + /// .collect(); + /// + /// assert_eq!(res, None); + /// assert_eq!(shared, 6); + /// ``` + /// + /// Since the third element caused an underflow, no further elements were taken, + /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16. + /// /// [`Iterator`]: ../iter/trait.Iterator.html #[inline] fn from_iter>>(iter: I) -> Option { From d5a61c0be25d47c39ab7909b83b3a2765a282eb1 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 20 Mar 2019 13:09:22 +0100 Subject: [PATCH 59/59] Expand `impl FromIterator for Result` doc to include examples of `Err` and early termination. --- src/libcore/result.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 967f7e3e2fe72..490cd5bb3fe1d 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1202,6 +1202,34 @@ impl> FromIterator> for Result { /// ).collect(); /// assert_eq!(res, Ok(vec![2, 3])); /// ``` + /// + /// Here is another example that tries to subtract one from another list + /// of integers, this time checking for underflow: + /// + /// ``` + /// let v = vec![1, 2, 0]; + /// let res: Result, &'static str> = v.iter().map(|x: &u32| + /// x.checked_sub(1).ok_or("Underflow!") + /// ).collect(); + /// assert_eq!(res, Err("Underflow!")); + /// ``` + /// + /// Here is a variation on the previous example, showing that no + /// further elements are taken from `iter` after the first `Err`. + /// + /// ``` + /// let v = vec![3, 2, 1, 10]; + /// let mut shared = 0; + /// let res: Result, &'static str> = v.iter().map(|x: &u32| + /// shared += x; + /// x.checked_sub(2).ok_or("Underflow!") + /// ).collect(); + /// assert_eq!(res, Err("Underflow!")); + /// assert_eq!(shared, 6); + /// ``` + /// + /// Since the third element caused an underflow, no further elements were taken, + /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16. #[inline] fn from_iter>>(iter: I) -> Result { // FIXME(#11084): This could be replaced with Iterator::scan when this